Skip to content

Conversation

@WolfGangS
Copy link
Contributor

@WolfGangS WolfGangS commented Dec 13, 2025

Changes globals uuid, quaternion, rotation to tables with __call meta method to preserve previous function like behavior for creating uuid's and quaternion's

All tables contain a create method to follow teh same pattern that the vector table implements.

quaternion, rotation also contain

  • normalize - (quat: quaternion) -> quaternion
  • magnitude - (quat: quaternion) -> number
  • dot - (quat1: quaternion, quat2: quaternion) -> number
  • slerp - (start: quaternion, target: quaternion, interpolation: number) -> quaternion
  • conjugate - (quat: quaternion) -> quaternion
  • tofwd - (quat: quaternion) -> vector
  • toleft - (quat: quaternion) -> vector
  • toright - (quat: quaternion) -> vector

Methods useful for working with quaternions.

Originally there was also an intent to add toeuler and fromeuler however as i could not find a way to implement them and match the output of LSL's llEuler2Rot exactly, this has been left out for now, for addition later, after either it's been decided if matching them exactly is needed or not, and if so someone with access to teh reference implementation might need to do it.

Personally looking at some of the various implementations I've seen, I'm not sure slua's implementation needs to match ll.Euler2Rot exactly, as that is still available if someone needed exact value matching. A "simpler" implementation could be used, as long as it provides expected results.

Update

A set of basic quaternion tests for lua have been added

…ementation

Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Copy link
Contributor

@HaroldCindy HaroldCindy left a comment

Choose a reason for hiding this comment

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

Generally looks pretty good! Just one question about the SLERP stuff.

…ife viewers slerp function

Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Signed-off-by: WolfGangS <flamin2k8@gmail.com>
Copy link
Contributor

@HaroldCindy HaroldCindy left a comment

Choose a reason for hiding this comment

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

Thanks! I'll get this out with the next release.

@HaroldCindy HaroldCindy merged commit ffe7276 into secondlife:main Dec 16, 2025
8 checks passed
@monty-linden monty-linden changed the title Convert globals uuid and quaternion to tables, to match vector's imementation Convert globals uuid and quaternion to tables, to match vector's implementation Dec 16, 2025
float invNorm = 1.0f / sqrtf(quaternion_dot(quat, quat));
luaSL_pushquaternion(L, quat[0] * invNorm, quat[1] * invNorm, quat[2] * invNorm, quat[3] * invNorm);
return 1;
}

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

3d26304 thanks!

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.

3 participants