From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../ConvexDecompositionDotNet/float4x4.cs | 170 ++++++++++----------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs') diff --git a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs index 087eba7..85a8cf1 100644 --- a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs +++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/float4x4.cs @@ -1,21 +1,21 @@ /* The MIT License - * + * * Copyright (c) 2010 Intel Corporation. * All rights reserved. * - * Based on the convexdecomposition library from + * Based on the convexdecomposition library from * by John W. Ratcliff and Stan Melax. - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,7 +30,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet +namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet { public class float4x4 { @@ -127,88 +127,88 @@ namespace OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet } public static float4x4 Inverse(float4x4 m) - { - float4x4 d = new float4x4(); - //float dst = d.x.x; - float[] tmp = new float[12]; // temp array for pairs - float[] src = new float[16]; // array of transpose source matrix - float det; // determinant - // transpose matrix - for (int i = 0; i < 4; i++) - { - src[i] = m[i].x; - src[i + 4] = m[i].y; - src[i + 8] = m[i].z; - src[i + 12] = m[i].w; - } - // calculate pairs for first 8 elements (cofactors) - tmp[0] = src[10] * src[15]; - tmp[1] = src[11] * src[14]; - tmp[2] = src[9] * src[15]; - tmp[3] = src[11] * src[13]; - tmp[4] = src[9] * src[14]; - tmp[5] = src[10] * src[13]; - tmp[6] = src[8] * src[15]; - tmp[7] = src[11] * src[12]; - tmp[8] = src[8] * src[14]; - tmp[9] = src[10] * src[12]; - tmp[10] = src[8] * src[13]; - tmp[11] = src[9] * src[12]; - // calculate first 8 elements (cofactors) - d.x.x = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7]; - d.x.x -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7]; - d.x.y = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7]; - d.x.y -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7]; - d.x.z = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7]; - d.x.z -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7]; - d.x.w = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6]; - d.x.w -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6]; - d.y.x = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3]; - d.y.x -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3]; - d.y.y = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3]; - d.y.y -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3]; - d.y.z = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3]; - d.y.z -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3]; - d.y.w = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2]; - d.y.w -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2]; - // calculate pairs for second 8 elements (cofactors) - tmp[0] = src[2]*src[7]; - tmp[1] = src[3]*src[6]; - tmp[2] = src[1]*src[7]; - tmp[3] = src[3]*src[5]; - tmp[4] = src[1]*src[6]; - tmp[5] = src[2]*src[5]; - tmp[6] = src[0]*src[7]; - tmp[7] = src[3]*src[4]; - tmp[8] = src[0]*src[6]; - tmp[9] = src[2]*src[4]; - tmp[10] = src[0]*src[5]; - tmp[11] = src[1]*src[4]; - // calculate second 8 elements (cofactors) - d.z.x = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15]; - d.z.x -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15]; - d.z.y = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15]; - d.z.y -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15]; - d.z.z = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15]; - d.z.z -= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15]; - d.z.w = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14]; - d.z.w-= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14]; - d.w.x = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9]; - d.w.x-= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10]; - d.w.y = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10]; - d.w.y-= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8]; - d.w.z = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8]; - d.w.z-= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9]; - d.w.w = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9]; - d.w.w-= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8]; - // calculate determinant + { + float4x4 d = new float4x4(); + //float dst = d.x.x; + float[] tmp = new float[12]; // temp array for pairs + float[] src = new float[16]; // array of transpose source matrix + float det; // determinant + // transpose matrix + for (int i = 0; i < 4; i++) + { + src[i] = m[i].x; + src[i + 4] = m[i].y; + src[i + 8] = m[i].z; + src[i + 12] = m[i].w; + } + // calculate pairs for first 8 elements (cofactors) + tmp[0] = src[10] * src[15]; + tmp[1] = src[11] * src[14]; + tmp[2] = src[9] * src[15]; + tmp[3] = src[11] * src[13]; + tmp[4] = src[9] * src[14]; + tmp[5] = src[10] * src[13]; + tmp[6] = src[8] * src[15]; + tmp[7] = src[11] * src[12]; + tmp[8] = src[8] * src[14]; + tmp[9] = src[10] * src[12]; + tmp[10] = src[8] * src[13]; + tmp[11] = src[9] * src[12]; + // calculate first 8 elements (cofactors) + d.x.x = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7]; + d.x.x -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7]; + d.x.y = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7]; + d.x.y -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7]; + d.x.z = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7]; + d.x.z -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7]; + d.x.w = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6]; + d.x.w -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6]; + d.y.x = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3]; + d.y.x -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3]; + d.y.y = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3]; + d.y.y -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3]; + d.y.z = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3]; + d.y.z -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3]; + d.y.w = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2]; + d.y.w -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2]; + // calculate pairs for second 8 elements (cofactors) + tmp[0] = src[2]*src[7]; + tmp[1] = src[3]*src[6]; + tmp[2] = src[1]*src[7]; + tmp[3] = src[3]*src[5]; + tmp[4] = src[1]*src[6]; + tmp[5] = src[2]*src[5]; + tmp[6] = src[0]*src[7]; + tmp[7] = src[3]*src[4]; + tmp[8] = src[0]*src[6]; + tmp[9] = src[2]*src[4]; + tmp[10] = src[0]*src[5]; + tmp[11] = src[1]*src[4]; + // calculate second 8 elements (cofactors) + d.z.x = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15]; + d.z.x -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15]; + d.z.y = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15]; + d.z.y -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15]; + d.z.z = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15]; + d.z.z -= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15]; + d.z.w = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14]; + d.z.w-= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14]; + d.w.x = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9]; + d.w.x-= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10]; + d.w.y = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10]; + d.w.y-= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8]; + d.w.z = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8]; + d.w.z-= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9]; + d.w.w = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9]; + d.w.w-= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8]; + // calculate determinant det = src[0] * d.x.x + src[1] * d.x.y + src[2] * d.x.z + src[3] * d.x.w; - // calculate matrix inverse - det = 1/det; + // calculate matrix inverse + det = 1/det; for (int j = 0; j < 4; j++) d[j] *= det; - return d; - } + return d; + } public static float4x4 MatrixRigidInverse(float4x4 m) { -- cgit v1.1