/// <summary>
        ///
        /// </summary>
        /// <param name="rayOrigin"></param>
        /// <param name="rayEnd"></param>
        /// <returns></returns>
        public override int Prepare(ref TSVector rayOrigin, ref TSVector rayEnd)
        {
            TSBBox box = TSBBox.SmallBox;

            box.AddPoint(ref rayOrigin);
            box.AddPoint(ref rayEnd);

            return(this.Prepare(ref box));
        }
示例#2
0
            public void UpdateBoundingBox()
            {
                boundingBox = TSBBox.SmallBox;
                boundingBox.AddPoint(owner.points[indices.I0].position);
                boundingBox.AddPoint(owner.points[indices.I1].position);
                boundingBox.AddPoint(owner.points[indices.I2].position);

                boundingBox.min -= new TSVector(owner.triangleExpansion);
                boundingBox.max += new TSVector(owner.triangleExpansion);
            }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rayOrigin"></param>
        /// <param name="rayDelta"></param>
        /// <returns></returns>
        public override int Prepare(ref TSVector rayOrigin, ref TSVector rayDelta)
        {
            TSBBox box = TSBBox.SmallBox;

            #region RayEnd + Expand Spherical
            TSVector rayEnd;
            TSVector.Normalize(rayDelta, out rayEnd);
            rayEnd = rayOrigin + rayDelta + rayEnd * sphericalExpansion;
            #endregion

            box.AddPoint(rayOrigin);
            box.AddPoint(rayEnd);

            return(this.Prepare(ref box));
        }
示例#4
0
        public virtual void Update(FP timestep)
        {
            active = false;

            foreach (MassPoint point in points)
            {
                if (point.isActive && !point.isStatic)
                {
                    active = true; break;
                }
            }

            if (!active)
            {
                return;
            }

            box    = TSBBox.SmallBox;
            volume = FP.Zero;
            mass   = FP.Zero;

            foreach (MassPoint point in points)
            {
                mass += point.Mass;
                box.AddPoint(point.position);
            }

            box.min -= new TSVector(TriangleExpansion);
            box.max += new TSVector(TriangleExpansion);

            foreach (Triangle t in triangles)
            {
                // Update bounding box and move proxy in dynamic tree.
                t.UpdateBoundingBox();

                TSVector linVel = t.VertexBody1.linearVelocity +
                                  t.VertexBody2.linearVelocity +
                                  t.VertexBody3.linearVelocity;

                linVel *= FP.One / (3 * FP.One);

                dynamicTree.MoveProxy(t.dynamicTreeID, ref t.boundingBox, linVel * timestep);

                TSVector v1 = points[t.indices.I0].position;
                TSVector v2 = points[t.indices.I1].position;
                TSVector v3 = points[t.indices.I2].position;

                volume -= ((v2.y - v1.y) * (v3.z - v1.z) -
                           (v2.z - v1.z) * (v3.y - v1.y)) * (v1.x + v2.x + v3.x);
            }

            volume /= (FP)6;

            AddPressureForces(timestep);
        }