当前位置: 首页>>代码示例>>C#>>正文


C# BoundingBoxD.Include方法代码示例

本文整理汇总了C#中BoundingBoxD.Include方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD.Include方法的具体用法?C# BoundingBoxD.Include怎么用?C# BoundingBoxD.Include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingBoxD的用法示例。


在下文中一共展示了BoundingBoxD.Include方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateWorldAABB

        public override void UpdateWorldAABB()
        {
            CulledObjects.GetAll(m_list, true);

            m_localAABB = BoundingBoxD.CreateInvalid();
            

            foreach (var element in m_list)
            {
                m_localAABB = m_localAABB.Include(element.WorldAABB);
            }

            m_aabb = m_localAABB.Transform(ref m_worldMatrix);

            base.UpdateWorldAABB();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:16,代码来源:MyManualCullableRenderObject.cs

示例2: AddItem

        /// <summary>
        /// Adds environment item to internal collections. Creates render and physics data. 
        /// </summary>
        /// <returns>True if successfully added, otherwise false.</returns>
        private bool AddItem(
            MyEnvironmentItemDefinition itemDefinition, 
            ref MatrixD worldMatrix, 
            ref BoundingBoxD aabbWorld, bool silentOverlaps = false)
        {
            if (!MyFakes.ENABLE_ENVIRONMENT_ITEMS)
                return true;

            Debug.Assert(m_definition.ContainsItemDefinition(itemDefinition),
                String.Format("Environment item with definition '{0}' not found in class '{1}'", itemDefinition.Id, m_definition.Id));
            if (!m_definition.ContainsItemDefinition(itemDefinition))
            {
                return false;
            }

            if (itemDefinition.Model == null)
                return false;

            //MyDefinitionId defId = new MyDefinitionId(envItemObjectBuilderType, subtypeId.ToString());
            int modelId = MyEnvironmentItems.GetModelId(itemDefinition.Id.SubtypeId);
            string modelName = MyModel.GetById(modelId);

            MyModel model = MyModels.GetModelOnlyData(modelName);
            if (model == null)
            {
                //Debug.Fail(String.Format("Environment item model of '{0}' not found, skipping the item...", itemDefinition.Id));
                return false;
            }

            CheckModelConsistency(itemDefinition);

            int localId = worldMatrix.Translation.GetHashCode();

            if (m_itemsData.ContainsKey(localId))
            {
                if (!silentOverlaps)
                {
                    Debug.Fail("More items on same place! " + worldMatrix.Translation.ToString());
                    MyLog.Default.WriteLine("WARNING: items are on the same place.");
                }
                return false;
            }

            MyEnvironmentItemData data = new MyEnvironmentItemData()
            {
                Id = localId,
                SubtypeId = itemDefinition.Id.SubtypeId,
                Transform = new MyTransformD(ref worldMatrix),
                Enabled = true,
                SectorInstanceId = -1,
                Model = model,
            };

            //Preload split planes
            //VRageRender.MyRenderProxy.PreloadMaterials(model.AssetName); 

            aabbWorld.Include(model.BoundingBox.Transform(worldMatrix));

            MatrixD transform = data.Transform.TransformMatrix;
            float sectorSize = MyFakes.ENVIRONMENT_ITEMS_ONE_INSTANCEBUFFER ? 20000 : m_definition.SectorSize;

            Vector3I sectorId = MyEnvironmentSector.GetSectorId(transform.Translation - CellsOffset, sectorSize);
            MyEnvironmentSector sector;
            if (!m_sectors.TryGetValue(sectorId, out sector))
            {
                sector = new MyEnvironmentSector(sectorId, sectorId * sectorSize + CellsOffset);
                m_sectors.Add(sectorId, sector);
            }

            // Adds instance of the given model. Local matrix specified might be changed internally in renderer.

            MatrixD sectorOffsetInv = MatrixD.CreateTranslation(-sectorId * sectorSize - CellsOffset);
            Matrix transformL = (Matrix)(data.Transform.TransformMatrix * sectorOffsetInv);

            data.SectorInstanceId = sector.AddInstance(itemDefinition.Id.SubtypeId, modelId, localId, ref transformL, model.BoundingBox, m_instanceFlags, m_definition.MaxViewDistance);
            data.Transform = new MyTransformD(transform);
            m_itemsData.Add(localId, data);

            if (ItemAdded != null)
            {
                ItemAdded(this,
                    new ItemInfo()
                    {
                        LocalId = localId,
                        SubtypeId = data.SubtypeId,
                        Transform = data.Transform,
                    });
            }

            return true;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:95,代码来源:MyEnvironmentItems.cs

示例3: UpdateBoundingFrustum

        void UpdateBoundingFrustum()
        {
            //  Update frustum
            BoundingFrustum.Matrix = ViewProjectionMatrix;

            //  Update bounding box
            BoundingBox = BoundingBoxD.CreateInvalid();
            BoundingBox.Include(ref BoundingFrustum);

            //  Update bounding sphere
            BoundingSphere = MyUtils.GetBoundingSphereFromBoundingBox(ref BoundingBox);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:12,代码来源:MyCamera.cs

示例4: AddItem

        /// <summary>
        /// Adds environment item to internal collections. Creates render and physics data. 
        /// </summary>
        /// <returns>True if successfully added, otherwise false.</returns>
        private bool AddItem(
            MyEnvironmentItemDefinition itemDefinition, 
            ref MatrixD worldMatrix, 
            ref BoundingBoxD aabbWorld,
            HkStaticCompoundShape sectorRootShape, 
            Dictionary<MyStringHash, HkShape> subtypeIdToShape,
            int localModelId = MAIN_MODEL_LOCAL_ID)
        {
            if (!MyFakes.ENABLE_ENVIRONMENT_ITEMS)
                return true;

            Debug.Assert(m_definition.ContainsItemDefinition(itemDefinition),
                String.Format("Environment item with definition '{0}' not found in class '{1}'", itemDefinition.Id, m_definition.Id));
            if (!m_definition.ContainsItemDefinition(itemDefinition))
            {
                return false;
            }

            if (itemDefinition.Model == null)
                return false;

            //MyDefinitionId defId = new MyDefinitionId(envItemObjectBuilderType, subtypeId.ToString());
            int modelId = MyEnvironmentItems.GetModelId(itemDefinition.Id.SubtypeId, localModelId);
            string modelName = MyModel.GetById(modelId);

            MyModel model = MyModels.GetModelOnlyData(modelName);
            if (model == null)
            {
                //Debug.Fail(String.Format("Environment item model of '{0}' not found, skipping the item...", itemDefinition.Id));
                return false;
            }

            CheckModelConsistency(itemDefinition);

            int localId = worldMatrix.Translation.GetHashCode();

            MyEnvironmentItemData data = new MyEnvironmentItemData()
            {
                Id = localId,
                SubtypeId = itemDefinition.Id.SubtypeId,
                Transform = new MyTransformD(ref worldMatrix),
                Enabled = true,
                SectorInstanceId = -1,
                ModelId = modelId,
            };

            //Preload split planes
            //VRageRender.MyRenderProxy.PreloadMaterials(model.AssetName); 

            aabbWorld.Include(model.BoundingBox.Transform(worldMatrix));

            MatrixD transform = data.Transform.TransformMatrix;

            Vector3I sectorId = MyEnvironmentSector.GetSectorId(transform.Translation - CellsOffset, m_definition.SectorSize);
            MyEnvironmentSector sector;
            if (!m_sectors.TryGetValue(sectorId, out sector))
            {
                sector = new MyEnvironmentSector(sectorId, sectorId * m_definition.SectorSize + CellsOffset);
                m_sectors.Add(sectorId, sector);
            }

            // Adds instance of the given model. Local matrix specified might be changed internally in renderer.

            MatrixD sectorOffset = MatrixD.CreateTranslation(-sectorId * m_definition.SectorSize - CellsOffset);
            Matrix transformL = (Matrix)(transform * sectorOffset);
            data.SectorInstanceId = sector.AddInstance(itemDefinition.Id.SubtypeId, data.ModelId, localId, ref transformL, model.BoundingBox, m_instanceFlags, m_definition.MaxViewDistance);

            int physicsShapeInstanceId;

            if (AddPhysicsShape(data.SubtypeId, model, ref transform, sectorRootShape, subtypeIdToShape, out physicsShapeInstanceId))
            {
                // Map to data index - note that itemData is added after this to its list!
                m_physicsShapeInstanceIdToLocalId[physicsShapeInstanceId] = localId;
                m_localIdToPhysicsShapeInstanceId[localId] = physicsShapeInstanceId;
            }

            data.Transform = new MyTransformD(transform);

            if (m_itemsData.ContainsKey(localId))
            {
                //Debug.Fail("More items on same place! " + transform.Translation.ToString());
            }
            else
            {
                m_itemsData.Add(localId, data);
            }

            if (ItemAdded != null)
            {
                ItemAdded(this,
                    new ItemInfo()
                    {
                        LocalId = localId,
                        SubtypeId = data.SubtypeId,
                        Transform = data.Transform,
                    });
//.........这里部分代码省略.........
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:101,代码来源:MyEnvironmentItems.cs

示例5: TestVoxelNavmeshTriangle

        public void TestVoxelNavmeshTriangle(ref Vector3D a, ref Vector3D b, ref Vector3D c, List<MyCubeGrid> gridsToTest, List<MyGridPathfinding.CubeId> linkCandidatesOutput, out bool intersecting)
        {
            ProfilerShort.Begin("TestVoxelNavmeshTriangle");

            ProfilerShort.Begin("Triangle-obstacle tests");
            Vector3D s = (a + b + c) / 3.0;
            if (m_obstacles.IsInObstacle(s))
            {
                intersecting = true;
                ProfilerShort.End();
                ProfilerShort.End();
                return;
            }
            ProfilerShort.End();

            BoundingBoxD triBB;
            Vector3D aLocal, bLocal, cLocal, gLocal;
            Vector3D g = Vector3D.Zero;
            if (MyPerGameSettings.NavmeshPresumesDownwardGravity)
            {
                g = Vector3.Down * 2.0f;
            }

            m_tmpLinkCandidates.Clear();

            intersecting = false;
            foreach (var grid in gridsToTest)
            {
                MatrixD mat = grid.PositionComp.WorldMatrixNormalizedInv;

                Vector3D.Transform(ref a, ref mat, out aLocal);
                Vector3D.Transform(ref b, ref mat, out bLocal);
                Vector3D.Transform(ref c, ref mat, out cLocal);
                Vector3D.TransformNormal(ref g, ref mat, out gLocal);

                triBB = new BoundingBoxD(Vector3D.MaxValue, Vector3D.MinValue);
                triBB.Include(ref aLocal, ref bLocal, ref cLocal);
                
                Vector3I min = grid.LocalToGridInteger(triBB.Min);
                Vector3I max = grid.LocalToGridInteger(triBB.Max);
                Vector3I pos = min - Vector3I.One;
                Vector3I max2 = max + Vector3I.One;
                for (var it = new Vector3I_RangeIterator(ref pos, ref max2); it.IsValid(); it.GetNext(out pos))
                {
                    if (grid.GetCubeBlock(pos) != null)
                    {
                        Vector3 largeMin = (pos - Vector3.One) * grid.GridSize;
                        Vector3 largeMax = (pos + Vector3.One) * grid.GridSize;
                        Vector3 smallMin = (pos - Vector3.Half) * grid.GridSize;
                        Vector3 smallMax = (pos + Vector3.Half) * grid.GridSize;
                        BoundingBoxD largeBb = new BoundingBoxD(largeMin, largeMax);
                        BoundingBoxD bb = new BoundingBoxD(smallMin, smallMax);

                        largeBb.Include(largeMin + gLocal);
                        largeBb.Include(largeMax + gLocal);
                        bb.Include(smallMin + gLocal);
                        bb.Include(smallMax + gLocal);

                        ProfilerShort.Begin("Triangle intersection tests");
                        if (largeBb.IntersectsTriangle(ref aLocal, ref bLocal, ref cLocal))
                        {
                            if (bb.IntersectsTriangle(ref aLocal, ref bLocal, ref cLocal))
                            {
                                intersecting = true;
                                ProfilerShort.End();
                                break;
                            }
                            else
                            {
                                int dx = Math.Min(Math.Abs(min.X - pos.X), Math.Abs(max.X - pos.X));
                                int dy = Math.Min(Math.Abs(min.Y - pos.Y), Math.Abs(max.Y - pos.Y));
                                int dz = Math.Min(Math.Abs(min.Z - pos.Z), Math.Abs(max.Z - pos.Z));
                                if ((dx + dy + dz) < 3)
                                    m_tmpLinkCandidates.Add(new MyGridPathfinding.CubeId() { Grid = grid, Coords = pos });
                            }
                        }
                        ProfilerShort.End();
                    }
                }

                if (intersecting) break;
            }

            if (!intersecting)
            {
                for (int i = 0; i < m_tmpLinkCandidates.Count; ++i)
                {
                    linkCandidatesOutput.Add(m_tmpLinkCandidates[i]);
                }
            }
            m_tmpLinkCandidates.Clear();

            ProfilerShort.End();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:94,代码来源:MyNavmeshCoordinator.cs

示例6: GetSafeBoundingBoxForPlayers

        private static void GetSafeBoundingBoxForPlayers(Vector3D start, double spawnDistance, out BoundingBoxD output)
        {
            double tolerance = 10.0f;
            BoundingSphereD sphere = new BoundingSphereD(start, tolerance);

            var players = MySession.Static.Players.GetOnlinePlayers();
            bool tryIncludeOtherPlayers = true;

            // We have to try adding other players until the bounding sphere stays the same
            while (tryIncludeOtherPlayers)
            {
                tryIncludeOtherPlayers = false;
                foreach (var player in players)
                {
                    Vector3D playerPosition = player.GetPosition();
                    double distanceFromSphere = (sphere.Center - playerPosition).Length() - sphere.Radius;

                    if (distanceFromSphere <= 0.0) continue;
                    if (distanceFromSphere > spawnDistance * 2.0f) continue;

                    sphere.Include(new BoundingSphereD(playerPosition, tolerance));
                    tryIncludeOtherPlayers = true;
                }
            }

            sphere.Radius += spawnDistance;
            output = new BoundingBoxD(sphere.Center - new Vector3D(sphere.Radius), sphere.Center + new Vector3D(sphere.Radius));

            var entities = MyEntities.GetEntitiesInAABB(ref output);
            foreach (var entity in entities)
            {
                if (entity is MyCubeGrid)
                {
                    var cubeGrid = entity as MyCubeGrid;
                    if (cubeGrid.IsStatic)
                    {
                        Vector3D gridPosition = cubeGrid.PositionComp.GetPosition();

                        // If grid is close to picked player we need to include it's "safe" bounding box for spawning ships,
                        // so cargo ships don't spawn near it.

                        output.Include(new BoundingBoxD(new Vector3D(gridPosition - spawnDistance), new Vector3D(gridPosition + spawnDistance)));
                    }
                }
            }
            entities.Clear();
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:47,代码来源:MyNeutralShipSpawner.cs

示例7: UpdateRenderObject

        protected void UpdateRenderObject()
        {
            m_actualWorldAABB = BoundingBoxD.CreateInvalid();

            if (AnimationController.CharacterBones != null)
            for (int i = 1; i < Model.Bones.Length; i++)
            {
                Vector3D p1 = Vector3D.Transform(AnimationController.CharacterBones[i].Parent.AbsoluteTransform.Translation, WorldMatrix);
                Vector3D p2 = Vector3D.Transform(AnimationController.CharacterBones[i].AbsoluteTransform.Translation, WorldMatrix);

                m_actualWorldAABB.Include(ref p1);
                m_actualWorldAABB.Include(ref p2);
            }

            ContainmentType containmentType;
            m_aabb.Contains(ref m_actualWorldAABB, out containmentType);
            if (containmentType != ContainmentType.Contains)
            {
                m_actualWorldAABB.Inflate(0.5f);
                MatrixD worldMatrix = WorldMatrix;
                VRageRender.MyRenderProxy.UpdateRenderObject(Render.RenderObjectIDs[0], ref worldMatrix, false, m_actualWorldAABB);
                m_aabb = m_actualWorldAABB;
            }
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:24,代码来源:MySkinnedEntity.cs

示例8: CalculateAABB

        private static void CalculateAABB(ref BoundingBoxD bbox, out float scaleZ, out float scaleXY, ref Vector3D position, ref Vector3D direction, ref Vector3D up, float reflectorConeMaxAngleCos, float reflectorRange)
        {
            scaleZ = 1;
            scaleXY = 1;
            float cosAngle = 1 - reflectorConeMaxAngleCos;
            scaleZ = reflectorRange;
            // Calculate cone side (hypotenuse of triangle)
            float side = reflectorRange / cosAngle;
            // Calculate cone bottom scale (Pythagoras theorem)
            scaleXY = (float)System.Math.Sqrt(side * side - reflectorRange * reflectorRange) * 2;

            if (scaleXY == 0)
                scaleXY = 1;

            up = MyUtils.Normalize(up);
            Vector3 coneSideDirection = Vector3.Cross(up, direction);
            coneSideDirection = MyUtils.Normalize(coneSideDirection);
            Vector3D coneCenter = position + direction * scaleZ;
            Vector3D pt1 = coneCenter + coneSideDirection * scaleXY / 2 + up * scaleXY / 2;
            Vector3D pt2 = coneCenter - coneSideDirection * scaleXY / 2 + up * scaleXY / 2;
            Vector3D pt3 = coneCenter + coneSideDirection * scaleXY / 2 - up * scaleXY / 2;
            Vector3D pt4 = coneCenter - coneSideDirection * scaleXY / 2 - up * scaleXY / 2;

            bbox = BoundingBoxD.CreateInvalid();
            bbox = bbox.Include(ref position);
            //bbox = bbox.Include(ref coneCenter);
            bbox = bbox.Include(ref pt1);
            bbox = bbox.Include(ref pt2);
            bbox = bbox.Include(ref pt3);
            bbox = bbox.Include(ref pt4);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:31,代码来源:MyRenderLight.cs

示例9: Update

        public bool Update()
        {
            if (!Enabled)
                return AutoDelete; //efect is not enabled at all and must be deleted

            System.Diagnostics.Debug.Assert(WorldMatrix != MatrixD.Zero, "Effect world matrix was not set!");

            if (!m_isPreloading && !m_wasPreloaded && m_preload > 0)
            {
                m_isPreloading = true;

                // TODO: Optimize (preload causes lags, depending on preload size, it's from 0 ms to 85 ms)
                while (m_elapsedTime < m_preload)
                {
                    Update();
                }

                m_isPreloading = false;
                m_wasPreloaded = true;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("ParticleEffect-Update");

            if (!m_isPreloading && IsInFrustum)
            {
                MyPerformanceCounter.PerCameraDrawWrite.ParticleEffectsDrawn++;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("ParticleEffect-UpdateGen");

            m_elapsedTime += MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            //m_distance = MySector.MainCamera.GetDistanceWithFOV(WorldMatrix.Translation) / (100.0f); //precalculate for LODs
            m_distance = (float)Vector3D.Distance(MyTransparentGeometry.Camera.Translation, WorldMatrix.Translation) / (100.0f); //precalculate for LODs
            m_particlesCount = 0;
            m_birthRate = 0;
            m_AABB = BoundingBoxD.CreateInvalid();


            //if (CalculateDeltaMatrix)
            //{
                //DeltaMatrix = Matrix.Invert(m_lastWorldMatrix) * m_worldMatrix;
            //}
           

            if (Velocity != Vector3.Zero)
            {
                var position = m_worldMatrix.Translation;
                position.X += Velocity.X * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                position.Y += Velocity.Y * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                position.Z += Velocity.Z * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                m_worldMatrix = MatrixD.CreateWorld(position, Vector3D.Normalize(Velocity), m_worldMatrix.Up);
            }

            //if (RenderCounter == 0 || ((MyRender.RenderCounter - RenderCounter) < FRAMES_TO_SKIP)) //more than FRAMES_TO_SKIP frames consider effect as invisible
            {
                foreach (MyParticleGeneration generation in m_generations)
                {
                    generation.EffectMatrix = WorldMatrix;
                    generation.Update();
                    m_particlesCount += generation.GetParticlesCount();
                    m_birthRate += generation.GetBirthRate();

                    BoundingBoxD bbox = generation.GetAABB();
                    m_AABB = m_AABB.Include(ref bbox);
                }


                if (m_particlesCount > 0)
                    m_hasShownSomething = true;

                //TODO
                IsInFrustum = true; // MySector.MainCamera.IsInFrustum(ref m_AABB);
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            m_lastWorldMatrix = m_worldMatrix;

            if (((m_particlesCount == 0 && HasShownSomething())
                || (m_particlesCount == 0 && m_birthRate == 0.0f))
                && AutoDelete && !m_isPreloading)
            {   //Effect was played and has to be deleted
                return true;
            }

            if (!m_isPreloading && OnUpdate != null)
                OnUpdate(this, null);

            return false;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:92,代码来源:MyParticleEffect.cs

示例10: CalcBox

 private void CalcBox()
 {
     m_boundingBox = new BoundingBoxD();
     m_boundingBox.Include(m_line.From);
     m_boundingBox.Include(m_line.To);
     m_calculatedBox = true;
 }
开发者ID:Souper07,项目名称:Autopilot,代码行数:7,代码来源:LineSegmentD.cs

示例11: Update

        public bool Update()
        {
            if (!Enabled)
                return AutoDelete; //efect is not enabled at all and must be deleted
            if (WorldMatrix == MatrixD.Zero)
                return true;

            System.Diagnostics.Debug.Assert(WorldMatrix != MatrixD.Zero, "Effect world matrix was not set!");

            if (!m_isPreloading && !m_wasPreloaded && m_preload > 0)
            {
                m_isPreloading = true;

                // TODO: Optimize (preload causes lags, depending on preload size, it's from 0 ms to 85 ms)
                while (m_elapsedTime < m_preload)
                {
                    Update();
                }

                m_isPreloading = false;
                m_wasPreloaded = true;
            }


            if (MyParticlesManager.CalculateGravityInPoint != null && m_updateCounter == 0)
                Gravity = MyParticlesManager.CalculateGravityInPoint(WorldMatrix.Translation);

            m_updateCounter++;

            if (m_updateCounter > GRAVITY_UPDATE_DELAY)
            {
                m_updateCounter = 0;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("ParticleEffect-Update");

            if (!m_isPreloading)
            {
                MyPerformanceCounter.PerCameraDrawWrite.ParticleEffectsDrawn++;
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("ParticleEffect-UpdateGen");

            m_elapsedTime += VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            //m_distance = MySector.MainCamera.GetDistanceWithFOV(WorldMatrix.Translation) / (100.0f); //precalculate for LODs
            m_distance = (float)Vector3D.Distance(MyTransparentGeometry.Camera.Translation, WorldMatrix.Translation) / (100.0f); //precalculate for LODs
            m_particlesCount = 0;
            m_birthRate = 0;
            m_AABB = BoundingBoxD.CreateInvalid();

            if (Velocity != Vector3.Zero)
            {
                var position = m_worldMatrix.Translation;
                position.X += Velocity.X * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                position.Y += Velocity.Y * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                position.Z += Velocity.Z * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                m_worldMatrix = MatrixD.CreateWorld(position, Vector3D.Normalize(Velocity), m_worldMatrix.Up);
            }

            foreach (MyParticleGeneration generation in m_generations)
            {
                generation.EffectMatrix = WorldMatrix;
                generation.Update();
                m_particlesCount += generation.GetParticlesCount();
                m_birthRate += generation.GetBirthRate();

                BoundingBoxD bbox = generation.GetAABB();
                m_AABB = m_AABB.Include(ref bbox);
            }


            if (m_particlesCount > 0)
                m_hasShownSomething = true;
 
            foreach (var particleLight in m_particleLights)
            {
                particleLight.Update();
            }



            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            m_lastWorldMatrix = m_worldMatrix;

            if (((m_particlesCount == 0 && HasShownSomething())
                || (m_particlesCount == 0 && m_birthRate == 0.0f))
                && AutoDelete && !m_isPreloading)
            {   //Effect was played and has to be deleted
                return true;
            }

            if (!m_isPreloading && OnUpdate != null)
                OnUpdate(this, null);

            return false;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:99,代码来源:MyParticleEffect.cs


注:本文中的BoundingBoxD.Include方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。