|
![]() |
#1 |
Senior Member
Professional user
Join Date: Jun 2003
Location: British Columbia, Canada
Posts: 255
|
![]()
Hi,
I'm working on a modification to my boolean plugin and notice that, for some tests, I am getting different results when fetching all triangulated surfaces from an object versus getting all surfaces then iterating them and triangulating as I go. Example: Code:
List * pObjectSurfaces = ac_object_get_surfacelist( (ACObject *)pSource ); List *pObjectTriangles = ac_object_get_triangle_surfaces((ACObject *)pSource ); List * pSingleSurface = 0; list_for_each( pObjectSurfaces, pSingleSurface ) { List *pTriangulatedSurfaces = surface_get_triangulations( (Surface *)pSingleSurface->data ); for ( List *pTriListIterator = pTriangulatedSurfaces; pTriListIterator; pTriListIterator = pTriListIterator->next) { // DO "SOMETHING" } ac_surfacelist_free(&pTriangulatedSurfaces); } I don't understand why this is happenning, and am pretty much out of ideas. Any information or theories would be welcome. Thanks, -- Jeff |
![]() |
![]() |
![]() |
#2 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,537
|
![]()
Hi Jeff,
Sorry about the delay, the office moving is almost complete now. ac_object_get_triangle_surfaces uses surface_get_triangulations so I can't only think that there may be non-poly or surfaces with < 3 vertices. Remember that the triangulation of a surface may fail fail (you get an empty list returned). ac_object_get_triangle_surfaces looks like this: Code:
Prototype List *ac_object_get_triangle_surfaces(ACObject *ob) // free with ac_surfacelist_free(&result) { List *tri = NULL; int n = 0; for (List *sp = ob->surfacelist; sp != NULL; sp = sp->next, n++) { Surface *s = (Surface *)sp->data; if ((s->numvert < 3) || (s->type != SURFACE_POLYGON) ) continue; if (s->numvert > 3) { List *slist = (List *)surface_get_triangulations(s); list_prepend_list(&tri, slist); } else { Surface *ns = surface_clone(s, ob); list_add_item_head(&tri, (void *)ns); } } // end for all surfaces in object return(tri); } |
![]() |
![]() |
![]() |
#3 |
Senior Member
Professional user
Join Date: Jun 2003
Location: British Columbia, Canada
Posts: 255
|
![]()
Well, I'm afraid I found the difference between our logics. When you get triangulated surfaces from the object the surface listing is in opposite order from the list you get if you just get 'surfaces'.
This seems to indicate that I have an input order dependency in my code, but I can't actually rely on the surfaces coming in in an order that works. What surprises me is that this hasn't been reported from the field, yet. Is there any magic behind internally tracked surface listings which has protected me from these problems, or has it just been luck that no-one has reported them? -- Jeff |
![]() |
![]() |
![]() |
#4 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,537
|
![]()
The only orders that are retained and are important inside AC3D are the order of the children of an object and the order of the vertices within a surface.
The order of other lists e.g. vertices in an object, surfaces in an object may be altered during editing. Will copying the above function and altering the list_prepend cure your problem? (note that it may slow down since adding to the start of a list is generally faster) Andy |
![]() |
![]() |
![]() |
#5 |
Senior Member
Professional user
Join Date: Jun 2003
Location: British Columbia, Canada
Posts: 255
|
![]()
Hi Andy,
No - altering the function is no good. I think I'll need to revisit my BSP tree building process and ensure that splitting surfaces (when chosen from the actual geometry) meet certain characteristics. This is mostly in place anyway... just figuring out exactly which characteristics I need to look for. -- Jeff |
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|