Merge pull request #706 from erwincoumans/master
Improve OpenVR support, fix some multi-threading issue (disable CProfileManager singleton), fix/remove old API
This commit is contained in:
@@ -265,8 +265,9 @@ public:
|
||||
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
#ifndef BT_NO_PROFILE
|
||||
CProfileManager::Reset();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -314,7 +315,9 @@ public:
|
||||
|
||||
|
||||
m_app->m_renderer->writeTransforms();
|
||||
#ifndef BT_NO_PROFILE
|
||||
CProfileManager::Increment_Frame_Counter();
|
||||
#endif
|
||||
}
|
||||
virtual void renderScene()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
|
||||
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
|
||||
|
||||
class MyProfileWindow : public Gwen::Controls::WindowControl
|
||||
@@ -42,8 +42,9 @@ protected:
|
||||
}
|
||||
public:
|
||||
|
||||
|
||||
|
||||
CProfileIterator* profIter;
|
||||
|
||||
class MyMenuItems* m_menuItems;
|
||||
MyProfileWindow ( Gwen::Controls::Base* pParent)
|
||||
: Gwen::Controls::WindowControl( pParent ),
|
||||
@@ -304,3 +305,5 @@ void destroyProfileWindow(MyProfileWindow* window)
|
||||
CProfileManager::Release_Iterator(window->profIter);
|
||||
delete window;
|
||||
}
|
||||
|
||||
#endif //BT_NO_PROFILE
|
||||
@@ -556,7 +556,7 @@ void b3RobotSimAPI::setJointMotorControl(int bodyUniqueId, int jointIndex, const
|
||||
{
|
||||
case CONTROL_MODE_VELOCITY:
|
||||
{
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit( m_data->m_physicsClient, CONTROL_MODE_VELOCITY);
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit2( m_data->m_physicsClient, bodyUniqueId, CONTROL_MODE_VELOCITY);
|
||||
b3JointInfo jointInfo;
|
||||
b3GetJointInfo(m_data->m_physicsClient, bodyUniqueId, jointIndex, &jointInfo);
|
||||
int uIndex = jointInfo.m_uIndex;
|
||||
@@ -567,7 +567,7 @@ void b3RobotSimAPI::setJointMotorControl(int bodyUniqueId, int jointIndex, const
|
||||
}
|
||||
case CONTROL_MODE_POSITION_VELOCITY_PD:
|
||||
{
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit( m_data->m_physicsClient, CONTROL_MODE_POSITION_VELOCITY_PD);
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit2( m_data->m_physicsClient, bodyUniqueId, CONTROL_MODE_POSITION_VELOCITY_PD);
|
||||
b3JointInfo jointInfo;
|
||||
b3GetJointInfo(m_data->m_physicsClient, bodyUniqueId, jointIndex, &jointInfo);
|
||||
int uIndex = jointInfo.m_uIndex;
|
||||
@@ -583,7 +583,7 @@ void b3RobotSimAPI::setJointMotorControl(int bodyUniqueId, int jointIndex, const
|
||||
}
|
||||
case CONTROL_MODE_TORQUE:
|
||||
{
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit( m_data->m_physicsClient, CONTROL_MODE_TORQUE);
|
||||
b3SharedMemoryCommandHandle command = b3JointControlCommandInit2( m_data->m_physicsClient, bodyUniqueId, CONTROL_MODE_TORQUE);
|
||||
b3JointInfo jointInfo;
|
||||
b3GetJointInfo(m_data->m_physicsClient, bodyUniqueId, jointIndex, &jointInfo);
|
||||
int uIndex = jointInfo.m_uIndex;
|
||||
|
||||
@@ -140,11 +140,11 @@ void MotionThreadFunc(void* userPtr,void* lsMemory)
|
||||
|
||||
btVector3 from = args->m_pos;
|
||||
btMatrix3x3 mat(args->m_orn);
|
||||
|
||||
btScalar pickDistance = 100.;
|
||||
btVector3 toX = args->m_pos+mat.getColumn(0);
|
||||
btVector3 toY = args->m_pos+mat.getColumn(1);
|
||||
btVector3 toZ = args->m_pos+mat.getColumn(2)*50.;
|
||||
|
||||
btVector3 toZ = args->m_pos+mat.getColumn(2)*pickDistance;
|
||||
|
||||
|
||||
if (args->m_isPicking)
|
||||
{
|
||||
|
||||
@@ -30,11 +30,14 @@ int gSharedMemoryKey = -1;
|
||||
#include "pathtools.h"
|
||||
|
||||
CommonExampleInterface* sExample;
|
||||
int sIsPressed=-1;
|
||||
|
||||
int sPrevPacketNum=0;
|
||||
GUIHelperInterface* sGuiPtr = 0;
|
||||
|
||||
|
||||
static vr::VRControllerState_t sPrevStates[vr::k_unMaxTrackedDeviceCount] = { 0 };
|
||||
|
||||
|
||||
#if defined(POSIX)
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
@@ -663,63 +666,57 @@ bool CMainApplication::HandleInput()
|
||||
vr::VRControllerState_t state;
|
||||
if( m_pHMD->GetControllerState( unDevice, &state ) )
|
||||
{
|
||||
uint64_t trigger = vr::ButtonMaskFromId(vr::k_EButton_SteamVR_Trigger);
|
||||
|
||||
if (sPrevPacketNum != state.unPacketNum)
|
||||
//we need to have the 'move' events, so no early out here
|
||||
//if (sPrevStates[unDevice].unPacketNum != state.unPacketNum)
|
||||
{
|
||||
|
||||
static int counter=0;
|
||||
sPrevPacketNum = state.unPacketNum;
|
||||
//b3Printf(".");
|
||||
bool isTrigger = (state.ulButtonPressed&trigger)!=0;
|
||||
if (isTrigger)
|
||||
sPrevStates[unDevice].unPacketNum = state.unPacketNum;
|
||||
|
||||
for (int button = 0; button < vr::k_EButton_Max; button++)
|
||||
{
|
||||
//printf("unDevice=%d\n",unDevice);
|
||||
b3Transform tr;
|
||||
getControllerTransform(unDevice,tr);
|
||||
float pos[3] = {tr.getOrigin()[0],tr.getOrigin()[1],tr.getOrigin()[2]};
|
||||
b3Quaternion born = tr.getRotation();
|
||||
float orn[4] = {born[0],born[1],born[2],born[3]};
|
||||
|
||||
uint64_t trigger = vr::ButtonMaskFromId((vr::EVRButtonId)button);
|
||||
|
||||
if (sIsPressed!=unDevice)
|
||||
bool isTrigger = (state.ulButtonPressed&trigger) != 0;
|
||||
if (isTrigger)
|
||||
{
|
||||
b3Printf("trigger pressed %d, %d\n",counter++, unDevice);
|
||||
sIsPressed=unDevice;
|
||||
|
||||
sExample->vrControllerButtonCallback(unDevice,1,1,pos, orn);
|
||||
|
||||
//
|
||||
//virtual void vrControllerMoveCallback(int controllerId, float pos[4], float orientation[4]) {}
|
||||
//virtual void vrControllerButtonCallback(int controllerId, int button, int state, float pos[4], float orientation[4]){}
|
||||
|
||||
//sExample->start
|
||||
} else
|
||||
{
|
||||
sExample->vrControllerMoveCallback(unDevice,pos,orn);
|
||||
}
|
||||
//sExample->exitPhysics();
|
||||
//m_app->m_instancingRenderer->removeAllInstances();
|
||||
///sExample->initPhysics();
|
||||
} else
|
||||
{
|
||||
if (unDevice==sIsPressed)
|
||||
{
|
||||
b3Transform tr;
|
||||
getControllerTransform(unDevice,tr);
|
||||
float pos[3] = {tr.getOrigin()[0],tr.getOrigin()[1],tr.getOrigin()[2]};
|
||||
getControllerTransform(unDevice, tr);
|
||||
float pos[3] = { tr.getOrigin()[0], tr.getOrigin()[1], tr.getOrigin()[2] };
|
||||
b3Quaternion born = tr.getRotation();
|
||||
float orn[4] = {born[0],born[1],born[2],born[3]};
|
||||
float orn[4] = { born[0], born[1], born[2], born[3] };
|
||||
|
||||
sIsPressed=-1;
|
||||
printf("device released: %d",unDevice);
|
||||
sExample->vrControllerButtonCallback(unDevice,1,0,pos, orn);
|
||||
//pressed now, not pressed before -> raise a button down event
|
||||
if ((sPrevStates[unDevice].ulButtonPressed&trigger)==0)
|
||||
{
|
||||
// printf("Device PRESSED: %d, button %d\n", unDevice, button);
|
||||
sExample->vrControllerButtonCallback(unDevice, button, 1, pos, orn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("Device MOVED: %d\n", unDevice);
|
||||
sExample->vrControllerMoveCallback(unDevice, pos, orn);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//not pressed now, but pressed before -> raise a button up event
|
||||
if ((sPrevStates[unDevice].ulButtonPressed&trigger) != 0)
|
||||
{
|
||||
b3Transform tr;
|
||||
getControllerTransform(unDevice, tr);
|
||||
float pos[3] = { tr.getOrigin()[0], tr.getOrigin()[1], tr.getOrigin()[2] };
|
||||
b3Quaternion born = tr.getRotation();
|
||||
float orn[4] = { born[0], born[1], born[2], born[3] };
|
||||
// printf("Device RELEASED: %d, button %d\n", unDevice,button);
|
||||
sExample->vrControllerButtonCallback(unDevice, button, 0, pos, orn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_rbShowTrackedDevice[ unDevice ] = state.ulButtonPressed == 0;
|
||||
}
|
||||
sPrevStates[unDevice] = state;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
||||
@@ -15,11 +15,8 @@
|
||||
|
||||
#include "btQuickprof.h"
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
|
||||
|
||||
static btClock gProfileClock;
|
||||
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#include <sys/sys_time.h>
|
||||
@@ -250,6 +247,10 @@ btScalar btClock::getTimeSeconds()
|
||||
return btScalar(getTimeMicroseconds()) * microseconds_to_seconds;
|
||||
}
|
||||
|
||||
#ifndef BT_NO_PROFILE
|
||||
|
||||
|
||||
static btClock gProfileClock;
|
||||
|
||||
|
||||
inline void Profile_Get_Ticks(unsigned long int * ticks)
|
||||
@@ -265,7 +266,6 @@ inline float Profile_Get_Tick_Rate(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileNode
|
||||
|
||||
@@ -15,18 +15,7 @@
|
||||
#ifndef BT_QUICK_PROF_H
|
||||
#define BT_QUICK_PROF_H
|
||||
|
||||
//To disable built-in profiling, please comment out next line
|
||||
//#define BT_NO_PROFILE 1
|
||||
#ifndef BT_NO_PROFILE
|
||||
#include <stdio.h>//@todo remove this, backwards compatibility
|
||||
#include "btScalar.h"
|
||||
#include "btAlignedAllocator.h"
|
||||
#include <new>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define USE_BT_CLOCK 1
|
||||
|
||||
#ifdef USE_BT_CLOCK
|
||||
@@ -64,6 +53,20 @@ private:
|
||||
#endif //USE_BT_CLOCK
|
||||
|
||||
|
||||
//To disable built-in profiling, please comment out next line
|
||||
#define BT_NO_PROFILE 1
|
||||
#ifndef BT_NO_PROFILE
|
||||
#include <stdio.h>//@todo remove this, backwards compatibility
|
||||
|
||||
#include "btAlignedAllocator.h"
|
||||
#include <new>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///A node in the Profile Hierarchy Tree
|
||||
|
||||
Reference in New Issue
Block a user