[Bf-committers] simple segfault fix in Blender.

Campbell Barton cbarton at metavr.com
Fri May 6 14:46:29 CEST 2005


Hi, I wrote tool in python that uses a much better method of converting 
Triangles to quads.

Basic formula - Its slow, gives *Best* results, but not that slow, even 
in python its very useable.
  * Find each possible Pair or triangles (Triangles that share an edge)
     Dont include pairs that have mis matching Material/UV/Mode/VertCol 
(All these are ignored by Blender at the moment)
  * Add a GOODNESS measurement for each pair.
    This is a combind value made up of a measurement of the following.
     - Coplaner- Difference in face normals. (Also tests switched 
direction of normals subdivided quad.)
     - Combine difference face corners are from 90d (so face pairs are 
weighted to prefer more rectangular combinations)
     - Difference in area from triabgles, made into a fraction so it can 
be evenly added to the weighting evenly.
     - Co-Linear/Concave test-. Weight worse for quads that approch 
being co-linear.

Now Sort the pairs by there Goodness value.

loop through each pair and join. tris into Quads.
tri pairs that no longet contain only 3 verts are ignored, as they have 
alredy been joined to another pair.
The loop is exited when the limit reaches the user set LIMIT value.


This cant realy replace Blenders j tool since its more of a mesh filter 
then a tool. In blender somtimes you just want to join 2 tri's only. 
Though mabe Blender could detect that of more then 2 tris are selected, 
then run this code- which is more like a filter, and gives realy nice 
results for an entire object.

I actually used this to convert over 100 bridge models from turbosquid, 
that I had recieved in a triangulated format.

- Cam.




For an example of the result and python source code see my page- Tri2Quads.
http://members.iinet.net.au/~cpbarton/ideasman/

- Cam

Ton Roosendaal wrote:
> Hi,
> 
> Confirmed, although it was for me on line 2310... :)
> 
> Can't really say this 'Join' tool makes a nice result though... it's  
> code unknown to me, written in NaN days. Can be much better, but I'll  
> commit at least the line to prevent it crashing.
> 
> Thanks,
> 
> -Ton-
> 
> On 5 May, 2005, at 6:54, Campbell Barton wrote:
> 
>> Hi, At the moment the join_triangles():2336 function in  
>> editmesh_tools.c dosent account for givequadverts():2017, assigning  
>> NULL to v3 and v4. (See line 2105)
>>
>> This makes a realy stupid segfault.
>> Try getting the monky.
>> Ctrl+T
>> Jkey
>> Ctrl+T
>> Jkey ...> Segfault.
>>
>>
>> To fix this, add this line in editmesh_tools.c:2391
>> if (v3 != NULL && v4 != NULL) {
>>
>> ... This checks that givequadverts() hasnt set v3 ir v4 as null.
>>
>> - Cam
>>
>>
>> --  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
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>>
> ------------------------------------------------------------------------ --
> Ton Roosendaal  Blender Foundation ton at blender.org  http://www.blender.org
> 
> 

-- 
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