Skip to content

refactor(physics): createAnchorPoint() returns Vec3 SYNTH-341 - #1490

Merged
PepperLola merged 2 commits into
devfrom
darora1/341/refactor-create-anchor
Aug 12, 2026
Merged

refactor(physics): createAnchorPoint() returns Vec3 SYNTH-341#1490
PepperLola merged 2 commits into
devfrom
darora1/341/refactor-create-anchor

Conversation

@Dhruv-0-Arora

@Dhruv-0-Arora Dhruv-0-Arora commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Task

This is a refactor made in #1418 which was closed.

SYNTH-341

Symptom

Currently in dev, createAnchorPoint() returns a RVec3 which is a static alias. There is inherently nothing wrong with this, but it could allow for problematic behaviors down the line such as -> Jolt.destroy(anchorPoint)

anchorPoint being a static alias means that if the function Jolt.AddRVec3() is run, the anchorPoint value is overwritten and the anchorPoint reference points to the new value.

Solution

Rather than creating 2 new Jolt.RVec3 for them only to be destroyed in the function scope:

  • create 1 new Jolt.RVec3 -> gets destroyed in function scope.
  • create 1 new Jolt.Vec3 -> passing ownership to function caller.

Jolt.RVec3 is actually fundamentally the same cpp data type as Jolt.Vec3 (both are the same byte size). Under the hood, JS wraps them differently though. Below is why:

Details

In CMakeLists.txt in JoltPhysics.js, double precision is turned off:
option(DOUBLE_PRECISION "Compile the library in double precision mode" OFF)

In Jolt/Math/Real.h:

#ifdef JPH_DOUBLE_PRECISION

...

#else

// Define real to float
using Real = float;
using Real3 = Float3;
using RVec3 = Vec3;

Because DOUBLE_PRECISION is off, RVec3 = Vec3


Before merging, ensure the following criteria are met:

  • All acceptance criteria outlined in the ticket are met.
  • Necessary test cases have been added and updated.
  • A feature toggle or safe disable path has been added (if applicable).
  • User-facing polish:
    • Ask: "Is this ready-looking?"
  • Cross-linking between Jira and GitHub:
    • PR links to the relevant Jira issue.
    • Jira ticket has a comment referencing this PR.

Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>

@AlexD717 AlexD717 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@PepperLola
PepperLola merged commit a56fdff into dev Aug 12, 2026
23 checks passed
@PepperLola
PepperLola deleted the darora1/341/refactor-create-anchor branch August 12, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants