Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vec3 and Quat should clone pass through Jolt objects #76

Open
DennisSmolek opened this issue Apr 19, 2024 · 0 comments
Open

Vec3 and Quat should clone pass through Jolt objects #76

DennisSmolek opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@DennisSmolek
Copy link
Collaborator

in the vec3 and quat helper utils the .jolt methods make sure no matter what type of input object you pass it automatically creates/converts it to a Jolt object. (anyVec & anyQuat)

For Tuples and ThreeJS objects it's understood that this will create a new Jolt object that must be destroyed.

However, if you pass a Jolt object to this function it will simply return the original function.

Consider:

const position = useLocal? SomeThreeJSBody.position | SomeJoltBody.GetPosition(); // this is a reference either way
const newPosition = vec3.jolt(position);
myObject.position = newPosition;
Raw.module.destroy(newPosition); // proper cleanup

If it's a threeJS object you put in, it will work fine, create a new Jolt item and be destroyed cleanly.

HOWEVER, if you passed the Jolt object, it will pass the ORIGINAL which in this case is a reference.
When you destroy that reference, stuff will break...

And you 100% will never be able to track it down because it's probably a memory corruption error that's throwing out of bounds error on some totally unrelated task.

Unfortunately jolt doesn't have a clone method which is annoying, especially for quaternions.

Probably should just add a .clone() method to both vec3 and quat

This isn't blocking anything right this minute so I just want to track that this fix needs to be done

@DennisSmolek DennisSmolek added the bug Something isn't working label Apr 19, 2024
@DennisSmolek DennisSmolek added this to the 0.0 Alpha milestone Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant