From b7e43127705537023f69483b85f978ec283d47f7 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sat, 11 Mar 2023 08:18:04 +0100 Subject: [PATCH] Don't use simd-aligned vectors for better compatibility --- packages/lib-roblox/src/datatypes/vector2.rs | 6 ++--- packages/lib-roblox/src/datatypes/vector3.rs | 24 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/lib-roblox/src/datatypes/vector2.rs b/packages/lib-roblox/src/datatypes/vector2.rs index 943fb7b..084d556 100644 --- a/packages/lib-roblox/src/datatypes/vector2.rs +++ b/packages/lib-roblox/src/datatypes/vector2.rs @@ -1,6 +1,6 @@ use core::fmt; -use glam::{Vec2, Vec3A}; +use glam::{Vec2, Vec3}; use mlua::prelude::*; use rbx_dom_weak::types::Vector2 as RbxVector2; @@ -33,8 +33,8 @@ impl LuaUserData for Vector2 { fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) { // Methods methods.add_method("Cross", |_, this, rhs: Vector2| { - let this_v3 = Vec3A::new(this.0.x, this.0.y, 0f32); - let rhs_v3 = Vec3A::new(rhs.0.x, rhs.0.y, 0f32); + let this_v3 = Vec3::new(this.0.x, this.0.y, 0f32); + let rhs_v3 = Vec3::new(rhs.0.x, rhs.0.y, 0f32); Ok(this_v3.cross(rhs_v3).z) }); methods.add_method("Dot", |_, this, rhs: Vector2| Ok(this.0.dot(rhs.0))); diff --git a/packages/lib-roblox/src/datatypes/vector3.rs b/packages/lib-roblox/src/datatypes/vector3.rs index e9e728d..f5374d3 100644 --- a/packages/lib-roblox/src/datatypes/vector3.rs +++ b/packages/lib-roblox/src/datatypes/vector3.rs @@ -1,6 +1,6 @@ use core::fmt; -use glam::Vec3A; +use glam::Vec3; use mlua::prelude::*; use rbx_dom_weak::types::Vector3 as RbxVector3; @@ -8,7 +8,7 @@ use super::*; /** An implementation of the [Vector3](https://create.roblox.com/docs/reference/engine/datatypes/Vector3) - Roblox datatype, backed by [`glam::Vec3A`]. + Roblox datatype, backed by [`glam::Vec3`]. This implements all documented properties & methods of the Vector3 class as of March 2023, as well as the `new(x, y, z)` constructor. @@ -17,7 +17,7 @@ use super::*; and instead allow us to implement all abovementioned APIs accurately. */ #[derive(Debug, Clone, Copy, PartialEq)] -pub struct Vector3(pub Vec3A); +pub struct Vector3(pub Vec3); impl fmt::Display for Vector3 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -70,7 +70,7 @@ impl LuaUserData for Vector3 { }); methods.add_meta_method(LuaMetaMethod::Mul, |_, this, rhs: LuaValue| { match &rhs { - LuaValue::Number(n) => return Ok(Vector3(this.0 * Vec3A::splat(*n as f32))), + LuaValue::Number(n) => return Ok(Vector3(this.0 * Vec3::splat(*n as f32))), LuaValue::UserData(ud) => { if let Ok(vec) = ud.borrow::() { return Ok(Vector3(this.0 * vec.0)); @@ -89,7 +89,7 @@ impl LuaUserData for Vector3 { }); methods.add_meta_method(LuaMetaMethod::Div, |_, this, rhs: LuaValue| { match &rhs { - LuaValue::Number(n) => return Ok(Vector3(this.0 / Vec3A::splat(*n as f32))), + LuaValue::Number(n) => return Ok(Vector3(this.0 / Vec3::splat(*n as f32))), LuaValue::UserData(ud) => { if let Ok(vec) = ud.borrow::() { return Ok(Vector3(this.0 / vec.0)); @@ -112,16 +112,16 @@ impl LuaUserData for Vector3 { impl DatatypeTable for Vector3 { fn make_dt_table(lua: &Lua, datatype_table: &LuaTable) -> LuaResult<()> { // Constants - datatype_table.set("xAxis", Vector3(Vec3A::X))?; - datatype_table.set("yAxis", Vector3(Vec3A::Y))?; - datatype_table.set("zAxis", Vector3(Vec3A::Z))?; - datatype_table.set("zero", Vector3(Vec3A::ZERO))?; - datatype_table.set("one", Vector3(Vec3A::ONE))?; + datatype_table.set("xAxis", Vector3(Vec3::X))?; + datatype_table.set("yAxis", Vector3(Vec3::Y))?; + datatype_table.set("zAxis", Vector3(Vec3::Z))?; + datatype_table.set("zero", Vector3(Vec3::ZERO))?; + datatype_table.set("one", Vector3(Vec3::ONE))?; // Constructors datatype_table.set( "new", lua.create_function(|_, (x, y, z): (Option, Option, Option)| { - Ok(Vector3(Vec3A { + Ok(Vector3(Vec3 { x: x.unwrap_or_default(), y: y.unwrap_or_default(), z: z.unwrap_or_default(), @@ -135,7 +135,7 @@ impl DatatypeTable for Vector3 { impl FromRbxVariant for Vector3 { fn from_rbx_variant(variant: &RbxVariant) -> RbxConversionResult { if let RbxVariant::Vector3(v) = variant { - Ok(Vector3(Vec3A { + Ok(Vector3(Vec3 { x: v.x, y: v.y, z: v.z,