shrink down cube size of BasicDemo 10 times (it looked ginormous in VR) from 2x2x2 meter to 0.2
add test for VR HUD/sub-titles fix issue in previous commit, partial string use %.8s not %8.s use long long int in b3Clock fix warning/error in pointer alignment in serialization Fix pybullet Windows compilation. (thanks to bkeys/https://github.com/bulletphysics/bullet3/pull/687)
This commit is contained in:
@@ -389,18 +389,10 @@ void bDNA::init(char *data, int len, bool swap)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cp = btAlignPointer(cp,4);
|
||||||
|
|
||||||
{
|
|
||||||
nr= (long)cp;
|
|
||||||
//long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TYPE (4 bytes)
|
TYPE (4 bytes)
|
||||||
<nr> amount of types (int)
|
<nr> amount of types (int)
|
||||||
@@ -426,17 +418,8 @@ void bDNA::init(char *data, int len, bool swap)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
cp = btAlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
// long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TLEN (4 bytes)
|
TLEN (4 bytes)
|
||||||
<len> (short) the lengths of types
|
<len> (short) the lengths of types
|
||||||
|
|||||||
@@ -460,15 +460,7 @@ void bFile::swapDNA(char* ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
cp = btAlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
//long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -497,16 +489,7 @@ void bFile::swapDNA(char* ptr)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
cp = btAlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
// long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TLEN (4 bytes)
|
TLEN (4 bytes)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct BasicExample : public CommonRigidBodyBase
|
|||||||
virtual void renderScene();
|
virtual void renderScene();
|
||||||
void resetCamera()
|
void resetCamera()
|
||||||
{
|
{
|
||||||
float dist = 41;
|
float dist = 4;
|
||||||
float pitch = 52;
|
float pitch = 52;
|
||||||
float yaw = 35;
|
float yaw = 35;
|
||||||
float targetPos[3]={0,0,0};
|
float targetPos[3]={0,0,0};
|
||||||
@@ -81,7 +81,7 @@ void BasicExample::initPhysics()
|
|||||||
//create a few dynamic rigidbodies
|
//create a few dynamic rigidbodies
|
||||||
// Re-using the same collision is better for memory usage and performance
|
// Re-using the same collision is better for memory usage and performance
|
||||||
|
|
||||||
btBoxShape* colShape = createBoxShape(btVector3(1,1,1));
|
btBoxShape* colShape = createBoxShape(btVector3(.1,.1,.1));
|
||||||
|
|
||||||
|
|
||||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||||
@@ -108,9 +108,9 @@ void BasicExample::initPhysics()
|
|||||||
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
||||||
{
|
{
|
||||||
startTransform.setOrigin(btVector3(
|
startTransform.setOrigin(btVector3(
|
||||||
btScalar(2.0*i),
|
btScalar(0.2*i),
|
||||||
btScalar(20+2.0*k),
|
btScalar(2+.2*k),
|
||||||
btScalar(2.0*j)));
|
btScalar(0.2*j)));
|
||||||
|
|
||||||
|
|
||||||
createRigidBody(mass,startTransform,colShape);
|
createRigidBody(mass,startTransform,colShape);
|
||||||
@@ -121,7 +121,9 @@ void BasicExample::initPhysics()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ SET(AppBasicExampleGui_SRCS
|
|||||||
../ExampleBrowser/OpenGLGuiHelper.cpp
|
../ExampleBrowser/OpenGLGuiHelper.cpp
|
||||||
../ExampleBrowser/GL_ShapeDrawer.cpp
|
../ExampleBrowser/GL_ShapeDrawer.cpp
|
||||||
../ExampleBrowser/CollisionShape2TriangleMesh.cpp
|
../ExampleBrowser/CollisionShape2TriangleMesh.cpp
|
||||||
|
../Utils/b3Clock.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
#this define maps StandaloneExampleCreateFunc to the right 'CreateFunc'
|
#this define maps StandaloneExampleCreateFunc to the right 'CreateFunc'
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ files {
|
|||||||
"../ExampleBrowser/OpenGLGuiHelper.cpp",
|
"../ExampleBrowser/OpenGLGuiHelper.cpp",
|
||||||
"../ExampleBrowser/GL_ShapeDrawer.cpp",
|
"../ExampleBrowser/GL_ShapeDrawer.cpp",
|
||||||
"../ExampleBrowser/CollisionShape2TriangleMesh.cpp",
|
"../ExampleBrowser/CollisionShape2TriangleMesh.cpp",
|
||||||
|
"../Utils/b3Clock.cpp",
|
||||||
|
"../Utils/b3Clock.h",
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is("Linux") then initX11() end
|
if os.is("Linux") then initX11() end
|
||||||
@@ -93,7 +95,9 @@ files {
|
|||||||
"../TinyRenderer/tgaimage.cpp",
|
"../TinyRenderer/tgaimage.cpp",
|
||||||
"../TinyRenderer/our_gl.cpp",
|
"../TinyRenderer/our_gl.cpp",
|
||||||
"../TinyRenderer/TinyRenderer.cpp",
|
"../TinyRenderer/TinyRenderer.cpp",
|
||||||
"../Utils/b3ResourcePath.cpp"
|
"../Utils/b3ResourcePath.cpp",
|
||||||
|
"../Utils/b3Clock.cpp",
|
||||||
|
"../Utils/b3Clock.h",
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is("Linux") then initX11() end
|
if os.is("Linux") then initX11() end
|
||||||
@@ -132,7 +136,9 @@ files {
|
|||||||
"../TinyRenderer/tgaimage.cpp",
|
"../TinyRenderer/tgaimage.cpp",
|
||||||
"../TinyRenderer/our_gl.cpp",
|
"../TinyRenderer/our_gl.cpp",
|
||||||
"../TinyRenderer/TinyRenderer.cpp",
|
"../TinyRenderer/TinyRenderer.cpp",
|
||||||
"../Utils/b3ResourcePath.cpp"
|
"../Utils/b3ResourcePath.cpp",
|
||||||
|
"../Utils/b3Clock.cpp",
|
||||||
|
"../Utils/b3Clock.h",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -179,6 +185,8 @@ files {
|
|||||||
"../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp",
|
"../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp",
|
||||||
"../ThirdPartyLibs/openvr/samples/shared/pathtools.h",
|
"../ThirdPartyLibs/openvr/samples/shared/pathtools.h",
|
||||||
"../ThirdPartyLibs/openvr/samples/shared/Vectors.h",
|
"../ThirdPartyLibs/openvr/samples/shared/Vectors.h",
|
||||||
|
"../Utils/b3Clock.cpp",
|
||||||
|
"../Utils/b3Clock.h",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ struct CommonCameraInterface
|
|||||||
virtual void getCameraProjectionMatrix(float m[16])const = 0;
|
virtual void getCameraProjectionMatrix(float m[16])const = 0;
|
||||||
virtual void getCameraViewMatrix(float m[16]) const = 0;
|
virtual void getCameraViewMatrix(float m[16]) const = 0;
|
||||||
|
|
||||||
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16])=0;
|
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16])=0;
|
||||||
|
virtual void disableVRCamera()=0;
|
||||||
|
virtual bool isVRCamera() const =0;
|
||||||
|
|
||||||
virtual void getCameraTargetPosition(float pos[3]) const = 0;
|
virtual void getCameraTargetPosition(float pos[3]) const = 0;
|
||||||
virtual void getCameraPosition(float pos[3]) const = 0;
|
virtual void getCameraPosition(float pos[3]) const = 0;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ struct GUIHelperInterface
|
|||||||
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId) = 0;
|
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId) = 0;
|
||||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) =0;
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) =0;
|
||||||
virtual void removeAllGraphicsInstances()=0;
|
virtual void removeAllGraphicsInstances()=0;
|
||||||
|
|
||||||
virtual Common2dCanvasInterface* get2dCanvasInterface()=0;
|
virtual Common2dCanvasInterface* get2dCanvasInterface()=0;
|
||||||
|
|
||||||
virtual CommonParameterInterface* getParameterInterface()=0;
|
virtual CommonParameterInterface* getParameterInterface()=0;
|
||||||
@@ -78,7 +78,7 @@ struct DummyGUIHelper : public GUIHelperInterface
|
|||||||
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId){return -1;}
|
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId){return -1;}
|
||||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) {return -1;}
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) {return -1;}
|
||||||
virtual void removeAllGraphicsInstances(){}
|
virtual void removeAllGraphicsInstances(){}
|
||||||
|
|
||||||
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
virtual Common2dCanvasInterface* get2dCanvasInterface()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct CommonRenderInterface
|
|||||||
virtual void init()=0;
|
virtual void init()=0;
|
||||||
virtual void updateCamera(int upAxis)=0;
|
virtual void updateCamera(int upAxis)=0;
|
||||||
virtual void removeAllInstances() = 0;
|
virtual void removeAllInstances() = 0;
|
||||||
|
|
||||||
virtual const CommonCameraInterface* getActiveCamera() const =0;
|
virtual const CommonCameraInterface* getActiveCamera() const =0;
|
||||||
virtual CommonCameraInterface* getActiveCamera()=0;
|
virtual CommonCameraInterface* getActiveCamera()=0;
|
||||||
virtual void setActiveCamera(CommonCameraInterface* cam)=0;
|
virtual void setActiveCamera(CommonCameraInterface* cam)=0;
|
||||||
@@ -52,6 +52,8 @@ struct CommonRenderInterface
|
|||||||
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0;
|
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0;
|
||||||
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex)=0;
|
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex)=0;
|
||||||
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex)=0;
|
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex)=0;
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(float* scale, int srcIndex)=0;
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(double* scale, int srcIndex)=0;
|
||||||
|
|
||||||
virtual int getTotalNumInstances() const = 0;
|
virtual int getTotalNumInstances() const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ enum TestExampleBrowserCommunicationEnums
|
|||||||
|
|
||||||
void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory)
|
void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory)
|
||||||
{
|
{
|
||||||
printf("thread started\n");
|
printf("ExampleBrowserThreadFunc started\n");
|
||||||
|
|
||||||
ExampleBrowserThreadLocalStorage* localStorage = (ExampleBrowserThreadLocalStorage*) lsMemory;
|
ExampleBrowserThreadLocalStorage* localStorage = (ExampleBrowserThreadLocalStorage*) lsMemory;
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("stopping threads\n");
|
printf("btShutDownExampleBrowser stopping threads\n");
|
||||||
delete data->m_threadSupport;
|
delete data->m_threadSupport;
|
||||||
delete data->m_sharedMem;
|
delete data->m_sharedMem;
|
||||||
delete data;
|
delete data;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
|||||||
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId);
|
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId);
|
||||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
|
||||||
virtual void removeAllGraphicsInstances();
|
virtual void removeAllGraphicsInstances();
|
||||||
|
|
||||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape);
|
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape);
|
||||||
|
|
||||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
|
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ files {
|
|||||||
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||||
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||||
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +91,9 @@ files {
|
|||||||
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||||
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||||
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||||
|
"../Utils/b3Clock.cpp",
|
||||||
|
"../Utils/b3Clock.h",
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is("Linux") then initX11() end
|
if os.is("Linux") then initX11() end
|
||||||
@@ -156,7 +158,7 @@ files {
|
|||||||
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
"../Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||||
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
"../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||||
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.is("Linux") then initX11() end
|
if os.is("Linux") then initX11() end
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ struct SampleThreadLocalStorage
|
|||||||
|
|
||||||
void SampleThreadFunc(void* userPtr,void* lsMemory)
|
void SampleThreadFunc(void* userPtr,void* lsMemory)
|
||||||
{
|
{
|
||||||
printf("thread started\n");
|
printf("SampleThreadFunc thread started\n");
|
||||||
|
|
||||||
SampleThreadLocalStorage* localStorage = (SampleThreadLocalStorage*) lsMemory;
|
SampleThreadLocalStorage* localStorage = (SampleThreadLocalStorage*) lsMemory;
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,8 @@ bool b3Win32ThreadSupport::isTaskCompleted(int *puiArgument0, int *puiArgument1,
|
|||||||
|
|
||||||
void b3Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threadConstructionInfo)
|
void b3Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threadConstructionInfo)
|
||||||
{
|
{
|
||||||
|
static int uniqueId = 0;
|
||||||
|
uniqueId++;
|
||||||
m_activeThreadStatus.resize(threadConstructionInfo.m_numThreads);
|
m_activeThreadStatus.resize(threadConstructionInfo.m_numThreads);
|
||||||
m_completeHandles.resize(threadConstructionInfo.m_numThreads);
|
m_completeHandles.resize(threadConstructionInfo.m_numThreads);
|
||||||
|
|
||||||
@@ -244,18 +245,40 @@ void b3Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threa
|
|||||||
|
|
||||||
threadStatus.m_userPtr=0;
|
threadStatus.m_userPtr=0;
|
||||||
|
|
||||||
sprintf(threadStatus.m_eventStartHandleName,"eventStart%8.s%d",threadConstructionInfo.m_uniqueName,i);
|
sprintf(threadStatus.m_eventStartHandleName,"es%.8s%d%d",threadConstructionInfo.m_uniqueName,uniqueId,i);
|
||||||
threadStatus.m_eventStartHandle = CreateEventA (0,false,false,threadStatus.m_eventStartHandleName);
|
threadStatus.m_eventStartHandle = CreateEventA (0,false,false,threadStatus.m_eventStartHandleName);
|
||||||
|
|
||||||
sprintf(threadStatus.m_eventCompletetHandleName,"eventComplete%8.s%d",threadConstructionInfo.m_uniqueName,i);
|
sprintf(threadStatus.m_eventCompletetHandleName,"ec%.8s%d%d",threadConstructionInfo.m_uniqueName,uniqueId,i);
|
||||||
threadStatus.m_eventCompletetHandle = CreateEventA (0,false,false,threadStatus.m_eventCompletetHandleName);
|
threadStatus.m_eventCompletetHandle = CreateEventA (0,false,false,threadStatus.m_eventCompletetHandleName);
|
||||||
|
|
||||||
m_completeHandles[i] = threadStatus.m_eventCompletetHandle;
|
m_completeHandles[i] = threadStatus.m_eventCompletetHandle;
|
||||||
|
|
||||||
HANDLE handle = CreateThread(lpThreadAttributes,dwStackSize,lpStartAddress,lpParameter, dwCreationFlags,lpThreadId);
|
HANDLE handle = CreateThread(lpThreadAttributes,dwStackSize,lpStartAddress,lpParameter, dwCreationFlags,lpThreadId);
|
||||||
//SetThreadPriority(handle,THREAD_PRIORITY_HIGHEST);
|
switch(threadConstructionInfo.m_priority)
|
||||||
SetThreadPriority(handle,THREAD_PRIORITY_TIME_CRITICAL);
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
SetThreadPriority(handle,THREAD_PRIORITY_HIGHEST);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
SetThreadPriority(handle,THREAD_PRIORITY_TIME_CRITICAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
SetThreadPriority(handle,THREAD_PRIORITY_BELOW_NORMAL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SetThreadAffinityMask(handle, 1<<i);
|
SetThreadAffinityMask(handle, 1<<i);
|
||||||
|
|
||||||
threadStatus.m_taskId = i;
|
threadStatus.m_taskId = i;
|
||||||
@@ -265,7 +288,7 @@ void b3Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threa
|
|||||||
threadStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
|
threadStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
|
||||||
threadStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
|
threadStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
|
||||||
|
|
||||||
printf("started thread %d with threadHandle %p\n",i,handle);
|
printf("started %s thread %d with threadHandle %p\n",threadConstructionInfo.m_uniqueName,i,handle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ public:
|
|||||||
m_userThreadFunc(userThreadFunc),
|
m_userThreadFunc(userThreadFunc),
|
||||||
m_lsMemoryFunc(lsMemoryFunc),
|
m_lsMemoryFunc(lsMemoryFunc),
|
||||||
m_numThreads(numThreads),
|
m_numThreads(numThreads),
|
||||||
m_threadStackSize(threadStackSize)
|
m_threadStackSize(threadStackSize),
|
||||||
|
m_priority(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -84,6 +85,7 @@ public:
|
|||||||
b3Win32lsMemorySetupFunc m_lsMemoryFunc;
|
b3Win32lsMemorySetupFunc m_lsMemoryFunc;
|
||||||
int m_numThreads;
|
int m_numThreads;
|
||||||
int m_threadStackSize;
|
int m_threadStackSize;
|
||||||
|
int m_priority;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ GLInstancingRenderer::GLInstancingRenderer(int maxNumObjectCapacity, int maxShap
|
|||||||
|
|
||||||
void GLInstancingRenderer::removeAllInstances()
|
void GLInstancingRenderer::removeAllInstances()
|
||||||
{
|
{
|
||||||
|
m_data->m_totalNumInstances = 0;
|
||||||
|
|
||||||
for (int i=0;i<m_graphicsInstances.size();i++)
|
for (int i=0;i<m_graphicsInstances.size();i++)
|
||||||
{
|
{
|
||||||
if (m_graphicsInstances[i]->m_index_vbo)
|
if (m_graphicsInstances[i]->m_index_vbo)
|
||||||
@@ -276,6 +278,7 @@ void GLInstancingRenderer::removeAllInstances()
|
|||||||
m_graphicsInstances.clear();
|
m_graphicsInstances.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLInstancingRenderer::~GLInstancingRenderer()
|
GLInstancingRenderer::~GLInstancingRenderer()
|
||||||
{
|
{
|
||||||
delete m_data->m_shadowMap;
|
delete m_data->m_shadowMap;
|
||||||
@@ -323,6 +326,7 @@ void GLInstancingRenderer::writeSingleInstanceTransformToCPU(const float* positi
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLInstancingRenderer::writeSingleInstanceColorToCPU(double* color, int srcIndex)
|
void GLInstancingRenderer::writeSingleInstanceColorToCPU(double* color, int srcIndex)
|
||||||
{
|
{
|
||||||
m_data->m_instance_colors_ptr[srcIndex*4+0]=float(color[0]);
|
m_data->m_instance_colors_ptr[srcIndex*4+0]=float(color[0]);
|
||||||
@@ -340,7 +344,19 @@ void GLInstancingRenderer::writeSingleInstanceColorToCPU(float* color, int srcIn
|
|||||||
m_data->m_instance_colors_ptr[srcIndex*4+3]=color[3];
|
m_data->m_instance_colors_ptr[srcIndex*4+3]=color[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLInstancingRenderer::writeSingleInstanceScaleToCPU(float* scale, int srcIndex)
|
||||||
|
{
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+0]=scale[0];
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+1]=scale[1];
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+2]=scale[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLInstancingRenderer::writeSingleInstanceScaleToCPU(double* scale, int srcIndex)
|
||||||
|
{
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+0]=scale[0];
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+1]=scale[1];
|
||||||
|
m_data->m_instance_scale_ptr[srcIndex*3+2]=scale[2];
|
||||||
|
}
|
||||||
|
|
||||||
void GLInstancingRenderer::writeSingleInstanceTransformToGPU(float* position, float* orientation, int objectIndex)
|
void GLInstancingRenderer::writeSingleInstanceTransformToGPU(float* position, float* orientation, int objectIndex)
|
||||||
{
|
{
|
||||||
@@ -389,27 +405,33 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
//glFlush();
|
//glFlush();
|
||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
int totalNumInstances= 0;
|
|
||||||
|
|
||||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
#ifdef B3_DEBUG
|
||||||
{
|
{
|
||||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
int totalNumInstances= 0;
|
||||||
totalNumInstances+=gfxObj->m_numGraphicsInstances;
|
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||||
|
{
|
||||||
|
b3GraphicsInstance* gfxObj = m_graphicsInstances[k];
|
||||||
|
totalNumInstances+=gfxObj->m_numGraphicsInstances;
|
||||||
|
}
|
||||||
|
b3Assert(m_data->m_totalNumInstances == totalNumInstances);
|
||||||
}
|
}
|
||||||
|
#endif//B3_DEBUG
|
||||||
|
|
||||||
int POSITION_BUFFER_SIZE = (totalNumInstances*sizeof(float)*4);
|
int POSITION_BUFFER_SIZE = (m_data->m_totalNumInstances*sizeof(float)*4);
|
||||||
int ORIENTATION_BUFFER_SIZE = (totalNumInstances*sizeof(float)*4);
|
int ORIENTATION_BUFFER_SIZE = (m_data->m_totalNumInstances*sizeof(float)*4);
|
||||||
int COLOR_BUFFER_SIZE = (totalNumInstances*sizeof(float)*4);
|
int COLOR_BUFFER_SIZE = (m_data->m_totalNumInstances*sizeof(float)*4);
|
||||||
// int SCALE_BUFFER_SIZE = (totalNumInstances*sizeof(float)*3);
|
// int SCALE_BUFFER_SIZE = (totalNumInstances*sizeof(float)*3);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes,totalNumInstances*sizeof(float)*4,
|
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes,m_data->m_totalNumInstances*sizeof(float)*4,
|
||||||
&m_data->m_instance_positions_ptr[0]);
|
&m_data->m_instance_positions_ptr[0]);
|
||||||
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE,totalNumInstances*sizeof(float)*4,
|
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE,m_data->m_totalNumInstances*sizeof(float)*4,
|
||||||
&m_data->m_instance_quaternion_ptr[0]);
|
&m_data->m_instance_quaternion_ptr[0]);
|
||||||
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes+ POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE, totalNumInstances*sizeof(float)*4,
|
glBufferSubData( GL_ARRAY_BUFFER,m_data->m_maxShapeCapacityInBytes+ POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE, m_data->m_totalNumInstances*sizeof(float)*4,
|
||||||
&m_data->m_instance_colors_ptr[0]);
|
&m_data->m_instance_colors_ptr[0]);
|
||||||
glBufferSubData( GL_ARRAY_BUFFER, m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE,totalNumInstances*sizeof(float)*3,
|
glBufferSubData( GL_ARRAY_BUFFER, m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE,m_data->m_totalNumInstances*sizeof(float)*3,
|
||||||
&m_data->m_instance_scale_ptr[0]);
|
&m_data->m_instance_scale_ptr[0]);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -419,7 +441,7 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_data->m_totalNumInstances = totalNumInstances;
|
|
||||||
|
|
||||||
for (int k=0;k<m_graphicsInstances.size();k++)
|
for (int k=0;k<m_graphicsInstances.size();k++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
void InitShaders();
|
void InitShaders();
|
||||||
void CleanupShaders();
|
void CleanupShaders();
|
||||||
virtual void removeAllInstances();
|
virtual void removeAllInstances();
|
||||||
|
|
||||||
virtual void updateShape(int shapeIndex, const float* vertices);
|
virtual void updateShape(int shapeIndex, const float* vertices);
|
||||||
|
|
||||||
///vertices must be in the format x,y,z, nx,ny,nz, u,v
|
///vertices must be in the format x,y,z, nx,ny,nz, u,v
|
||||||
@@ -95,6 +95,9 @@ public:
|
|||||||
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex);
|
||||||
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex);
|
||||||
|
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(float* scale, int srcIndex);
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(double* scale, int srcIndex);
|
||||||
|
|
||||||
|
|
||||||
virtual struct GLInstanceRendererInternalData* getInternalData();
|
virtual struct GLInstanceRendererInternalData* getInternalData();
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,16 @@ void SimpleCamera::setVRCamera(const float viewMat[16], const float projectionMa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleCamera::disableVRCamera()
|
||||||
|
{
|
||||||
|
m_data->m_enableVR = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimpleCamera::isVRCamera() const
|
||||||
|
{
|
||||||
|
return m_data->m_enableVR ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void b3CreateFrustum(
|
static void b3CreateFrustum(
|
||||||
float left,
|
float left,
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ struct SimpleCamera : public CommonCameraInterface
|
|||||||
virtual void getCameraViewMatrix(float m[16]) const;
|
virtual void getCameraViewMatrix(float m[16]) const;
|
||||||
|
|
||||||
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16]);
|
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16]);
|
||||||
|
virtual void disableVRCamera();
|
||||||
|
virtual bool isVRCamera() const;
|
||||||
|
|
||||||
virtual void getCameraTargetPosition(float pos[3]) const;
|
virtual void getCameraTargetPosition(float pos[3]) const;
|
||||||
virtual void getCameraPosition(float pos[3]) const;
|
virtual void getCameraPosition(float pos[3]) const;
|
||||||
|
|||||||
@@ -65,6 +65,14 @@ void SimpleOpenGL2Renderer::writeSingleInstanceColorToCPU(double* color, int src
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleOpenGL2Renderer::writeSingleInstanceScaleToCPU(float* scale, int srcIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void SimpleOpenGL2Renderer::writeSingleInstanceScaleToCPU(double* scale, int srcIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int SimpleOpenGL2Renderer::getTotalNumInstances() const
|
int SimpleOpenGL2Renderer::getTotalNumInstances() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ struct SimpleOpenGL2Renderer : public CommonRenderInterface
|
|||||||
|
|
||||||
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex);
|
||||||
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex);
|
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex);
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(float* scale, int srcIndex);
|
||||||
|
virtual void writeSingleInstanceScaleToCPU(double* scale, int srcIndex);
|
||||||
virtual void getCameraViewMatrix(float viewMat[16]) const;
|
virtual void getCameraViewMatrix(float viewMat[16]) const;
|
||||||
virtual void getCameraProjectionMatrix(float projMat[16]) const;
|
virtual void getCameraProjectionMatrix(float projMat[16]) const;
|
||||||
|
|
||||||
|
|||||||
@@ -97,11 +97,9 @@ struct MotionThreadLocalStorage
|
|||||||
|
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
|
|
||||||
|
|
||||||
void MotionThreadFunc(void* userPtr,void* lsMemory)
|
void MotionThreadFunc(void* userPtr,void* lsMemory)
|
||||||
{
|
{
|
||||||
printf("thread started\n");
|
printf("MotionThreadFunc thread started\n");
|
||||||
|
|
||||||
MotionThreadLocalStorage* localStorage = (MotionThreadLocalStorage*) lsMemory;
|
MotionThreadLocalStorage* localStorage = (MotionThreadLocalStorage*) lsMemory;
|
||||||
|
|
||||||
MotionArgs* args = (MotionArgs*) userPtr;
|
MotionArgs* args = (MotionArgs*) userPtr;
|
||||||
@@ -116,41 +114,23 @@ void MotionThreadFunc(void* userPtr,void* lsMemory)
|
|||||||
args->m_cs->setSharedParam(0,eMotionIsInitialized);
|
args->m_cs->setSharedParam(0,eMotionIsInitialized);
|
||||||
args->m_cs->unlock();
|
args->m_cs->unlock();
|
||||||
|
|
||||||
double m_x=0;
|
|
||||||
double m_y=0;
|
|
||||||
double m_z=0;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
double deltaTimeInSeconds = double(clock.getTimeMicroseconds())/1000000.;
|
double deltaTimeInSeconds = double(clock.getTimeMicroseconds())/1000000.;
|
||||||
//if (deltaTimeInSeconds<.3)
|
|
||||||
//if (deltaTimeInSeconds<(1./15.))
|
|
||||||
if (deltaTimeInSeconds<(1./260.))
|
if (deltaTimeInSeconds<(1./260.))
|
||||||
{
|
{
|
||||||
skip++;
|
skip++;
|
||||||
//if (deltaTimeInSeconds<.001)
|
if (deltaTimeInSeconds<.001)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_x+=deltaTimeInSeconds;
|
|
||||||
m_y+=deltaTimeInSeconds;
|
|
||||||
m_z+=deltaTimeInSeconds;
|
|
||||||
|
|
||||||
clock.reset();
|
clock.reset();
|
||||||
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
index++;
|
|
||||||
|
|
||||||
if (!blockme)
|
if (!blockme)
|
||||||
{
|
{
|
||||||
args->m_physicsServerPtr->processClientCommands();
|
args->m_physicsServerPtr->processClientCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} while (args->m_cs->getSharedParam(0)!=eRequestTerminateMotion);
|
} while (args->m_cs->getSharedParam(0)!=eRequestTerminateMotion);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -160,9 +140,6 @@ void MotionThreadFunc(void* userPtr,void* lsMemory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
args->m_cs->lock();
|
|
||||||
args->m_cs->setSharedParam(0,eMotionHasTerminated);
|
|
||||||
args->m_cs->unlock();
|
|
||||||
printf("finished, #skip = %d\n",skip);
|
printf("finished, #skip = %d\n",skip);
|
||||||
skip=0;
|
skip=0;
|
||||||
//do nothing
|
//do nothing
|
||||||
@@ -358,7 +335,7 @@ public:
|
|||||||
|
|
||||||
virtual CommonGraphicsApp* getAppInterface()
|
virtual CommonGraphicsApp* getAppInterface()
|
||||||
{
|
{
|
||||||
return 0;
|
return m_childGuiHelper->getAppInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -615,7 +592,7 @@ void PhysicsServerExample::exitPhysics()
|
|||||||
delete m_threadSupport;
|
delete m_threadSupport;
|
||||||
m_threadSupport = 0;
|
m_threadSupport = 0;
|
||||||
|
|
||||||
m_physicsServer.resetDynamicsWorld();
|
//m_physicsServer.resetDynamicsWorld();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,6 +675,9 @@ void PhysicsServerExample::stepSimulation(float deltaTime)
|
|||||||
case eGUIHelperRemoveAllGraphicsInstances:
|
case eGUIHelperRemoveAllGraphicsInstances:
|
||||||
{
|
{
|
||||||
m_multiThreadedHelper->m_childGuiHelper->removeAllGraphicsInstances();
|
m_multiThreadedHelper->m_childGuiHelper->removeAllGraphicsInstances();
|
||||||
|
int numRenderInstances = m_multiThreadedHelper->m_childGuiHelper->getRenderInterface()->getTotalNumInstances();
|
||||||
|
b3Assert(numRenderInstances==0);
|
||||||
|
|
||||||
m_multiThreadedHelper->getCriticalSection()->lock();
|
m_multiThreadedHelper->getCriticalSection()->lock();
|
||||||
m_multiThreadedHelper->getCriticalSection()->setSharedParam(1,eGUIHelperIdle);
|
m_multiThreadedHelper->getCriticalSection()->setSharedParam(1,eGUIHelperIdle);
|
||||||
m_multiThreadedHelper->getCriticalSection()->unlock();
|
m_multiThreadedHelper->getCriticalSection()->unlock();
|
||||||
@@ -739,12 +719,45 @@ void PhysicsServerExample::stepSimulation(float deltaTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PhysicsServerExample::renderScene()
|
void PhysicsServerExample::renderScene()
|
||||||
{
|
{
|
||||||
///debug rendering
|
///debug rendering
|
||||||
//m_args[0].m_cs->lock();
|
//m_args[0].m_cs->lock();
|
||||||
|
|
||||||
m_physicsServer.renderScene();
|
m_physicsServer.renderScene();
|
||||||
|
|
||||||
|
if (m_guiHelper->getAppInterface()->m_renderer->getActiveCamera()->isVRCamera())
|
||||||
|
{
|
||||||
|
//some little experiment to add text/HUD to a VR camera (HTC Vive/Oculus Rift)
|
||||||
|
|
||||||
|
static int frameCount=0;
|
||||||
|
frameCount++;
|
||||||
|
char bla[1024];
|
||||||
|
sprintf(bla,"VR sub-title text test, frame %d", frameCount/2);
|
||||||
|
float pos[4];
|
||||||
|
m_guiHelper->getAppInterface()->m_renderer->getActiveCamera()->getCameraTargetPosition(pos);
|
||||||
|
btTransform viewTr;
|
||||||
|
btScalar m[16];
|
||||||
|
float mf[16];
|
||||||
|
m_guiHelper->getAppInterface()->m_renderer->getActiveCamera()->getCameraViewMatrix(mf);
|
||||||
|
for (int i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
m[i] = mf[i];
|
||||||
|
}
|
||||||
|
viewTr.setFromOpenGLMatrix(m);
|
||||||
|
btTransform viewTrInv = viewTr.inverse();
|
||||||
|
float upMag = -.6;
|
||||||
|
btVector3 side = viewTrInv.getBasis().getColumn(0);
|
||||||
|
btVector3 up = viewTrInv.getBasis().getColumn(1);
|
||||||
|
up+=0.35*side;
|
||||||
|
m_guiHelper->getAppInterface()->drawText3D(bla,pos[0]+upMag*up[0],pos[1]+upMag*up[1],pos[2]+upMag*up[2],1);
|
||||||
|
//btVector3 fwd = viewTrInv.getBasis().getColumn(2);
|
||||||
|
sprintf(bla,"VR line 2 sub-title text test, frame %d", frameCount/2);
|
||||||
|
upMag = -0.7;
|
||||||
|
m_guiHelper->getAppInterface()->drawText3D(bla,pos[0]+upMag*up[0],pos[1]+upMag*up[1],pos[2]+upMag*up[2],1);
|
||||||
|
}
|
||||||
|
|
||||||
//m_args[0].m_cs->unlock();
|
//m_args[0].m_cs->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1486,7 +1486,34 @@ void CMainApplication::RenderStereoTargets()
|
|||||||
{
|
{
|
||||||
|
|
||||||
Matrix4 viewMatLeft = m_mat4eyePosLeft * m_mat4HMDPose * rotYtoZ;
|
Matrix4 viewMatLeft = m_mat4eyePosLeft * m_mat4HMDPose * rotYtoZ;
|
||||||
|
Matrix4 viewMatCenter = m_mat4HMDPose * rotYtoZ;
|
||||||
|
//0,1,2,3
|
||||||
|
//4,5,6,7,
|
||||||
|
//8,9,10,11
|
||||||
|
//12,13,14,15
|
||||||
|
|
||||||
|
//m_mat4eyePosLeft.get()[10]
|
||||||
|
//m_app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(
|
||||||
|
// m_mat4eyePosLeft.get()[3],
|
||||||
|
// m_mat4eyePosLeft.get()[7],
|
||||||
|
// m_mat4eyePosLeft.get()[11]);
|
||||||
|
Matrix4 m;
|
||||||
|
m = viewMatCenter;
|
||||||
|
const float* mat = m.invertAffine().get();
|
||||||
|
|
||||||
|
/*printf("camera:\n,%f,%f,%f,%f\n%f,%f,%f,%f\n%f,%f,%f,%f\n%f,%f,%f,%f",
|
||||||
|
mat[0],mat[1],mat[2],mat[3],
|
||||||
|
mat[4],mat[5],mat[6],mat[7],
|
||||||
|
mat[8],mat[9],mat[10],mat[11],
|
||||||
|
mat[12],mat[13],mat[14],mat[15]);
|
||||||
|
*/
|
||||||
|
float dist=1;
|
||||||
|
m_app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(
|
||||||
|
mat[12]-dist*mat[8],
|
||||||
|
mat[13]-dist*mat[9],
|
||||||
|
mat[14]-dist*mat[10]
|
||||||
|
);
|
||||||
|
m_app->m_instancingRenderer->getActiveCamera()->setCameraUpVector(mat[0],mat[1],mat[2]);
|
||||||
m_app->m_instancingRenderer->getActiveCamera()->setVRCamera(viewMatLeft.get(),m_mat4ProjectionLeft.get());
|
m_app->m_instancingRenderer->getActiveCamera()->setVRCamera(viewMatLeft.get(),m_mat4ProjectionLeft.get());
|
||||||
m_app->m_instancingRenderer->updateCamera(m_app->getUpAxis());
|
m_app->m_instancingRenderer->updateCamera(m_app->getUpAxis());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,9 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "../CommonInterfaces/CommonExampleInterface.h"
|
#include "../CommonInterfaces/CommonExampleInterface.h"
|
||||||
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
#include "../Utils/b3Clock.h"
|
||||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
|
||||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "LinearMath/btTransform.h"
|
|
||||||
#include "LinearMath/btHashMap.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "../OpenGLWindow/SimpleOpenGL3App.h"
|
#include "../OpenGLWindow/SimpleOpenGL3App.h"
|
||||||
@@ -74,7 +69,7 @@ public:
|
|||||||
};
|
};
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
SimpleOpenGL3App* app = new SimpleOpenGL3App("Bullet Standalone Example",1024,768,true);
|
SimpleOpenGL3App* app = new SimpleOpenGL3App("Bullet Standalone Example",1024,768,true);
|
||||||
|
|
||||||
prevMouseButtonCallback = app->m_window->getMouseButtonCallback();
|
prevMouseButtonCallback = app->m_window->getMouseButtonCallback();
|
||||||
@@ -93,13 +88,17 @@ int main(int argc, char* argv[])
|
|||||||
example->initPhysics();
|
example->initPhysics();
|
||||||
example->resetCamera();
|
example->resetCamera();
|
||||||
|
|
||||||
|
b3Clock clock;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
app->m_instancingRenderer->init();
|
app->m_instancingRenderer->init();
|
||||||
app->m_instancingRenderer->updateCamera(app->getUpAxis());
|
app->m_instancingRenderer->updateCamera(app->getUpAxis());
|
||||||
|
|
||||||
example->stepSimulation(1./60.);
|
btScalar dtSec = btScalar(clock.getTimeInSeconds());
|
||||||
|
example->stepSimulation(dtSec);
|
||||||
|
clock.reset();
|
||||||
|
|
||||||
example->renderScene();
|
example->renderScene();
|
||||||
|
|
||||||
DrawGridData dg;
|
DrawGridData dg;
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ unsigned long int b3Clock::getTimeMilliseconds()
|
|||||||
|
|
||||||
/// Returns the time in us since the last call to reset or since
|
/// Returns the time in us since the last call to reset or since
|
||||||
/// the Clock was created.
|
/// the Clock was created.
|
||||||
unsigned long int b3Clock::getTimeMicroseconds()
|
unsigned long long int b3Clock::getTimeMicroseconds()
|
||||||
{
|
{
|
||||||
#ifdef B3_USE_WINDOWS_TIMERS
|
#ifdef B3_USE_WINDOWS_TIMERS
|
||||||
LARGE_INTEGER currentTime;
|
LARGE_INTEGER currentTime;
|
||||||
@@ -175,14 +175,14 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
|||||||
m_data->mStartTime.QuadPart;
|
m_data->mStartTime.QuadPart;
|
||||||
|
|
||||||
// Compute the number of millisecond ticks elapsed.
|
// Compute the number of millisecond ticks elapsed.
|
||||||
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime /
|
unsigned long long msecTicks = (unsigned long long)(1000 * elapsedTime /
|
||||||
m_data->mClockFrequency.QuadPart);
|
m_data->mClockFrequency.QuadPart);
|
||||||
|
|
||||||
// Check for unexpected leaps in the Win32 performance counter.
|
// Check for unexpected leaps in the Win32 performance counter.
|
||||||
// (This is caused by unexpected data across the PCI to ISA
|
// (This is caused by unexpected data across the PCI to ISA
|
||||||
// bridge, aka south bridge. See Microsoft KB274323.)
|
// bridge, aka south bridge. See Microsoft KB274323.)
|
||||||
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
unsigned long long elapsedTicks = GetTickCount() - m_data->mStartTick;
|
||||||
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
|
signed long long msecOff = (signed long)(msecTicks - elapsedTicks);
|
||||||
if (msecOff < -100 || msecOff > 100)
|
if (msecOff < -100 || msecOff > 100)
|
||||||
{
|
{
|
||||||
// Adjust the starting time forwards.
|
// Adjust the starting time forwards.
|
||||||
@@ -197,7 +197,7 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
|||||||
m_data->mPrevElapsedTime = elapsedTime;
|
m_data->mPrevElapsedTime = elapsedTime;
|
||||||
|
|
||||||
// Convert to microseconds.
|
// Convert to microseconds.
|
||||||
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
unsigned long long usecTicks = (unsigned long)(1000000 * elapsedTime /
|
||||||
m_data->mClockFrequency.QuadPart);
|
m_data->mClockFrequency.QuadPart);
|
||||||
|
|
||||||
return usecTicks;
|
return usecTicks;
|
||||||
@@ -222,3 +222,8 @@ unsigned long int b3Clock::getTimeMicroseconds()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double b3Clock::getTimeInSeconds()
|
||||||
|
{
|
||||||
|
return double(getTimeMicroseconds()/1.e6);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ public:
|
|||||||
|
|
||||||
/// Returns the time in us since the last call to reset or since
|
/// Returns the time in us since the last call to reset or since
|
||||||
/// the Clock was created.
|
/// the Clock was created.
|
||||||
unsigned long int getTimeMicroseconds();
|
unsigned long long int getTimeMicroseconds();
|
||||||
|
|
||||||
|
/// Returns the time in seconds since the last call to reset or since
|
||||||
|
/// the Clock was created.
|
||||||
|
double getTimeInSeconds();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct b3ClockData* m_data;
|
struct b3ClockData* m_data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -374,8 +374,8 @@ static PyObject* pybullet_setJointMotorControl(PyObject* self, PyObject* args)
|
|||||||
{
|
{
|
||||||
case CONTROL_MODE_VELOCITY:
|
case CONTROL_MODE_VELOCITY:
|
||||||
{
|
{
|
||||||
|
double kd = gains;
|
||||||
b3JointControlSetDesiredVelocity(commandHandle, info.m_uIndex, targetValue);
|
b3JointControlSetDesiredVelocity(commandHandle, info.m_uIndex, targetValue);
|
||||||
double kd = gains;
|
|
||||||
b3JointControlSetKd(commandHandle,info.m_uIndex,kd);
|
b3JointControlSetKd(commandHandle,info.m_uIndex,kd);
|
||||||
b3JointControlSetMaximumForce(commandHandle,info.m_uIndex,maxForce);
|
b3JointControlSetMaximumForce(commandHandle,info.m_uIndex,maxForce);
|
||||||
break;
|
break;
|
||||||
@@ -389,8 +389,8 @@ static PyObject* pybullet_setJointMotorControl(PyObject* self, PyObject* args)
|
|||||||
|
|
||||||
case CONTROL_MODE_POSITION_VELOCITY_PD:
|
case CONTROL_MODE_POSITION_VELOCITY_PD:
|
||||||
{
|
{
|
||||||
|
double kp = gains;
|
||||||
b3JointControlSetDesiredPosition( commandHandle, info.m_qIndex, targetValue);
|
b3JointControlSetDesiredPosition( commandHandle, info.m_qIndex, targetValue);
|
||||||
double kp = gains;
|
|
||||||
b3JointControlSetKp(commandHandle,info.m_uIndex,kp);
|
b3JointControlSetKp(commandHandle,info.m_uIndex,kp);
|
||||||
b3JointControlSetMaximumForce(commandHandle,info.m_uIndex,maxForce);
|
b3JointControlSetMaximumForce(commandHandle,info.m_uIndex,maxForce);
|
||||||
break;
|
break;
|
||||||
@@ -1270,10 +1270,12 @@ static PyObject* pybullet_applyExternalTorque(PyObject* self, PyObject* args)
|
|||||||
PyErr_SetString(SpamError, "flag has to be either WORLD_FRAME or LINK_FRAME");
|
PyErr_SetString(SpamError, "flag has to be either WORLD_FRAME or LINK_FRAME");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
b3SharedMemoryStatusHandle statusHandle;
|
{
|
||||||
b3SharedMemoryCommandHandle command = b3ApplyExternalForceCommandInit(sm);
|
b3SharedMemoryStatusHandle statusHandle;
|
||||||
b3ApplyExternalTorque(command,objectUniqueId,-1,torque, flags);
|
b3SharedMemoryCommandHandle command = b3ApplyExternalForceCommandInit(sm);
|
||||||
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
|
b3ApplyExternalTorque(command,objectUniqueId,-1,torque, flags);
|
||||||
|
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, command);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1389,12 +1391,13 @@ static PyObject* pybullet_getEulerFromQuaternion(PyObject* self, PyObject* args)
|
|||||||
|
|
||||||
{
|
{
|
||||||
double rpy[3];
|
double rpy[3];
|
||||||
sqx = quat[0] * quat[0];
|
double sarg;
|
||||||
|
sqx = quat[0] * quat[0];
|
||||||
sqy = quat[1] * quat[1];
|
sqy = quat[1] * quat[1];
|
||||||
sqz = quat[2] * quat[2];
|
sqz = quat[2] * quat[2];
|
||||||
squ = quat[3] * quat[3];
|
squ = quat[3] * quat[3];
|
||||||
rpy[0] = atan2(2 * (quat[1]*quat[2] + quat[3]*quat[0]), squ - sqx - sqy + sqz);
|
rpy[0] = atan2(2 * (quat[1]*quat[2] + quat[3]*quat[0]), squ - sqx - sqy + sqz);
|
||||||
double sarg = -2 * (quat[0]*quat[2] - quat[3] * quat[1]);
|
sarg = -2 * (quat[0]*quat[2] - quat[3] * quat[1]);
|
||||||
rpy[1] = sarg <= -1.0 ? -0.5*3.141592538 : (sarg >= 1.0 ? 0.5*3.141592538 : asin(sarg));
|
rpy[1] = sarg <= -1.0 ? -0.5*3.141592538 : (sarg >= 1.0 ? 0.5*3.141592538 : asin(sarg));
|
||||||
rpy[2] = atan2(2 * (quat[0]*quat[1] + quat[3]*quat[2]), squ + sqx - sqy - sqz);
|
rpy[2] = atan2(2 * (quat[0]*quat[1] + quat[3]*quat[2]), squ + sqx - sqy - sqz);
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -389,16 +389,8 @@ void bDNA::init(char *data, int len, bool swap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
cp = b3AlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
//long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TYPE (4 bytes)
|
TYPE (4 bytes)
|
||||||
@@ -425,16 +417,8 @@ void bDNA::init(char *data, int len, bool swap)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
nr= (long)cp;
|
|
||||||
// long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
cp = b3AlignPointer(cp,4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TLEN (4 bytes)
|
TLEN (4 bytes)
|
||||||
|
|||||||
@@ -428,16 +428,7 @@ void bFile::swapDNA(char* ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
cp = b3AlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
//long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TYPE (4 bytes)
|
TYPE (4 bytes)
|
||||||
@@ -465,16 +456,7 @@ void bFile::swapDNA(char* ptr)
|
|||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
cp = b3AlignPointer(cp,4);
|
||||||
nr= (long)cp;
|
|
||||||
// long mask=3;
|
|
||||||
nr= ((nr+3)&~3)-nr;
|
|
||||||
while (nr--)
|
|
||||||
{
|
|
||||||
cp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TLEN (4 bytes)
|
TLEN (4 bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user