Skip to content
Altena-WorksPublic

About

An MMD-compatible animation and rendering environment

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Nexa

An MMD-compatible animation and rendering environment

Nexa is in early development. The current Rust workspace contains a numerical physics core and a C ABI for external verification. It does not yet provide an editor or rendering application.

nexa-win32 also contains native D3DX9 observation probes. The compiler probe has been verified against the earlier parser experiment. The effect-pool drawing probe builds, but its Rust image comparison is pending: the current remote session exposes no Direct3D9 adapters. Neither probe implements MME host scripts or establishes full effect compatibility.

The standalone Saba observers reproduce the earlier PMD/PMX reset, PMD/VPD pose, and box-scale experiments through a pinned native ABI. Rust owns their execution and complete bone/body/mesh/contact observations; Saba/Bullet remain native research dependencies.

The intended scope is a compact MMD-style editor, DirectX 9/MME compatibility, improved physics, additional model formats, and Blender camera import/sync.

Build and test

Requires Rust 1.95.0 and the MSVC build tools for Windows x64. The workspace has no external Rust dependencies.

cargo build --offline --locked
cargo test --offline --locked
cargo test --offline --locked --release

Native probes require the installed System32 DirectX 9/D3DX9 runtime and the separately maintained research fixtures. Output directories must not exist yet.

cargo run -p nexa-win32 --offline --locked -- compiler <fixture-directory> <new-output-directory>
cargo run -p nexa-win32 --offline --locked -- pool <magenta.fx> <new-output-directory>

The pool probe requires a HAL device with hardware vertex processing. It uses a hidden window and offscreen readback, without presenting a frame or taking input. Both commands save native results and owned-resource cleanup events as JSON. --fail-at N injects an expected error after checkpoint N for cleanup checks.

nexa-core produces an rlib and a cdylib. The default DLL exports solve_steps, solve_schedule, make_normal_row, make_friction_row, body_properties, joint_limits, joint_row, pair_add, d3dx_quaternion, d3dx_rotation, d3dx_multiply, ik_solve_phase, ik_solve_limited_phase, pmd_skin, ik_solve_improved_phase, ik_solve_improved_limited_phase, ik_solve_active_phase, ik_solve_clamp_phase, euler_pi, euler_saba_decompose, euler_saba_compose, euler_mmd_choose, euler_continuity_choose, ik_solve_continuity_phase, experiment_box_contact, integrate_world, synchronize_motion_states, motion_state_get, bone_writeback, and nexa_abi_layout; the optional verification feature adds test-only floating-point and panic probes.

Current scope

contact_frame::solve_mixed_constraints prepares ordinary Spring6DOF joints and contact rows from current body poses, velocities and carried caches, then runs one shared solver. Positive-row joints allocate bodies before contacts; zero-row joints resolve bodies when iteration begins. Velocity, joint state and cache writeback commit together. Manifold selection, world/island management and outer stepping remain separate. The existing contact-only entries retain their behavior.

The row solver accepts caller-supplied bodies, rows, order, and bounds. The scheduler generates joint, normal, and friction row order, updating friction bounds from the current normal impulse. Both check inputs before writing and preserve the original arithmetic order. Normal rows can be generated from rigid-body and contact inputs with unit factors, zero cached impulse, and split impulse disabled. Friction rows support the default direction selection, with unit factors, zero cached impulse, and anisotropy disabled. Box properties include mode-dependent mass, local and world inverse inertia, and damping settings. Joint limits and individual constraint rows use supplied relative coordinates, axes, and spring state. A preallocated 128-entry pair cache supports group/mask filtering, signed ID ordering, hash chains, and duplicate lookup. Capacity growth, callbacks, rendering, file import, and editor integration are pending.

Post-solver integration updates supplied body positions, rotations, interpolation velocities, and world inverse inertia. It retains the observed state/flag gates and float32 arithmetic order, with explicit sin/cos callbacks. A required convex CCD sweep returns -3; any returned error leaves caller body records unchanged. The normalized record layout does not validate a general rigid-body transform. Four build variants matched 491 original-binary emulation cases and 787 complete 212-byte body records, including trig call traces. Another 74 cases connected actual Rust scheduler output to Rust integration through the verification harness. Those cases still supply captured contact rows.

Motion-state synchronization predicts from interpolation state and remaining time, leaving current bodies unchanged. Its default setter and getter retain the original asymmetric offset multiplication order. Bone writeback separately reads current bodies: it applies the observed distance correction, writes all bone globals, then updates local transforms, grant fields, and mode 2 behavior. Negative-parent mode 2 requires an explicit diagnostic parent matrix; it never reads before the supplied bone array. Native helpers still provide matrix inverse and matrix-to-quaternion conversion. Returned errors preserve caller records as a Rust API guarantee, not a claim about original MMD error handling.

Four builds matched all record bits for 461 synchronization cases (including empty input) and 415 bone cases. The verification harness connected actual Rust integration, synchronization, bone writeback, and PMD skinning for 296 conditions with 12 constructed vertices each; 74 conditions also start with the Rust row solver. Negative skin indices are explicitly mapped to an added zero matrix for the existing valid-PMD API. These checks do not establish a complete model, native vertex buffer, collision world, animation frame, or rendering application.

contact_frame::step now owns a connected numerical path in Rust: raw contact geometry and physical body state produce normal/friction rows, solver deltas, velocity writeback, transform integration, motion synchronization, bone writeback, and PMD vertices in one call. It uses cold start, unit factors, one friction direction, and caller-selected eligible contacts. Four builds matched 36 original conditions, including generated rows and complete kernel traces, through twelve constructed vertices per condition. Recorded row coefficients are not inputs to this path. The tests map negative skin indices to an explicit zero-matrix fixture.

The safe API commits all State fields together; returned errors leave them unchanged. Trig and bone-helper side effects are outside that guarantee. Zero-mass bodies share a reserved solver slot and receive no velocity writeback; bodies absent from every contact are also untouched by the solver. At most 255 dynamic solver slots are available. Static-static contacts and zero-mass bodies with nonzero world inverse inertia are rejected. Forces, collision detection, world ownership of contact manifolds, joints, and a world timestep loop remain pending. Matrix inverse and matrix-to-quaternion helpers remain native; the test host compares float32 scalar traces through a Rust float64 adapter.

contact_frame::step_cached adds normal-impulse warmstart and optional two-direction friction. The caller keeps the cache in contact order; a successful step replaces its normal impulses together with the state, while returned errors preserve both. The two tangents are recomputed and processed in the original second-first order. Four builds matched initial seed deltas and the complete contact-to-vertex outputs for 144 original SSE/unit-factor conditions. Lateral impulse caching, cached directions, anisotropy, nonunit factors, and manifold identity management remain outside this entry point. This does not establish garment penetration improvement.

contact_frame::step_contact_cache also consumes and updates lateral impulses and friction directions. Cached directions run in first-second order, while recomputed directions retain second-first order. A successful call commits the entire cache with State. The original one-direction finish copies the next friction pool row into the second cache slot; the last contact requires an explicit finite spare-row impulse instead of an out-of-bounds read. Four builds matched 256 original conditions plus 32 controlled cache reuses through skinning. These repeat cases reset physical inputs and reuse the prior Rust cache; they do not establish a persistent manifold or world loop. Anisotropy, general body-type gates, nonunit factors, and garment penetration improvement remain unverified.

physics::contact_manifold manages four persistent contact slots: nearest-point matching, area-based replacement at capacity, cached-impulse preservation on a near replacement, swap removal, and transform-based refresh. It preserves all 176 bytes per point, including unused storage and the original stale-tail behavior. Refresh updates every point before reverse-order removal, and contact age wraps as a 32-bit integer. Returned errors preserve manifold storage.

The verifier compares complete four-slot storage for 880 original operations, including threshold ties, all replacement slots, age wrap, and unequal body transforms. Active slots map into the existing solver's contact and cache types in their current order. Original collision detection still supplies candidates; body bindings remain external.

Manifold::solve writes solver impulses and friction directions back into raw point storage and commits them together with body velocities. It preserves the original direction write widths, flag padding, unused lanes, and skipped points. A separate processing threshold filters contacts after resolving body slots; static-static pairs produce no rows. Forced plane-based friction directions are available through the binding. The verifier carries actual Rust point storage and velocities through repeated solves and contact refresh/replacement. Active callbacks and a complete collision world remain pending. These checks do not establish garment penetration improvement.

Quaternion products, quaternion-to-matrix conversion, and row-major matrix products preserve the observed D3DX float32 operation order without normalization. These functions reject nonfinite inputs/results. Baseline unlimited IK uses them for captured five/six-node chains, with native normalization and scalar callbacks. It preserves the original link/update order and early stop. Limited IK adds fixed axes, Euler constraints, first-half reflection, and phase selection for captured four-to-six-node chains. It uses explicit axis-rotation, matrix-to-quaternion, and scalar helpers. PMD two-bone skinning uses supplied bone matrices, preserves output UV/color bits, and leaves normals unnormalized. General skeletons, PMX skinning, full-frame integration, and garment improvements remain pending.

An experimental unlimited IK variant adds descendant matrix updates, per-link skips, zero-angle repair, and best full-pass pose restoration. It preserves the historical first-skip active-merge limitation and is not a production default. Its five/six-node chain contract does not establish general convergence or garment collision improvement. The constrained experimental variant combines these changes with fixed axes, Euler limits, and phase selection for four-to-six nodes. It retains the initial-skip limitation and recorded cases with worse goal error; it is also a research comparison, not a production default. The active-merge experiment exposes two policies: suppress the first skip for an unmerged nonidentity input (mode 0), or complete the input merge on the first processed step while retaining skips (mode 1). Both retain iteration-zero merges for repeated bone entries and expose per-direction merge decisions. A separate clamp-only control disables Euler-bound reflection while retaining the iteration count and plane selection. This policy was rejected because it also worsens recorded cases; it remains available for research comparison. Euler research helpers retain fixed Saba decomposition, GLM composition, and offline MMD chart choices, including known roundtrip and bounds counterexamples. Decomposition status 1 commits a nonfinite result; negative status preserves output storage. See third-party notices. The connected two-family continuity control keeps separate histories for each chain ordinal and resets them every phase. It remains a rejected research policy: the recorded corpus retains 132 unchanged inputs and two worse outcomes.

The BoxBox experiment translates the fixed Bullet/ODE detector into Rust with four modes: Bullet conventions (0), raw face points (1), raw face points without cross-axis epsilon (2), and projected face points without that epsilon (3). It returns at most four ordered contacts. It is not connected to the world solver and does not establish garment penetration improvement. Finite degenerate input is accepted for comparison but does not carry a valid-geometry guarantee.

The Rust collide_mmd entry retains the original raw-face convention and cross-axis reciprocal multiplication order. Its ordered detector outputs are checked directly against original MMD execution. The four research modes and their existing FFI values remain available.

physics::box_contacts derives detector poses from current bodies, converts contacts into original local/world records and feeds the persistent manifold and solver. Returned errors preserve both manifold and body state. Copied fourth lanes and uninitialized native scratch bytes are explicit opaque storage inputs; contact geometry is computed in Rust. Broadphase, custom callbacks and world scheduling remain external.

physics::pre_step reproduces force accumulation, velocity integration and damping before collision solving, then predicts the interpolation pose. Force accumulators persist across substeps and have a separate outer-step clear. The existing body record stays unchanged; force/damping fields and the selected powf semantics are explicit inputs. Full world scheduling remains external.

physics::box_step connects force accumulation, current-pose box detection, contact solving, integration, motion synchronization, bone reflection and PMD skinning for one selected pair. Bodies, contacts and eight friction impulse slots persist between steps. Force accumulators clear after successful output; returned errors preserve the complete state. step_mixed also carries joint state and solves joint and contact rows together once per step. Its transaction includes the final bone and vertex output. Pair selection, joint construction, islands and the outer timestep accumulator remain caller responsibilities. The four-body, two-joint comparison covers 96 initial configurations over 12 steps, with contact loss and recontact, using original instruction emulation. This is a bounded numeric path, not a full world or garment collision test.

physics::joint_preparation derives Spring6DOF coordinates, axes, limits, updated spring motors and solver coefficients from current body poses and initial local-frame settings. Joint state and solver velocities can carry across calls without supplying saved rows. Returned errors preserve preparation state. The current path requires finite, nondegenerate geometry and unit factors; constructor/loader behavior and mixed contact/world scheduling remain external.

External local verification compared four build variants against 226 recorded original-binary cases covering 2,719 row iterations per variant, plus 84 direct arithmetic boundary cases. Scheduler verification covered 89 original-binary cases and 1,515 row iterations per variant, with exact trace and final-state comparisons. These checks use finite, bounded inputs and supplied constraint rows; shuffle, split impulse, and stateful callbacks are outside the current scope. Research fixtures and third-party binaries are maintained separately from this source repository. Full compatibility has not been established.

About

An MMD-compatible animation and rendering environment

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages