pybullet: allow to replace existing text, to avoid flickering (remove/add)
allow texture caching (disable using the disable file caching)
This commit is contained in:
@@ -13,13 +13,14 @@
|
||||
#include "../Utils/b3Clock.h"
|
||||
#include "../MultiThreading/b3ThreadSupportInterface.h"
|
||||
#include "SharedMemoryPublic.h"
|
||||
//#define BT_ENABLE_VR
|
||||
#ifdef BT_ENABLE_VR
|
||||
#include "../RenderingExamples/TinyVRGui.h"
|
||||
#endif//BT_ENABLE_VR
|
||||
|
||||
|
||||
#include "../CommonInterfaces/CommonParameterInterface.h"
|
||||
|
||||
#include "../Importers/ImportURDFDemo/urdfStringSplit.h"
|
||||
|
||||
//@todo(erwincoumans) those globals are hacks for a VR demo, move this to Python/pybullet!
|
||||
bool gEnablePicking=true;
|
||||
@@ -36,9 +37,7 @@ static bool gEnableDefaultKeyboardShortcuts = true;
|
||||
static bool gEnableDefaultMousePicking = true;
|
||||
|
||||
|
||||
//extern btVector3 gLastPickPos;
|
||||
btVector3 gVRTeleportPosLocal(0,0,0);
|
||||
btQuaternion gVRTeleportOrnLocal(0,0,0,1);
|
||||
|
||||
|
||||
|
||||
btScalar gVRTeleportRotZ = 0;
|
||||
@@ -1132,10 +1131,17 @@ public:
|
||||
|
||||
UserDebugText m_tmpText;
|
||||
int m_resultUserDebugTextUid;
|
||||
virtual int addUserDebugText3D( const char* txt, const double positionXYZ[3], const double orientation[4], const double textColorRGB[3], double size, double lifeTime, int trackingVisualShapeIndex, int optionFlags)
|
||||
|
||||
virtual int addUserDebugText3D( const char* txt, const double positionXYZ[3], const double orientation[4], const double textColorRGB[3], double size, double lifeTime, int trackingVisualShapeIndex, int optionFlags, int replaceItemUid)
|
||||
{
|
||||
|
||||
m_tmpText.m_itemUniqueId = m_uidGenerator++;
|
||||
if (replaceItemUid>=0)
|
||||
{
|
||||
m_tmpText.m_itemUniqueId = replaceItemUid;
|
||||
} else
|
||||
{
|
||||
m_tmpText.m_itemUniqueId = m_uidGenerator++;
|
||||
}
|
||||
m_tmpText.m_lifeTime = lifeTime;
|
||||
m_tmpText.textSize = size;
|
||||
//int len = strlen(txt);
|
||||
@@ -2171,10 +2177,26 @@ void PhysicsServerExample::updateGraphics()
|
||||
case eGUIUserDebugAddText:
|
||||
{
|
||||
B3_PROFILE("eGUIUserDebugAddText");
|
||||
|
||||
bool replaced = false;
|
||||
|
||||
m_multiThreadedHelper->m_userDebugText.push_back(m_multiThreadedHelper->m_tmpText);
|
||||
m_multiThreadedHelper->m_resultUserDebugTextUid = m_multiThreadedHelper->m_userDebugText[m_multiThreadedHelper->m_userDebugText.size()-1].m_itemUniqueId;
|
||||
for (int i=0;i<m_multiThreadedHelper->m_userDebugText.size();i++)
|
||||
{
|
||||
if (m_multiThreadedHelper->m_userDebugText[i].m_itemUniqueId == m_multiThreadedHelper->m_tmpText.m_itemUniqueId)
|
||||
{
|
||||
m_multiThreadedHelper->m_userDebugText[i] = m_multiThreadedHelper->m_tmpText;
|
||||
m_multiThreadedHelper->m_resultUserDebugTextUid = m_multiThreadedHelper->m_tmpText.m_itemUniqueId;
|
||||
replaced = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!replaced)
|
||||
{
|
||||
m_multiThreadedHelper->m_userDebugText.push_back(m_multiThreadedHelper->m_tmpText);
|
||||
m_multiThreadedHelper->m_resultUserDebugTextUid = m_multiThreadedHelper->m_userDebugText[m_multiThreadedHelper->m_userDebugText.size()-1].m_itemUniqueId;
|
||||
}
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
|
||||
break;
|
||||
}
|
||||
case eGUIUserDebugAddParameter:
|
||||
@@ -2503,10 +2525,35 @@ void PhysicsServerExample::drawUserDebugLines()
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
btAlignedObjectArray<std::string> pieces;
|
||||
btAlignedObjectArray<std::string> separators;
|
||||
separators.push_back("\n");
|
||||
urdfStringSplit(pieces,m_multiThreadedHelper->m_userDebugText[i].m_text,separators);
|
||||
|
||||
double sz = m_multiThreadedHelper->m_userDebugText[i].textSize;
|
||||
|
||||
btTransform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(btVector3(pos[0],pos[1],pos[2]));
|
||||
tr.setRotation(btQuaternion(orientation[0],orientation[1],orientation[2],orientation[3]));
|
||||
|
||||
m_guiHelper->getAppInterface()->drawText3D(m_multiThreadedHelper->m_userDebugText[i].m_text,
|
||||
pos,orientation,colorRGBA,
|
||||
m_multiThreadedHelper->m_userDebugText[i].textSize,optionFlag);
|
||||
//float newpos[3]={pos[0]-float(t)*sz,pos[1],pos[2]};
|
||||
|
||||
for (int t=0;t<pieces.size();t++)
|
||||
{
|
||||
btTransform offset;
|
||||
offset.setIdentity();
|
||||
offset.setOrigin(btVector3(0,-float(t)*sz,0));
|
||||
btTransform result = tr*offset;
|
||||
float newpos[3] = {result.getOrigin()[0],result.getOrigin()[1],result.getOrigin()[2]};
|
||||
|
||||
m_guiHelper->getAppInterface()->drawText3D(pieces[t].c_str(),
|
||||
newpos,orientation,colorRGBA,
|
||||
sz,optionFlag);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*m_guiHelper->getAppInterface()->drawText3D(m_multiThreadedHelper->m_userDebugText[i].m_text,
|
||||
|
||||
Reference in New Issue
Block a user