[Bf-committers] Edge Drawing with derived mesh (all edges currently drawn twice)

Campbell Barton cbarton at metavr.com
Sat Dec 23 06:05:33 CET 2006


Tested and the problems still there,
did a redraw benchmark for redrawing a cube subdivided to 1.5m verts 
with the change below

- 20 redraws
before: 17.19sec
after: 13.10

The lines now DerivedMesh.c:1990

Campbell Barton wrote:
> Maybe this is the solution for double edge drawing
>
> draw_em_fancy's  1871 draws the cage if (cageDM!=finalDM) {
>
> The problem is  DerivedMesh.c's editmesh_calc_modifiers that is called 
> before draw_em_fancy.
>
> static void editmesh_calc_modifiers(DerivedMesh **cage_r, DerivedMesh 
> **final_r)
>
> At the moment this will never make cage_r == final_r
>
> This looks like it may be a 1 liner though.
>
> at DerivedMesh.c:3114
>
> the line
>    *final_r = getEditMeshDerivedMesh(em, ob, deformedVerts);
> can be replaced by
>    *final_r = *cage_r;
>
> I assume this saves memory as well as CPU time making a new derived 
> mesh, which would be nice since this is done as verts are dragging.
>
> it may be possible cage_r is not set, though in my tests it didnt 
> happen, so that could be checked fro also.
>
> _________________  DerivedMesh.c:3114
>    if(dm && deformedVerts) {
>        *final_r = CDDM_copy(dm);
>
>        if(!(cage_r && dm == *cage_r)) dm->release(dm);
>
>        CDDM_apply_vert_coords(*final_r, deformedVerts);
>        CDDM_calc_normals(*final_r);
>
>        MEM_freeN(deformedVerts);
>    } else if (dm) {
>        *final_r = dm;
>    } else {
>        *final_r = getEditMeshDerivedMesh(em, ob, deformedVerts);
>    }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Campbell Barton wrote:
>> Hey,
>> Im posting because this isnt an area Im familier with..
>> just looking at a way to stop hidden faces being drawn in editmode 
>> and discovered that with a normal mesh (no modifiers)
>> all edges are being drawn twice.
>>
>> Once  drawobject.c:1819 - Draws light wire edges, weather there 
>> hidden or not, but only in wire display mode.
>>  finalDM->drawEdges(finalDM, 1);
>>
>> and the normal edge draw
>>  drawobject.c:1864
>> draw_em_fancy_edges(cageDM);
>>
>>
>> From 2104 - Read down to the last line,  if cageDM != finalDM then a 
>> second wire mesh is drawn. (line 1819)
>> I assume cageDM != finalDM means that the modifier has made the 2 
>> derived meshes different then draw the wire cage,
>> But you can see that  cageDM will never == finalDM, for the editmode 
>> object, I dried commenting drawobject.c:1819  and it worked fine.
>> __________________________________________
>> static int draw_mesh_object(Base *base, int dt)
>> {
>>    Object *ob= base->object;
>>    Mesh *me= ob->data;
>>    int has_alpha= 0, drawlinked= 0, retval= 0;
>>      if(G.obedit && ob!=G.obedit && ob->data==G.obedit->data) {
>>        if(ob_get_key(ob));
>>        else drawlinked= 1;
>>    }
>>      if(ob==G.obedit || drawlinked) {
>>        int cageNeedsFree, finalNeedsFree;
>>        DerivedMesh *finalDM, *cageDM;
>>              if (G.obedit!=ob) {
>>            finalDM = cageDM = editmesh_get_derived_base();
>>            cageNeedsFree = 0;
>>            finalNeedsFree = 1;
>>        } else {
>>            cageDM = editmesh_get_derived_cage_and_final(&finalDM, 
>> &cageNeedsFree, &finalNeedsFree);
>>        }
>>
>>        if(dt>OB_WIRE) init_gl_materials(ob, 0);    // no transp in 
>> editmode, the fancy draw over goes bad then
>>        draw_em_fancy(ob, G.editMesh, cageDM, finalDM, dt);
>>
>>
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-committers mailing list