mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Revert #85 to fix SIGSEGV
This commit is contained in:
parent
83db30496d
commit
52a6c4f4da
2 changed files with 15 additions and 31 deletions
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
use std::ops;
|
||||
|
||||
use glam::{EulerRot, Mat4, Quat, Vec3};
|
||||
use mlua::{prelude::*, Variadic};
|
||||
use mlua::prelude::*;
|
||||
use rbx_dom_weak::types::{CFrame as DomCFrame, Matrix3 as DomMatrix3, Vector3 as DomVector3};
|
||||
|
||||
use super::{super::*, Vector3};
|
||||
|
@ -210,46 +210,38 @@ impl LuaUserData for CFrame {
|
|||
translation,
|
||||
)))
|
||||
});
|
||||
methods.add_method(
|
||||
"ToWorldSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<CFrame>>| {
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|cf| *this * *cf)))
|
||||
},
|
||||
);
|
||||
methods.add_method(
|
||||
"ToObjectSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<CFrame>>| {
|
||||
let inverse = this.inverse();
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|cf| inverse * *cf)))
|
||||
},
|
||||
);
|
||||
methods.add_method("ToWorldSpace", |_, this, rhs: LuaUserDataRef<CFrame>| {
|
||||
Ok(*this * *rhs)
|
||||
});
|
||||
methods.add_method("ToObjectSpace", |_, this, rhs: LuaUserDataRef<CFrame>| {
|
||||
let inverse = this.inverse();
|
||||
Ok(inverse * *rhs)
|
||||
});
|
||||
methods.add_method(
|
||||
"PointToWorldSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<Vector3>>| {
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|v3| *this * *v3)))
|
||||
},
|
||||
|_, this, rhs: LuaUserDataRef<Vector3>| Ok(*this * *rhs),
|
||||
);
|
||||
methods.add_method(
|
||||
"PointToObjectSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<Vector3>>| {
|
||||
|_, this, rhs: LuaUserDataRef<Vector3>| {
|
||||
let inverse = this.inverse();
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|v3| inverse * *v3)))
|
||||
Ok(inverse * *rhs)
|
||||
},
|
||||
);
|
||||
methods.add_method(
|
||||
"VectorToWorldSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<Vector3>>| {
|
||||
|_, this, rhs: LuaUserDataRef<Vector3>| {
|
||||
let result = *this - Vector3(this.position());
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|v3| result * *v3)))
|
||||
Ok(result * *rhs)
|
||||
},
|
||||
);
|
||||
methods.add_method(
|
||||
"VectorToObjectSpace",
|
||||
|_, this, rhs: Variadic<LuaUserDataRef<Vector3>>| {
|
||||
|_, this, rhs: LuaUserDataRef<Vector3>| {
|
||||
let inverse = this.inverse();
|
||||
let result = inverse - Vector3(inverse.position());
|
||||
|
||||
Ok(Variadic::from_iter(rhs.into_iter().map(|v3| result * *v3)))
|
||||
Ok(result * *rhs)
|
||||
},
|
||||
);
|
||||
#[rustfmt::skip]
|
||||
|
|
|
@ -99,18 +99,10 @@ assertEq(
|
|||
|
||||
-- World & object space conversions
|
||||
|
||||
-- FIXME: ToWorldSpace and/or ToObjectSpace are causing SIGTRAP? What the heck?
|
||||
if true then
|
||||
return
|
||||
end
|
||||
|
||||
local offset = CFrame.new(0, 0, -5)
|
||||
assert(offset:ToWorldSpace(offset).Z == offset.Z * 2)
|
||||
assert(offset:ToObjectSpace(offset).Z == 0)
|
||||
|
||||
assert(select("#", offset:ToWorldSpace(offset, offset, offset)) == 3)
|
||||
assert(select("#", offset:ToObjectSpace(offset, offset, offset)) == 3)
|
||||
|
||||
local world = CFrame.fromOrientation(0, math.rad(90), 0) * CFrame.new(0, 0, -5)
|
||||
local world2 = CFrame.fromOrientation(0, -math.rad(90), 0) * CFrame.new(0, 0, -5)
|
||||
assertEq(CFrame.identity:ToObjectSpace(world), world)
|
||||
|
|
Loading…
Reference in a new issue