Context:I can’t paint weights fast enough;I don’t want to use strechmesh unless the studio I work for uses it, pm_heatWeight is useless for facial joints since they’re usually the last child joints in the hierarchy; that leaves Bryce Dorman’s nutils plugin to do the weighting for me. I’ve been debugging it for awhile now since Bryce doesn’t care about it anymore, but I’m stuck on this section of ngeombase.h:
namespace SuperTool
{
class SString;
class Point3:public SAlignedMemory<Point3>
{
public:
Point3(float x, float y, float z):x(x), y(y), z(z), index(0){};
Point3():x(0), y(0), z(0){};
float x;
float y;
float z;
long index;
static const float EPSILON;
inline Point3& operator -(){x = -1; y = -y; z = -z; return (*this);}
inline Point3& operator =(const Point3& p){if(*this != p){index=p.index; x = p.x; y = p.y; z = p.z;} return (*this);}
inline Point3& operator +=(const Point3& p){x += p.x; y += p.y; z += p.z; return (*this);}
inline bool Point3::operator ==(const Point3& p)const{
return (x==p.x&&y==p.y&&z==p.z);
}
inline bool Point3::operator !=(const Point3& p)const{return !operator==(p);}
inline Point3& operator /=(float f){x /= f; y /= f; z /= f; return (*this);}
SString asString() const;
};
The line not working is the return line under Point3::operator==, how do I fix it?
The problem manifests itself there, but it caused somewhere else. There’s really not enough information provided to help anyone diagnose the problem- you can either give a lot more information (callstack, crash dump, what you were doing, etc.), or hope someone has run into it already and can point you in the right direction.
Here’s the entire project:http://www.4shared.com/file/dVydfWR3/nutils.html
The original can be downloaded here:NUTILs download | SourceForge.net
Originally the problem was the “bad access to memory location” error that occurs when I try to compile the plugin for a 64-bit system. I managed to get passed that by going into nallocation.h and changing
static const long ARRAY_ALIGNMENT = 16;
static const long ARRAY_OFFSET = 4;
static const long ARRAY_POINTER_OFFSET = 4;
static const size_t VOID_SIZE = 4;
to:
static const long ARRAY_ALIGNMENT = 64;
static const long ARRAY_OFFSET = 16;
static const long ARRAY_POINTER_OFFSET = 16;
static const size_t VOID_SIZE = 16;
then I could load the plugin, but then there’s a crash right when I utilize the “smoothBindSkin” command, and nutils.exe also crashes. I assumed that if I could get nutils.exe to work, the plugin will also function properly. So I started to debug it and found that in nallocation.h there was a problem with “if (*freeblock==0)” in:
class SFixedAllocator:public SSystemMemory
{
public:
SMemBlock firstBlock;
SMemBlock* lastBlock;
void** freeHead;
long cellSize;
long offsetSize;
long cellCount;
long allocationCount;
long blockCount;
size_t baseBlockSize;
void** maxAddress;
void** minAddress;
SFixedAllocator(long cellSize, long cellCount);
~SFixedAllocator()
{
freeBlocks();
}
void initFreeList(void** rawMemory);
inline void* allocate()
{
if(*freeHead==0)
{
expand();
if(*freeHead==0)
return 0;
}
void* freeBlock = freeHead;
freeHead = (void**)*freeHead;
return freeBlock;
}
So I fixed that by:
inline void* allocate()
{
if((int*)freeHead==NULL)
{
expand();
if((int*)freeHead==NULL)
return 0;
}
void* freeBlock = freeHead;
*freeHead = (void**)*freeHead;
return freeBlock;
}
One thing led to the next, and I’ve forgotten what else I changed in that file, but both it and ngeombase are the only ones I’ve edited, but I think it all goes back to nutils needing to be entirely rewritten for 64-bit operating systems. A process I can’t find any tutorials for in this instance…
Yes you’re going to need to make changes to work with 64 bit programs, which, if that code is any indication, is not going to be easy. If you run it on WoW (Win32 on Win64) does it work (ie, an x86 maya). Are you sure nutils.exe is running as x86? Can you try this all on an x86 machine and see what happens?
nutils.exe doesn’t crash on my x64 machine if it’s compiled as Win32…it’s maya that originally had problems with it…If I knew how to debug a .mll file I probably could find out where exactly the code was failing…
Figured out how to debug in Maya, in nallocation.h:
struct SRawAllocation:public SMemConstants
{
static size_t openSystemAllocationSize;
static inline void* allocateBlock(size_t size)
{
return HeapAlloc(heap, 0, size);
}
static inline void deallocateBlock(void* block, size_t size)
{
deallocateBlock(block);
}
static inline void deallocateBlock(void* block)
{
HeapFree(heap, 0, block);
}
static inline void* allocateAlignedBlock(size_t size)
{
size = roundAllocationSize(size);
size+=VOID_SIZE;
size+=ARRAY_ALIGNMENT;
void* baseAddress = allocateBlock(size);
if(baseAddress==0)
{
dout+"out of memory!";
dout++;
SThreadUtil::die();
}
void* adjustedAddress = alignAndPrependAddress(baseAddress);
return adjustedAddress;
}
static void inline deallocateAlignedBlock(void* address)
{
deallocateBlock(getPrependedAddress(address));
}
static inline void* allocateSystemBlock(size_t size)
{
size = roundAllocationSize(size);
size+=VOID_SIZE;
size+=ARRAY_ALIGNMENT;
void* baseAddress = HeapAlloc(systemHeap, 0, size);
if(baseAddress==0)
{
dout+"out of memory! total system allocations: "+openSystemAllocationSize;
dout++;
SThreadUtil::die();
}
openSystemAllocationSize+=size;
void* adjustedAddress = alignAndPrependAddress(baseAddress);
return adjustedAddress;
}
static void inline deallocateSystemBlock(void* address)
{
HeapFree(systemHeap, 0, getPrependedAddress(address));
}
};
Maya is breaking at:
static inline void* allocateBlock(size_t size)
{
return HeapAlloc(heap, 0, size);
}
I still don’t know what I need to change…