diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-07-26 07:00:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-07-26 07:00:55 +0400 |
commit | 794f3291fed5f85f8057a49683acdcb80edb0a02 (patch) | |
tree | 90dcffc20aef49385116f25651d2edec9a04d308 /source/blender/blenkernel/intern | |
parent | e59ef5e419b52e16f831bfc31c5773419c546ae1 (diff) | |
parent | 9fb2e5dde70bd971dabfdf3b1099d92241dc96ed (diff) |
svn merge -r38200:38300 https://svn.blender.org/svnroot/bf-blender/trunk/blender, source/blender/gpu/intern/gpu_buffers.c updated from trunk and re-made edits to use getTessFace* functions.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/boids.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 43 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 41 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 77 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/softbody.c | 90 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 4 |
11 files changed, 139 insertions, 155 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 9f808704eee..a0f38e675f9 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -937,6 +937,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) BoidValues val; BoidState *state = get_boid_state(boids, pa); BoidParticle *bpa = pa->boid; + ParticleSystem *psys = bbd->sim->psys; int rand; //BoidCondition *cond; @@ -959,9 +960,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; /* create random seed for every particle & frame */ - BLI_srandom(bbd->sim->psys->seed + p); - rand = BLI_rand(); - BLI_srandom((int)bbd->cfra + rand); + rand = (int)(PSYS_FRAND(psys->seed + p) * 1000); + rand = (int)(PSYS_FRAND((int)bbd->cfra + rand) * 1000); set_boid_values(&val, bbd->part->boids, pa); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index c3840e91c3b..505b836e3d3 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -315,8 +315,10 @@ static void cdDM_drawVerts(DerivedMesh *dm) else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); if( !GPU_buffer_legacy(dm) ) { - if(dm->drawObject->nelements) glDrawArrays(GL_POINTS,0, dm->drawObject->nelements); - else glDrawArrays(GL_POINTS,0, dm->drawObject->nlooseverts); + if(dm->drawObject->tot_triangle_point) + glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point); + else + glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point); } GPU_buffer_unbind(); } @@ -578,9 +580,10 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, GPU_normal_setup( dm ); if( !GPU_buffer_legacy(dm) ) { glShadeModel(GL_SMOOTH); - for( a = 0; a < dm->drawObject->nmaterials; a++ ) { + for( a = 0; a < dm->drawObject->totmaterial; a++ ) { if( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) ) - glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start, dm->drawObject->materials[a].end-dm->drawObject->materials[a].start); + glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start, + dm->drawObject->materials[a].totpoint); } } GPU_buffer_unbind( ); @@ -660,13 +663,13 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha GPU_color_setup(dm); if( !GPU_buffer_legacy(dm) ) { glShadeModel(GL_SMOOTH); - glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements); + glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->tot_triangle_point); if( useTwoSided ) { GPU_color4_upload(dm,cp2); GPU_color_setup(dm); glCullFace(GL_FRONT); - glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements); + glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->tot_triangle_point); glCullFace(GL_BACK); } } @@ -818,8 +821,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, glShadeModel( GL_SMOOTH ); lastFlag = 0; - for(i = 0; i < dm->drawObject->nelements/3; i++) { - int actualFace = dm->drawObject->faceRemap[i]; + for(i = 0; i < dm->drawObject->tot_triangle_point/3; i++) { + int actualFace = dm->drawObject->triangle_to_mface[i]; int flag = 1; if(drawParams) { @@ -850,13 +853,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, startFace = i; } } - if( startFace < dm->drawObject->nelements/3 ) { + if( startFace < dm->drawObject->tot_triangle_point/3 ) { if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */ if (lastFlag==1 && col) GPU_color_switch(1); else GPU_color_switch(0); - glDrawArrays(GL_TRIANGLES,startFace*3,dm->drawObject->nelements-startFace*3); + glDrawArrays(GL_TRIANGLES, startFace*3, dm->drawObject->tot_triangle_point - startFace*3); } } } @@ -968,7 +971,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if( useColors && mc ) GPU_color_setup(dm); if( !GPU_buffer_legacy(dm) ) { - int tottri = dm->drawObject->nelements/3; + int tottri = dm->drawObject->tot_triangle_point/3; glShadeModel(GL_SMOOTH); if(tottri == 0) { @@ -980,17 +983,17 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us } else { /* we need to check if the next material changes */ - int next_actualFace= dm->drawObject->faceRemap[0]; + int next_actualFace= dm->drawObject->triangle_to_mface[0]; for( i = 0; i < tottri; i++ ) { - //int actualFace = dm->drawObject->faceRemap[i]; + //int actualFace = dm->drawObject->triangle_to_mface[i]; int actualFace = next_actualFace; MFace *mface= mf + actualFace; int drawSmooth= (mface->flag & ME_SMOOTH); int draw = 1; if(i != tottri-1) - next_actualFace= dm->drawObject->faceRemap[i+1]; + next_actualFace= dm->drawObject->triangle_to_mface[i+1]; orig= (index==NULL) ? actualFace : index[actualFace]; @@ -1161,9 +1164,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo GPU_normal_setup(dm); if( !GPU_buffer_legacy(dm) ) { - for( i = 0; i < dm->drawObject->nelements/3; i++ ) { + for( i = 0; i < dm->drawObject->tot_triangle_point/3; i++ ) { - a = dm->drawObject->faceRemap[i]; + a = dm->drawObject->triangle_to_mface[i]; mface = mf + a; new_matnr = mface->mat_nr + 1; @@ -1185,7 +1188,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo if( numdata != 0 ) { - GPU_buffer_free(buffer, NULL); + GPU_buffer_free(buffer); buffer = NULL; } @@ -1225,7 +1228,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } if( numdata != 0 ) { elementsize = GPU_attrib_element_size( datatypes, numdata ); - buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, NULL ); + buffer = GPU_buffer_alloc( elementsize*dm->drawObject->tot_triangle_point); if( buffer == NULL ) { GPU_buffer_unbind(); dm->drawObject->legacy = 1; @@ -1234,7 +1237,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo varray = GPU_buffer_lock_stream(buffer); if( varray == NULL ) { GPU_buffer_unbind(); - GPU_buffer_free(buffer, NULL); + GPU_buffer_free(buffer); dm->drawObject->legacy = 1; return; } @@ -1373,7 +1376,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } GPU_buffer_unbind(); } - GPU_buffer_free( buffer, NULL ); + GPU_buffer_free(buffer); } glShadeModel(GL_FLAT); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index dfc615f4489..d3c47a5e66b 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2432,6 +2432,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) { float *p1,*p2,*p3, pt[3]; float dx1,dy1,dz1,dx,dy,dz,vx,vy,vz,len,len1,len2; + const float eps= 1e-5; if(bezt->h1==0 && bezt->h2==0) return; @@ -2588,30 +2589,38 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(bezt->f1 & SELECT) { /* order of calculation */ if(bezt->h2==HD_ALIGN) { /* aligned */ - len= len2/len1; - p2[3]= p2[0]+len*(p2[0]-p2[-3]); - p2[4]= p2[1]+len*(p2[1]-p2[-2]); - p2[5]= p2[2]+len*(p2[2]-p2[-1]); + if(len1>eps) { + len= len2/len1; + p2[3]= p2[0]+len*(p2[0]-p2[-3]); + p2[4]= p2[1]+len*(p2[1]-p2[-2]); + p2[5]= p2[2]+len*(p2[2]-p2[-1]); + } } if(bezt->h1==HD_ALIGN) { - len= len1/len2; - p2[-3]= p2[0]+len*(p2[0]-p2[3]); - p2[-2]= p2[1]+len*(p2[1]-p2[4]); - p2[-1]= p2[2]+len*(p2[2]-p2[5]); + if(len2>eps) { + len= len1/len2; + p2[-3]= p2[0]+len*(p2[0]-p2[3]); + p2[-2]= p2[1]+len*(p2[1]-p2[4]); + p2[-1]= p2[2]+len*(p2[2]-p2[5]); + } } } else { if(bezt->h1==HD_ALIGN) { - len= len1/len2; - p2[-3]= p2[0]+len*(p2[0]-p2[3]); - p2[-2]= p2[1]+len*(p2[1]-p2[4]); - p2[-1]= p2[2]+len*(p2[2]-p2[5]); + if(len2>eps) { + len= len1/len2; + p2[-3]= p2[0]+len*(p2[0]-p2[3]); + p2[-2]= p2[1]+len*(p2[1]-p2[4]); + p2[-1]= p2[2]+len*(p2[2]-p2[5]); + } } if(bezt->h2==HD_ALIGN) { /* aligned */ - len= len2/len1; - p2[3]= p2[0]+len*(p2[0]-p2[-3]); - p2[4]= p2[1]+len*(p2[1]-p2[-2]); - p2[5]= p2[2]+len*(p2[2]-p2[-1]); + if(len1>eps) { + len= len2/len1; + p2[3]= p2[0]+len*(p2[0]-p2[-3]); + p2[4]= p2[1]+len*(p2[1]-p2[-2]); + p2[5]= p2[2]+len*(p2[2]-p2[-1]); + } } } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c2800410657..d39be9d683c 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -599,7 +599,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if(part->ren_as == PART_DRAW_GR && part->dup_group) { for(go=part->dup_group->gobject.first; go; go=go->next) { node2 = dag_get_node(dag, go->ob); - dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Group Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2f29074834b..962c7fd5e86 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -550,7 +550,7 @@ Material *material_pop_id(ID *id, int index) Material **mat; if(index + 1 != (*totcol)) - memmove((*matar), (*matar) + 1, (*totcol) - (index + 1)); + memmove((*matar), (*matar) + 1, sizeof(void *) * ((*totcol) - (index + 1))); (*totcol)--; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 518ee3c341a..13469e0b58b 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2418,6 +2418,11 @@ void ntreeBeginExecTree(bNodeTree *ntree) if(ntree->type==NTREE_COMPOSIT) composit_begin_exec(ntree, ntree->stack); + + /* ensures only a single output node is enabled, texnode allows multiple though */ + if(ntree->type!=NTREE_TEXTURE) + ntreeSetOutput(ntree); + } ntree->init |= NTREE_EXEC_INIT; @@ -2765,9 +2770,6 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) /* fixed seed, for example noise texture */ BLI_srandom(rd->cfra); - /* ensures only a single output node is enabled */ - ntreeSetOutput(ntree); - /* sets need_exec tags in nodes */ curnode = totnode= setExecutableNodes(ntree, &thdata); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 16b83abe0b3..ff8ae20dbc9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2891,8 +2891,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if(psys_in_edit_mode(sim->scene, psys)) if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) return; - - BLI_srandom(psys->seed); keyed = psys->flag & PSYS_KEYED; baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR; @@ -4376,58 +4374,45 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa Object *ob = sim->ob; ParticleSystem *psys = sim->psys; ParticleSystemModifierData *psmd = sim->psmd; - float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4]; - float xvec[3] = {-1.0, 0.0, 0.0}, q[4], nmat[3][3]; + float loc[3], nor[3], vec[3], side[3], len; + float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3]; sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co); len= normalize_v3(vec); - if(psys->part->rotmode) { - if(pa == NULL) - pa= psys->particles+cpa->pa[0]; - - vec_to_quat( q,xvec, ob->trackflag, ob->upflag); - quat_to_mat4( obrotmat,q); - obrotmat[3][3]= 1.0f; + if(pa == NULL && psys->part->childflat != PART_CHILD_FACES) + pa = psys->particles + cpa->pa[0]; - quat_to_mat4( qmat,pa->state.rot); - mul_m4_m4m4(mat, obrotmat, qmat); - } - else { - if(pa == NULL && psys->part->childflat != PART_CHILD_FACES) - pa = psys->particles + cpa->pa[0]; - - if(pa) - psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); - else - psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0); + if(pa) + psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0); + else + psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0); - copy_m3_m4(nmat, ob->imat); - transpose_m3(nmat); - mul_m3_v3(nmat, nor); - - /* make sure that we get a proper side vector */ - if(fabs(dot_v3v3(nor,vec))>0.999999) { - if(fabs(dot_v3v3(nor,xvec))>0.999999) { - nor[0] = 0.0f; - nor[1] = 1.0f; - nor[2] = 0.0f; - } - else { - nor[0] = 1.0f; - nor[1] = 0.0f; - nor[2] = 0.0f; - } - } - cross_v3_v3v3(side, nor, vec); - normalize_v3(side); - cross_v3_v3v3(nor, vec, side); + copy_m3_m4(nmat, ob->imat); + transpose_m3(nmat); + mul_m3_v3(nmat, nor); - unit_m4(mat); - VECCOPY(mat[0], vec); - VECCOPY(mat[1], side); - VECCOPY(mat[2], nor); + /* make sure that we get a proper side vector */ + if(fabs(dot_v3v3(nor,vec))>0.999999) { + if(fabs(dot_v3v3(nor,xvec))>0.999999) { + nor[0] = 0.0f; + nor[1] = 1.0f; + nor[2] = 0.0f; + } + else { + nor[0] = 1.0f; + nor[1] = 0.0f; + nor[2] = 0.0f; + } } + cross_v3_v3v3(side, nor, vec); + normalize_v3(side); + cross_v3_v3v3(nor, vec, side); + + unit_m4(mat); + VECCOPY(mat[0], vec); + VECCOPY(mat[1], side); + VECCOPY(mat[2], nor); *scale= len; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 2cdb5ecd5d3..399273ab99e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3510,13 +3510,15 @@ static void do_hair_dynamics(ParticleSimulationData *sim) static void hair_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; -/* ParticleSettings *part = psys->part; */ + ParticleSettings *part = psys->part; PARTICLE_P; float disp = (float)psys_get_current_display_percentage(psys)/100.0f; - BLI_srandom(psys->seed); - LOOP_PARTICLES { + pa->size = part->size; + if(part->randsize > 0.0f) + pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); + if(PSYS_FRAND(p) > disp) pa->flag |= PARS_NO_DISP; else @@ -3801,8 +3803,6 @@ static void cached_step(ParticleSimulationData *sim, float cfra) PARTICLE_P; float disp, dietime; - BLI_srandom(psys->seed); - psys_update_effectors(sim); disp= (float)psys_get_current_display_percentage(psys)/100.0f; @@ -4054,7 +4054,6 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* set particles to be not calculated TODO: can't work with pointcache */ disp= (float)psys_get_current_display_percentage(psys)/100.0f; - BLI_srandom(psys->seed); LOOP_PARTICLES { if(PSYS_FRAND(p) > disp) pa->flag |= PARS_NO_DISP; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 85a4b4b7032..2960d8a41e5 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -75,6 +75,7 @@ variables on the UI for now #include "BKE_curve.h" #include "BKE_effect.h" #include "BKE_global.h" +#include "BKE_modifier.h" #include "BKE_softbody.h" #include "BKE_DerivedMesh.h" #include "BKE_pointcache.h" @@ -289,21 +290,24 @@ typedef struct ccd_Mesh { -static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) +static ccd_Mesh *ccd_mesh_make(Object *ob) { + CollisionModifierData *cmd; ccd_Mesh *pccd_M = NULL; ccdf_minmax *mima =NULL; MFace *mface=NULL; float v[3],hull; int i; + cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); + /* first some paranoia checks */ - if (!dm) return NULL; - if (!dm->getNumVerts(dm) || !dm->getNumTessFaces(dm)) return NULL; + if (!cmd) return NULL; + if (!cmd->numverts || !cmd->numfaces) return NULL; pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh"); - pccd_M->totvert = dm->getNumVerts(dm); - pccd_M->totface = dm->getNumTessFaces(dm); + pccd_M->totvert = cmd->numverts; + pccd_M->totface = cmd->numfaces; pccd_M->savety = CCD_SAVETY; pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; @@ -314,12 +318,10 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft); /* alloc and copy verts*/ - pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ - /* and determine the ortho BB on the fly */ + pccd_M->mvert = MEM_dupallocN(cmd->xnew); + /* note that xnew coords are already in global space, */ + /* determine the ortho BB */ for(i=0; i < pccd_M->totvert; i++){ - mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); @@ -332,7 +334,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) } /* alloc and copy faces*/ - pccd_M->mface = dm->dupTessFaceArray(dm); + pccd_M->mface = MEM_dupallocN(cmd->mfaces); /* OBBs for idea1 */ pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima"); @@ -386,19 +388,22 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm) } return pccd_M; } -static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) +static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M) { - ccdf_minmax *mima =NULL; + CollisionModifierData *cmd; + ccdf_minmax *mima =NULL; MFace *mface=NULL; float v[3],hull; int i; + cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); + /* first some paranoia checks */ - if (!dm) return ; - if (!dm->getNumVerts(dm) || !dm->getNumTessFaces(dm)) return ; + if (!cmd) return ; + if (!cmd->numverts || !cmd->numfaces) return ; - if ((pccd_M->totvert != dm->getNumVerts(dm)) || - (pccd_M->totface != dm->getNumTessFaces(dm))) return; + if ((pccd_M->totvert != cmd->numverts) || + (pccd_M->totface != cmd->numfaces)) return; pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f; pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f; @@ -411,12 +416,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm) if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert); pccd_M->mprevvert = pccd_M->mvert; /* alloc and copy verts*/ - pccd_M->mvert = dm->dupVertArray(dm); - /* ah yeah, put the verices to global coords once */ - /* and determine the ortho BB on the fly */ + pccd_M->mvert = MEM_dupallocN(cmd->xnew); + /* note that xnew coords are already in global space, */ + /* determine the ortho BB */ for(i=0; i < pccd_M->totvert; i++){ - mul_m4_v3(ob->obmat, pccd_M->mvert[i].co); - /* evaluate limits */ VECCOPY(v,pccd_M->mvert[i].co); pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull); @@ -555,21 +558,8 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h /*+++ only with deflecting set */ if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) { - DerivedMesh *dm= NULL; - - if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */ - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - else - dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - - if(dm){ - ccd_Mesh *ccdmesh = ccd_mesh_make(ob, dm); - BLI_ghash_insert(hash, ob, ccdmesh); - - /* we did copy & modify all we need so give 'em away again */ - dm->release(dm); - - } + ccd_Mesh *ccdmesh = ccd_mesh_make(ob); + BLI_ghash_insert(hash, ob, ccdmesh); }/*--- only with deflecting set */ }/* mesh && layer*/ @@ -595,21 +585,9 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash * /*+++ only with deflecting set */ if(ob->pd && ob->pd->deflect) { - DerivedMesh *dm= NULL; - - if(ob->softflag & OB_SB_COLLFINAL) { /* so maybe someone wants overkill to collide with subsurfed */ - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - } else { - dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - } - if(dm){ - ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob); - if (ccdmesh) - ccd_mesh_update(ob,ccdmesh,dm); - - /* we did copy & modify all we need so give 'em away again */ - dm->release(dm); - } + ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob); + if (ccdmesh) + ccd_mesh_update(ob,ccdmesh); }/*--- only with deflecting set */ }/* mesh && layer*/ @@ -2140,9 +2118,9 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN forcefactor = iks/bs->len; else forcefactor = iks; - kw = (bp1->springweight+bp2->springweight)/2.0f; - kw = kw * kw; - kw = kw * kw; + kw = (bp1->springweight+bp2->springweight)/2.0f; + kw = kw * kw; + kw = kw * kw; switch (bs->springtype){ case SB_EDGE: case SB_HANDLE: @@ -3484,7 +3462,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object * if (dostiff) { - if(w){ + if(w){ if( v && u ) { bs->v1 = bpc; bs->v2 = bpc-dw-dv-1; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 35b7d3dfd7a..f89e50b8f7e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1395,7 +1395,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); - int i, edgeSize = ccgSubSurf_getEdgeSize(ss); + int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); + int totedge = ccgSubSurf_getNumEdges(ss); int gridSize = ccgSubSurf_getGridSize(ss); int useAging; @@ -1403,13 +1404,16 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); - for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { - CCGEdge *e = ccgEdgeIterator_getCurrent(ei); + for (j=0; j< totedge; j++) { + CCGEdge *e = ccgdm->edgeMap[j].edge; DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e)) continue; + if(ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW)) + continue; + if (useAging && !(G.f&G_BACKBUFSEL)) { int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4; glColor3ub(0, ageCol>0?ageCol:0, 0); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 64f3c111434..036ba34d0c8 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1486,6 +1486,10 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) // assume anything in adt means the texture is animated return 1; } + else if(texture->type == TEX_NOISE) { + // noise always varies with time + return 1; + } return 0; } |