MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / stepSimulation

Method stepSimulation

examples/SharedMemory/PhysicsClientExample.cpp:790–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790void PhysicsClientExample::stepSimulation(float deltaTime)
791{
792 if (m_options == eCLIENTEXAMPLE_SERVER)
793 {
794 for (int i = 0; i < 100; i++)
795 {
796 m_physicsServer.processClientCommands();
797 }
798 }
799
800 if (m_prevSelectedBody != m_selectedBody)
801 {
802 createButtons();
803 m_prevSelectedBody = m_selectedBody;
804 }
805
806 //while (!b3CanSubmitCommand(m_physicsClientHandle))
807 {
808 b3SharedMemoryStatusHandle status = b3ProcessServerStatus(m_physicsClientHandle);
809 bool hasStatus = (status != 0);
810 if (hasStatus)
811 {
812 int statusType = b3GetStatusType(status);
813 if (statusType == CMD_ACTUAL_STATE_UPDATE_COMPLETED)
814 {
815 //b3Printf("bla\n");
816 }
817 if (statusType == CMD_CAMERA_IMAGE_COMPLETED)
818 {
819 // static int counter=0;
820 // char msg[1024];
821 // sprintf(msg,"Camera image %d OK\n",counter++);
822 b3CameraImageData imageData;
823 b3GetCameraImageData(m_physicsClientHandle, &imageData);
824 if (m_canvas)
825 {
826 //compute depth image range
827 float minDepthValue = 1e20f;
828 float maxDepthValue = -1e20f;
829
830 for (int i = 0; i < camVisualizerWidth; i++)
831 {
832 for (int j = 0; j < camVisualizerHeight; j++)
833 {
834 int xIndex = int(float(i) * (float(imageData.m_pixelWidth) / float(camVisualizerWidth)));
835 int yIndex = int(float(j) * (float(imageData.m_pixelHeight) / float(camVisualizerHeight)));
836 btClamp(xIndex, 0, imageData.m_pixelWidth);
837 btClamp(yIndex, 0, imageData.m_pixelHeight);
838
839 if (m_canvasDepthIndex >= 0)
840 {
841 int depthPixelIndex = (xIndex + yIndex * imageData.m_pixelWidth);
842 float depthValue = imageData.m_depthValues[depthPixelIndex];
843 //todo: rescale the depthValue to [0..255]
844 if (depthValue > -1e20)
845 {
846 maxDepthValue = btMax(maxDepthValue, depthValue);
847 minDepthValue = btMin(minDepthValue, depthValue);

Callers

nothing calls this directly

Calls 15

b3GetStatusTypeFunction · 0.85
b3GetCameraImageDataFunction · 0.85
btClampFunction · 0.85
btFabsFunction · 0.85
btVector4Class · 0.85
b3GetStatusBodyIndicesFunction · 0.85
b3GetNumJointsFunction · 0.85
b3GetStatusBodyIndexFunction · 0.85
b3GetJointInfoFunction · 0.85

Tested by

no test coverage detected