Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/drawobject.c')
-rw-r--r--source/blender/editors/space_view3d/drawobject.c362
1 files changed, 13 insertions, 349 deletions
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 466b55ba862..55565c83f5e 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -5309,356 +5309,20 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
/* draw code for smoke */
- if((md = modifiers_findByType(ob, eModifierType_Smoke)))
- {
- SmokeModifierData *smd = (SmokeModifierData *)md;
-
- // draw collision objects
- if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll)
- {
- /*SmokeCollSettings *scs = smd->coll;
- if(scs->points)
- {
- size_t i;
-
- wmLoadMatrix(rv3d->viewmat);
-
- if(col || (ob->flag & SELECT)) cpack(0xFFFFFF);
- glDepthMask(GL_FALSE);
- glEnable(GL_BLEND);
-
-
- // glPointSize(3.0);
- bglBegin(GL_POINTS);
-
- for(i = 0; i < scs->numpoints; i++)
- {
- bglVertex3fv(&scs->points[3*i]);
- }
-
- bglEnd();
- glPointSize(1.0);
-
- wmMultMatrix(ob->obmat);
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
- if(col) cpack(col);
-
- }
- */
- }
-
- // only draw domains
- if(smd->domain && smd->domain->fluid)
- {
- int x, y, z, i;
- float viewnormal[3];
- int mainaxis[3] = {0,0,0};
- float align = 0, signed_align = 0;
- int max_textures = 0, counter_textures = 0;
- float *buffer = NULL;
- int res[3];
- float bigfactor = 1.0;
- int big = (smd->domain->flags & MOD_SMOKE_HIGHRES) && (smd->domain->viewsettings & MOD_SMOKE_VIEW_USEBIG);
- int new = 0;
- int have_lamp = 0;
-
- // GUI sent redraw event
- if(smd->domain->flags & MOD_SMOKE_VIEW_REDRAWNICE)
- {
- new = 1;
- smd->domain->flags &= ~MOD_SMOKE_VIEW_REDRAWNICE;
- }
-
- if(!big)
- {
- res[0] = smd->domain->res[0];
- res[1] = smd->domain->res[1];
- res[2] = smd->domain->res[2];
- }
- else
- {
- smoke_turbulence_get_res(smd->domain->wt, res);
- bigfactor = 1.0 / (smd->domain->amplify + 1);
- }
-
- wmLoadMatrix(rv3d->viewmat);
-
- if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
- glDepthMask(GL_FALSE);
- glEnable(GL_BLEND);
-
- // get view vector
- VECCOPY(viewnormal, rv3d->viewinv[2]);
- Normalize(viewnormal);
- for(i = 0; i < 3; i++)
- {
- if(ABS(viewnormal[i]) > align)
- {
- mainaxis[0] = i;
- align = ABS(viewnormal[i]);
- signed_align = viewnormal[i];
- }
- }
- mainaxis[1] = (mainaxis[0] + 1) % 3;
- mainaxis[2] = (mainaxis[0] + 2) % 3;
-
- if(!smd->domain->bind)
- {
- smd->domain->bind = MEM_callocN(sizeof(GLuint)*256, "Smoke_bind");
- if(big)
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG;
- new = 3;
- }
-
- // check if view axis / mode has been changed
- if(smd->domain->viewsettings)
- {
- if(big)
- {
- if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG))
- new = 2;
- else if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG))
- new = 1;
-
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_CHANGETOBIG;
- }
- else
- {
- if(!(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL))
- new = 2;
- else if(smd->domain->viewsettings & MOD_SMOKE_VIEW_CHANGETOBIG)
- new = 1;
-
- smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_CHANGETOBIG;
- }
-
- if(!new)
- {
- if((mainaxis[0] == 0) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_X))
- new = 1;
- else if((mainaxis[0] == 1) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Y))
- new = 1;
- else if((mainaxis[0] == 2) && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_Z))
- new = 1;
-
- // printf("check axis\n");
- }
- }
- else
- new = 3;
-
- if(new > 1)
- {
- float light[3] = {0.0,0.0,0.0}; // TODO: take real LAMP coordinates - dg
- Base *base_tmp = NULL;
-
- for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next)
- {
- if(base_tmp->object->type == OB_LAMP)
- {
- Lamp *la = (Lamp *)base_tmp->object->data;
-
- if(la->type == LA_LOCAL)
- {
- VECCOPY(light, base_tmp->object->obmat[3]);
- have_lamp = 1;
- break;
- }
- }
- }
-
- if(!big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_SMALL))
- {
- smoke_prepare_View(smd, light);
- // printf("prepared View!\n");
- }
- else if(big && !(smd->domain->viewsettings & MOD_SMOKE_VIEW_BIG))
- {
- smoke_prepare_bigView(smd, light);
- // printf("prepared bigView!\n");
- }
- }
-
- // printf("big: %d, new: %d\n", big, new);
-
- // only create buffer if we need to create new textures
- if(new)
- buffer = MEM_mallocN(sizeof(float)*res[mainaxis[1]]*res[mainaxis[2]]*4, "SmokeDrawBuffer");
-
- if(buffer || smd->domain->viewsettings)
- {
- int mod_texture = 0;
-
- // printf("if(buffer || smd->domain->viewsettings)\n");
-
- max_textures = (res[mainaxis[0]] > 256) ? 256 : res[mainaxis[0]];
-
- if(!smd->domain->viewsettings) // new frame or new start
- {
- smd->domain->max_textures = max_textures;
- glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
- new = 1;
- // printf("glGenTextures\n");
- }
- else
- {
- if(new)
- {
- // printf("glDeleteTextures\n");
- glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
- smd->domain->max_textures = max_textures;
- glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
- }
- }
-
- mod_texture = MAX3(1, smd->domain->visibility, (int)(res[mainaxis[0]] / smd->domain->max_textures ));
-
- // align order of billboards to be front or backview (e.g. +x or -x axis)
- if(signed_align < 0)
- {
- z = res[mainaxis[0]] - 1;
- }
- else
- {
- z = 0;
- }
-
- for (; signed_align > 0 ? (z < res[mainaxis[0]]) : (z >= 0); signed_align > 0 ? z++ : z--) // 2
- {
- float quad[4][3];
-
- if(new)
- {
- for (y = 0; y < res[mainaxis[1]]; y++) // 1
- {
- for (x = 0; x < res[mainaxis[2]]; x++) // 0
- {
- size_t index;
- size_t image_index;
- float tray, tvox;
-
- image_index = smoke_get_index2d(y, res[mainaxis[1]], x);
-
- if(mainaxis[0] == 0)
- {
- // mainaxis[1] == 1, mainaxis[2] == 2
- index = smoke_get_index(z, res[mainaxis[0]], y, res[mainaxis[1]], x);
- }
- else if(mainaxis[0] == 1)
- {
- // mainaxis[1] == 2, mainaxis[2] == 0
- index = smoke_get_index(x, res[mainaxis[2]], z, res[mainaxis[0]], y);
- }
- else // mainaxis[0] == 2
- {
- // mainaxis[1] == 0, mainaxis[2] == 1
- index = smoke_get_index(y, res[mainaxis[1]], x, res[mainaxis[2]], z);
- }
-
- if(!big)
- {
- tvox = smoke_get_tvox(smd, index);
- tray = smoke_get_tray(smd, index);
- }
- else
- {
- tvox = smoke_get_bigtvox(smd, index);
- tray = smoke_get_bigtray(smd, index);
- }
-
- if(!have_lamp)
- tray = 1.0;
-
- // fill buffer with luminance and alpha
- // 1 - T_vox
- buffer[image_index*4 + 3] = 1.0 - tvox; // 0 = transparent => d.h. tvox = 1
-
- // L_vox = Omega * L_light * (1 - T_vox) * T_ray
- buffer[image_index*4] = buffer[image_index*4 + 1] = buffer[image_index*4 + 2] = smd->domain->omega * 1.0 * tvox * tray;
- }
- }
- }
- glBindTexture(GL_TEXTURE_2D, smd->domain->bind[counter_textures]);
- glEnable(GL_TEXTURE_2D);
-
- if(new)
- {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, res[mainaxis[1]], res[mainaxis[2]], 0, GL_RGBA, GL_FLOAT, buffer);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
- }
-
- if((z % mod_texture) == 0 )
- {
- // botttom left
- quad[3][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[3][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5;
- quad[3][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5;
-
- // top right
- quad[1][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[1][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[1][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
-
- // top left
- quad[2][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[2][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + smd->domain->dx * bigfactor * 0.5;
- quad[2][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + (res[mainaxis[2]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
-
- // bottom right
- quad[0][mainaxis[0]] = smd->domain->p0[mainaxis[0]] + z * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[0][mainaxis[1]] = smd->domain->p0[mainaxis[1]] + (res[mainaxis[1]] - 1) * smd->domain->dx * bigfactor + smd->domain->dx * bigfactor * 0.5;
- quad[0][mainaxis[2]] = smd->domain->p0[mainaxis[2]] + smd->domain->dx * bigfactor * 0.5;
-
- glBegin(GL_QUADS); // Start Drawing Quads
-
- glTexCoord2f(1.0f, 0.0f);
- glVertex3fv(quad[0]); // Left And Up 1 Unit (Top Left)
- glTexCoord2f(1.0f, 1.0f);
- glVertex3fv(quad[1]); // Right And Up 1 Unit (Top Right)
- glTexCoord2f(0.0f, 1.0f);
- glVertex3fv(quad[2]); // Right And Down One Unit (Bottom Right)
- glTexCoord2f(0.0f, 0.0f);
- glVertex3fv(quad[3]); // Left And Down One Unit (Bottom Left)
-
- glEnd();
- }
- counter_textures++;
- }
- }
- if(buffer)
- {
- MEM_freeN(buffer);
- buffer = NULL;
- }
-
- // set correct flag for viewsettings
- if(1)
- {
- // do not clear BIG/SMALL flag
- smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_X;
- smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Y;
- smd->domain->viewsettings &= ~MOD_SMOKE_VIEW_Z;
-
- // set what caches we have
- if(big)
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_BIG;
- else
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_SMALL;
-
- if(mainaxis[0] == 0)
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_X;
- else if(mainaxis[0] == 1)
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_Y;
- else if(mainaxis[0] == 2)
- smd->domain->viewsettings |= MOD_SMOKE_VIEW_Z;
+ if(((SmokeHRModifierData *)(md = modifiers_findByType(ob, eModifierType_SmokeHR)) && (((SmokeHRModifierData *)md)->flags & MOD_SMOKE_SHOWHIGHRES))) {
+ // GPU_create_smoke(smd);
+ // draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res);
+ // GPU_free_smoke(smd);
+ }
+ else {
+ md = modifiers_findByType(ob, eModifierType_Smoke);
+ if (md) {
+ SmokeModifierData *smd = (SmokeModifierData *)md;
+ if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
+ GPU_create_smoke(smd);
+ draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res);
+ GPU_free_smoke(smd);
}
-
- wmMultMatrix(ob->obmat);
- glDisable(GL_BLEND);
- glDepthMask(GL_TRUE);
- if(col) cpack(col);
}
}