Added pmxRigidBody command - #8
Merged
Merged
Conversation
…nchors) Native C++ pmxRigidBody command — the single body-modification path for pmxPhysicsNode. Create mode only, SIMULATION IS DISABLED: writes the full body DATA (PMX shape_size verbatim into bodyShapeSize, group/mask, physics mode via the core Simulation::PhysicsMode enum) and binds FOLLOW_BONE bodies to their related joint through the kinematic-anchor input. Dynamic bodies are data-only (no write-back, no stepping) — edit/query/remove and the rigid-body-constraint command are later PRs. Adapted from the PR #3 draft to the merged node schema: - bodyShapeSize (single float3) instead of bodyRadius/bodyExtents/bodyLength - core Simulation::PhysicsMode (no node-side enum) - single groupInverseWorldMatrix instead of per-anchor anchorParentInverseMatrix Registration in MayaMMD.cpp + CMake source list + integration tests wired into the 'cmd' suite (11 new tests).
Design cleanup of the pmxRigidBody command (per review): - Rename rigid_body_cmd.h -> rigid_body_cmd.hpp and make it a PURE interface: all private static helpers (resolveSolver, doCreate, matrixFromTR, worldMatrix, connectOrReplace, jointPmxBoneIndex, resolveBone) moved into the .cpp's anonymous namespace. The header now exposes only kName/creator/syntaxCreator/doIt/isUndoable. - Add shared plug utilities to maya_utils.hpp (setPlugMatrixValue, setPlugDouble3, connectOrReplace) so the constraint command reuses them in the next PR instead of duplicating. - const/constexpr pass: use physics_math deg2rad/rad2deg (constexpr), constexpr clamp01, const locals, 3-arg findPlug (non-deprecated). - Bring back rigid-body population in rigid_body_builder.py: every PMX rigid body is now added to the node via pmxRigidBody at import (data + kinematic anchors for FOLLOW_BONE). Simulation still disabled (no joints/write-back/time). Dict lookups keyed by enum VALUE so a duplicate enum class (mayapy double-load of mmd.core) cannot break the mapping. - Import test now asserts bodies mirror the PMX rigid bodies (count + first body data). - Expand cmd integration tests: write-back K offset baked, wiring-field defaults, per-collider shape_size verbatim, MMD->Maya rest-pose conversion, kinematic anchor ordering with multiple bodies. Verified: node/cmd/import suites pass, C++ unit tests 31/31, clang-tidy clean, ruff/clang-format clean.
…plugin reload mmd.maya.pmx.rigid_body_builder was missing from plugin.py's _MMD_MODULES reload list. In a live Maya session the module stays cached in sys.modules with the OLD (empty-node) create_physics_from_pmx_data, so recompiling the .mll and reloading the plugin kept importing the stale builder and bodies never appeared on the node. Add it to the list, BEFORE pmx_scene_builder (which imports create_physics_from_pmx_data from it) so the fresh module is picked up when pmx_scene_builder is reloaded.
- connectOrReplace now returns early when dst is already driven by the SAME source, instead of queuing a duplicate connect that fails. This makes the repeated groupInverseWorldMatrix re-connect (one per kinematic body create) a real no-op instead of a swallowed kFailure. - Add cmd integration tests: numeric -bone <pmxBoneIdx> resolution, query/edit rejection, invalid-target rejection, missing-solver-argument rejection.
- rigid_body_cmd.cpp: anchor offsets (joint-anchored AND static-collider) now build the world matrix directly from world-space T/R via matrixFromTR(worldT, worldR) instead of the group-space round-trip matrixFromTR(localT, localR) * groupWorld, which dropped scale from the offset (the exact bug the K-offset write-back comment documents). - rigid_body_cmd.cpp: clamp -group to the PMX 0..15 range with plain ifs (replaces a nested ternary that tripped clang-tidy). - rigid_body_cmd.hpp: document -group range in the header. - test_pmx_rigid_body_cmd_integration.py: add test_group_clamped (-group=-5 -> 0, -group=99 -> 15); format.
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Native C++
pmxRigidBodycommand — the single body-modification path forpmxPhysicsNode. Create mode only, SIMULATION IS DISABLED: writes the full body DATA and binds FOLLOW_BONE bodies to their related joint via the kinematic-anchor input. Dynamic bodies are data-only (no write-back, no stepping) — edit/query/remove and the rigid-body-constraint command are later PRs.Changes
mmd/maya/cmds/rigid_body_cmd.h/.cpp— new native command (create mode only):-index,-name,-nameUniversal,-bone,-shape,-size,-position,-rotation,-mass,-linearDamping,-angularDamping,-friction,-restitution,-group,-mask,-physicsModeshape_sizeverbatim intobodyShapeSize, group/mask bools, physics mode via the coreSimulation::PhysicsModeenum)anchorWorldMatrix+ singlegroupInverseWorldMatrix+ bakedanchorOffset; no-bone bodies become pinned static collidersbodyWriteBackOffset(K) for every body (identity when no joint)mmd/MayaMMD.cpp— registerspmxRigidBody(+ deregisters on unload)CMakeLists.txt— addsrigid_body_cmd.cppto the plugin targettests/integration/maya/cmds/test_pmx_rigid_body_cmd_integration.py— 11 new integration tests (no PMX model needed), wired into thecmdsuitetests/integration/maya/run_all_integration_tests.py—cmdsuite now runs both native command test modules