make the source code compile with older compilers again (Visual Studio 2006 in particular)

renamed btDbvt::Volume to btDbvtVolume and btDbvt::Node to btDbvtNode to distinguish from btSoftBody::Node
This commit is contained in:
erwin.coumans
2008-07-15 23:27:18 +00:00
parent 6f8b396575
commit 884a494412
17 changed files with 1557 additions and 1482 deletions

View File

@@ -28,65 +28,36 @@ CFG=appAllBulletDemos - Win32 Release
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "appAllBulletDemos - Win32 Release"
!IF "$(CFG)" == "appAllBulletDemos - Win32 DebugDoublePrecision"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "release"
# PROP BASE Intermediate_Dir "release"
# PROP BASE Output_Dir "debug_dbl"
# PROP BASE Intermediate_Dir "debug_dbl"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\out\release6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\release6\build\appAllBulletDemos\"
# PROP Ignore_Export_Lib 0
# PROP Output_Dir "..\..\out\debug_dbl6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\debug_dbl6\build\appAllBulletDemos\"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /vmb /vms /W3 /Gm /G5 /D "WIN32" /FD /c
# ADD CPP /nologo /vmb /vms /W3 /Gm /G5 /FD /c /Gy /GF /MD /Ob2 /Og /Oi /Ot /Oy /D "_MT" /D "_MBCS" /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils"
# ADD BASE MTL /nologo /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 /fo".\..\..\out\release6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /machine:I386 /OPT:NOREF /out:"..\..\AllBulletDemos.exe" /subsystem:console /libpath:"..\..\Glut"
!ELSEIF "$(CFG)" == "appAllBulletDemos - Win32 ReleaseDoublePrecision"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries
# PROP BASE Output_Dir "release_dbl"
# PROP BASE Intermediate_Dir "release_dbl"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries
# PROP Output_Dir "..\..\out\release_dbl6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\release_dbl6\build\appAllBulletDemos\"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /vmb /vms /W3 /Gm /G5 /D "WIN32" /FD /c
# ADD CPP /nologo /vmb /vms /W3 /Gm /G5 /FD /c /D "_MT" /D "_MBCS" /D "NDEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils"
MTL=midl.exe
# ADD BASE MTL /nologo /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "NDEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "_DEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD BASE CPP /nologo /G5 /W3 /D "WIN32" /FD /c
# ADD CPP /nologo /G5 /W3 /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils" /D "_MT" /D "_MBCS" /D "_DEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 /fo".\..\..\out\release_dbl6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
# ADD RSC /l 0x409 /fo".\..\..\out\debug_dbl6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /machine:I386 /out:"..\..\AllBulletDemos.exe" /subsystem:console /libpath:"..\..\Glut"
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /out:"..\..\AllBulletDemos.exe" /libpath:"..\..\Glut"
!ELSEIF "$(CFG)" == "appAllBulletDemos - Win32 Debug"
@@ -101,58 +72,90 @@ LINK32=link.exe
# PROP Intermediate_Dir "..\..\out\debug6\build\appAllBulletDemos\"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /vmb /vms /W3 /Gm /G5 /D "WIN32" /FD /c
# ADD CPP /nologo /vmb /vms /W3 /Gm /G5 /FD /c /GR /MDd /ZI /Od /D "_MT" /D "_MBCS" /D "_DEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils"
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
MTL=midl.exe
# ADD BASE MTL /nologo /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "_DEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD BASE CPP /nologo /G5 /W3 /D "WIN32" /FD /c
# ADD CPP /nologo /G5 /MDd /W3 /Gm /GR /ZI /Od /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils" /D "_MT" /D "_MBCS" /D "_DEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /FD /Zm1000 /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 /fo".\..\..\out\debug6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /out:"..\..\AllBulletDemos.exe" /pdbtype:sept /libpath:"..\..\Glut"
!ELSEIF "$(CFG)" == "appAllBulletDemos - Win32 ReleaseDoublePrecision"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "release_dbl"
# PROP BASE Intermediate_Dir "release_dbl"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\out\release_dbl6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\release_dbl6\build\appAllBulletDemos\"
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /machine:I386 /debug /pdbtype:sept /out:"..\..\AllBulletDemos.exe" /subsystem:console /libpath:"..\..\Glut"
!ELSEIF "$(CFG)" == "appAllBulletDemos - Win32 DebugDoublePrecision"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries
# PROP BASE Output_Dir "debug_dbl"
# PROP BASE Intermediate_Dir "debug_dbl"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries
# PROP Output_Dir "..\..\out\debug_dbl6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\debug_dbl6\build\appAllBulletDemos\"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /vmb /vms /W3 /Gm /G5 /D "WIN32" /FD /c
# ADD CPP /nologo /vmb /vms /W3 /Gm /G5 /FD /c /D "_MT" /D "_MBCS" /D "_DEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils"
MTL=midl.exe
# ADD BASE MTL /nologo /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "_DEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "NDEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD BASE CPP /nologo /G5 /W3 /D "WIN32" /FD /c
# ADD CPP /nologo /G5 /W3 /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils" /D "_MT" /D "_MBCS" /D "NDEBUG" /D "BT_USE_DOUBLE_PRECISION" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 /fo".\..\..\out\debug_dbl6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
# ADD RSC /l 0x409 /fo".\..\..\out\release_dbl6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /out:"..\..\AllBulletDemos.exe" /libpath:"..\..\Glut"
!ELSEIF "$(CFG)" == "appAllBulletDemos - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "release"
# PROP BASE Intermediate_Dir "release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\out\release6\build\appAllBulletDemos\"
# PROP Intermediate_Dir "..\..\out\release6\build\appAllBulletDemos\"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
MTL=midl.exe
# ADD BASE MTL /nologo /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /mktyplib203 /o "NUL" /win32 /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE"
# ADD BASE CPP /nologo /G5 /W3 /D "WIN32" /FD /c
# ADD CPP /nologo /G5 /MD /W3 /Ot /Og /Oi /Oy /Ob2 /Gy /I "." /I "..\.." /I "..\..\src" /I "..\..\Glut" /I "..\..\Extras" /I "..\..\Extras\ConvexHull" /I "..\..\Demos\OpenGL" /I "..\..\Extras\ConvexDecomposition" /I "..\..\Extras\GIMPACT\include" /I "..\..\Extras\GIMPACTUtils" /D "_MT" /D "_MBCS" /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_NONSTDC_NO_DEPRECATE" /D "WIN32" /FR /FD /GF /Zm1000 /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409 /fo".\..\..\out\release6\build\appAllBulletDemos\appAllBulletDemos.res" /i "." /i "..\.." /i "..\..\src" /i "..\..\Glut" /i "..\..\Extras" /i "..\..\Extras\ConvexHull" /i "..\..\Demos\OpenGL" /i "..\..\Extras\ConvexDecomposition" /i "..\..\Extras\GIMPACT\include" /i "..\..\Extras\GIMPACTUtils"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib advapi32.lib /nologo /machine:I386
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /machine:I386 /out:"..\..\AllBulletDemos.exe" /subsystem:console /libpath:"..\..\Glut"
# ADD LINK32 shell32.lib user32.lib gdi32.lib advapi32.lib glut32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /out:"..\..\AllBulletDemos.exe" /libpath:"..\..\Glut" /OPT:NOREF
!ENDIF
# Begin Target
# Name "appAllBulletDemos - Win32 Release"
# Name "appAllBulletDemos - Win32 ReleaseDoublePrecision"
# Name "appAllBulletDemos - Win32 Debug"
# Name "appAllBulletDemos - Win32 DebugDoublePrecision"
# Name "appAllBulletDemos - Win32 Debug"
# Name "appAllBulletDemos - Win32 ReleaseDoublePrecision"
# Name "appAllBulletDemos - Win32 Release"
# Begin Group "Source Files"
# PROP Default_Filter ""
@@ -202,7 +205,7 @@ SOURCE=..\..\Demos\AllBulletDemos\..\ConvexDecompositionDemo\ConvexDecomposition
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\..\DynamicControlDemo\MotorDemo.cpp
SOURCE=..\..\Demos\AllBulletDemos\DemoEntries.cpp
# End Source File
# Begin Source File
@@ -214,6 +217,14 @@ SOURCE=..\..\Demos\AllBulletDemos\..\GjkConvexCastDemo\LinearConvexCastDemo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\Main.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\..\DynamicControlDemo\MotorDemo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\..\RagdollDemo\RagdollDemo.cpp
# End Source File
# Begin Source File
@@ -232,14 +243,6 @@ SOURCE=..\..\Demos\AllBulletDemos\..\SoftDemo\SoftDemo.cpp
SOURCE=..\..\Demos\AllBulletDemos\..\VehicleDemo\VehicleDemo.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\DemoEntries.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Demos\AllBulletDemos\Main.cpp
# End Source File
# End Group
# Begin Group "Header Files"

View File

@@ -17,33 +17,33 @@ subject to the following restrictions:
#include "btDbvt.h"
//
typedef btAlignedObjectArray<btDbvt::Node*> tNodeArray;
typedef btAlignedObjectArray<const btDbvt::Node*> tConstNodeArray;
typedef btAlignedObjectArray<btDbvtNode*> tNodeArray;
typedef btAlignedObjectArray<const btDbvtNode*> tConstNodeArray;
//
struct btDbvtNodeEnumerator : btDbvt::ICollide
{
tConstNodeArray nodes;
void Process(const btDbvt::Node* n) { nodes.push_back(n); }
void Process(const btDbvtNode* n) { nodes.push_back(n); }
};
//
static inline int indexof(const btDbvt::Node* node)
static inline int indexof(const btDbvtNode* node)
{
return(node->parent->childs[1]==node);
}
//
static inline btDbvt::Volume merge( const btDbvt::Volume& a,
const btDbvt::Volume& b)
static inline btDbvtVolume merge( const btDbvtVolume& a,
const btDbvtVolume& b)
{
btDbvt::Volume res;
btDbvtVolume res;
Merge(a,b,res);
return(res);
}
// volume+edge lengths
static inline btScalar size(const btDbvt::Volume& a)
static inline btScalar size(const btDbvtVolume& a)
{
const btVector3 edges=a.Lengths();
return( edges.x()*edges.y()*edges.z()+
@@ -52,7 +52,7 @@ return( edges.x()*edges.y()*edges.z()+
//
static inline void deletenode( btDbvt* pdbvt,
btDbvt::Node* node)
btDbvtNode* node)
{
btAlignedFree(pdbvt->m_free);
pdbvt->m_free=node;
@@ -60,7 +60,7 @@ pdbvt->m_free=node;
//
static inline void recursedeletenode( btDbvt* pdbvt,
btDbvt::Node* node)
btDbvtNode* node)
{
if(!node->isleaf())
{
@@ -72,16 +72,16 @@ deletenode(pdbvt,node);
}
//
static inline btDbvt::Node* createnode( btDbvt* pdbvt,
btDbvt::Node* parent,
const btDbvt::Volume& volume,
static inline btDbvtNode* createnode( btDbvt* pdbvt,
btDbvtNode* parent,
const btDbvtVolume& volume,
void* data)
{
btDbvt::Node* node;
btDbvtNode* node;
if(pdbvt->m_free)
{ node=pdbvt->m_free;pdbvt->m_free=0; }
else
{ node=new(btAlignedAlloc(sizeof(btDbvt::Node),16)) btDbvt::Node(); }
{ node=new(btAlignedAlloc(sizeof(btDbvtNode),16)) btDbvtNode(); }
node->parent = parent;
node->volume = volume;
node->data = data;
@@ -91,8 +91,8 @@ return(node);
//
static inline void insertleaf( btDbvt* pdbvt,
btDbvt::Node* root,
btDbvt::Node* leaf)
btDbvtNode* root,
btDbvtNode* leaf)
{
if(!pdbvt->m_root)
{
@@ -111,8 +111,8 @@ if(!pdbvt->m_root)
root=root->childs[1];
} while(!root->isleaf());
}
btDbvt::Node* prev=root->parent;
btDbvt::Node* node=createnode(pdbvt,prev,merge(leaf->volume,root->volume),0);
btDbvtNode* prev=root->parent;
btDbvtNode* node=createnode(pdbvt,prev,merge(leaf->volume,root->volume),0);
if(prev)
{
prev->childs[indexof(root)] = node;
@@ -136,8 +136,8 @@ if(!pdbvt->m_root)
}
//
static inline btDbvt::Node* removeleaf( btDbvt* pdbvt,
btDbvt::Node* leaf)
static inline btDbvtNode* removeleaf( btDbvt* pdbvt,
btDbvtNode* leaf)
{
if(leaf==pdbvt->m_root)
{
@@ -146,9 +146,9 @@ if(leaf==pdbvt->m_root)
}
else
{
btDbvt::Node* parent=leaf->parent;
btDbvt::Node* prev=parent->parent;
btDbvt::Node* sibling=parent->childs[1-indexof(leaf)];
btDbvtNode* parent=leaf->parent;
btDbvtNode* prev=parent->parent;
btDbvtNode* sibling=parent->childs[1-indexof(leaf)];
if(prev)
{
prev->childs[indexof(parent)]=sibling;
@@ -156,7 +156,7 @@ if(leaf==pdbvt->m_root)
deletenode(pdbvt,parent);
while(prev)
{
const btDbvt::Volume pb=prev->volume;
const btDbvtVolume pb=prev->volume;
Merge(prev->childs[0]->volume,prev->childs[1]->volume,prev->volume);
if(NotEqual(pb,prev->volume))
{
@@ -177,7 +177,7 @@ if(leaf==pdbvt->m_root)
//
static void fetchleaves(btDbvt* pdbvt,
btDbvt::Node* root,
btDbvtNode* root,
tNodeArray& leaves,
int depth=-1)
{
@@ -212,9 +212,9 @@ for(int i=0,ni=leaves.size();i<ni;++i)
}
//
static btDbvt::Volume bounds( const tNodeArray& leaves)
static btDbvtVolume bounds( const tNodeArray& leaves)
{
btDbvt::Volume volume=leaves[0]->volume;
btDbvtVolume volume=leaves[0]->volume;
for(int i=1,ni=leaves.size();i<ni;++i)
{
volume=merge(volume,leaves[i]->volume);
@@ -243,8 +243,8 @@ while(leaves.size()>1)
}
}
}
btDbvt::Node* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
btDbvt::Node* p = createnode(pdbvt,0,merge(n[0]->volume,n[1]->volume),0);
btDbvtNode* n[] = {leaves[minidx[0]],leaves[minidx[1]]};
btDbvtNode* p = createnode(pdbvt,0,merge(n[0]->volume,n[1]->volume),0);
p->childs[0] = n[0];
p->childs[1] = n[1];
n[0]->parent = p;
@@ -256,7 +256,7 @@ while(leaves.size()>1)
}
//
static btDbvt::Node* topdown(btDbvt* pdbvt,
static btDbvtNode* topdown(btDbvt* pdbvt,
tNodeArray& leaves,
int bu_treshold)
{
@@ -267,13 +267,14 @@ if(leaves.size()>1)
{
if(leaves.size()>bu_treshold)
{
const btDbvt::Volume vol=bounds(leaves);
const btDbvtVolume vol=bounds(leaves);
const btVector3 org=vol.Center();
tNodeArray sets[2];
int bestaxis=-1;
int bestmidp=leaves.size();
int splitcount[3][2]={{0,0},{0,0},{0,0}};
for(int i=0;i<leaves.size();++i)
int i;
for( i=0;i<leaves.size();++i)
{
const btVector3 x=leaves[i]->volume.Center()-org;
for(int j=0;j<3;++j)
@@ -281,7 +282,7 @@ if(leaves.size()>1)
++splitcount[j][dot(x,axis[j])>0?1:0];
}
}
for(int i=0;i<3;++i)
for( i=0;i<3;++i)
{
if((splitcount[i][0]>0)&&(splitcount[i][1]>0))
{
@@ -308,7 +309,7 @@ if(leaves.size()>1)
sets[i&1].push_back(leaves[i]);
}
}
btDbvt::Node* node=createnode(pdbvt,0,vol,0);
btDbvtNode* node=createnode(pdbvt,0,vol,0);
node->childs[0]=topdown(pdbvt,sets[0],bu_treshold);
node->childs[1]=topdown(pdbvt,sets[1],bu_treshold);
node->childs[0]->parent=node;
@@ -325,16 +326,16 @@ return(leaves[0]);
}
//
static inline btDbvt::Node* sort(btDbvt::Node* n,btDbvt::Node*& r)
static inline btDbvtNode* sort(btDbvtNode* n,btDbvtNode*& r)
{
btDbvt::Node* p=n->parent;
btDbvtNode* p=n->parent;
btAssert(n->isinternal());
if(p>n)
{
const int i=indexof(n);
const int j=1-i;
btDbvt::Node* s=p->childs[j];
btDbvt::Node* q=p->parent;
btDbvtNode* s=p->childs[j];
btDbvtNode* q=p->parent;
btAssert(n==p->childs[i]);
if(q) q->childs[indexof(p)]=n; else r=n;
s->parent=n;
@@ -353,7 +354,7 @@ return(n);
}
//
static inline btDbvt::Node* walkup(btDbvt::Node* n,int count)
static inline btDbvtNode* walkup(btDbvtNode* n,int count)
{
while(n&&(count--)) n=n->parent;
return(n);
@@ -419,7 +420,7 @@ if(passes<0) passes=m_leaves;
if(m_root&&(passes>0))
{
do {
Node* node=m_root;
btDbvtNode* node=m_root;
unsigned bit=0;
while(node->isinternal())
{
@@ -433,18 +434,18 @@ if(m_root&&(passes>0))
}
//
btDbvt::Node* btDbvt::insert(const Volume& volume,void* data)
btDbvtNode* btDbvt::insert(const btDbvtVolume& volume,void* data)
{
Node* leaf=createnode(this,0,volume,data);
btDbvtNode* leaf=createnode(this,0,volume,data);
insertleaf(this,m_root,leaf);
++m_leaves;
return(leaf);
}
//
void btDbvt::update(Node* leaf,int lookahead)
void btDbvt::update(btDbvtNode* leaf,int lookahead)
{
Node* root=removeleaf(this,leaf);
btDbvtNode* root=removeleaf(this,leaf);
if(root)
{
if(lookahead>=0)
@@ -459,9 +460,9 @@ insertleaf(this,root,leaf);
}
//
void btDbvt::update(Node* leaf,const Volume& volume)
void btDbvt::update(btDbvtNode* leaf,const btDbvtVolume& volume)
{
Node* root=removeleaf(this,leaf);
btDbvtNode* root=removeleaf(this,leaf);
if(root)
{
if(m_lkhd>=0)
@@ -477,7 +478,7 @@ insertleaf(this,root,leaf);
}
//
bool btDbvt::update(Node* leaf,Volume volume,const btVector3& velocity,btScalar margin)
bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity,btScalar margin)
{
if(leaf->volume.Contain(volume)) return(false);
volume.Expand(btVector3(margin,margin,margin));
@@ -487,7 +488,7 @@ return(true);
}
//
bool btDbvt::update(Node* leaf,Volume volume,const btVector3& velocity)
bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity)
{
if(leaf->volume.Contain(volume)) return(false);
volume.SignedExpand(velocity);
@@ -496,7 +497,7 @@ return(true);
}
//
bool btDbvt::update(Node* leaf,Volume volume,btScalar margin)
bool btDbvt::update(btDbvtNode* leaf,btDbvtVolume volume,btScalar margin)
{
if(leaf->volume.Contain(volume)) return(false);
volume.Expand(btVector3(margin,margin,margin));
@@ -505,7 +506,7 @@ return(true);
}
//
void btDbvt::remove(Node* leaf)
void btDbvt::remove(btDbvtNode* leaf)
{
removeleaf(this,leaf);
deletenode(this,leaf);
@@ -521,7 +522,7 @@ enumNodes(m_root,nodes);
iwriter->Prepare(m_root,nodes.nodes.size());
for(int i=0;i<nodes.nodes.size();++i)
{
const Node* n=nodes.nodes[i];
const btDbvtNode* n=nodes.nodes[i];
int p=-1;
if(n->parent) p=nodes.nodes.findLinearSearch(n->parent);
if(n->isinternal())
@@ -549,7 +550,7 @@ if(m_root!=0)
do {
const int i=stack.size()-1;
const sStkCLN e=stack[i];
Node* n=createnode(&dest,e.parent,e.node->volume,e.node->data);
btDbvtNode* n=createnode(&dest,e.parent,e.node->volume,e.node->data);
stack.pop_back();
if(e.parent!=0)
e.parent->childs[i&1]=n;
@@ -569,7 +570,7 @@ if(m_root!=0)
}
//
int btDbvt::countLeaves(const Node* node)
int btDbvt::countLeaves(const btDbvtNode* node)
{
if(node->isinternal())
return(countLeaves(node->childs[0])+countLeaves(node->childs[1]));
@@ -578,7 +579,7 @@ if(node->isinternal())
}
//
void btDbvt::extractLeaves(const Node* node,btAlignedObjectArray<const Node*>& leaves)
void btDbvt::extractLeaves(const btDbvtNode* node,btAlignedObjectArray<const btDbvtNode*>& leaves)
{
if(node->isinternal())
{
@@ -612,8 +613,8 @@ Benchmarking dbvt...
Extents base: 1.000000
Extents range: 4.000000
Leaves: 8192
[1] btDbvt::Volume intersections: 3986 ms (0%)
[2] btDbvt::Volume merges: 5815 ms (-1%)
[1] btDbvtVolume intersections: 3986 ms (0%)
[2] btDbvtVolume merges: 5815 ms (-1%)
[3] btDbvt::collideTT: 3267 ms (0%)
[4] btDbvt::collideTT self: 1657 ms (0%)
[5] btDbvt::collideTT xform: 7201 ms (0%)
@@ -623,7 +624,7 @@ Benchmarking dbvt...
[9] updates (teleport): 3281 ms (0%),(639180 u/s)
[10] updates (jitter): 2658 ms (0%),(788996 u/s)
[11] optimize (incremental): 5091 ms (0%),(823000 o/s)
[12] btDbvt::Volume notequal: 4151 ms (0%)
[12] btDbvtVolume notequal: 4151 ms (0%)
[13] culling(OCL): 2486 ms (0%),(411 t/s)
[14] culling(OCL+qsort): 599 ms (-2%),(1709 t/s)
[15] culling(KDOP+qsort): 306 ms (0%),(3346 t/s)
@@ -634,9 +635,9 @@ struct btDbvtBenchmark
struct NilPolicy : btDbvt::ICollide
{
NilPolicy() : m_pcount(0),m_depth(-SIMD_INFINITY),m_checksort(true) {}
void Process(const btDbvt::Node*,const btDbvt::Node*) { ++m_pcount; }
void Process(const btDbvt::Node*) { ++m_pcount; }
void Process(const btDbvt::Node*,btScalar depth)
void Process(const btDbvtNode*,const btDbvtNode*) { ++m_pcount; }
void Process(const btDbvtNode*) { ++m_pcount; }
void Process(const btDbvtNode*,btScalar depth)
{
++m_pcount;
if(m_checksort)
@@ -648,45 +649,45 @@ struct NilPolicy : btDbvt::ICollide
};
struct P14 : btDbvt::ICollide
{
struct Node
struct btDbvtNode
{
const btDbvt::Node* leaf;
const btDbvtNode* leaf;
btScalar depth;
};
void Process(const btDbvt::Node* leaf,btScalar depth)
void Process(const btDbvtNode* leaf,btScalar depth)
{
Node n;
btDbvtNode n;
n.leaf = leaf;
n.depth = depth;
}
static int sortfnc(const Node& a,const Node& b)
static int sortfnc(const btDbvtNode& a,const btDbvtNode& b)
{
if(a.depth<b.depth) return(+1);
if(a.depth>b.depth) return(-1);
return(0);
}
btAlignedObjectArray<Node> m_nodes;
btAlignedObjectArray<btDbvtNode> m_nodes;
};
struct P15 : btDbvt::ICollide
{
struct Node
struct btDbvtNode
{
const btDbvt::Node* leaf;
const btDbvtNode* leaf;
btScalar depth;
};
void Process(const btDbvt::Node* leaf)
void Process(const btDbvtNode* leaf)
{
Node n;
btDbvtNode n;
n.leaf = leaf;
n.depth = dot(leaf->volume.Center(),m_axis);
}
static int sortfnc(const Node& a,const Node& b)
static int sortfnc(const btDbvtNode& a,const btDbvtNode& b)
{
if(a.depth<b.depth) return(+1);
if(a.depth>b.depth) return(-1);
return(0);
}
btAlignedObjectArray<Node> m_nodes;
btAlignedObjectArray<btDbvtNode> m_nodes;
btVector3 m_axis;
};
static btScalar RandUnit()
@@ -701,9 +702,9 @@ static btVector3 RandVector3(btScalar cs)
{
return(RandVector3()*cs-btVector3(cs,cs,cs)/2);
}
static btDbvt::Volume RandVolume(btScalar cs,btScalar eb,btScalar es)
static btDbvtVolume RandVolume(btScalar cs,btScalar eb,btScalar es)
{
return(btDbvt::Volume::FromCE(RandVector3(cs),btVector3(eb,eb,eb)+RandVector3()*es));
return(btDbvtVolume::FromCE(RandVector3(cs),btVector3(eb,eb,eb)+RandVector3()*es));
}
static btTransform RandTransform(btScalar cs)
{
@@ -730,11 +731,11 @@ static const btScalar cfgVolumeExentsScale = 4;
static const int cfgLeaves = 8192;
static const bool cfgEnable = true;
//[1] btDbvt::Volume intersections
//[1] btDbvtVolume intersections
bool cfgBenchmark1_Enable = cfgEnable;
static const int cfgBenchmark1_Iterations = 8;
static const int cfgBenchmark1_Reference = 3980;
//[2] btDbvt::Volume merges
//[2] btDbvtVolume merges
bool cfgBenchmark2_Enable = cfgEnable;
static const int cfgBenchmark2_Iterations = 4;
static const int cfgBenchmark2_Reference = 5924;
@@ -782,7 +783,7 @@ bool cfgBenchmark11_Enable = cfgEnable;
static const int cfgBenchmark11_Passes = 64;
static const int cfgBenchmark11_Iterations = 65536;
static const int cfgBenchmark11_Reference = 5075;
//[12] btDbvt::Volume notequal
//[12] btDbvtVolume notequal
bool cfgBenchmark12_Enable = cfgEnable;
static const int cfgBenchmark12_Iterations = 32;
static const int cfgBenchmark12_Reference = 4118;
@@ -808,7 +809,7 @@ printf("\tLeaves: %u\r\n",cfgLeaves);
if(cfgBenchmark1_Enable)
{// Benchmark 1
srand(380843);
btAlignedObjectArray<btDbvt::Volume> volumes;
btAlignedObjectArray<btDbvtVolume> volumes;
btAlignedObjectArray<bool> results;
volumes.resize(cfgLeaves);
results.resize(cfgLeaves);
@@ -816,7 +817,7 @@ if(cfgBenchmark1_Enable)
{
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
}
printf("[1] btDbvt::Volume intersections: ");
printf("[1] btDbvtVolume intersections: ");
wallclock.reset();
for(int i=0;i<cfgBenchmark1_Iterations;++i)
{
@@ -834,15 +835,15 @@ if(cfgBenchmark1_Enable)
if(cfgBenchmark2_Enable)
{// Benchmark 2
srand(380843);
btAlignedObjectArray<btDbvt::Volume> volumes;
btAlignedObjectArray<btDbvt::Volume> results;
btAlignedObjectArray<btDbvtVolume> volumes;
btAlignedObjectArray<btDbvtVolume> results;
volumes.resize(cfgLeaves);
results.resize(cfgLeaves);
for(int i=0;i<cfgLeaves;++i)
{
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
}
printf("[2] btDbvt::Volume merges: ");
printf("[2] btDbvtVolume merges: ");
wallclock.reset();
for(int i=0;i<cfgBenchmark2_Iterations;++i)
{
@@ -989,7 +990,7 @@ if(cfgBenchmark9_Enable)
{// Benchmark 9
srand(380843);
btDbvt dbvt;
btAlignedObjectArray<const btDbvt::Node*> leaves;
btAlignedObjectArray<const btDbvtNode*> leaves;
btDbvtBenchmark::RandTree(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale,cfgLeaves,dbvt);
dbvt.optimizeTopDown();
dbvt.extractLeaves(dbvt.m_root,leaves);
@@ -999,7 +1000,7 @@ if(cfgBenchmark9_Enable)
{
for(int j=0;j<cfgBenchmark9_Iterations;++j)
{
dbvt.update(const_cast<btDbvt::Node*>(leaves[rand()%cfgLeaves]),
dbvt.update(const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]),
btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale));
}
}
@@ -1011,7 +1012,7 @@ if(cfgBenchmark10_Enable)
{// Benchmark 10
srand(380843);
btDbvt dbvt;
btAlignedObjectArray<const btDbvt::Node*> leaves;
btAlignedObjectArray<const btDbvtNode*> leaves;
btAlignedObjectArray<btVector3> vectors;
vectors.resize(cfgBenchmark10_Iterations);
for(int i=0;i<vectors.size();++i)
@@ -1029,8 +1030,8 @@ if(cfgBenchmark10_Enable)
for(int j=0;j<cfgBenchmark10_Iterations;++j)
{
const btVector3& d=vectors[j];
btDbvt::Node* l=const_cast<btDbvt::Node*>(leaves[rand()%cfgLeaves]);
btDbvt::Volume v=btDbvt::Volume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d);
btDbvtNode* l=const_cast<btDbvtNode*>(leaves[rand()%cfgLeaves]);
btDbvtVolume v=btDbvtVolume::FromMM(l->volume.Mins()+d,l->volume.Maxs()+d);
dbvt.update(l,v);
}
}
@@ -1057,7 +1058,7 @@ if(cfgBenchmark11_Enable)
if(cfgBenchmark12_Enable)
{// Benchmark 12
srand(380843);
btAlignedObjectArray<btDbvt::Volume> volumes;
btAlignedObjectArray<btDbvtVolume> volumes;
btAlignedObjectArray<bool> results;
volumes.resize(cfgLeaves);
results.resize(cfgLeaves);
@@ -1065,7 +1066,7 @@ if(cfgBenchmark12_Enable)
{
volumes[i]=btDbvtBenchmark::RandVolume(cfgVolumeCenterScale,cfgVolumeExentsBase,cfgVolumeExentsScale);
}
printf("[12] btDbvt::Volume notequal: ");
printf("[12] btDbvtVolume notequal: ");
wallclock.reset();
for(int i=0;i<cfgBenchmark12_Iterations;++i)
{

View File

@@ -26,8 +26,13 @@ subject to the following restrictions:
//
#ifdef WIN32
//only define templates for visual studio 2005 and later, it just causes headaches for other compilers
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
#define DBVT_USE_TEMPLATE 1 // Enable template for ICollide
#else
#define DBVT_USE_TEMPLATE 0 // Don't
#endif
#else
#define DBVT_USE_TEMPLATE 0 // Enable template for ICollide
#endif
@@ -117,51 +122,55 @@ private:
btVector3 mi,mx;
};
// Types
typedef btDbvtAabbMm btDbvtVolume;
/* btDbvtNode */
struct btDbvtNode
{
btDbvtVolume volume;
btDbvtNode* parent;
bool isleaf() const { return(childs[1]==0); }
bool isinternal() const { return(!isleaf()); }
union {
btDbvtNode* childs[2];
void* data;
};
};
//
// Dynamic bounding volume tree
//
struct btDbvt
{
// Types
typedef btDbvtAabbMm Volume;
/* Node */
struct Node
{
Volume volume;
Node* parent;
bool isleaf() const { return(childs[1]==0); }
bool isinternal() const { return(!isleaf()); }
union {
Node* childs[2];
void* data;
};
};
/* Stack element */
struct sStkNN
{
const Node* a;
const Node* b;
sStkNN(const Node* na,const Node* nb) : a(na),b(nb) {}
const btDbvtNode* a;
const btDbvtNode* b;
sStkNN(const btDbvtNode* na,const btDbvtNode* nb) : a(na),b(nb) {}
};
struct sStkNP
{
const Node* node;
const btDbvtNode* node;
int mask;
sStkNP(const Node* n,unsigned m) : node(n),mask(m) {}
sStkNP(const btDbvtNode* n,unsigned m) : node(n),mask(m) {}
};
struct sStkNPS
{
const Node* node;
const btDbvtNode* node;
int mask;
btScalar value;
sStkNPS() {}
sStkNPS(const Node* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
sStkNPS(const btDbvtNode* n,unsigned m,btScalar v) : node(n),mask(m),value(v) {}
};
struct sStkCLN
{
const Node* node;
Node* parent;
sStkCLN(const Node* n,Node* p) : node(n),parent(p) {}
const btDbvtNode* node;
btDbvtNode* parent;
sStkCLN(const btDbvtNode* n,btDbvtNode* p) : node(n),parent(p) {}
};
// Policies/Interfaces
@@ -169,25 +178,25 @@ struct btDbvt
struct ICollide
{
DBVT_VIRTUAL_DTOR(ICollide)
DBVT_VIRTUAL void Process(const Node*,const Node*) {}
DBVT_VIRTUAL void Process(const Node*) {}
DBVT_VIRTUAL void Process(const Node* n,btScalar) { Process(n); }
DBVT_VIRTUAL bool Descent(const Node*) { return(true); }
DBVT_VIRTUAL bool AllLeaves(const Node*) { return(true); }
DBVT_VIRTUAL void Process(const btDbvtNode*,const btDbvtNode*) {}
DBVT_VIRTUAL void Process(const btDbvtNode*) {}
DBVT_VIRTUAL void Process(const btDbvtNode* n,btScalar) { Process(n); }
DBVT_VIRTUAL bool Descent(const btDbvtNode*) { return(true); }
DBVT_VIRTUAL bool AllLeaves(const btDbvtNode*) { return(true); }
};
/* IWriter */
struct IWriter
{
virtual ~IWriter() {}
virtual void Prepare(const Node* root,int numnodes)=0;
virtual void WriteNode(const Node*,int index,int parent,int child0,int child1)=0;
virtual void WriteLeaf(const Node*,int index,int parent)=0;
virtual void Prepare(const btDbvtNode* root,int numnodes)=0;
virtual void WriteNode(const btDbvtNode*,int index,int parent,int child0,int child1)=0;
virtual void WriteLeaf(const btDbvtNode*,int index,int parent)=0;
};
/* IClone */
struct IClone
{
virtual ~IClone() {}
virtual void CloneLeaf(Node*) {}
virtual void CloneLeaf(btDbvtNode*) {}
};
// Constants
@@ -197,8 +206,8 @@ struct btDbvt
};
// Fields
Node* m_root;
Node* m_free;
btDbvtNode* m_root;
btDbvtNode* m_free;
int m_lkhd;
int m_leaves;
unsigned m_opath;
@@ -210,17 +219,17 @@ struct btDbvt
void optimizeBottomUp();
void optimizeTopDown(int bu_treshold=128);
void optimizeIncremental(int passes);
Node* insert(const Volume& box,void* data);
void update(Node* leaf,int lookahead=-1);
void update(Node* leaf,const Volume& volume);
bool update(Node* leaf,Volume volume,const btVector3& velocity,btScalar margin);
bool update(Node* leaf,Volume volume,const btVector3& velocity);
bool update(Node* leaf,Volume volume,btScalar margin);
void remove(Node* leaf);
btDbvtNode* insert(const btDbvtVolume& box,void* data);
void update(btDbvtNode* leaf,int lookahead=-1);
void update(btDbvtNode* leaf,const btDbvtVolume& volume);
bool update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity,btScalar margin);
bool update(btDbvtNode* leaf,btDbvtVolume volume,const btVector3& velocity);
bool update(btDbvtNode* leaf,btDbvtVolume volume,btScalar margin);
void remove(btDbvtNode* leaf);
void write(IWriter* iwriter) const;
void clone(btDbvt& dest,IClone* iclone=0) const;
static int countLeaves(const Node* node);
static void extractLeaves(const Node* node,btAlignedObjectArray<const Node*>& leaves);
static int countLeaves(const btDbvtNode* node);
static void extractLeaves(const btDbvtNode* node,btAlignedObjectArray<const btDbvtNode*>& leaves);
#if DBVT_ENABLE_BENCHMARK
static void benchmark();
#else
@@ -228,43 +237,43 @@ struct btDbvt
#endif
// DBVT_IPOLICY must support ICollide policy/interface
DBVT_PREFIX
static void enumNodes( const Node* root,
static void enumNodes( const btDbvtNode* root,
DBVT_IPOLICY);
DBVT_PREFIX
static void enumLeaves( const Node* root,
static void enumLeaves( const btDbvtNode* root,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideTT( const Node* root0,
const Node* root1,
static void collideTT( const btDbvtNode* root0,
const btDbvtNode* root1,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideTT( const Node* root0,
const Node* root1,
static void collideTT( const btDbvtNode* root0,
const btDbvtNode* root1,
const btTransform& xform,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideTT( const Node* root0,
static void collideTT( const btDbvtNode* root0,
const btTransform& xform0,
const Node* root1,
const btDbvtNode* root1,
const btTransform& xform1,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideTV( const Node* root,
const Volume& volume,
static void collideTV( const btDbvtNode* root,
const btDbvtVolume& volume,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideRAY( const Node* root,
static void collideRAY( const btDbvtNode* root,
const btVector3& origin,
const btVector3& direction,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideKDOP(const Node* root,
static void collideKDOP(const btDbvtNode* root,
const btVector3* normals,
const btScalar* offsets,
int count,
DBVT_IPOLICY);
DBVT_PREFIX
static void collideOCL( const Node* root,
static void collideOCL( const btDbvtNode* root,
const btVector3* normals,
const btScalar* offsets,
const btVector3& sortaxis,
@@ -272,7 +281,7 @@ struct btDbvt
DBVT_IPOLICY,
bool fullsort=true);
DBVT_PREFIX
static void collideTU( const Node* root,
static void collideTU( const btDbvtNode* root,
DBVT_IPOLICY);
// Helpers
static inline int nearest(const int* i,const btDbvt::sStkNPS* a,btScalar v,int l,int h)
@@ -286,8 +295,8 @@ struct btDbvt
return(h);
}
static inline int allocate( btAlignedObjectArray<int>& ifree,
btAlignedObjectArray<btDbvt::sStkNPS>& stock,
const btDbvt::sStkNPS& value)
btAlignedObjectArray<sStkNPS>& stock,
const sStkNPS& value)
{
int i;
if(ifree.size()>0)
@@ -528,7 +537,7 @@ return( (a.mi.x()!=b.mi.x())||
//
DBVT_PREFIX
inline void btDbvt::enumNodes( const Node* root,
inline void btDbvt::enumNodes( const btDbvtNode* root,
DBVT_IPOLICY)
{
DBVT_CHECKTYPE
@@ -542,7 +551,7 @@ if(root->isinternal())
//
DBVT_PREFIX
inline void btDbvt::enumLeaves( const Node* root,
inline void btDbvt::enumLeaves( const btDbvtNode* root,
DBVT_IPOLICY)
{
DBVT_CHECKTYPE
@@ -559,8 +568,8 @@ if(root->isinternal())
//
DBVT_PREFIX
inline void btDbvt::collideTT( const Node* root0,
const Node* root1,
inline void btDbvt::collideTT( const btDbvtNode* root0,
const btDbvtNode* root1,
DBVT_IPOLICY)
{
DBVT_CHECKTYPE
@@ -617,8 +626,8 @@ if(root0&&root1)
//
DBVT_PREFIX
inline void btDbvt::collideTT( const Node* root0,
const Node* root1,
inline void btDbvt::collideTT( const btDbvtNode* root0,
const btDbvtNode* root1,
const btTransform& xform,
DBVT_IPOLICY)
{
@@ -667,9 +676,9 @@ if(root0&&root1)
//
DBVT_PREFIX
inline void btDbvt::collideTT( const Node* root0,
inline void btDbvt::collideTT( const btDbvtNode* root0,
const btTransform& xform0,
const Node* root1,
const btDbvtNode* root1,
const btTransform& xform1,
DBVT_IPOLICY)
{
@@ -679,18 +688,18 @@ collideTT(root0,root1,xform,policy);
//
DBVT_PREFIX
inline void btDbvt::collideTV( const Node* root,
const Volume& volume,
inline void btDbvt::collideTV( const btDbvtNode* root,
const btDbvtVolume& volume,
DBVT_IPOLICY)
{
DBVT_CHECKTYPE
if(root)
{
btAlignedObjectArray<const Node*> stack;
btAlignedObjectArray<const btDbvtNode*> stack;
stack.reserve(SIMPLE_STACKSIZE);
stack.push_back(root);
do {
const Node* n=stack[stack.size()-1];
const btDbvtNode* n=stack[stack.size()-1];
stack.pop_back();
if(Intersect(n->volume,volume))
{
@@ -710,7 +719,7 @@ if(root)
//
DBVT_PREFIX
inline void btDbvt::collideRAY( const Node* root,
inline void btDbvt::collideRAY( const btDbvtNode* root,
const btVector3& origin,
const btVector3& direction,
DBVT_IPOLICY)
@@ -725,11 +734,11 @@ if(root)
const unsigned signs[]={ direction.x()<0,
direction.y()<0,
direction.z()<0};
btAlignedObjectArray<const Node*> stack;
btAlignedObjectArray<const btDbvtNode*> stack;
stack.reserve(SIMPLE_STACKSIZE);
stack.push_back(root);
do {
const Node* node=stack[stack.size()-1];
const btDbvtNode* node=stack[stack.size()-1];
stack.pop_back();
if(Intersect(node->volume,origin,invdir,signs))
{
@@ -749,7 +758,7 @@ if(root)
//
DBVT_PREFIX
inline void btDbvt::collideKDOP(const Node* root,
inline void btDbvt::collideKDOP(const btDbvtNode* root,
const btVector3* normals,
const btScalar* offsets,
int count,
@@ -804,7 +813,7 @@ if(root)
//
DBVT_PREFIX
inline void btDbvt::collideOCL( const Node* root,
inline void btDbvt::collideOCL( const btDbvtNode* root,
const btVector3* normals,
const btScalar* offsets,
const btVector3& sortaxis,
@@ -859,7 +868,7 @@ if(root)
{
if(se.node->isinternal())
{
const Node* pns[]={ se.node->childs[0],se.node->childs[1]};
const btDbvtNode* pns[]={ se.node->childs[0],se.node->childs[1]};
sStkNPS nes[]={ sStkNPS(pns[0],se.mask,pns[0]->volume.ProjectMinimum(sortaxis,srtsgns)),
sStkNPS(pns[1],se.mask,pns[1]->volume.ProjectMinimum(sortaxis,srtsgns))};
const int q=nes[0].value<nes[1].value?1:0;
@@ -902,17 +911,17 @@ if(root)
//
DBVT_PREFIX
inline void btDbvt::collideTU( const Node* root,
inline void btDbvt::collideTU( const btDbvtNode* root,
DBVT_IPOLICY)
{
DBVT_CHECKTYPE
if(root)
{
btAlignedObjectArray<const Node*> stack;
btAlignedObjectArray<const btDbvtNode*> stack;
stack.reserve(SIMPLE_STACKSIZE);
stack.push_back(root);
do {
const Node* n=stack[stack.size()-1];
const btDbvtNode* n=stack[stack.size()-1];
stack.pop_back();
if(policy.Descent(n))
{

View File

@@ -92,9 +92,9 @@ struct btDbvtLeafCollider : btDbvt::ICollide
btDbvtBroadphase* pbp;
btDbvtProxy* ppx;
btDbvtLeafCollider(btDbvtBroadphase* p,btDbvtProxy* px) : pbp(p),ppx(px) {}
void Process(const btDbvt::Node* na)
void Process(const btDbvtNode* na)
{
const btDbvt::Node* nb=ppx->leaf;
const btDbvtNode* nb=ppx->leaf;
if(nb!=na)
{
btDbvtProxy* pa=(btDbvtProxy*)na->data;
@@ -115,7 +115,7 @@ struct btDbvtTreeCollider : btDbvt::ICollide
{
btDbvtBroadphase* pbp;
btDbvtTreeCollider(btDbvtBroadphase* p) : pbp(p) {}
void Process(const btDbvt::Node* na,const btDbvt::Node* nb)
void Process(const btDbvtNode* na,const btDbvtNode* nb)
{
btDbvtProxy* pa=(btDbvtProxy*)na->data;
btDbvtProxy* pb=(btDbvtProxy*)nb->data;

View File

@@ -39,7 +39,7 @@ struct btDbvtProxy : btBroadphaseProxy
{
/* Fields */
btDbvtAabbMm aabb;
btDbvt::Node* leaf;
btDbvtNode* leaf;
btDbvtProxy* links[2];
int stage;
/* ctor */

View File

@@ -209,8 +209,9 @@ void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aab
m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax);
int i;
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
{
btVector3 worldAabbMin,worldAabbMax;
multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax);
@@ -307,7 +308,7 @@ void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aab
//update
for (int i=0;i<multiProxy->m_bridgeProxies.size();i++)
for ( i=0;i<multiProxy->m_bridgeProxies.size();i++)
{
btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i];
bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher);

View File

@@ -83,7 +83,6 @@ public:
protected:
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
@@ -108,6 +107,8 @@ public:
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);

View File

@@ -171,7 +171,7 @@ static int intersectRectQuad2 (btScalar h[2], btScalar p[8], btScalar ret[16])
return nr;
}
#define dAtan2(y,x) ((float)atan2f((y),(x))) /* arc tangent with 2 args */
#define M__PI 3.14159265f
// given n points in the plane (array p, of size 2*n), generate m points that
@@ -214,7 +214,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
// compute the angle of each point w.r.t. the centroid
btScalar A[8];
for (i=0; i<n; i++) A[i] = dAtan2(p[i*2+1]-cy,p[i*2]-cx);
for (i=0; i<n; i++) A[i] = btAtan2(p[i*2+1]-cy,p[i*2]-cx);
// search for points that have angles closest to A[i0] + i*(2*pi/m).
int avail[8];
@@ -231,7 +231,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
#endif
for (i=0; i<n; i++) {
if (avail[i]) {
diff = fabsf (A[i]-a);
diff = btFabs (A[i]-a);
if (diff > M__PI) diff = 2*M__PI - diff;
if (diff < maxdiff) {
maxdiff = diff;
@@ -284,9 +284,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2);
R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2);
Q11 = fabsf(R11); Q12 = fabsf(R12); Q13 = fabsf(R13);
Q21 = fabsf(R21); Q22 = fabsf(R22); Q23 = fabsf(R23);
Q31 = fabsf(R31); Q32 = fabsf(R32); Q33 = fabsf(R33);
Q11 = btFabs(R11); Q12 = btFabs(R12); Q13 = btFabs(R13);
Q21 = btFabs(R21); Q22 = btFabs(R22); Q23 = btFabs(R23);
Q31 = btFabs(R31); Q32 = btFabs(R32); Q33 = btFabs(R33);
// for all 15 possible separating axes:
// * see if the axis separates the boxes. if so, return 0.
@@ -299,7 +299,7 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
// the normal should be flipped.
#define TST(expr1,expr2,norm,cc) \
s2 = fabsf(expr1) - (expr2); \
s2 = btFabs(expr1) - (expr2); \
if (s2 > 0) return 0; \
if (s2 > s) { \
s = s2; \
@@ -326,9 +326,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
// normal (n1,n2,n3) is relative to box 1.
#undef TST
#define TST(expr1,expr2,n1,n2,n3,cc) \
s2 = fabsf(expr1) - (expr2); \
s2 = btFabs(expr1) - (expr2); \
if (s2 > 0) return 0; \
l = sqrtf((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \
l = btSqrt((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \
if (l > 0) { \
s2 /= l; \
if (s2*fudge_factor > s) { \
@@ -461,9 +461,9 @@ int dBoxBox2 (const btVector3& p1, const dMatrix3 R1,
normal2[2] = -normal[2];
}
dMULTIPLY1_331 (nr,Rb,normal2);
anr[0] = fabsf (nr[0]);
anr[1] = fabsf (nr[1]);
anr[2] = fabsf (nr[2]);
anr[0] = btFabs (nr[0]);
anr[1] = btFabs (nr[1]);
anr[2] = btFabs (nr[2]);
// find the largest compontent of anr: this corresponds to the normal
// for the indident face. the other axis numbers of the indicent face

View File

@@ -283,7 +283,7 @@ void* btCollisionDispatcher::allocateCollisionAlgorithm(int size)
}
//warn user for overflow?
return btAlignedAlloc(static_cast<std::size_t>(size), 16);
return btAlignedAlloc(static_cast<size_t>(size), 16);
}
void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)

View File

@@ -99,6 +99,7 @@ struct MinkowskiDiff
typedef MinkowskiDiff tShape;
// GJK
struct GJK
{
@@ -515,6 +516,30 @@ sList m_stock;
{
Initialize();
}
static inline void bind(sFace* fa,U ea,sFace* fb,U eb)
{
fa->e[ea]=(U1)eb;fa->f[ea]=fb;
fb->e[eb]=(U1)ea;fb->f[eb]=fa;
}
static inline void append(sList& list,sFace* face)
{
face->l[0] = 0;
face->l[1] = list.root;
if(list.root) list.root->l[0]=face;
list.root = face;
++list.count;
}
static inline void remove(sList& list,sFace* face)
{
if(face->l[1]) face->l[1]->l[0]=face->l[0];
if(face->l[0]) face->l[0]->l[1]=face->l[1];
if(face==list.root) list.root=face->l[1];
--list.count;
}
void Initialize()
{
m_status = eStatus::Failed;
@@ -531,10 +556,11 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
GJK::sSimplex& simplex=*gjk.m_simplex;
if((simplex.rank>1)&&gjk.EncloseOrigin())
{
/* Clean up */
while(m_hull.root)
{
sFace* f(m_hull.root);
sFace* f = m_hull.root;
remove(m_hull,f);
append(m_stock,f);
}
@@ -716,26 +742,7 @@ bool expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon)
}
return(false);
}
static inline void bind(sFace* fa,U ea,sFace* fb,U eb)
{
fa->e[ea]=(U1)eb;fa->f[ea]=fb;
fb->e[eb]=(U1)ea;fb->f[eb]=fa;
}
static inline void append(sList& list,sFace* face)
{
face->l[0] = 0;
face->l[1] = list.root;
if(list.root) list.root->l[0]=face;
list.root = face;
++list.count;
}
static inline void remove(sList& list,sFace* face)
{
if(face->l[1]) face->l[1]->l[0]=face->l[0];
if(face->l[0]) face->l[0]->l[1]=face->l[1];
if(face==list.root) list.root=face->l[1];
--list.count;
}
};
//

View File

@@ -131,8 +131,8 @@ typedef btScalar *dRealMutablePtr;
//#define dRealAllocaArray(name,size) btScalar *name = (btScalar*) stackAlloc->allocate(dEFFICIENT_SIZE(size)*sizeof(btScalar));
#define dRealAllocaArray(name,size) btScalar *name = NULL; \
unsigned int memNeeded_##name = dEFFICIENT_SIZE(size)*sizeof(btScalar); \
if (memNeeded_##name < static_cast<std::size_t>(stackAlloc->getAvailableMemory())) name = (btScalar*) stackAlloc->allocate(memNeeded_##name); \
else{ btAssert(memNeeded_##name < static_cast<std::size_t>(stackAlloc->getAvailableMemory())); name = (btScalar*) alloca(memNeeded_##name); }
if (memNeeded_##name < static_cast<size_t>(stackAlloc->getAvailableMemory())) name = (btScalar*) stackAlloc->allocate(memNeeded_##name); \
else{ btAssert(memNeeded_##name < static_cast<size_t>(stackAlloc->getAvailableMemory())); name = (btScalar*) alloca(memNeeded_##name); }

View File

@@ -716,7 +716,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
rel_vel = cp.m_normalWorldOnB.dot(vel);
solverConstraint.m_penetration = btMin(cp.getDistance()+infoGlobal.m_linearSlop,0.f);
solverConstraint.m_penetration = btMin(cp.getDistance()+infoGlobal.m_linearSlop,btScalar(0.));
//solverConstraint.m_penetration = cp.getDistance();
solverConstraint.m_friction = cp.m_combinedFriction;

View File

@@ -421,19 +421,21 @@ static void PointersToIndices(btSoftBody* psb)
{
#define PTR2IDX(_p_,_b_) reinterpret_cast<btSoftBody::Node*>((_p_)-(_b_))
btSoftBody::Node* base=&psb->m_nodes[0];
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
int i,ni;
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
if(psb->m_nodes[i].m_leaf)
{
psb->m_nodes[i].m_leaf->data=*(void**)&i;
}
}
for(int i=0,ni=psb->m_links.size();i<ni;++i)
for(i=0,ni=psb->m_links.size();i<ni;++i)
{
psb->m_links[i].m_n[0]=PTR2IDX(psb->m_links[i].m_n[0],base);
psb->m_links[i].m_n[1]=PTR2IDX(psb->m_links[i].m_n[1],base);
}
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
psb->m_faces[i].m_n[0]=PTR2IDX(psb->m_faces[i].m_n[0],base);
psb->m_faces[i].m_n[1]=PTR2IDX(psb->m_faces[i].m_n[1],base);
@@ -443,11 +445,11 @@ static void PointersToIndices(btSoftBody* psb)
psb->m_faces[i].m_leaf->data=*(void**)&i;
}
}
for(int i=0,ni=psb->m_anchors.size();i<ni;++i)
for(i=0,ni=psb->m_anchors.size();i<ni;++i)
{
psb->m_anchors[i].m_node=PTR2IDX(psb->m_anchors[i].m_node,base);
}
for(int i=0,ni=psb->m_notes.size();i<ni;++i)
for(i=0,ni=psb->m_notes.size();i<ni;++i)
{
for(int j=0;j<psb->m_notes[i].m_rank;++j)
{
@@ -463,19 +465,21 @@ static void IndicesToPointers(btSoftBody* psb,const int* map=0)
#define IDX2PTR(_p_,_b_) map?(&(_b_)[map[(((char*)_p_)-(char*)0)]]): \
(&(_b_)[(((char*)_p_)-(char*)0)])
btSoftBody::Node* base=&psb->m_nodes[0];
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
int i,ni;
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
if(psb->m_nodes[i].m_leaf)
{
psb->m_nodes[i].m_leaf->data=&psb->m_nodes[i];
}
}
for(int i=0,ni=psb->m_links.size();i<ni;++i)
for(i=0,ni=psb->m_links.size();i<ni;++i)
{
psb->m_links[i].m_n[0]=IDX2PTR(psb->m_links[i].m_n[0],base);
psb->m_links[i].m_n[1]=IDX2PTR(psb->m_links[i].m_n[1],base);
}
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
psb->m_faces[i].m_n[0]=IDX2PTR(psb->m_faces[i].m_n[0],base);
psb->m_faces[i].m_n[1]=IDX2PTR(psb->m_faces[i].m_n[1],base);
@@ -485,11 +489,11 @@ static void IndicesToPointers(btSoftBody* psb,const int* map=0)
psb->m_faces[i].m_leaf->data=&psb->m_faces[i];
}
}
for(int i=0,ni=psb->m_anchors.size();i<ni;++i)
for(i=0,ni=psb->m_anchors.size();i<ni;++i)
{
psb->m_anchors[i].m_node=IDX2PTR(psb->m_anchors[i].m_node,base);
}
for(int i=0,ni=psb->m_notes.size();i<ni;++i)
for(i=0,ni=psb->m_notes.size();i<ni;++i)
{
for(int j=0;j<psb->m_notes[i].m_rank;++j)
{
@@ -500,13 +504,13 @@ static void IndicesToPointers(btSoftBody* psb,const int* map=0)
}
//
static inline btDbvt::Volume VolumeOf( const btSoftBody::Face& f,
static inline btDbvtVolume VolumeOf( const btSoftBody::Face& f,
btScalar margin)
{
const btVector3* pts[]={ &f.m_n[0]->m_x,
&f.m_n[1]->m_x,
&f.m_n[2]->m_x};
btDbvt::Volume vol=btDbvt::Volume::FromPoints(pts,3);
btDbvtVolume vol=btDbvtVolume::FromPoints(pts,3);
vol.Expand(btVector3(margin,margin,margin));
return(vol);
}
@@ -585,7 +589,7 @@ struct RayCaster : btDbvt::ICollide
face = 0;
tests = 0;
}
void Process(const btDbvt::Node* leaf)
void Process(const btDbvtNode* leaf)
{
btSoftBody::Face& f=*(btSoftBody::Face*)leaf->data;
const btScalar t=RayTriangle( o,d,
@@ -723,11 +727,13 @@ static bool CheckContact( btSoftBody* psb,
static void UpdateNormals(btSoftBody* psb)
{
const btVector3 zv(0,0,0);
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
int i,ni;
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
psb->m_nodes[i].m_n=zv;
}
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
btSoftBody::Face& f=psb->m_faces[i];
const btVector3 n=cross(f.m_n[1]->m_x-f.m_n[0]->m_x,
@@ -737,7 +743,7 @@ static void UpdateNormals(btSoftBody* psb)
f.m_n[1]->m_n+=n;
f.m_n[2]->m_n+=n;
}
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
psb->m_nodes[i].m_n.normalize();
}
@@ -811,8 +817,10 @@ static void UpdatePose(btSoftBody* psb)
//
static void UpdateConstants(btSoftBody* psb)
{
int i,ni;
/* Links */
for(int i=0,ni=psb->m_links.size();i<ni;++i)
for(i=0,ni=psb->m_links.size();i<ni;++i)
{
btSoftBody::Link& l=psb->m_links[i];
btSoftBody::Material& m=*l.m_material;
@@ -821,7 +829,7 @@ static void UpdateConstants(btSoftBody* psb)
l.m_c1 = l.m_rl*l.m_rl;
}
/* Faces */
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
btSoftBody::Face& f=psb->m_faces[i];
f.m_ra = AreaOf(f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x);
@@ -829,11 +837,11 @@ static void UpdateConstants(btSoftBody* psb)
/* Area's */
btAlignedObjectArray<int> counts;
counts.resize(psb->m_nodes.size(),0);
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
psb->m_nodes[i].m_area = 0;
}
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
btSoftBody::Face& f=psb->m_faces[i];
for(int j=0;j<3;++j)
@@ -843,7 +851,7 @@ static void UpdateConstants(btSoftBody* psb)
f.m_n[j]->m_area+=btFabs(f.m_ra);
}
}
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
if(counts[i]>0)
psb->m_nodes[i].m_area/=(btScalar)counts[i];
@@ -872,6 +880,7 @@ static inline void ApplyClampedForce( btSoftBody::Node& n,
static void ApplyForces(btSoftBody* psb,btScalar dt)
{
BT_PROFILE("SoftBody applyForces");
int i,ni;
const btScalar kLF=psb->m_cfg.kLF;
const btScalar kDG=psb->m_cfg.kDG;
const btScalar kPR=psb->m_cfg.kPR;
@@ -900,7 +909,7 @@ static void ApplyForces(btSoftBody* psb,btScalar dt)
dvolumetv = (psb->m_pose.m_volume-volume)*kVC;
}
/* Per vertex forces */
for(int i=0,ni=psb->m_nodes.size();i<ni;++i)
for(i=0,ni=psb->m_nodes.size();i<ni;++i)
{
btSoftBody::Node& n=psb->m_nodes[i];
if(n.m_im>0)
@@ -951,7 +960,7 @@ static void ApplyForces(btSoftBody* psb,btScalar dt)
}
}
/* Per face forces */
for(int i=0,ni=psb->m_faces.size();i<ni;++i)
for(i=0,ni=psb->m_faces.size();i<ni;++i)
{
btSoftBody::Face& f=psb->m_faces[i];
if(as_faero)
@@ -1171,7 +1180,7 @@ btSoftBody::btSoftBody(btSoftBody::btSoftBodyWorldInfo* worldInfo,int node_count
n.m_q = n.m_x;
n.m_im = m?*m++:1;
n.m_im = n.m_im>0?1/n.m_im:0;
n.m_leaf = m_ndbvt.insert(btDbvt::Volume::FromCR(n.m_x,margin),&n);
n.m_leaf = m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n);
n.m_material= pm;
}
UpdateBounds(this);
@@ -1313,7 +1322,7 @@ n.m_x = x;
n.m_q = n.m_x;
n.m_im = m>0?1/m:0;
n.m_material = m_materials[0];
n.m_leaf = m_ndbvt.insert(btDbvt::Volume::FromCR(n.m_x,margin),&n);
n.m_leaf = m_ndbvt.insert(btDbvtVolume::FromCR(n.m_x,margin),&n);
}
//
@@ -1448,13 +1457,16 @@ btScalar btSoftBody::getTotalMass() const
//
void btSoftBody::setTotalMass(btScalar mass,bool fromfaces)
{
int i;
if(fromfaces)
{
for(int i=0;i<m_nodes.size();++i)
for(i=0;i<m_nodes.size();++i)
{
m_nodes[i].m_im=0;
}
for(int i=0;i<m_faces.size();++i)
for(i=0;i<m_faces.size();++i)
{
const Face& f=m_faces[i];
const btScalar twicearea=AreaOf( f.m_n[0]->m_x,
@@ -1465,14 +1477,14 @@ void btSoftBody::setTotalMass(btScalar mass,bool fromfaces)
f.m_n[j]->m_im+=twicearea;
}
}
for(int i=0;i<m_nodes.size();++i)
for(i=0;i<m_nodes.size();++i)
{
m_nodes[i].m_im=1/m_nodes[i].m_im;
}
}
const btScalar tm=getTotalMass();
const btScalar itm=1/tm;
for(int i=0;i<m_nodes.size();++i)
for( i=0;i<m_nodes.size();++i)
{
m_nodes[i].m_im/=itm*mass;
}
@@ -1495,7 +1507,7 @@ void btSoftBody::transform(const btTransform& trs)
n.m_x=trs*n.m_x;
n.m_q=trs*n.m_q;
n.m_n=trs.getBasis()*n.m_n;
m_ndbvt.update(n.m_leaf,btDbvt::Volume::FromCR(n.m_x,margin));
m_ndbvt.update(n.m_leaf,btDbvtVolume::FromCR(n.m_x,margin));
}
UpdateNormals(this);
UpdateBounds(this);
@@ -1529,7 +1541,7 @@ void btSoftBody::scale(const btVector3& scl)
Node& n=m_nodes[i];
n.m_x*=scl;
n.m_q*=scl;
m_ndbvt.update(n.m_leaf,btDbvt::Volume::FromCR(n.m_x,margin));
m_ndbvt.update(n.m_leaf,btDbvtVolume::FromCR(n.m_x,margin));
}
UpdateNormals(this);
UpdateBounds(this);
@@ -1546,11 +1558,13 @@ void btSoftBody::setPose(bool bvolume,bool bframe)
const btScalar kmass=omass*m_nodes.size()*1000;
btScalar tmass=omass;
m_pose.m_wgh.resize(m_nodes.size());
for(int i=0,ni=m_nodes.size();i<ni;++i)
int i,ni;
for(i=0,ni=m_nodes.size();i<ni;++i)
{
if(m_nodes[i].m_im<=0) tmass+=kmass;
}
for(int i=0,ni=m_nodes.size();i<ni;++i)
for(i=0,ni=m_nodes.size();i<ni;++i)
{
Node& n=m_nodes[i];
m_pose.m_wgh[i]= n.m_im>0 ?
@@ -1560,7 +1574,7 @@ void btSoftBody::setPose(bool bvolume,bool bframe)
/* Pos */
const btVector3 com=EvaluateCom(this);
m_pose.m_pos.resize(m_nodes.size());
for(int i=0,ni=m_nodes.size();i<ni;++i)
for(i=0,ni=m_nodes.size();i<ni;++i)
{
m_pose.m_pos[i]=m_nodes[i].m_x-com;
}
@@ -1572,7 +1586,7 @@ void btSoftBody::setPose(bool bvolume,bool bframe)
m_pose.m_aqq[0] =
m_pose.m_aqq[1] =
m_pose.m_aqq[2] = btVector3(0,0,0);
for(int i=0,ni=m_nodes.size();i<ni;++i)
for(i=0,ni=m_nodes.size();i<ni;++i)
{
const btVector3& q=m_pose.m_pos[i];
const btVector3 mq=m_pose.m_wgh[i]*q;
@@ -1611,7 +1625,10 @@ int btSoftBody::generateBendingConstraints(int distance,Material* mat)
const unsigned inf=(~(unsigned)0)>>1;
unsigned* adj=new unsigned[n*n];
#define IDX(_x_,_y_) ((_y_)*n+(_x_))
for(int j=0;j<n;++j)
int i,j;
for( j=0;j<n;++j)
{
for(int i=0;i<n;++i)
{
@@ -1620,7 +1637,7 @@ int btSoftBody::generateBendingConstraints(int distance,Material* mat)
adj[IDX(i,j)]=adj[IDX(j,i)]=0;
}
}
for(int i=0;i<m_links.size();++i)
for(i=0;i<m_links.size();++i)
{
const int ia=(int)(m_links[i].m_n[0]-&m_nodes[0]);
const int ib=(int)(m_links[i].m_n[1]-&m_nodes[0]);
@@ -1629,7 +1646,7 @@ int btSoftBody::generateBendingConstraints(int distance,Material* mat)
}
for(int k=0;k<n;++k)
{
for(int j=0;j<n;++j)
for(j=0;j<n;++j)
{
for(int i=j+1;i<n;++i)
{
@@ -1643,7 +1660,7 @@ int btSoftBody::generateBendingConstraints(int distance,Material* mat)
}
/* Build links */
int nlinks=0;
for(int j=0;j<n;++j)
for(j=0;j<n;++j)
{
for(int i=j+1;i<n;++i)
{
@@ -1666,11 +1683,14 @@ void btSoftBody::randomizeConstraints()
{
unsigned long seed=243703;
#define NEXTRAND (seed=(1664525L*seed+1013904223L)&0xffffffff)
for(int i=0,ni=m_links.size();i<ni;++i)
int i,ni;
for(i=0,ni=m_links.size();i<ni;++i)
{
btSwap(m_links[i],m_links[NEXTRAND%ni]);
}
for(int i=0,ni=m_faces.size();i<ni;++i)
for(i=0,ni=m_faces.size();i<ni;++i)
{
btSwap(m_faces[i],m_faces[NEXTRAND%ni]);
}
@@ -1680,12 +1700,14 @@ unsigned long seed=243703;
//
void btSoftBody::refine(ImplicitFn* ifn,btScalar accurary,bool cut)
{
const Node* nbase(&m_nodes[0]);
Node* nbase = &m_nodes[0];
int ncount(m_nodes.size());
btSymMatrix<int> edges(ncount,-2);
int newnodes=0;
int i,ni;
/* Filter out */
for(int i=0;i<m_links.size();++i)
for(i=0;i<m_links.size();++i)
{
Link& l=m_links[i];
if(l.m_bbending)
@@ -1698,12 +1720,12 @@ for(int i=0;i<m_links.size();++i)
}
}
/* Fill edges */
for(int i=0;i<m_links.size();++i)
for(i=0;i<m_links.size();++i)
{
Link& l=m_links[i];
edges(int(l.m_n[0]-nbase),int(l.m_n[1]-nbase))=-1;
}
for(int i=0;i<m_faces.size();++i)
for(i=0;i<m_faces.size();++i)
{
Face& f=m_faces[i];
edges(int(f.m_n[0]-nbase),int(f.m_n[1]-nbase))=-1;
@@ -1711,7 +1733,7 @@ for(int i=0;i<m_faces.size();++i)
edges(int(f.m_n[2]-nbase),int(f.m_n[0]-nbase))=-1;
}
/* Intersect */
for(int i=0;i<ncount;++i)
for(i=0;i<ncount;++i)
{
for(int j=i+1;j<ncount;++j)
{
@@ -1757,7 +1779,7 @@ for(int i=0;i<ncount;++i)
}
nbase=&m_nodes[0];
/* Refine links */
for(int i=0,ni=m_links.size();i<ni;++i)
for(i=0,ni=m_links.size();i<ni;++i)
{
Link& feat=m_links[i];
const int idx[]={ int(feat.m_n[0]-nbase),
@@ -1778,7 +1800,7 @@ for(int i=0,ni=m_links.size();i<ni;++i)
}
}
/* Refine faces */
for(int i=0;i<m_faces.size();++i)
for(i=0;i<m_faces.size();++i)
{
const Face& feat=m_faces[i];
const int idx[]={ int(feat.m_n[0]-nbase),
@@ -1815,7 +1837,7 @@ if(cut)
ncount=m_nodes.size();
cnodes.resize(ncount,0);
/* Nodes */
for(int i=0;i<ncount;++i)
for(i=0;i<ncount;++i)
{
const btVector3 x=m_nodes[i].m_x;
if((i>=pcount)||(btFabs(ifn->Eval(x))<accurary))
@@ -1830,7 +1852,7 @@ if(cut)
}
nbase=&m_nodes[0];
/* Links */
for(int i=0,ni=m_links.size();i<ni;++i)
for(i=0,ni=m_links.size();i<ni;++i)
{
const int id[]={ int(m_links[i].m_n[0]-nbase),
int(m_links[i].m_n[1]-nbase)};
@@ -1857,7 +1879,7 @@ if(cut)
}
}
/* Faces */
for(int i=0,ni=m_faces.size();i<ni;++i)
for( i=0,ni=m_faces.size();i<ni;++i)
{
Node** n= m_faces[i].m_n;
if( (ifn->Eval(n[0]->m_x)<accurary)&&
@@ -1876,15 +1898,15 @@ if(cut)
btAlignedObjectArray<int> ranks;
btAlignedObjectArray<int> todelete;
ranks.resize(nnodes,0);
for(int i=0,ni=m_links.size();i<ni;++i)
for(i=0,ni=m_links.size();i<ni;++i)
{
for(int j=0;j<2;++j) ranks[int(m_links[i].m_n[j]-nbase)]++;
}
for(int i=0,ni=m_faces.size();i<ni;++i)
for(i=0,ni=m_faces.size();i<ni;++i)
{
for(int j=0;j<3;++j) ranks[int(m_faces[i].m_n[j]-nbase)]++;
}
for(int i=0;i<m_links.size();++i)
for(i=0;i<m_links.size();++i)
{
const int id[]={ int(m_links[i].m_n[0]-nbase),
int(m_links[i].m_n[1]-nbase)};
@@ -1899,7 +1921,7 @@ if(cut)
}
}
#if 0
for(int i=nnodes-1;i>=0;--i)
for(i=nnodes-1;i>=0;--i)
{
if(!ranks[i]) todelete.push_back(i);
}
@@ -1957,7 +1979,9 @@ Node* pn[2]={ &m_nodes[m_nodes.size()-2],
&m_nodes[m_nodes.size()-1]};
pn[0]->m_v=v;
pn[1]->m_v=v;
for(int i=0,ni=m_links.size();i<ni;++i)
int i,ni;
for(i=0,ni=m_links.size();i<ni;++i)
{
const int mtch=MatchEdge(m_links[i].m_n[0],m_links[i].m_n[1],pa,pb);
if(mtch!=-1)
@@ -1969,7 +1993,7 @@ for(int i=0,ni=m_links.size();i<ni;++i)
done=true;
}
}
for(int i=0,ni=m_faces.size();i<ni;++i)
for(i=0,ni=m_faces.size();i<ni;++i)
{
for(int k=2,l=0;l<3;k=l++)
{
@@ -2070,7 +2094,7 @@ void btSoftBody::predictMotion(btScalar dt)
n.m_v += n.m_f*n.m_im*m_sst.sdt;
n.m_x += n.m_v*m_sst.sdt;
m_ndbvt.update( n.m_leaf,
btDbvt::Volume::FromCR(n.m_x,m_sst.radmrg),
btDbvtVolume::FromCR(n.m_x,m_sst.radmrg),
n.m_v*m_sst.velmrg,
m_sst.updmrg);
}
@@ -2116,15 +2140,17 @@ void btSoftBody::predictMotion(btScalar dt)
//
void btSoftBody::solveConstraints()
{
int i,ni;
/* Prepare links */
for(int i=0,ni=m_links.size();i<ni;++i)
for(i=0,ni=m_links.size();i<ni;++i)
{
Link& l=m_links[i];
l.m_c3 = l.m_n[1]->m_x-l.m_n[0]->m_x;
l.m_c2 = 1/(l.m_c3.length2()*l.m_c0);
}
/* Prepare anchors */
for(int i=0,ni=m_anchors.size();i<ni;++i)
for(i=0,ni=m_anchors.size();i<ni;++i)
{
Anchor& a=m_anchors[i];
const btVector3 ra=a.m_body->getWorldTransform().getBasis()*a.m_local;
@@ -2177,7 +2203,7 @@ if(m_cfg.piterations>0)
if(m_cfg.diterations>0)
{
const btScalar vcf=m_cfg.kVCF*m_sst.isdt;
for(int i=0,ni=m_nodes.size();i<ni;++i)
for(i=0,ni=m_nodes.size();i<ni;++i)
{
Node& n=m_nodes[i];
n.m_q = n.m_x;
@@ -2189,7 +2215,7 @@ if(m_cfg.diterations>0)
PSolvers[m_cfg.m_dsequence[iseq]](this,1);
}
}
for(int i=0,ni=m_nodes.size();i<ni;++i)
for(i=0,ni=m_nodes.size();i<ni;++i)
{
Node& n=m_nodes[i];
n.m_v += (n.m_x-n.m_q)*vcf;
@@ -2231,15 +2257,15 @@ switch(m_cfg.collisions&fCollision::RVSmask)
{
struct DoCollide : btDbvt::ICollide
{
void Process(const btDbvt::Node* leaf)
void Process(const btDbvtNode* leaf)
{
Node* node=(Node*)leaf->data;
btSoftBody::Node* node=(btSoftBody::Node*)leaf->data;
DoNode(*node);
}
void DoNode(Node& n) const
void DoNode(btSoftBody::Node& n) const
{
const btScalar m=n.m_im>0?dynmargin:stamargin;
RContact c;
btSoftBody::RContact c;
if( (!n.m_battach)&&
CheckContact(psb,prb,n.m_x,m,c.m_cti))
{
@@ -2280,11 +2306,11 @@ switch(m_cfg.collisions&fCollision::RVSmask)
const btScalar basemargin=getCollisionShape()->getMargin();
btVector3 mins;
btVector3 maxs;
btDbvt::Volume volume;
btDbvtVolume volume;
pco->getCollisionShape()->getAabb( pco->getInterpolationWorldTransform(),
mins,
maxs);
volume=btDbvt::Volume::FromMM(mins,maxs);
volume=btDbvtVolume::FromMM(mins,maxs);
volume.Expand(btVector3(basemargin,basemargin,basemargin));
docollide.psb = this;
docollide.prb = prb;
@@ -2306,11 +2332,11 @@ switch(cf&fCollision::SVSmask)
{
struct DoCollide : btDbvt::ICollide
{
void Process(const btDbvt::Node* lnode,
const btDbvt::Node* lface)
void Process(const btDbvtNode* lnode,
const btDbvtNode* lface)
{
Node* node=(Node*)lnode->data;
Face* face=(Face*)lface->data;
btSoftBody::Node* node=(btSoftBody::Node*)lnode->data;
btSoftBody::Face* face=(btSoftBody::Face*)lface->data;
btVector3 o=node->m_x;
btVector3 p;
btScalar d=SIMD_INFINITY;
@@ -2321,7 +2347,7 @@ switch(cf&fCollision::SVSmask)
const btScalar m=mrg+(o-node->m_q).length()*2;
if(d<(m*m))
{
const Node* n[]={face->m_n[0],face->m_n[1],face->m_n[2]};
const btSoftBody::Node* n[]={face->m_n[0],face->m_n[1],face->m_n[2]};
const btVector3 w=BaryCoord(n[0]->m_x,n[1]->m_x,n[2]->m_x,p+o);
const btScalar ma=node->m_im;
btScalar mb=BaryEval(n[0]->m_im,n[1]->m_im,n[2]->m_im,w);
@@ -2334,7 +2360,7 @@ switch(cf&fCollision::SVSmask)
const btScalar ms=ma+mb;
if(ms>0)
{
SContact c;
btSoftBody::SContact c;
c.m_normal = p/-btSqrt(d);
c.m_margin = m;
c.m_node = node;

View File

@@ -192,7 +192,7 @@ public:
btVector3 m_n; // Normal
btScalar m_im; // 1/mass
btScalar m_area; // Area
btDbvt::Node* m_leaf; // Leaf data
btDbvtNode* m_leaf; // Leaf data
int m_battach:1; // Attached
};
/* Link */
@@ -212,12 +212,12 @@ public:
Node* m_n[3]; // Node pointers
btVector3 m_normal; // Normal
btScalar m_ra; // Rest area
btDbvt::Node* m_leaf; // Leaf data
btDbvtNode* m_leaf; // Leaf data
};
/* RContact */
struct RContact
{
btSoftBody::sCti m_cti; // Contact infos
sCti m_cti; // Contact infos
Node* m_node; // Owner node
btMatrix3x3 m_c0; // Impulse matrix
btVector3 m_c1; // Relative anchor
@@ -310,7 +310,7 @@ public:
typedef btAlignedObjectArray<Note> tNoteArray;
typedef btAlignedObjectArray<Node> tNodeArray;
typedef btAlignedObjectArray<btDbvt::Node*> tLeafArray;
typedef btAlignedObjectArray<btDbvtNode*> tLeafArray;
typedef btAlignedObjectArray<Link> tLinkArray;
typedef btAlignedObjectArray<Face> tFaceArray;
typedef btAlignedObjectArray<Anchor> tAnchorArray;
@@ -346,7 +346,7 @@ public:
//
/* ctor */
btSoftBody( btSoftBody::btSoftBodyWorldInfo* worldInfo,int node_count,
btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count,
const btVector3* x,
const btScalar* m);
/* dtor */

View File

@@ -53,7 +53,7 @@ idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
//
static void drawTree( btIDebugDraw* idraw,
const btDbvt::Node* node,
const btDbvtNode* node,
int depth,
const btVector3& ncolor,
const btVector3& lcolor,
@@ -175,7 +175,9 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
/* Anchors */
if(0!=(drawflags&fDrawFlags::Anchors))
{
for(int i=0;i<psb->m_anchors.size();++i)
int i;
for(i=0;i<psb->m_anchors.size();++i)
{
const btSoftBody::Anchor& a=psb->m_anchors[i];
const btVector3 q=a.m_body->getWorldTransform()*a.m_local;
@@ -183,7 +185,7 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
drawVertex(idraw,q,0.25,btVector3(0,1,0));
idraw->drawLine(a.m_node->m_x,q,btVector3(1,1,1));
}
for(int i=0;i<psb->m_nodes.size();++i)
for(i=0;i<psb->m_nodes.size();++i)
{
const btSoftBody::Node& n=psb->m_nodes[i];
if(0==(n.m_material->m_flags&btSoftBody::fMaterial::DebugDraw)) continue;
@@ -313,7 +315,9 @@ btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBody::btSoftBodyWorldInfo& wor
const int r=res+2;
btVector3* x=new btVector3[r];
btScalar* m=new btScalar[r];
for(int i=0;i<r;++i)
int i;
for(i=0;i<r;++i)
{
const btScalar t=i/(btScalar)(r-1);
x[i]=lerp(from,to,t);
@@ -325,7 +329,7 @@ btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBody::btSoftBodyWorldInfo& wor
delete[] x;
delete[] m;
/* Create links */
for(int i=1;i<r;++i)
for(i=1;i<r;++i)
{
psb->appendLink(i-1,i);
}
@@ -351,7 +355,9 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBody::btSoftBodyWorldInfo& wor
const int tot=rx*ry;
btVector3* x=new btVector3[tot];
btScalar* m=new btScalar[tot];
for(int iy=0;iy<ry;++iy)
int iy;
for(iy=0;iy<ry;++iy)
{
const btScalar ty=iy/(btScalar)(ry-1);
const btVector3 py0=lerp(corner00,corner01,ty);
@@ -371,7 +377,7 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBody::btSoftBodyWorldInfo& wor
delete[] x;
delete[] m;
/* Create links and faces */
for(int iy=0;iy<ry;++iy)
for(iy=0;iy<ry;++iy)
{
for(int ix=0;ix<rx;++ix)
{
@@ -446,7 +452,10 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBody::btSoftBodyWorldInf
int ntriangles)
{
int maxidx=0;
for(int i=0,ni=ntriangles*3;i<ni;++i)
int i,j;
int ni;
for( i=0,ni=ntriangles*3;i<ni;++i)
{
maxidx=btMax(triangles[i],maxidx);
}
@@ -455,12 +464,12 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBody::btSoftBodyWorldInf
btAlignedObjectArray<btVector3> vtx;
chks.resize(maxidx*maxidx,false);
vtx.resize(maxidx);
for(int i=0,j=0,ni=maxidx*3;i<ni;++j,i+=3)
for( i=0,j=0,ni=maxidx*3;i<ni;++j,i+=3)
{
vtx[j]=btVector3(vertices[i],vertices[i+1],vertices[i+2]);
}
btSoftBody* psb=new btSoftBody(&worldInfo,vtx.size(),&vtx[0],0);
for(int i=0,ni=ntriangles*3;i<ni;i+=3)
for(i=0,ni=ntriangles*3;i<ni;i+=3)
{
const int idx[]={triangles[i],triangles[i+1],triangles[i+2]};
#define IDX(_x_,_y_) ((_y_)*maxidx+(_x_))

View File

@@ -20,6 +20,26 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
// Modified Paul Hsieh hash
template <const int DWORDLEN>
unsigned int HsiehHash(const void* pdata)
{
const unsigned short* data=(const unsigned short*)pdata;
unsigned hash=DWORDLEN<<2,tmp;
for(int i=0;i<DWORDLEN;++i)
{
hash += data[0];
tmp = (data[1]<<11)^hash;
hash = (hash<<16)^tmp;
data += 2;
hash += hash>>11;
}
hash^=hash<<3;hash+=hash>>5;
hash^=hash<<4;hash+=hash>>17;
hash^=hash<<25;hash+=hash>>6;
return(hash);
}
template <const int CELLSIZE>
struct btSparseSdf
{
@@ -258,32 +278,29 @@ struct btSparseSdf
{
return(a+(b-a)*t);
}
//
static inline unsigned Hash(int x,int y,int z,btCollisionShape* shape)
static inline unsigned int Hash(int x,int y,int z,btCollisionShape* shape)
{
struct { int x,y,z;void* p; } set;
set.x=x;set.y=y;set.z=z;set.p=shape;
return(HsiehHash<sizeof(set)/4>(&set));
}
// Modified Paul Hsieh hash
template <const int DWORDLEN>
static inline unsigned HsiehHash(const void* pdata)
struct btS
{
const unsigned short* data=(const unsigned short*)pdata;
unsigned hash=DWORDLEN<<2,tmp;
for(int i=0;i<DWORDLEN;++i)
{
hash += data[0];
tmp = (data[1]<<11)^hash;
hash = (hash<<16)^tmp;
data += 2;
hash += hash>>11;
}
hash^=hash<<3;hash+=hash>>5;
hash^=hash<<4;hash+=hash>>17;
hash^=hash<<25;hash+=hash>>6;
return(hash);
int x,y,z;
void* p;
};
btS myset;
myset.x=x;myset.y=y;myset.z=z;myset.p=shape;
const void* ptr = &myset;
unsigned int result = HsiehHash<sizeof(btS)/4> (ptr);
return result;
}
};
#endif

View File

@@ -18,6 +18,7 @@ subject to the following restrictions:
#define SIMD___SCALAR_H
#include <math.h>
#include <stdlib.h>//size_t for MSVC 6.0
#include <cstdlib>
#include <cfloat>
@@ -144,9 +145,9 @@ typedef float btScalar;
#define BT_DECLARE_ALIGNED_ALLOCATOR() \
SIMD_FORCE_INLINE void* operator new(std::size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void* operator new(std::size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete(void*, void*) { } \