Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rayOrigin"></param>
        /// <param name="rayEnd"></param>
        /// <returns></returns>
        public override int Prepare(ref Vector3 rayOrigin, ref Vector3 rayEnd)
        {
            JBBox box = JBBox.SmallBox;

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

            return(this.Prepare(ref box));
        }
Exemplo n.º 2
0
            public void UpdateBoundingBox()
            {
                boundingBox = JBBox.SmallBox;
                boundingBox.AddPoint(ref owner.points[indices.I0].position);
                boundingBox.AddPoint(ref owner.points[indices.I1].position);
                boundingBox.AddPoint(ref owner.points[indices.I2].position);

                boundingBox.Min -= new JVector(owner.triangleExpansion);
                boundingBox.Max += new JVector(owner.triangleExpansion);
            }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rayOrigin"></param>
        /// <param name="rayDelta"></param>
        /// <returns></returns>
        public override int Prepare(ref JVector rayOrigin, ref JVector rayDelta)
        {
            JBBox box = JBBox.SmallBox;

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

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

            return(this.Prepare(ref box));
        }
Exemplo n.º 4
0
        public virtual void Update(float timestep)
        {
            active = false;

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

            if (!active)
            {
                return;
            }

            box    = JBBox.SmallBox;
            volume = 0.0f;
            mass   = 0.0f;

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

            box.Min -= new JVector(TriangleExpansion);
            box.Max += new JVector(TriangleExpansion);

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

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

                linVel *= 1.0f / 3.0f;

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

                JVector v1 = points[t.indices.I0].position;
                JVector v2 = points[t.indices.I1].position;
                JVector 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 /= 6.0f;

            AddPressureForces(timestep);
        }