mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-10-04 07:55:24 +00:00
add pybullet.unsupportedChangeScaling feature for some small experiments, this is not general and has many limitations that are not likely are going to be resolved,
so unless it does what you want, ignore this api, it is unsupported!
This commit is contained in:
@@ -488,6 +488,18 @@ void TCPThreadFunc(void* userPtr, void* lsMemory)
|
||||
printf("GFX_CMD_CHANGE_RGBA_COLOR\n");
|
||||
break;
|
||||
}
|
||||
case GFX_CMD_CHANGE_SCALING:
|
||||
{
|
||||
args->submitCommand();
|
||||
while (args->isCommandOutstanding())
|
||||
{
|
||||
clock.usleep(0);
|
||||
}
|
||||
if (gVerboseNetworkMessagesServer)
|
||||
printf("GFX_CMD_CHANGE_SCALING\n");
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_CMD_GET_CAMERA_INFO:
|
||||
{
|
||||
args->submitCommand();
|
||||
@@ -833,6 +845,14 @@ public:
|
||||
m_args.processCommand();
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_CMD_CHANGE_SCALING:
|
||||
{
|
||||
m_guiHelper->changeScaling(clientCmd.m_changeScalingCommand.m_graphicsUid, clientCmd.m_changeScalingCommand.m_scaling);
|
||||
m_args.processCommand();
|
||||
break;
|
||||
}
|
||||
|
||||
case GFX_CMD_GET_CAMERA_INFO:
|
||||
{
|
||||
serverStatusOut.m_type = GFX_CMD_GET_CAMERA_INFO_FAILED;
|
||||
|
||||
@@ -112,6 +112,14 @@ struct GraphicsChangeRGBAColorCommand
|
||||
double m_rgbaColor[4];
|
||||
};
|
||||
|
||||
struct GraphicsChangeScalingCommand
|
||||
{
|
||||
int m_graphicsUid;
|
||||
double m_scaling[3];
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct GraphicsGetCameraInfoStatus
|
||||
{
|
||||
int width;
|
||||
@@ -150,6 +158,7 @@ struct GraphicsSharedMemoryCommand
|
||||
struct GraphicsSyncTransformsCommand m_syncTransformsCommand;
|
||||
struct GraphicsRemoveInstanceCommand m_removeGraphicsInstanceCommand;
|
||||
struct GraphicsChangeRGBAColorCommand m_changeRGBAColorCommand;
|
||||
struct GraphicsChangeScalingCommand m_changeScalingCommand;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ enum EnumGraphicsSharedMemoryClientCommand
|
||||
GFX_CMD_REMOVE_SINGLE_GRAPHICS_INSTANCE,
|
||||
GFX_CMD_CHANGE_RGBA_COLOR,
|
||||
GFX_CMD_GET_CAMERA_INFO,
|
||||
GFX_CMD_CHANGE_SCALING,
|
||||
//don't go beyond this command!
|
||||
GFX_CMD_MAX_CLIENT_COMMANDS,
|
||||
};
|
||||
|
||||
@@ -2240,6 +2240,22 @@ B3_SHARED_API int b3CreatePoseCommandSetBasePosition(b3SharedMemoryCommandHandle
|
||||
return 0;
|
||||
}
|
||||
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseScaling(b3SharedMemoryCommandHandle commandHandle, double scaling[3])
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||
b3Assert(command);
|
||||
b3Assert(command->m_type == CMD_INIT_POSE);
|
||||
command->m_updateFlags |= INIT_POSE_HAS_SCALING;
|
||||
|
||||
command->m_initPoseArgs.m_scaling[0] = scaling[0];
|
||||
command->m_initPoseArgs.m_scaling[1] = scaling[1];
|
||||
command->m_initPoseArgs.m_scaling[2] = scaling[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX, double startOrnY, double startOrnZ, double startOrnW)
|
||||
{
|
||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||
|
||||
@@ -574,6 +574,8 @@ extern "C"
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX, double startOrnY, double startOrnZ, double startOrnW);
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseLinearVelocity(b3SharedMemoryCommandHandle commandHandle, const double linVel[/*3*/]);
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseAngularVelocity(b3SharedMemoryCommandHandle commandHandle, const double angVel[/*3*/]);
|
||||
B3_SHARED_API int b3CreatePoseCommandSetBaseScaling(b3SharedMemoryCommandHandle commandHandle, double scaling[/* 3*/]);
|
||||
|
||||
|
||||
B3_SHARED_API int b3CreatePoseCommandSetJointPositions(b3SharedMemoryCommandHandle commandHandle, int numJointPositions, const double* jointPositions);
|
||||
B3_SHARED_API int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition);
|
||||
|
||||
@@ -10032,6 +10032,20 @@ bool PhysicsServerCommandProcessor::processInitPoseCommand(const struct SharedMe
|
||||
{
|
||||
btMultiBody* mb = body->m_multiBody;
|
||||
|
||||
if (clientCmd.m_updateFlags & INIT_POSE_HAS_SCALING)
|
||||
{
|
||||
btVector3 scaling(clientCmd.m_initPoseArgs.m_scaling[0], clientCmd.m_initPoseArgs.m_scaling[1], clientCmd.m_initPoseArgs.m_scaling[2]);
|
||||
|
||||
mb->getBaseCollider()->getCollisionShape()->setLocalScaling(scaling);
|
||||
//refresh broadphase
|
||||
m_data->m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(
|
||||
mb->getBaseCollider()->getBroadphaseHandle(),
|
||||
m_data->m_dynamicsWorld->getDispatcher());
|
||||
//also visuals
|
||||
int graphicsIndex = mb->getBaseCollider()->getUserIndex();
|
||||
m_data->m_guiHelper->changeScaling(graphicsIndex, clientCmd.m_initPoseArgs.m_scaling);
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & INIT_POSE_HAS_BASE_LINEAR_VELOCITY)
|
||||
{
|
||||
mb->setBaseVel(baseLinVel);
|
||||
|
||||
@@ -128,6 +128,7 @@ enum MultiThreadedGUIHelperCommunicationEnums
|
||||
eGUIHelperRemoveTexture,
|
||||
eGUIHelperSetVisualizerFlagCheckRenderedFrame,
|
||||
eGUIHelperUpdateShape,
|
||||
eGUIHelperChangeGraphicsInstanceScaling,
|
||||
eGUIUserDebugRemoveAllParameters,
|
||||
};
|
||||
|
||||
@@ -1035,6 +1036,19 @@ public:
|
||||
workerThreadWait();
|
||||
}
|
||||
|
||||
int m_graphicsInstanceChangeScaling;
|
||||
double m_baseScaling[3];
|
||||
virtual void changeScaling(int instanceUid, const double scaling[3])
|
||||
{
|
||||
m_graphicsInstanceChangeScaling = instanceUid;
|
||||
m_baseScaling[0] = scaling[0];
|
||||
m_baseScaling[1] = scaling[1];
|
||||
m_baseScaling[2] = scaling[2];
|
||||
m_cs->lock();
|
||||
m_cs->setSharedParam(1, eGUIHelperChangeGraphicsInstanceScaling);
|
||||
workerThreadWait();
|
||||
}
|
||||
|
||||
double m_specularColor[3];
|
||||
int m_graphicsInstanceChangeSpecular;
|
||||
virtual void changeSpecularColor(int instanceUid, const double specularColor[3])
|
||||
@@ -2181,6 +2195,16 @@ void PhysicsServerExample::updateGraphics()
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
break;
|
||||
}
|
||||
|
||||
case eGUIHelperChangeGraphicsInstanceScaling:
|
||||
{
|
||||
B3_PROFILE("eGUIHelperChangeGraphicsInstanceScaling");
|
||||
|
||||
m_multiThreadedHelper->m_childGuiHelper->changeScaling(m_multiThreadedHelper->m_graphicsInstanceChangeScaling, m_multiThreadedHelper->m_baseScaling);
|
||||
m_multiThreadedHelper->mainThreadRelease();
|
||||
break;
|
||||
}
|
||||
|
||||
case eGUIHelperChangeGraphicsInstanceSpecularColor:
|
||||
{
|
||||
B3_PROFILE("eGUIHelperChangeGraphicsInstanceSpecularColor");
|
||||
|
||||
@@ -529,6 +529,11 @@ void RemoteGUIHelper::removeGraphicsInstance(int graphicsUid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteGUIHelper::changeScaling(int instanceUid, const double scaling[3])
|
||||
{
|
||||
|
||||
}
|
||||
void RemoteGUIHelper::changeRGBAColor(int instanceUid, const double rgbaColor[4])
|
||||
{
|
||||
GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
|
||||
|
||||
@@ -38,6 +38,7 @@ struct RemoteGUIHelper : public GUIHelperInterface
|
||||
virtual void removeAllGraphicsInstances();
|
||||
virtual void removeGraphicsInstance(int graphicsUid);
|
||||
virtual void changeRGBAColor(int instanceUid, const double rgbaColor[4]);
|
||||
virtual void changeScaling(int instanceUid, const double scaling[3]);
|
||||
|
||||
virtual Common2dCanvasInterface* get2dCanvasInterface();
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ enum EnumInitPoseFlags
|
||||
INIT_POSE_HAS_BASE_LINEAR_VELOCITY = 8,
|
||||
INIT_POSE_HAS_BASE_ANGULAR_VELOCITY = 16,
|
||||
INIT_POSE_HAS_JOINT_VELOCITY = 32,
|
||||
INIT_POSE_HAS_SCALING=64,
|
||||
};
|
||||
|
||||
///InitPoseArgs is mainly to initialize (teleport) the robot in a particular position
|
||||
@@ -228,6 +229,7 @@ struct InitPoseArgs
|
||||
double m_initialStateQ[MAX_DEGREE_OF_FREEDOM];
|
||||
int m_hasInitialStateQdot[MAX_DEGREE_OF_FREEDOM];
|
||||
double m_initialStateQdot[MAX_DEGREE_OF_FREEDOM];
|
||||
double m_scaling[3];
|
||||
};
|
||||
|
||||
struct RequestDebugLinesArgs
|
||||
|
||||
Reference in New Issue
Block a user