Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Edge_IsVertexUsedByEdges?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development
View previous topic :: View next topic  
Author Message
chronozphere
DeleD PRO user


Joined: 20 Jun 2006
Posts: 1010
Location: Netherlands

PostPosted: Thu Jan 28, 2010 5:21 pm    Post subject: Edge_IsVertexUsedByEdges? Reply with quote

Hey,

I was browsing through the source and I encountered this

Code:

// determines if a vertex is used by any of the provided edges
function TBasePrimitive.Edge_IsVertexUsedByEdges(edgeList: TEdgeList; vertex: TVertice): boolean;
var i,edgeCounter: integer;
    vertexUsedByEdges: boolean;
begin
    vertexUsedByEdges := false;
    for i := 0 to edgeList.Count-1 do begin
        edgeCounter := 0;
        repeat
            vertexUsedByEdges := Edge_IsVertexUsedByEdge(edgeList[edgeCounter],vertex);
            inc(edgeCounter);
        until (edgeCounter>=edgeList.Count) or (vertexUsedByEdges);
        if not vertexUsedByEdges then
            break;
    end;
    Result := vertexUsedByEdges;
end;


I don't understand it. Why 2 nested loops?? Shocked

Shouldn't this be:


Code:

// determines if a vertex is used by any of the provided edges
function TBasePrimitive.Edge_IsVertexUsedByEdges(edgeList: TEdgeList; vertex: TVertice): boolean;
var
    i: integer;
begin
    Result := false;
    for i:=0 to edgeList.count-1 do
       if Edge_IsVertexUsedByEdge(edgeList[i],vertex) then
       begin
           Result := true;
           Exit;
       end;
end;


Way easier to understand, and faster too. Smile

I could make a patch with a few improvements, if I encounter more of these. Smile
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Jan 28, 2010 7:34 pm    Post subject: Reply with quote

Looks like a bug. Please verify if your new version works as expected and patch it up! Smile
Back to top
View user's profile Send private message Visit poster's website
Jeroen
Site Admin


Joined: 07 Aug 2004
Posts: 5332
Location: The Netherlands

PostPosted: Fri Jan 29, 2010 8:23 am    Post subject: Reply with quote

Laughing Yep, code like that should be improved. Go ahead and do so immediately if you encounter any more of these.
_________________
Check out Figuro, our online 3D app! More powerful 3D tools for free.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum