protected override void CapacityChanged()
 {
     unsafe
     {
         m_Ptr = (Quaternion *)m_AlignedPtr.ToPointer();
     }
 }
Exemplo n.º 2
0
        public static unsafe Quaternion AddScaledVector(Quaternion q, Vector3 v, float scale)
        {
            float      num        = v.x * scale;
            float      num2       = v.y * scale;
            float      num3       = v.z * scale;
            float      num4       = ((-q.x * num) - (q.y * num2)) - (q.z * num3);
            float      num5       = ((num * q.w) + (num2 * q.z)) - (num3 * q.y);
            float      num6       = ((num2 * q.w) + (num3 * q.x)) - (num * q.z);
            float      num7       = ((num3 * q.w) + (num * q.y)) - (num2 * q.x);
            Quaternion quaternion = new Quaternion(q.x + (0.5f * num5), q.y + (0.5f * num6), q.z + (0.5f * num7), q.w + (0.5f * num4));
            float      f          = (((quaternion.w * quaternion.w) + (quaternion.x * quaternion.x)) + (quaternion.y * quaternion.y)) + (quaternion.z * quaternion.z);

            if (f == 0f)
            {
                quaternion.w = 1f;
            }
            else
            {
                f = 1f / Mathf.Sqrt(f);
                Quaternion *quaternionPtr1 = &quaternion;
                quaternionPtr1->w *= f;
                Quaternion *quaternionPtr2 = &quaternion;
                quaternionPtr2->x *= f;
                Quaternion *quaternionPtr3 = &quaternion;
                quaternionPtr3->y *= f;
                Quaternion *quaternionPtr4 = &quaternion;
                quaternionPtr4->z *= f;
            }
            return(quaternion);
        }
Exemplo n.º 3
0
 public static unsafe Quaternion *Add(Quaternion *a, Quaternion *b, Quaternion *result)
 {
     result->X = a->X + b->X;
     result->Y = a->Y + b->Y;
     result->Z = a->Z + b->Z;
     result->W = a->W + b->W;
     return(result);
 }
Exemplo n.º 4
0
 public static unsafe Quaternion *Subtracts(Quaternion *a, Quaternion *b, Quaternion *result)
 {
     result->X = a->X - b->X;
     result->Y = a->Y - b->Y;
     result->Z = a->Z - b->Z;
     result->W = a->W - b->W;
     return(result);
 }
Exemplo n.º 5
0
 public static unsafe Quaternion *Div(Quaternion *a, Quaternion *b, Quaternion *result)
 {
     result->X = a->X / b->X;
     result->Y = a->Y / b->Y;
     result->Z = a->Z / b->Z;
     result->W = a->W / b->W;
     return(result);
 }
Exemplo n.º 6
0
 public static unsafe Quaternion *Negate(Quaternion *a, Quaternion *result)
 {
     result->X = -a->X;
     result->Y = -a->Y;
     result->Z = -a->Z;
     result->W = -a->W;
     return(result);
 }
Exemplo n.º 7
0
        public unsafe void QuaternionFieldOffsetTest()
        {
            Quaternion *ptr = (Quaternion *)0;

            Assert.Equal(new IntPtr(0), new IntPtr(&ptr->X));
            Assert.Equal(new IntPtr(4), new IntPtr(&ptr->Y));
            Assert.Equal(new IntPtr(8), new IntPtr(&ptr->Z));
            Assert.Equal(new IntPtr(12), new IntPtr(&ptr->W));
        }
Exemplo n.º 8
0
        public unsafe void QuaternionFieldOffsetTest()
        {
            Quaternion quat = new Quaternion();

            float *     basePtr = &quat.X; // Take address of first element
            Quaternion *quatPtr = &quat;   // Take address of whole Quaternion

            Assert.Equal(new IntPtr(basePtr), new IntPtr(quatPtr));

            Assert.Equal(new IntPtr(basePtr + 0), new IntPtr(&quat.X));
            Assert.Equal(new IntPtr(basePtr + 1), new IntPtr(&quat.Y));
            Assert.Equal(new IntPtr(basePtr + 2), new IntPtr(&quat.Z));
            Assert.Equal(new IntPtr(basePtr + 3), new IntPtr(&quat.W));
        }
Exemplo n.º 9
0
        private static unsafe void SetTransformQuaternionPatch(IntPtr instance, Quaternion *quat)
        {
            if (!(quat->x > MaxAllowedValueBottom && quat->x < MaxAllowedValueTop) ||
                !(quat->y > MaxAllowedValueBottom && quat->y < MaxAllowedValueTop) ||
                !(quat->z > MaxAllowedValueBottom && quat->z < MaxAllowedValueTop) ||
                !(quat->w > MaxAllowedValueBottom && quat->w < MaxAllowedValueTop))
            {
                quat->x = 0f;
                quat->y = 0f;
                quat->z = 0f;
                quat->w = 1f;
            }

            ourOriginalTransformRotSetter(instance, quat);
        }
Exemplo n.º 10
0
        private static unsafe void SetRigidbodyRotMovePatch(IntPtr instance, Quaternion *quat)
        {
            if (!(quat->x > MaxAllowedValueBottom && quat->x < MaxAllowedValueTop) ||
                !(quat->y > MaxAllowedValueBottom && quat->y < MaxAllowedValueTop) ||
                !(quat->z > MaxAllowedValueBottom && quat->z < MaxAllowedValueTop) ||
                !(quat->w > MaxAllowedValueBottom && quat->w < MaxAllowedValueTop))
            {
                quat->x = 0f;
                quat->y = 0f;
                quat->z = 0f;
                quat->w = 1f;
            }

            ourOriginalRigidbodyRotMove(instance, quat);
        }
Exemplo n.º 11
0
        public static unsafe Quaternion *Normalize(Quaternion *v, Quaternion *result)
        {
            *     result = *v;
            float length = (float)System.Math.Sqrt(v->X * v->X + v->Y * v->Y + v->Z * v->Z + v->W * v->W);

            if (length != 0f)
            {
                float num = (1.0f / length);
                result->X *= num;
                result->Y *= num;
                result->Z *= num;
                result->W *= num;
            }
            return(result);
        }
Exemplo n.º 12
0
        public unsafe void TestSketchBinaryWriter()
        {
            byte[] b0    = MakeData(0);
            byte[] b10   = MakeData(10);
            byte[] b5000 = MakeData(5000);

            using (var astr = new MemoryStream())
                using (var bstr = new MemoryStream())
                    using (var aw = new BinaryWriter(astr, System.Text.Encoding.UTF8))
                    {
                        var        bw = new SketchBinaryWriter(bstr);
                        Quaternion q1 = new Quaternion(4.1f, 4.2f, 4.3f, 4.4f);
                        Quaternion q2 = new Quaternion(2.5f, 3.5f, 4.5f, 5.3f);

                        aw.Write(0x7123abcd);
                        aw.Write(0xdb1f117eu);
                        aw.Write(-0f);
                        aw.Write(-1f);
                        aw.Write(1e27f);
                        aw.Write(q1.x);
                        aw.Write(q1.y);
                        aw.Write(q1.z);
                        aw.Write(q1.w);
                        aw.Write(q2.x);
                        aw.Write(q2.y);
                        aw.Write(q2.z);
                        aw.Write(q2.w);
                        aw.Flush();
                        astr.Write(b0, 0, b0.Length);
                        astr.Write(b10, 0, b10.Length);
                        astr.Write(b5000, 0, b5000.Length);

                        bw.Int32(0x7123abcd);
                        bw.UInt32(0xdb1f117eu);
                        bw.Vec3(new Vector3(-0f, -1f, 1e27f));
                        bw.Quaternion(q1);
                        Quaternion *pq2 = &q2;
                        bw.Write((IntPtr)pq2, sizeof(Quaternion));
                        WriteBuf(bw, b0);
                        WriteBuf(bw, b10);
                        WriteBuf(bw, b5000);

                        Assert.AreEqual(astr.ToArray(), bstr.ToArray());
                    }
        }
Exemplo n.º 13
0
        private static unsafe void SetTransformQuaternionPatch(IntPtr instance, Quaternion *quat)
        {
            if ((*(int *)&quat->x & int.MaxValue) >= 2139095040)
            {
                quat->x = 0f;
            }
            if ((*(int *)&quat->y & int.MaxValue) >= 2139095040)
            {
                quat->y = 0f;
            }
            if ((*(int *)&quat->z & int.MaxValue) >= 2139095040)
            {
                quat->z = 0f;
            }
            if ((*(int *)&quat->w & int.MaxValue) >= 2139095040)
            {
                quat->w = 1f;
            }

            ourOriginalTransformRotSetter(instance, quat);
        }
Exemplo n.º 14
0
        private static unsafe void QuaternionPatch(IntPtr arg1, Quaternion *quat, int enumValue)
        {
            ourOriginalQuaternionMethod(arg1, quat, enumValue);

            if ((*(int *)&quat->x & int.MaxValue) >= 2139095040)
            {
                quat->x = 0f;
            }
            if ((*(int *)&quat->y & int.MaxValue) >= 2139095040)
            {
                quat->y = 0f;
            }
            if ((*(int *)&quat->z & int.MaxValue) >= 2139095040)
            {
                quat->z = 0f;
            }
            if ((*(int *)&quat->w & int.MaxValue) >= 2139095040)
            {
                quat->w = 1f;
            }
        }
Exemplo n.º 15
0
        private static unsafe void SetRigidbodyRotMovePatch(IntPtr instance, Quaternion *quat)
        {
            if ((*(int *)&quat->x & int.MaxValue) >= 2139095040)
            {
                quat->x = 0f;
            }
            if ((*(int *)&quat->y & int.MaxValue) >= 2139095040)
            {
                quat->y = 0f;
            }
            if ((*(int *)&quat->z & int.MaxValue) >= 2139095040)
            {
                quat->z = 0f;
            }
            if ((*(int *)&quat->w & int.MaxValue) >= 2139095040)
            {
                quat->w = 1f;
            }

            ourOriginalRigidbodyRotMove(instance, quat);
        }
Exemplo n.º 16
0
 public unsafe extern static void SDK_GfxBoneDesc_SetInvQuat(NativePointer self, Quaternion *value);
Exemplo n.º 17
0
 private unsafe static extern Quaternion *D3DXQuaternionRotationMatrix(Quaternion *res, Matrix *src);
Exemplo n.º 18
0
 public unsafe extern static void D3DXQuaternionToAxisAngle(Quaternion *pQ, Vector3 *pAxis, float *pAngle);
Exemplo n.º 19
0
 private extern static unsafe vBOOL SDK_PhyShape_IfGetScaling(NativePointer self, Vector3 *scale, Quaternion *scaleRot);
Exemplo n.º 20
0
 public unsafe extern static Matrix *D3DXMatrixTransformation(Matrix *pOut, Vector3 *pScalingCenter, Quaternion *pScalingRotation, Vector3 *pScaling, Vector3 *pRotationCenter, Quaternion *pRotation, Vector3 *pTranslation);
Exemplo n.º 21
0
 public unsafe extern static Quaternion *D3DXQuaternionSquad(Quaternion *pOut, Quaternion *pQ1, Quaternion *pA, Quaternion *pB, Quaternion *pC, float t);
Exemplo n.º 22
0
 public unsafe extern static Quaternion *D3DXQuaternionRotationMatrix(Quaternion *pOut, Matrix *pM);
Exemplo n.º 23
0
 public unsafe extern static Quaternion *D3DXQuaternionLn(Quaternion *pOut, Quaternion *pQ);
Exemplo n.º 24
0
 public unsafe extern static Quaternion *D3DXQuaternionBaryCentric(Quaternion *pOut, Quaternion *pQ1, Quaternion *pQ2, Quaternion *pQ3, float f, float g);
Exemplo n.º 25
0
 private extern static unsafe CPhyShape.NativePointer SDK_PhyContext_CreateShapeTriMesh(NativePointer self, CPhyMaterial.NativePointer material, Support.CBlobObject.NativePointer blob, Vector3 *scale, Quaternion *scaleRot);
Exemplo n.º 26
0
 public unsafe static float Dot(Quaternion *a, Quaternion *b)
 {
     return(a->X * b->X + a->Y * b->Y + a->Z * b->Z + a->W * b->W);
 }
Exemplo n.º 27
0
 public unsafe static float Lenght(Quaternion *a)
 {
     return((float)System.Math.Sqrt(a->X * a->X + a->Y * a->Y + a->Z * a->Z + a->W * a->W));
 }
Exemplo n.º 28
0
 public unsafe static float LenghtSquared(Quaternion *a)
 {
     return(a->X * a->X + a->Y * a->Y + a->Z * a->Z + a->W * a->W);
 }
Exemplo n.º 29
0
 public unsafe extern static void D3DXQuaternionSquadSetup(Quaternion *pAOut, Quaternion *pBOut, Quaternion *pCOut, Quaternion *pQ0, Quaternion *pQ1, Quaternion *pQ2, Quaternion *pQ3);
Exemplo n.º 30
0
 public unsafe extern static int D3DXMatrixDecompose(Vector3 *pOutScale, Quaternion *pOutRotation, Vector3 *pOutTranslation, Matrix *pM);