added fix for heightfield (division by floating point scalar, instead of integer),
added default aligned alloc/free
This commit is contained in:
@@ -145,25 +145,25 @@ void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
|
||||
{
|
||||
vertex.setValue(
|
||||
height,
|
||||
(-m_width/2 ) + x,
|
||||
(-m_length/2 ) + y
|
||||
(-m_width/btScalar(2.0)) + x,
|
||||
(-m_length/btScalar(2.0) ) + y
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
vertex.setValue(
|
||||
(-m_width/2 ) + x,
|
||||
(-m_width/btScalar(2.0)) + x,
|
||||
height,
|
||||
(-m_length/2 ) + y
|
||||
(-m_length/btScalar(2.0)) + y
|
||||
);
|
||||
break;
|
||||
};
|
||||
case 2:
|
||||
{
|
||||
vertex.setValue(
|
||||
(-m_width/2 ) + x,
|
||||
(-m_length/2 ) + y,
|
||||
(-m_width/btScalar(2.0)) + x,
|
||||
(-m_length/btScalar(2.0)) + y,
|
||||
height
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -54,17 +54,33 @@ void btAlignedFree (void* ptr)
|
||||
}
|
||||
|
||||
#else
|
||||
///todo
|
||||
///will add some multi-platform version that works without _aligned_malloc/_aligned_free
|
||||
|
||||
void* btAlignedAlloc (int size, int alignment)
|
||||
{
|
||||
return new char[size];
|
||||
void *ret;
|
||||
char *real;
|
||||
unsigned long offset;
|
||||
|
||||
real = (char *)malloc(size + sizeof(void *) + (alignment-1));
|
||||
if (real) {
|
||||
offset = (alignment - (unsigned long)(real + sizeof(void *))) & (alignment-1);
|
||||
ret = (void *)((real + sizeof(void *)) + offset);
|
||||
*((void **)(ret)-1) = (void *)(real);
|
||||
} else {
|
||||
ret = (void *)(real);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void btAlignedFree (void* ptr)
|
||||
{
|
||||
delete [] (char*) ptr;
|
||||
|
||||
void* real;
|
||||
|
||||
if (ptr) {
|
||||
real = *((void **)(ptr)-1);
|
||||
free(real);
|
||||
}
|
||||
}
|
||||
#endif //
|
||||
|
||||
|
||||
Reference in New Issue
Block a user