warn = -pedantic -Wall
-CFLAGS = $(warn) $(opt) $(dbg) $(incpath)
-CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(incpath)
+CFLAGS = $(warn) $(opt) $(dbg) $(incpath) -fopenmp
+CXXFLAGS = -std=c++11 $(warn) $(opt) $(dbg) $(incpath) -fopenmp
LDFLAGS = $(libpath) -ldrawtext $(libgl_$(sys)) $(libal_$(sys)) -lm -lgmath -lvmath \
-limago -lresman -lpthread -lassimp -ltreestore -lgoatvr \
- `pkg-config --libs sdl2 freetype2` -lpng -ljpeg -lz -lvorbisfile
+ `pkg-config --libs sdl2 freetype2` -lpng -ljpeg -lz -lvorbisfile -lgomp
sys = $(shell uname -s | sed 's/MINGW.*/mingw/')
libgl_Linux = -lGL -lGLU -lGLEW
}
msurf_set_threshold(priv->msurf, 8);
msurf_set_inside(priv->msurf, MSURF_GREATER);
- msurf_set_bounds(priv->msurf, -3.5, 3.5, -3.5, 3.5, -3.5, 3.5);
+ msurf_set_bounds(priv->msurf, -3.5, -3.5, -3.5, 3.5, 3.5, 3.5);
msurf_enable(priv->msurf, MSURF_NORMALIZE);
priv->tex = texman.get_texture("data/sphmap.jpg");
+
return true;
}
float max_energy = 0.0f;
-//#pragma omp parallel for
+#pragma omp parallel for
for(int i=0; i<zres; i++) {
float z = zmin + i * zstep;
float *voxptr = msurf_slice(priv->msurf, i);
- if(!voxptr) break;
for(int j=0; j<yres; j++) {
float y = ymin + j * ystep;
glLoadIdentity();
glScalef(1, -1, 1);
- glFrontFace(GL_CW);
-
-
int nverts = msurf_vertex_count(priv->msurf);
float *varr = msurf_vertices(priv->msurf);
float *narr = msurf_normals(priv->msurf);
- glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
- for(int i=0; i<nverts; i++) {
- glNormal3f(narr[0], narr[1], narr[2]);
- glVertex3f(varr[0], varr[1], varr[2]);
- varr += 3;
- narr += 3;
- }
- glEnd();
- glFrontFace(GL_CCW);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, varr);
+ glNormalPointer(GL_FLOAT, 0, narr);
+
+ glDrawArrays(GL_TRIANGLES, 0, nverts);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ /*
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
narr += 3;
}
glEnd();
+ */
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
{
switch(inside) {
case MSURF_GREATER:
- msurf_disable(ms, MSURF_FLIP);
+ msurf_enable(ms, MSURF_FLIP);
break;
case MSURF_LESS:
- msurf_enable(ms, MSURF_FLIP);
+ msurf_disable(ms, MSURF_FLIP);
break;
default:
slice_size = ms->res[0] * ms->res[1];
cellptr = ms->voxels + slice_size * zcell + ms->res[0] * ycell + xcell;
- val[0] = *cellptr;
- val[1] = *(cellptr + 1);
- val[2] = *(cellptr + 1 + ms->res[0]);
- val[3] = *(cellptr + ms->res[0]);
- cellptr += slice_size;
- val[4] = *cellptr;
- val[5] = *(cellptr + 1);
- val[6] = *(cellptr + 1 + ms->res[0]);
- val[7] = *(cellptr + ms->res[0]);
- cellptr -= slice_size;
+#define GRIDOFFS(x, y, z) ((z) * slice_size + (y) * ms->res[0] + (x))
+
+ for(i=0; i<8; i++) {
+ val[i] = cellptr[GRIDOFFS(offs[i][0], offs[i][1], offs[i][2])];
+ }
code = mc_bitcode(val, ms->thres);
if(ms->flags & MSURF_FLIP) {
/* calculate normals at the 8 corners */
for(i=0; i<8; i++) {
- float *ptr = cellptr + offs[i][2] * slice_size + offs[i][1] * ms->res[0] + offs[i][0];
+ float *ptr = cellptr + GRIDOFFS(offs[i][0], offs[i][1], offs[i][2]);
if(xcell < ms->res[0] - 1) {
- dfdx[i] = *(ptr + 1) - *ptr;
+ dfdx[i] = ptr[GRIDOFFS(1, 0, 0)] - *ptr;
} else {
- dfdx[i] = *ptr - *(ptr - 1);
+ dfdx[i] = *ptr - ptr[GRIDOFFS(-1, 0, 0)];
}
if(ycell < ms->res[1] - 1) {
- dfdy[i] = *(ptr + ms->res[0]) - *ptr;
+ dfdy[i] = ptr[GRIDOFFS(0, 1, 0)] - *ptr;
} else {
- dfdy[i] = *ptr - *(ptr - ms->res[0]);
+ dfdy[i] = *ptr - ptr[GRIDOFFS(0, -1, 0)];
}
if(zcell < ms->res[2] - 1) {
- dfdz[i] = *(ptr + slice_size) - *ptr;
+ dfdz[i] = ptr[GRIDOFFS(0, 0, 1)] - *ptr;
} else {
- dfdz[i] = *ptr - *(ptr - slice_size);
+ dfdz[i] = *ptr - ptr[GRIDOFFS(0, 0, -1)];
}
}