From 58699258dd1458771da9e2b9ad88d22c1c0b1cb9 Mon Sep 17 00:00:00 2001 From: Tigran Gasparian Date: Tue, 11 Sep 2018 14:44:06 +0200 Subject: [PATCH] Change b3GetLinkState to use numLinks in status handle Changes the b3GetLinkState function to use numLinks from the SharedMemoryStatus returned from RequestActualState instead of the cached number of link value returned by b3GetNumJoints. The cached value can be outdated when a new body is added and SyncBodyInfo isn't used, while using the value in the status is always up-to-date. --- examples/SharedMemory/PhysicsClientC_API.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp index 8f2f12449..8d43b9714 100644 --- a/examples/SharedMemory/PhysicsClientC_API.cpp +++ b/examples/SharedMemory/PhysicsClientC_API.cpp @@ -1008,10 +1008,10 @@ B3_SHARED_API int b3GetLinkState(b3PhysicsClientHandle physClient, b3SharedMemor int bodyIndex = status->m_sendActualStateArgs.m_bodyUniqueId; b3Assert(bodyIndex>=0); b3Assert(linkIndex >= 0); - int numJoints = b3GetNumJoints(physClient,bodyIndex); - b3Assert(linkIndex < numJoints); + int numLinks = status->m_sendActualStateArgs.m_numLinks; + b3Assert(linkIndex < numLinks); - if ((bodyIndex>=0) && (linkIndex >= 0) && linkIndex < numJoints) + if ((bodyIndex>=0) && (linkIndex >= 0) && linkIndex < numLinks) { b3Transform wlf,com,inertial;