Remesh modifier: extensive refactoring of the Octree class.

The changes mostly center around two new structures, InternalNode and
LeafNode. These provide an explicit representation of the Octree
nodes, which formerly were manipulated as opaque byte arrays.

A fair amount of commented out/unused code was also removed. This
includes the "CINDY" code, which may yet be useful, easy to bring back
if so.

There should be no difference in the output of the remesh modifier,
but memory usage may be slightly different. The flood fill bytes are
no longer optional; they will be allocated whether or not the 'remove
disconnect components' flag is set. The leaf node is probably not as
tightly packed due to alignment issues; this could be fixed with the
__attribute__((packed)) flag in gcc (probably there's an MSVC
equivalent), but not sure it's worth it. The internal nodes should
take up less space on 32-bit systems, allocating sizeof(pointer) now
rather than constant eight bytes.

These changes were made in persuit of bug #30158 (remesh crashes on
PowerPC). There's still a fair amount of bitwise stuff in the Octree,
so may still be endian issues and not yet sure if this fixes the bug,
but should be much easier to track down problems now.
This commit is contained in:
Nicholas Bishop 2012-02-18 11:34:53 +00:00
parent f3bef40b0c
commit 850636e0e4
3 changed files with 2261 additions and 3613 deletions

@ -43,8 +43,8 @@
class VirtualMemoryAllocator
{
public:
virtual UCHAR * allocate( ) = 0 ;
virtual void deallocate( UCHAR * obj ) = 0 ;
virtual void * allocate( ) = 0 ;
virtual void deallocate( void * obj ) = 0 ;
virtual void destroy( ) = 0 ;
virtual void printInfo( ) = 0 ;
@ -161,7 +161,7 @@ public:
/**
* Allocation method
*/
UCHAR * allocate ( )
void * allocate ( )
{
if ( available == 0 )
{
@ -170,13 +170,13 @@ public:
// printf("Allocating %d\n", header[ allocated ]) ;
available -- ;
return stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] ;
return (void*)stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] ;
}
/**
* De-allocation method
*/
void deallocate ( UCHAR * obj )
void deallocate ( void * obj )
{
if ( available == stacksize )
{
@ -184,7 +184,7 @@ public:
}
// printf("De-allocating %d\n", ( obj - data ) / N ) ;
stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] = obj ;
stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] = (UCHAR*)obj ;
available ++ ;
// printf("%d %d\n", allocated, header[ allocated ]) ;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff