diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-10-28 09:06:05 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-10-28 09:06:05 +0300 |
commit | 243c73e96e18c126227d43728e2d3639c9f7ee41 (patch) | |
tree | 7c34c44f28125754586c414a602327d4421e468a /source/blender/editors | |
parent | 93beb0b85a4a0e301d9bfae9edee1fe7bdabba12 (diff) |
Moved the PBVH from sculpt session to DerivedMesh/CDDM.
* Multires sculpting appears to work now
* PBVH gets recalculated in some cases where it shouldn't, haven't looked into this yet
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 67 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 8 |
2 files changed, 7 insertions, 68 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index b4b002283fd..28ca5d2fecf 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -193,57 +193,6 @@ static void projectf(bglMats *mats, const float v[3], float p[2]) /*** BVH Tree ***/ -/* Updates all the face and vertex normals in a node - - Note: the correctness of some vertex normals will be a little - off, not sure if this will be noticeable or not */ -static void sculpt_update_normals(const int *face_indices, - const int *vert_indices, - int totface, int totvert, void *data) -{ - SculptSession *ss = data; - int i; - - /* Update face normals */ - for(i = 0; i < totface; ++i) { - MFace *f = ss->mface + face_indices[i]; - float *fn = ss->face_normals + face_indices[i] * 3; - - if(f->v4) - CalcNormFloat4(ss->mvert[f->v1].co, ss->mvert[f->v2].co, - ss->mvert[f->v3].co, ss->mvert[f->v4].co, fn); - else - CalcNormFloat(ss->mvert[f->v1].co, ss->mvert[f->v2].co, - ss->mvert[f->v3].co, fn); - } - - /* Update vertex normals */ - for(i = 0; i < totvert; ++i) { - const int v = vert_indices[i]; - float no[3] = {0,0,0}; - IndexNode *face; - - for(face = ss->fmap[v].first; face; face = face->next) - VecAddf(no, no, ss->face_normals + face->index*3); - - Normalize(no); - - ss->mvert[v].no[0] = no[0] * 32767; - ss->mvert[v].no[1] = no[1] * 32767; - ss->mvert[v].no[2] = no[2] * 32767; - } -} - -static void sculpt_rebuild_tree(SculptSession *ss) -{ - if(ss->tree) - BLI_pbvh_free(ss->tree); - - ss->tree = BLI_pbvh_new(sculpt_update_normals, ss); - BLI_pbvh_build(ss->tree, ss->mface, ss->mvert, ss->totface, - ss->totvert); -} - /* Get a screen-space rectangle of the modified area */ int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *rect) @@ -1054,11 +1003,10 @@ static struct MultiresModifierData *sculpt_multires_active(Object *ob) static void sculpt_update_mesh_elements(bContext *C) { Object *ob = CTX_data_active_object(C); + DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); SculptSession *ss = ob->sculpt; - int oldtotvert = ss->totvert; if((ss->multires = sculpt_multires_active(ob))) { - DerivedMesh *dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); ss->totvert = dm->getNumVerts(dm); ss->totface = dm->getNumFaces(dm); ss->mvert = dm->getVertDataArray(dm, CD_MVERT); @@ -1075,17 +1023,8 @@ static void sculpt_update_mesh_elements(bContext *C) ss->face_normals = MEM_callocN(sizeof(float) * 3 * me->totface, "sculpt face normals"); } - if(ss->tree) - BLI_pbvh_set_source(ss->tree, ss->mvert, ss->mface); - - if(ss->totvert != oldtotvert) { - if(ss->fmap) MEM_freeN(ss->fmap); - if(ss->fmap_mem) MEM_freeN(ss->fmap_mem); - create_vert_face_map(&ss->fmap, &ss->fmap_mem, ss->mface, ss->totvert, ss->totface); - ss->fmap_size = ss->totvert; - - sculpt_rebuild_tree(ss); - } + ss->tree = dm->getPBVH(dm); + ss->fmap = dm->getFaceMap(dm); } static int sculpt_mode_poll(bContext *C) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5d7e5932bd8..f7dba10200a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2692,7 +2692,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) drawFacesSolid() doesn't draw the transparent faces */ if(ob->dtx & OB_DRAWTRANSP) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - dm->drawFacesSolid(dm, NULL, NULL, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, GPU_enable_material); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); GPU_disable_material(); } @@ -2802,10 +2802,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D ob->sculpt->partial_redraw = 0; } - dm->drawFacesSolid(dm, ob->sculpt->tree, fpl, GPU_enable_material); + dm->drawFacesSolid(dm, fpl, GPU_enable_material); } else - dm->drawFacesSolid(dm, NULL, NULL, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, GPU_enable_material); GPU_disable_material(); @@ -6276,7 +6276,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r glEnable(GL_LIGHTING); if(dm) { - dm->drawFacesSolid(dm, NULL, NULL, GPU_enable_material); + dm->drawFacesSolid(dm, NULL, GPU_enable_material); GPU_end_object_materials(); } else if(edm) |