コード例 #1
0
        /// <summary>
        ///    Retrieves the axis-aligned bounding box for this object in world coordinates.
        /// </summary>
        /// <returns></returns>
        public override AxisAlignedBox GetWorldBoundingBox(bool derive)
        {
            if (derive && this.BoundingBox != null)
            {
                worldAABB = this.BoundingBox;
                worldAABB.Transform(this.ParentFullTransform);
                ComputeContainedWorldAABBs();
            }

            return(worldAABB);
        }
コード例 #2
0
        /* Update the octreezone specific data for a node */

        public override void update()
        {
            this.mOctreeWorldAABB.IsNull = true;

            // need to use object iterator here.
            foreach (PCZSceneNode m in mAssociatedNode.Children)
            {
                // merge world bounds of object
                //mOctreeWorldAABB.Merge(m.GetWorldBoundingBox(true));
                AxisAlignedBox b = m.WorldAABB;
                b.Transform(m.Parent.FullTransform);
                this.mOctreeWorldAABB.Merge(b);
            }

            // update the Octant for the node because things might have moved.
            // if it hasn't been added to the octree, add it, and if has moved
            // enough to leave it's current node, we'll update it.
            if (!this.mOctreeWorldAABB.IsNull)
            {
                ((OctreeZone)mAssociatedZone).UpdateNodeOctant(this);
            }
        }
コード例 #3
0
        protected void UpdateBounds()
        {
            if (parentNode != null && (boundsAutoUpdate || boundsUpdateTime > 0.0f))
            {
                Vector3 min;
                Vector3 max;
                if (!boundsAutoUpdate)
                {
                    // We're on a limit, grow rather than reset each time
                    // so that we pick up the worst case scenario
                    min = worldAABB.Minimum;
                    max = worldAABB.Maximum;
                }
                else
                {
                    min.x = min.y = min.z = float.PositiveInfinity;
                    max.x = max.y = max.z = float.NegativeInfinity;
                }
                Vector3 halfScale      = Vector3.UnitScale * 0.5f;
                Vector3 defaultPadding =
                    halfScale * (float)Math.Max(defaultHeight, defaultWidth);
                foreach (Particle p in activeParticles)
                {
                    if (p.HasOwnDimensions)
                    {
                        Vector3 padding =
                            halfScale * (float)Math.Max(p.Width, p.Height);
                        min.Floor(p.Position - padding);
                        max.Ceil(p.Position + padding);
                    }
                    else
                    {
                        min.Floor(p.Position - defaultPadding);
                        max.Ceil(p.Position + defaultPadding);
                    }
                }
                worldAABB.SetExtents(min, max);

                if (activeParticles.Count > 0)
                {
                    if (localSpace)
                    {
                        // Merge calculated box with current AABB to preserve any user-set AABB
                        aab = (AxisAlignedBox)worldAABB.Clone();
                    }
                    else
                    {
                        // We've already put particles in world space to decouple them from the
                        // node transform, so reverse transform back since we're expected to
                        // provide a local AABB
                        AxisAlignedBox newAABB = (AxisAlignedBox)worldAABB.Clone();
                        newAABB.Transform(parentNode.FullTransform.Inverse());

                        // Merge calculated box with current AABB to preserve any user-set AABB
                        aab = newAABB;
                    }
                }

                parentNode.NeedUpdate();
            }
        }