From 91511364d0091a40f7deeef9b275cda805cd32d8 Mon Sep 17 00:00:00 2001 From: fffffq00 Date: Mon, 15 Jun 2026 23:11:08 +0800 Subject: [PATCH] add explicit feedback for illegal operations in GPU mode (warn on get, throw on set) instead of silent ignore. --- src/physx/articulation.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/physx/articulation.cpp b/src/physx/articulation.cpp index b95c8108..3ee1267d 100644 --- a/src/physx/articulation.cpp +++ b/src/physx/articulation.cpp @@ -359,41 +359,41 @@ PhysxArticulation::getLinkIncomingJointForces() { } Pose PhysxArticulation::getRootPose() { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("getting root pose is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + logger::warn("getting root pose may yields unsynchronized CPU data in GPU simulation."); + } return PxTransformToPose(mPxArticulation->getRootGlobalPose()); } Vec3 PhysxArticulation::getRootLinearVelocity() { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("getting root velocity is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + logger::warn("getting root linear velocity may yield unsynchronized CPU data in GPU simulation."); + } return PxVec3ToVec3(mPxArticulation->getRootLinearVelocity()); } Vec3 PhysxArticulation::getRootAngularVelocity() { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("getting root velocity is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + logger::warn("getting root angular velocity may yield unsynchronized CPU data in GPU simulation."); + } return PxVec3ToVec3(mPxArticulation->getRootAngularVelocity()); } void PhysxArticulation::setRootPose(Pose const &pose) { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("setting root pose is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + throw std::runtime_error("setting root pose is illegal in GPU simulation."); + } mPxArticulation->setRootGlobalPose(PoseToPxTransform(pose)); syncPose(); } void PhysxArticulation::setRootLinearVelocity(Vec3 const &v) { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("setting root velocity is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + throw std::runtime_error("setting root linear velocity is illegal in GPU simulation."); + } mPxArticulation->setRootLinearVelocity(Vec3ToPxVec3(v)); } void PhysxArticulation::setRootAngularVelocity(Vec3 const &v) { - // if (getRoot()->isUsingDirectGPUAPI()) { - // throw std::runtime_error("setting root angular is not supported in GPU simulation."); - // } + if (getRoot()->isUsingDirectGPUAPI()) { + throw std::runtime_error("setting root angular velocity is illegal in GPU simulation."); + } mPxArticulation->setRootAngularVelocity(Vec3ToPxVec3(v)); }