From 918f887c0c10fda33633548f3601bdf07d74edfd Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 29 May 2008 20:20:50 +0000 Subject: * Applying Dahlia's interim path curve patch. it adds initial support for some tori/ring parameters. Thanks Dahlia! * Some situations do not match the client's render of the tori, we know and are working on it. This is an initial support patch, so expect it to not be exact. * Some tapers are acting slightly odd. Will fix. --- OpenSim/Region/Physics/Meshing/HelperTypes.cs | 36 ++++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing/HelperTypes.cs') diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs index 584133c..f031fb6 100644 --- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs @@ -51,9 +51,13 @@ public class Quaternion { // using (* 0.5) instead of (/2) w = (float)Math.Cos(angle * 0.5f); - x = axis.X * (float)Math.Sin(angle * 0.5f); - y = axis.Y * (float)Math.Sin(angle * 0.5f); - z = axis.Z * (float)Math.Sin(angle * 0.5f); + float sin = (float)Math.Sin(angle * 0.5f); + //x = axis.X * (float)Math.Sin(angle * 0.5f); + //y = axis.Y * (float)Math.Sin(angle * 0.5f); + //z = axis.Z * (float)Math.Sin(angle * 0.5f); + x = axis.X * sin; + y = axis.Y * sin; + z = axis.Z * sin; normalize(); } public static Quaternion operator *(Quaternion a, Quaternion b) @@ -73,12 +77,18 @@ public class Quaternion } public void normalize() { - float mag = length(); + //float mag = length(); - w /= mag; - x /= mag; - y /= mag; - z /= mag; + //w /= mag; + //x /= mag; + //y /= mag; + //z /= mag; + float iMag = 1.0f / length(); + + w *= iMag; + x *= iMag; + y *= iMag; + z *= iMag; } public float length() { @@ -169,7 +179,8 @@ public class Vertex : PhysicsVector, IComparable float tlength = length(); if (tlength != 0) { - return new Vertex(X / tlength, Y / tlength, Z / tlength); + float mul = 1.0f / tlength; + return new Vertex(X * mul, Y * mul, Z * mul); } else { @@ -230,9 +241,10 @@ public class Vertex : PhysicsVector, IComparable { return new Vertex(0f,0f,0f); } - v1.X /= am; - v1.Y /= am; - v1.Z /= am; + float mul = 1.0f / am; + v1.X *= mul; + v1.Y *= mul; + v1.Z *= mul; return v1; } -- cgit v1.1