public static void GetBoundsPointers(int broadPhaseIndex, ref Tree tree, out Vector3 *minPointer, out Vector3 *maxPointer)
        {
            var leaf      = tree.Leaves[broadPhaseIndex];
            var nodeChild = (&tree.NodesPointer[leaf.NodeIndex].A) + leaf.ChildIndex;

            minPointer = &nodeChild->Min;
            maxPointer = &nodeChild->Max;
        }
Beispiel #2
0
 private extern static unsafe PhyControllerCollisionFlag SDK_PhyController_Move(NativePointer self, Vector3 *disp, float minDist, float elapsedTime, PhyFilterData *filterData, PhyQueryFlag filterFlags);
Beispiel #3
0
 public void GetActiveBoundsPointers(int index, out Vector3 *minPointer, out Vector3 *maxPointer)
 {
     GetBoundsPointers(index, ref ActiveTree, out minPointer, out maxPointer);
 }
Beispiel #4
0
 public unsafe extern static Matrix *v3dxMatrixAffineTransformation(Matrix *pOut, float Scaling, Vector3 *pRotationCenter, Quaternion *pRotation, Vector3 *pTranslation);
Beispiel #5
0
 public unsafe extern static void v3dxQuaternionToAxisAngle(Quaternion *pQ, Vector3 *pAxis, float *pAngle);
Beispiel #6
0
 public unsafe extern static int v3dxComputeBoundingSphere(Vector3 *pFirstPosition, UInt32 NumVertices, UInt32 dwStride, Vector3 *pCenter, float *pRadius);
Beispiel #7
0
 public unsafe extern static Vector3 *v3dxVec3TransformNormalArray(Vector3 *pOut, UInt32 OutStride, Vector3 *pV, UInt32 VStride, Matrix *pM, UInt32 n);
Beispiel #8
0
 public static Vector3 Max(Vector3 v1, Vector3 *v2)
 {
     return(new Vector3(Math.Max(v1._x, v2->_x), Math.Max(v1._y, v2->_y), Math.Max(v1._z, v2->_z)));
 }
Beispiel #9
0
 public void Add(Vector3 *v)
 {
     _x += v->_x; _y += v->_y; _z += v->_z;
 }
Beispiel #10
0
 public void Multiply(Vector3 *v)
 {
     _x *= v->_x; _y *= v->_y; _z *= v->_z;
 }
Beispiel #11
0
 public float Dot(Vector3 *v)
 {
     return((_x * v->_x) + (_y * v->_y) + (_z * v->_z));
 }
Beispiel #12
0
 public void Sub(Vector3 *v)
 {
     _x -= v->_x; _y -= v->_y; _z -= v->_z;
 }
Beispiel #13
0
 /// <summary>
 /// Return ray hit distance or infinity if no hit. Requires raw data to be set. Optionally return hit normal and hit uv coordinates at intersect point.
 /// </summary>
 public float GetHitDistance(Urho.Ray ray, Vector3 *outNormal = null, Vector2 *outUV = null)
 {
     Runtime.ValidateRefCounted(this);
     return(Geometry_GetHitDistance(handle, ref ray, outNormal, outUV));
 }
Beispiel #14
0
 internal static extern float Geometry_GetHitDistance(IntPtr handle, ref Urho.Ray ray, Vector3 *outNormal, Vector2 *outUV);
Beispiel #15
0
 public unsafe extern static Matrix *v3dxMatrixTransformationOrigin(Matrix *pOut, Vector3 *pScaling, Quaternion *pRotation, Vector3 *pTranslation);
Beispiel #16
0
        private static unsafe void SetTransformVectorQuaternionPatch(IntPtr instance, Vector3 *vector, Quaternion *quat)
        {
            if ((*(int *)&vector->x & int.MaxValue) >= 2139095040)
            {
                vector->x = 0f;
            }
            if ((*(int *)&vector->y & int.MaxValue) >= 2139095040)
            {
                vector->y = 0f;
            }
            if ((*(int *)&vector->z & int.MaxValue) >= 2139095040)
            {
                vector->z = 0f;
            }

            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;
            }

            ourOriginalTransformTwinSetter(instance, vector, quat);
        }
Beispiel #17
0
 public unsafe extern static Matrix *v3dxMatrixLookAtLH(Matrix *pOut, Vector3 *pCamera, Vector3 *pAt, Vector3 *pUp);
Beispiel #18
0
 private extern static unsafe void SDK_PhySceneDesc_GetGravity(NativePointer self, Vector3 *gravity);
Beispiel #19
0
 public unsafe extern static int v3dxIntersectTri(Vector3 *p0, Vector3 *p1, Vector3 *p2, Vector3 *pRayPos, Vector3 *pRayDir, float *pU, float *pV, float *pDist);
Beispiel #20
0
 private extern static unsafe vBOOL SDK_PhyScene_RaycastWithFilter(NativePointer self, Vector3 *origin, Vector3 *unitDir, float maxDistance, PhyQueryFilterData *queryFilterData, GamePlay.SceneGraph.VHitResult *hitResult);
Beispiel #21
0
 public unsafe extern static int v3dxMatrixDecompose(Vector3 *pOutScale, Quaternion *pOutRotation, Vector3 *pOutTranslation, Matrix *pM);
Beispiel #22
0
 private extern static unsafe vBOOL SDK_PhyScene_SweepWithFilter(NativePointer self, CPhyShape.NativePointer shape, Vector3 *position, Vector3 *unitDir, float maxDistance, PhyQueryFilterData *queryFilterData, GamePlay.SceneGraph.VHitResult *hitResult);
Beispiel #23
0
 public unsafe extern static Vector3 *v3dxPlaneIntersectLine(Vector3 *pOut, Plane *pP, Vector3 *pV1, Vector3 *pV2);
Beispiel #24
0
 private extern static unsafe vBOOL SDK_PhyScene_OverlapWithFilter(NativePointer self, CPhyShape.NativePointer shape, Vector3 *position, Quaternion *rotation, PhyQueryFilterData *queryFilterData, GamePlay.SceneGraph.VHitResult *hitResult);
Beispiel #25
0
 private extern unsafe static void SDK_PhyBoxControllerDesc_SetExtent(NativePointer self, Vector3 *v);
Beispiel #26
0
        ////!!!!temp
        //bool OBBToFrustumIntersect2( Frustum frustum, Box box )
        ////bool OBBToFrustumIntersect2( Frustum frustum, Vector3[] points )
        //{
        //	//!!!!slowly

        //	var points = box.ToPoints();

        //	foreach( var plane in frustum.Planes )
        //	{
        //		bool allClipped = true;
        //		foreach( var p in points )
        //		{
        //			if( plane.GetSide( p ) == Plane.Side.Negative )
        //			{
        //				allClipped = false;
        //				break;
        //			}
        //		}
        //		if( allClipped )
        //			return false;
        //	}

        //	return true;
        //}

        //!!!!temp
        //bool OBBToFrustumIntersect( Frustum frustum, Box box )
        //{
        //	// Do a SAT test along each frustum axis.
        //	// A frustum consists of six planes. Note that as near and far planes are parallel, we could optimize
        //	// one iteration away.
        //	var planes = frustum.Planes;
        //	for( int i = 0; i < planes.Length; i++ )
        //	{
        //		var planeNormal = planes[ i ].Normal;
        //		//var planeDistance = planes[ i ].Distance;
        //		var planeDistance = -planes[ i ].Distance;

        //		// Find the negative and positive far points of the OBB to the current frustum plane.
        //		var x = Vector3.Dot( box.Axis[ 0 ], planeNormal ) >= 0.0f ? box.Extents[ 0 ] : -box.Extents[ 0 ];
        //		var y = Vector3.Dot( box.Axis[ 1 ], planeNormal ) >= 0.0f ? box.Extents[ 1 ] : -box.Extents[ 1 ];
        //		var z = Vector3.Dot( box.Axis[ 2 ], planeNormal ) >= 0.0f ? box.Extents[ 2 ] : -box.Extents[ 2 ];

        //		// There are eight half-diagonal vectors on an OBB. (A half-diagonal is a vector from OBB center to one of its
        //		// corner vertices). Compute the half-diagonal vector that points most in the same direction than the plane normal.
        //		var diag = x * box.Axis[ 0 ] + y * box.Axis[ 1 ] + z * box.Axis[ 2 ];
        //		// nPoint is now the corner point of the OBB that lies "the most" inside the frustum,
        //		// its projection on the plane normal extends the most to the negative direction of that normal.
        //		var nPoint = box.Center - diag;
        //		//		const float3 pPoint = obb.center + diag;

        //		if( Vector3.Dot( nPoint, planeNormal ) + planeDistance >= 0.0f )
        //			return false; // OBB outside frustum.

        //		// If we would like to check whether the OBB is fully inside the frustum, need to compute
        //		// Dot(pPoint, frustum.planes.normal) + frustum.planes.d. If it's < 0 for all planes, OBB is totally
        //		// inside the frustum and doesn't intersect any of the frustum planes.
        //	}

        //	return true; // OBB inside the frustum or part of the OBB intersects the frustum.
        //}

        //!!!!temp
        //public static bool GetOrientedBoxIntersection( Frustum frustum, Box box )
        //{
        //	//ref Bounds box, ref Vector3 right, ref Vector3 up, ref Vector3 forward

        //	var center = box.Center;
        //	var extents = box.Extents;

        //	//!!!!
        //	var right = box.Axis * Vector3.XAxis;
        //	var up = box.Axis * Vector3.YAxis;
        //	var forward = box.Axis * Vector3.ZAxis;
        //	//var forward = box.Axis * Vector3.XAxis;
        //	//var up = box.Axis * Vector3.ZAxis;
        //	//var right = box.Axis * Vector3.YAxis;

        //	var planes = frustum.Planes;
        //	for( int i = 0; i < planes.Length; i++ )
        //	{
        //		var planeNormal = planes[ i ].Normal;
        //		//!!!!
        //		var planeDistance = planes[ i ].Distance;
        //		//var planeDistance = -planes[ i ].Distance;

        //		var r =
        //			extents.X * Math.Abs( Vector3.Dot( planeNormal, right ) ) +
        //			extents.Y * Math.Abs( Vector3.Dot( planeNormal, up ) ) +
        //			extents.Z * Math.Abs( Vector3.Dot( planeNormal, forward ) );

        //		var s = planeNormal.X * center.X + planeNormal.Y * center.Y + planeNormal.Z * center.Z;

        //		if( s + r < -planeDistance )
        //			return false;
        //	}

        //	return true;
        //}



        ///// <summary>
        ///// Fast culling. Not cull everything outside the frustum.
        ///// </summary>
        ///// <param name="bounds"></param>
        ///// <returns></returns>
        //public bool IntersectsFast( ref Bounds bounds )
        //{
        //	if( projection == ProjectionType.Perspective )
        //	{
        //		Vector3 center;
        //		bounds.GetCenter( out center );
        //		//Vec3 center = bounds.GetCenter();

        //		Vector3 extents;
        //		Vector3.Subtract( ref bounds.Maximum, ref center, out extents );
        //		//Vec3 extents = bounds.maximum - center;

        //		//Mat3 transposedAxis;
        //		//_axis.GetTranspose( out transposedAxis );
        //		//Mat3 transposedAxis = axis.GetTranspose();

        //		Vector3 localOrigin;
        //		Vector3 diff;
        //		Vector3.Subtract( ref center, ref origin, out diff );
        //		Matrix3.Multiply( ref diff, ref _axisTransposed, out localOrigin );
        //		//Vec3 localOrigin = ( center - origin ) * transposedAxis;

        //		return !CullLocalBox( localOrigin, extents, ref _axisTransposed );
        //	}
        //	else
        //	{
        //		Box box;
        //		GetOrthoBox( out box );
        //		return box.Intersects( ref bounds );
        //	}
        //}

        ///// <summary>
        ///// Fast culling. Not cull everything outside the frustum.
        ///// </summary>
        ///// <param name="bounds"></param>
        ///// <returns></returns>
        //public bool IntersectsFast( Bounds bounds )
        //{
        //	return IntersectsFast( ref bounds );
        //}

        //!!!!Bugged.
        ///// <summary>
        ///// Fast culling. Not cull everything outside the frustum.
        ///// </summary>
        ///// <param name="box"></param>
        ///// <returns></returns>
        //public bool IntersectsFast( ref Box box )
        //{
        //	if( projection == ProjectionType.Perspective )
        //	{
        //		//Mat3 transposedAxis;
        //		//_axis.GetTranspose( out transposedAxis );
        //		//Mat3 transposedAxis = axis.GetTranspose();

        //		Vector3 localOrigin;
        //		Vector3 diff;
        //		Vector3.Subtract( ref box.Center, ref origin, out diff );
        //		Matrix3.Multiply( ref diff, ref _axisTransposed, out localOrigin );
        //		//Vec3 localOrigin = ( box.center - origin ) * transposedAxis;

        //		Matrix3 localAxis;
        //		Matrix3.Multiply( ref box.Axis, ref _axisTransposed, out localAxis );
        //		//Mat3 localAxis = box.axis * transposedAxis;

        //		return !CullLocalBox( localOrigin, box.Extents, ref localAxis );
        //	}
        //	else
        //	{
        //		Box frustumBox;
        //		GetOrthoBox( out frustumBox );
        //		return frustumBox.Intersects( ref box );
        //	}
        //}

        ///// <summary>
        ///// Fast culling. Not cull everything outside the frustum.
        ///// </summary>
        ///// <param name="box"></param>
        ///// <returns></returns>
        //public bool IntersectsFast( Box box )
        //{
        //	return IntersectsFast( ref box );
        //}

        //bool CullLocalBox( Vector3 localOrigin, Vector3 extents, ref Matrix3 localAxis )
        //{
        //	double d1, d2;
        //	Vector3 testOrigin;
        //	Matrix3 testAxis;

        //	// near plane
        //	d1 = nearDistance - localOrigin.X;
        //	d2 = Math.Abs( extents.X * localAxis.Item0.X ) +
        //		Math.Abs( extents.Y * localAxis.Item1.X ) +
        //		Math.Abs( extents.Z * localAxis.Item2.X );
        //	if( d1 - d2 > 0.0f )
        //		return true;

        //	// far plane
        //	d1 = localOrigin.X - farDistance;
        //	if( d1 - d2 > 0.0f )
        //		return true;

        //	testOrigin = localOrigin;
        //	testAxis = localAxis;

        //	if( testOrigin.Y < 0.0f )
        //	{
        //		testOrigin.Y = -testOrigin.Y;
        //		testAxis[ 0, 1 ] = -testAxis.Item0.Y;
        //		testAxis[ 1, 1 ] = -testAxis.Item1.Y;
        //		testAxis[ 2, 1 ] = -testAxis.Item2.Y;
        //	}

        //	// test left/right planes
        //	d1 = farDistance * testOrigin.Y - halfWidth * testOrigin.X;
        //	d2 = Math.Abs( extents.X * ( farDistance * testAxis.Item0.Y - halfWidth * testAxis.Item0.X ) ) +
        //		Math.Abs( extents.Y * ( farDistance * testAxis.Item1.Y - halfWidth * testAxis.Item1.X ) ) +
        //		Math.Abs( extents.Z * ( farDistance * testAxis.Item2.Y - halfWidth * testAxis.Item2.X ) );
        //	if( d1 - d2 > 0.0f )
        //		return true;

        //	if( testOrigin.Z < 0.0f )
        //	{
        //		testOrigin.Z = -testOrigin.Z;
        //		testAxis[ 0, 2 ] = -testAxis.Item0.Z;
        //		testAxis[ 1, 2 ] = -testAxis.Item1.Z;
        //		testAxis[ 2, 2 ] = -testAxis.Item2.Z;
        //	}

        //	// test up/down planes
        //	d1 = farDistance * testOrigin.Z - halfHeight * testOrigin.X;
        //	d2 = Math.Abs( extents.X * ( farDistance * testAxis.Item0.Z - halfHeight * testAxis.Item0.X ) ) +
        //		Math.Abs( extents.Y * ( farDistance * testAxis.Item1.Z - halfHeight * testAxis.Item1.X ) ) +
        //		Math.Abs( extents.Z * ( farDistance * testAxis.Item2.Z - halfHeight * testAxis.Item2.X ) );
        //	if( d1 - d2 > 0.0f )
        //		return true;

        //	return false;
        //}

        ///// <summary>
        ///// Exact intersection test.
        ///// </summary>
        ///// <param name="bounds"></param>
        ///// <returns></returns>
        //public bool Intersects( ref Bounds bounds )
        //{
        //	if( projection == ProjectionType.Perspective )
        //	{
        //		unsafe
        //		{
        //			Vector3* indexPoints = stackalloc Vector3[ 8 ];
        //			Vector3* cornerVecs = stackalloc Vector3[ 4 ];

        //			Vector3 center;
        //			bounds.GetCenter( out center );
        //			//Vec3 center = bounds.GetCenter();

        //			Vector3 extents;
        //			Vector3.Subtract( ref bounds.Maximum, ref center, out extents );
        //			//Vec3 extents = bounds.Maximum - center;

        //			//Mat3 transposedAxis;
        //			//_axis.GetTranspose( out transposedAxis );
        //			//Mat3 transposedAxis = axis.GetTranspose();

        //			Vector3 localOrigin;
        //			Vector3 diff;
        //			Vector3.Subtract( ref center, ref origin, out diff );
        //			Matrix3.Multiply( ref diff, ref _axisTransposed, out localOrigin );
        //			//Vec3 localOrigin = ( center - origin ) * transposedAxis;

        //			if( CullLocalBox( localOrigin, extents, ref _axisTransposed ) )
        //				return false;

        //			ToIndexPointsAndCornerVecs( indexPoints, cornerVecs );

        //			if( BoundsCullLocalFrustum( ref bounds, this, indexPoints, cornerVecs ) )
        //				return false;

        //			Vector3 p;
        //			p = indexPoints[ 2 ]; indexPoints[ 2 ] = indexPoints[ 3 ]; indexPoints[ 3 ] = p;
        //			p = indexPoints[ 6 ]; indexPoints[ 6 ] = indexPoints[ 7 ]; indexPoints[ 7 ] = p;

        //			if( LocalFrustumIntersectsBounds( indexPoints, ref bounds ) )
        //				return true;

        //			Box box;
        //			box.Center = localOrigin;
        //			box.Extents = extents;
        //			box.Axis = _axisTransposed;
        //			box.ToPoints( indexPoints );
        //			//new Box( localOrigin, extents, transposedAxis ).ToPoints( indexPoints );

        //			if( LocalFrustumIntersectsFrustum( indexPoints, true ) )
        //				return true;
        //		}

        //		return false;
        //	}
        //	else
        //	{
        //		Box box;
        //		GetOrthoBox( out box );
        //		return box.Intersects( ref bounds );
        //	}
        //}

        ///// <summary>
        ///// Exact intersection test.
        ///// </summary>
        ///// <param name="bounds"></param>
        ///// <returns></returns>
        //public bool Intersects( Bounds bounds )
        //{
        //	return Intersects( ref bounds );
        //}

        unsafe void ToIndexPointsAndCornerVecs(Vector3 *indexPoints, Vector3 *cornerVecs)
        {
            Vector3 scaled0, scaled1, scaled2;

            scaled0.X = origin.X + _axis.Item0.X * nearDistance;
            scaled0.Y = origin.Y + _axis.Item0.Y * nearDistance;
            scaled0.Z = origin.Z + _axis.Item0.Z * nearDistance;
            //scaled0 = origin + axis.mat0 * nearDistance;
            Vector3.Multiply(ref _axis.Item1, halfWidth * nearDistance * invFarDistance, out scaled1);
            //scaled1 = axis.mat1 * ( halfWidth * nearDistance * invFarDistance );
            Vector3.Multiply(ref _axis.Item2, halfHeight * nearDistance * invFarDistance, out scaled2);
            //scaled2 = axis.mat2 * ( halfHeight * nearDistance * invFarDistance );
            //Mat3 scaled = new Mat3(
            //   origin + axis.mat0 * nearDistance,
            //   axis.mat1 * ( halfWidth * nearDistance * invFarDistance ),
            //   axis.mat2 * ( halfHeight * nearDistance * invFarDistance ) );

            indexPoints[0] = new Vector3(
                scaled0.X - scaled1.X - scaled2.X,
                scaled0.Y - scaled1.Y - scaled2.Y,
                scaled0.Z - scaled1.Z - scaled2.Z);
            //indexPoints[ 0 ] = scaled0 - scaled1 - scaled2;

            indexPoints[1] = new Vector3(
                scaled0.X - scaled1.X + scaled2.X,
                scaled0.Y - scaled1.Y + scaled2.Y,
                scaled0.Z - scaled1.Z + scaled2.Z);
            //indexPoints[ 1 ] = scaled0 - scaled1 + scaled2;

            indexPoints[2] = new Vector3(
                scaled0.X + scaled1.X - scaled2.X,
                scaled0.Y + scaled1.Y - scaled2.Y,
                scaled0.Z + scaled1.Z - scaled2.Z);
            //indexPoints[ 2 ] = scaled0 + scaled1 - scaled2;

            indexPoints[3] = new Vector3(
                scaled0.X + scaled1.X + scaled2.X,
                scaled0.Y + scaled1.Y + scaled2.Y,
                scaled0.Z + scaled1.Z + scaled2.Z);
            //indexPoints[ 3 ] = scaled0 + scaled1 + scaled2;

            //indexPoints[ 0 ] = scaled0 - scaled1;
            //indexPoints[ 2 ] = scaled0 + scaled1;
            //indexPoints[ 1 ] = indexPoints[ 0 ] + scaled2;
            //indexPoints[ 3 ] = indexPoints[ 2 ] + scaled2;
            //indexPoints[ 0 ] -= scaled2;
            //indexPoints[ 2 ] -= scaled2;

            Vector3.Multiply(ref _axis.Item0, farDistance, out scaled0);
            //scaled0 = axis.mat0 * farDistance;
            Vector3.Multiply(ref _axis.Item1, halfWidth, out scaled1);
            //scaled1 = axis.mat1 * halfWidth;
            Vector3.Multiply(ref _axis.Item2, halfHeight, out scaled2);
            //scaled2 = axis.mat2 * halfHeight;

            cornerVecs[0] = new Vector3(
                scaled0.X - scaled1.X - scaled2.X,
                scaled0.Y - scaled1.Y - scaled2.Y,
                scaled0.Z - scaled1.Z - scaled2.Z);
            //cornerVecs[ 0 ] = scaled0 - scaled1 - scaled2;

            cornerVecs[2] = new Vector3(
                scaled0.X + scaled1.X - scaled2.X,
                scaled0.Y + scaled1.Y - scaled2.Y,
                scaled0.Z + scaled1.Z - scaled2.Z);
            //cornerVecs[ 2 ] = scaled0 + scaled1 - scaled2;

            cornerVecs[1] = new Vector3(
                scaled0.X - scaled1.X + scaled2.X,
                scaled0.Y - scaled1.Y + scaled2.Y,
                scaled0.Z - scaled1.Z + scaled2.Z);
            //cornerVecs[ 1 ] = scaled0 - scaled1 + scaled2;

            cornerVecs[3] = new Vector3(
                scaled0.X + scaled1.X + scaled2.X,
                scaled0.Y + scaled1.Y + scaled2.Y,
                scaled0.Z + scaled1.Z + scaled2.Z);
            //cornerVecs[ 3 ] = scaled0 + scaled1 + scaled2;

            //cornerVecs[ 0 ] = scaled0 - scaled1;
            //cornerVecs[ 2 ] = scaled0 + scaled1;
            //cornerVecs[ 1 ] = cornerVecs[ 0 ] + scaled2;
            //cornerVecs[ 3 ] = cornerVecs[ 2 ] + scaled2;
            //cornerVecs[ 0 ] -= scaled2;
            //cornerVecs[ 2 ] -= scaled2;

            Vector3.Add(ref cornerVecs[0], ref origin, out indexPoints[4]);
            //indexPoints[ 4 ] = cornerVecs[ 0 ] + origin;
            Vector3.Add(ref cornerVecs[1], ref origin, out indexPoints[5]);
            //indexPoints[ 5 ] = cornerVecs[ 1 ] + origin;
            Vector3.Add(ref cornerVecs[2], ref origin, out indexPoints[6]);
            //indexPoints[ 6 ] = cornerVecs[ 2 ] + origin;
            Vector3.Add(ref cornerVecs[3], ref origin, out indexPoints[7]);
            //indexPoints[ 7 ] = cornerVecs[ 3 ] + origin;
        }
Beispiel #27
0
 private extern static unsafe void SDK_PhyController_SetFootPosition(NativePointer self, Vector3 *position);
Beispiel #28
0
        static unsafe bool BoundsCullLocalFrustum(ref Bounds bounds, Frustum localFrustum, Vector3 *indexPoints, Vector3 *cornerVecs)
        {
            int    index;
            double dx, dy, dz;

            dy     = -localFrustum._axis.Item1.X;
            dz     = -localFrustum._axis.Item2.X;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = -cornerVecs[index].X;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].X < bounds.Minimum.X)
            {
                return(true);
            }

            dy     = localFrustum._axis.Item1.X;
            dz     = localFrustum._axis.Item2.X;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = cornerVecs[index].X;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].X > bounds.Maximum.X)
            {
                return(true);
            }

            dy     = -localFrustum._axis.Item1.Y;
            dz     = -localFrustum._axis.Item2.Y;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = -cornerVecs[index].Y;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].Y < bounds.Minimum.Y)
            {
                return(true);
            }

            dy     = localFrustum._axis.Item1.Y;
            dz     = localFrustum._axis.Item2.Y;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = cornerVecs[index].Y;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].Y > bounds.Maximum.Y)
            {
                return(true);
            }

            dy     = -localFrustum._axis.Item1.Z;
            dz     = -localFrustum._axis.Item2.Z;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = -cornerVecs[index].Z;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].Z < bounds.Minimum.Z)
            {
                return(true);
            }

            dy     = localFrustum._axis.Item1.Z;
            dz     = localFrustum._axis.Item2.Z;
            index  = (FLOATSIGNBITSET(dy) << 1) | FLOATSIGNBITSET(dz);
            dx     = cornerVecs[index].Z;
            index |= (FLOATSIGNBITSET(dx) << 2);

            if (indexPoints[index].Z > bounds.Maximum.Z)
            {
                return(true);
            }

            return(false);
        }
Beispiel #29
0
 public void GetStaticBoundsPointers(int index, out Vector3 *minPointer, out Vector3 *maxPointer)
 {
     GetBoundsPointers(index, ref StaticTree, out minPointer, out maxPointer);
 }
Beispiel #30
0
        private void RandomizeObject(SuperObject *superObject)
        {
            Perso *perso = (Perso *)superObject->engineObjectPtr;

            Brain *brain = perso->brain;

            if (brain == null)
            {
                return;
            }

            DsgMem *dsgMem = brain->mind->dsgMem;

            if (dsgMem == null)
            {
                return;
            }

            DsgVar *dsgVars = *dsgMem->dsgVar;

            for (int i = 0; i < dsgVars->dsgVarInfosLength; i++)
            {
                if (random.NextDouble() > randomizeChance)
                {
                    continue;
                }

                DsgVarInfo info = dsgVars->dsgVarInfos[i];
                DsgVarType type = info.type;

                byte *buffer = dsgMem->memoryBufferCurrent;
                int   ptr    = (int)buffer + info.offsetInBuffer;

                switch (type)
                {
                case DsgVarType.Boolean:
                    *(bool *)ptr = random.Next(0, 2) == 0;
                    break;

                case DsgVarType.Byte:
                    *(sbyte *)ptr = (sbyte)random.Next(-127, 128);
                    break;

                case DsgVarType.UByte:
                    *(byte *)ptr = (byte)random.Next(0, 256);
                    break;

                case DsgVarType.Short:
                    *(short *)ptr = (short)random.Next();
                    break;

                case DsgVarType.UShort:
                    *(ushort *)ptr = (ushort)random.Next();
                    break;

                case DsgVarType.Int:
                    *(int *)ptr = random.Next();
                    break;

                case DsgVarType.UInt:
                    *(uint *)ptr = (uint)random.Next();
                    break;

                case DsgVarType.Float:
                    *(float *)ptr += random.RandomFloat(-10f, 10f);
                    break;

                case DsgVarType.Vector:
                    Vector3 *vector = (Vector3 *)ptr;
                    vector->X += random.RandomFloat(-10f, 10f);
                    vector->Y += random.RandomFloat(-10f, 10f);
                    vector->Z += random.RandomFloat(-10f, 10f);
                    break;

                case DsgVarType.IntegerArray:
                    int *array = brain->mind->GetDsgVar <int>(i, buffer, out byte size);
                    for (int j = 0; j < size; j++)
                    {
                        array[j] = random.Next();
                    }
                    break;
                }
            }
        }