Ejemplo n.º 1
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities     = block.GetEntityData();
            var collider     = block.GetSharedComponentData <MeshCollider>();
            var hasRigidBody = block.TryGetComponentData(out Span <RigidBody> rbs);
            var hasScale     = block.TryGetComponentData(out Span <Scale> scales);

            Vector3 defaultScale = Vector3.One;

            for (int i = 0; i < block.length; i++)
            {
                Vector3 scale = defaultScale;
                if (hasScale)
                {
                    scale = new Vector3(scales[i].value.x, scales[i].value.y, scales[i].value.z);
                }
                Mesh mesh = new Mesh(collider.GetTriangles(), scale, PhysicsSystem.BufferPool);

                TypedIndex shapeIdx = PhysicsSystem.Simulation.Shapes.Add(mesh);

                BodyInertia inertia = new BodyInertia();
                if (hasRigidBody)
                {
                    mesh.ComputeOpenInertia(rbs[i].mass, out inertia);
                }

                afterUpdateCommands.AddComponent(entities[i],
                                                 new InternalColliderHandle()
                {
                    inertia  = inertia,
                    shapeIdx = shapeIdx
                });
            }
        }
Ejemplo n.º 2
0
        public void UpdateFilter(BlockAccessor block)
        {
            long id      = block.Id;
            long version = block.GetComponentVersion <T>();

            blockComponentVersions[id] = version;
        }
Ejemplo n.º 3
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities     = block.GetEntityData();
            var colliders    = block.GetReadOnlyComponentData <BoxCollider>();
            var hasRigidBody = block.TryGetComponentData(out Span <RigidBody> rbs);
            var hasScale     = block.TryGetComponentData(out Span <Scale> scales);

            vec3 defaultScale = vec3.Ones;

            for (int i = 0; i < block.length; i++)
            {
                vec3 scale = hasScale ? scales[i].value : defaultScale;

                Box box = new Box(colliders[i].width * scale.x, colliders[i].height * scale.y, colliders[i].length * scale.z);

                TypedIndex shapeIdx = PhysicsSystem.Simulation.Shapes.Add(box);

                BodyInertia inertia = new BodyInertia();
                if (hasRigidBody)
                {
                    box.ComputeInertia(rbs[i].mass, out inertia);
                }

                afterUpdateCommands.AddComponent(entities[i],
                                                 new InternalColliderHandle()
                {
                    inertia  = inertia,
                    shapeIdx = shapeIdx
                });
            }
        }
Ejemplo n.º 4
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var rbs  = block.GetReadOnlyComponentData <RigidBody>();
            var rbh  = block.GetReadOnlyComponentData <InternalRigidBodyHandle>();
            var pos  = block.GetReadOnlyComponentData <Position>();
            var rot  = block.GetReadOnlyComponentData <Rotation>();
            var vel  = block.GetReadOnlyComponentData <Velocity>();
            var avel = block.GetReadOnlyComponentData <AngularVelocity>();

            for (int i = 0; i < block.length; i++)
            {
                var reference = PhysicsSystem.Simulation.Bodies.GetBodyReference(rbh[i].rigidBodyHandle);

                if (vec3.DistanceSqr(rbs[i].lastPosition, pos[i].value) > Threshold)
                {
                    reference.Pose.Position = new Vector3(pos[i].value.x, pos[i].value.y, pos[i].value.z);
                }
                if (vec3.DistanceSqr(rbs[i].lastLinearVel, vel[i].value) > Threshold)
                {
                    reference.Velocity.Linear = new Vector3(vel[i].value.x, vel[i].value.y, vel[i].value.z);
                }
                if (vec3.DistanceSqr(rbs[i].lastAngularVel, avel[i].value) > Threshold)
                {
                    reference.Velocity.Angular = new Vector3(avel[i].value.x, avel[i].value.y, avel[i].value.z);
                }
                if (quat.Dot(rbs[i].lastRotation, rot[i].value) < 1 - Threshold)
                {
                    reference.Pose.Orientation = new BepuUtilities.Quaternion(rot[i].value.x, rot[i].value.y, rot[i].value.z, rot[i].value.w);
                }
            }
        }
        public void UpdateFilter(BlockAccessor block)
        {
            long id      = block.Id;
            long version = block.GetEntityVersion();

            blockEntityVersions[id] = version;
        }
Ejemplo n.º 6
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var players           = block.GetReadOnlyComponentData <Player>();
            var rotations         = block.GetReadOnlyComponentData <Rotation>();
            var velocities        = block.GetComponentData <Velocity>();
            var angularVelocities = block.GetComponentData <AngularVelocity>();

            for (int i = 0; i < block.length; i++)
            {
                if (Input.GetKey(Key.W))
                {
                    var dir = rotations[i].value * vec3.UnitY;
                    velocities[i].value += dir * deltaTime * players[i].movementSpeed;
                }

                if (Input.GetKey(Key.A))
                {
                    angularVelocities[i].value -= vec3.UnitZ * deltaTime * players[i].turningSpeed;
                }

                if (Input.GetKey(Key.D))
                {
                    angularVelocities[i].value += vec3.UnitZ * deltaTime * players[i].turningSpeed;
                }
            }
        }
Ejemplo n.º 7
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var rbs  = block.GetComponentData <RigidBody>();
            var rbh  = block.GetReadOnlyComponentData <InternalRigidBodyHandle>();
            var pos  = block.GetComponentData <Position>();
            var rot  = block.GetComponentData <Rotation>();
            var vel  = block.GetComponentData <Velocity>();
            var avel = block.GetComponentData <AngularVelocity>();

            for (int i = 0; i < block.length; i++)
            {
                var reference = PhysicsSystem.Simulation.Bodies.GetBodyReference(rbh[i].rigidBodyHandle);
                var p         = reference.Pose.Position;
                var r         = reference.Pose.Orientation;
                var lv        = reference.Velocity.Linear;
                var av        = reference.Velocity.Angular;


                pos[i].value  = new vec3(p.X, p.Y, p.Z);
                rot[i].value  = new quat(r.X, r.Y, r.Z, r.W);
                vel[i].value  = new vec3(lv.X, lv.Y, lv.Z);
                avel[i].value = new vec3(av.X, av.Y, av.Z);

                rbs[i].lastPosition   = pos[i].value;
                rbs[i].lastRotation   = rot[i].value;
                rbs[i].lastLinearVel  = vel[i].value;
                rbs[i].lastAngularVel = avel[i].value;
            }
        }
Ejemplo n.º 8
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block, ECSWorld world)
        {
            var positions = block.GetComponentData <Position>();
            var follows   = block.GetReadOnlyComponentData <FollowTarget>();
            var rotations = block.GetComponentData <Rotation>();

            for (int i = 0; i < block.length; i++)
            {
                if (!world.ComponentManager.TryGetComponent(follows[i].target, out Position targetPos))
                {
                    continue;
                }
                if (!world.ComponentManager.TryGetComponent(follows[i].target, out Rotation targetRot))
                {
                    targetRot = new Rotation();
                }

                var p    = targetPos.value + follows[i].offset;
                var rOff = new quat(follows[i].angleOffset);
                var r    = targetRot.value * rOff;

                positions[i].value = p;
                rotations[i].value = r;
            }
        }
Ejemplo n.º 9
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities = block.GetEntityData();

            for (int i = 0; i < block.length; i++)
            {
                afterUpdateCommands.AddComponent(entities[i], new PhysicsBodyLockedValues());
            }
        }
Ejemplo n.º 10
0
        //Remove any leftover internal static bodies
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities = block.GetEntityData();

            for (int i = 0; i < block.length; i++)
            {
                entities[i].RemoveComponent <InternalStaticBodyHandle>(afterUpdateCommands);
            }
        }
Ejemplo n.º 11
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var positions         = block.GetComponentData <Position>();
            var velocities        = block.GetComponentData <Velocity>();
            var rotations         = block.GetComponentData <Rotation>();
            var angularVelocities = block.GetComponentData <AngularVelocity>();
            var values            = block.GetReadOnlyComponentData <PhysicsBodyLockedValues>();
            var locked            = block.GetReadOnlyComponentData <PhysicsBodyLockAxis>();

            for (int i = 0; i < block.length; i++)
            {
                var newPosition = positions[i].value;
                var newVelocity = velocities[i].value;
                if (locked[i].lockX)
                {
                    newPosition.x = values[i].pos.x;
                    newVelocity.x = 0;
                }
                if (locked[i].lockY)
                {
                    newPosition.y = values[i].pos.y;
                    newVelocity.y = 0;
                }
                if (locked[i].lockZ)
                {
                    newPosition.z = values[i].pos.z;
                    newVelocity.z = 0;
                }

                var newRot    = (vec3)rotations[i].value.EulerAngles;
                var oldRot    = (vec3)values[i].rot.EulerAngles;
                var newRotVel = angularVelocities[i].value;

                if (locked[i].lockRotX)
                {
                    newRot.x    = oldRot.x;
                    newRotVel.x = 0;
                }
                if (locked[i].lockRotY)
                {
                    newRot.y    = oldRot.y;
                    newRotVel.y = 0;
                }
                if (locked[i].lockRotZ)
                {
                    newRot.z    = oldRot.z;
                    newRotVel.z = 0;
                }

                positions[i].value         = newPosition;
                rotations[i].value         = new quat(newRot);
                velocities[i].value        = newVelocity;
                angularVelocities[i].value = newRotVel;
            }
        }
Ejemplo n.º 12
0
            public override void ProcessBlock(float deltaTime, BlockAccessor block)
            {
                var positions = block.GetComponentData <Position>();
                var rotations = block.GetComponentData <Rotation>();

                for (int i = 0; i < block.length; i++)
                {
                    rotations[i].value = MathHelper.LookAt(positions[i].value, cameraPosition, vec3.UnitY);
                    //positions[i].value += rotations[i].value * vec3.UnitZ * deltaTime;
                }
            }
Ejemplo n.º 13
0
            public override void ProcessBlock(float deltaTime, BlockAccessor block)
            {
                var rot   = block.GetComponentData <Rotation>();
                var speed = block.GetReadOnlyComponentData <RotateComponent>();

                for (int i = 0; i < block.length; i++)
                {
                    var rotation = quat.FromAxisAngle(speed[i].rotationSpeed * deltaTime, vec3.UnitY);
                    rot[i].value = rot[i].value * rotation;
                }
            }
        public bool FilterBlock(BlockAccessor block)
        {
            long id      = block.Id;
            long version = block.GetEntityVersion();

            if (!blockEntityVersions.TryGetValue(id, out long oldVersion))
            {
                return(false);
            }
            return(oldVersion == version);
        }
Ejemplo n.º 15
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var positions = block.GetReadOnlyComponentData <Position>();
            var rotations = block.GetReadOnlyComponentData <Rotation>();
            var values    = block.GetComponentData <PhysicsBodyLockedValues>();

            for (int i = 0; i < block.length; i++)
            {
                values[i].pos = positions[i].value;
                values[i].rot = rotations[i].value;
            }
        }
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var position = block.GetReadOnlyComponentData <Position>();
            var oToW     = block.GetComponentData <ObjectToWorld>();

            for (int i = 0; i < block.length; i++)
            {
                vec3 pos = position[i].value;
                oToW[i].model  = mat4.Translate(pos);
                oToW[i].normal = mat3.Identity;
            }
        }
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var mesh       = block.GetSharedComponentData <MeshRenderer>();
            var boxes      = block.GetComponentData <BoundingBox>();
            var objToW     = block.GetReadOnlyComponentData <ObjectToWorld>();
            var initialBox = mesh.mesh.bounds;

            for (int i = 0; i < block.length; i++)
            {
                boxes[i].value = initialBox.TransformAabb(objToW[i].model);
            }
        }
Ejemplo n.º 18
0
        //Cache to avoid dictionary lookups
//            private readonly int _grassSubMat;
//            private readonly int _grassSideSubMat;
//            private readonly int _dirtSubMat;

        public override void RenderPass(BlockAccessor blockData)
        {
            blockData.Material.Value = _material;

            blockData.SubMaterial.Value = _subMaterial;

//                renderData.SetSubMaterial(Direction.Down, _dirtSubMat);
//
//                renderData.SetSubMaterial(Direction.Left, _grassSideSubMat);
//                renderData.SetSubMaterial(Direction.Right, _grassSideSubMat);
//                renderData.SetSubMaterial(Direction.Forward, _grassSideSubMat);
//                renderData.SetSubMaterial(Direction.Backward, _grassSideSubMat);

//                renderData.Version.Dirty();
        }
Ejemplo n.º 19
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities  = block.GetEntityData();
            var rbs       = block.GetComponentData <RigidBody>();
            var colliders = block.GetReadOnlyComponentData <InternalColliderHandle>();

            for (int i = 0; i < block.length; i++)
            {
                var shapeIdx = colliders[i].shapeIdx;


                int handle;
                if (rbs[i].mass == 0)
                {
                    afterUpdateCommands.AddComponent(entities[i],
                                                     new InternalRigidBodyHandle()
                    {
                        rigidBodyHandle = handle =
                            PhysicsSystem.Simulation.Bodies.Add(
                                BodyDescription.CreateKinematic(RigidPose.Identity,
                                                                new CollidableDescription(
                                                                    shapeIdx, 0.1f,
                                                                    new ContinuousDetectionSettings {
                            Mode = (ContinuousDetectionMode)rbs[i].detectionMode
                        }),
                                                                new BodyActivityDescription(sleepThreshold: 0.001f)))
                    });
                }
                else
                {
                    afterUpdateCommands.AddComponent(entities[i],
                                                     new InternalRigidBodyHandle()
                    {
                        rigidBodyHandle = handle =
                            PhysicsSystem.Simulation.Bodies.Add(
                                BodyDescription.CreateDynamic(RigidPose.Identity, colliders[i].inertia,
                                                              new CollidableDescription(
                                                                  shapeIdx, 0.1f,
                                                                  new ContinuousDetectionSettings {
                            Mode = (ContinuousDetectionMode)rbs[i].detectionMode
                        }),
                                                              new BodyActivityDescription(sleepThreshold: 0.001f)))
                    });
                }

                PhysicsSystem.rigidBodyEntityDictionary.Add(handle, entities[i]);
            }
        }
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var position = block.GetReadOnlyComponentData <Position>();
            var rotation = block.GetReadOnlyComponentData <Rotation>();
            var oToW     = block.GetComponentData <ObjectToWorld>();

            for (int i = 0; i < block.length; i++)
            {
                vec3 pos = position[i].value;
                quat rot = rotation[i].value;
                var  p   = mat4.Translate(pos);

                var matrix = p * rot.ToMat4;
                oToW[i].model  = matrix;
                oToW[i].normal = new mat3(oToW[i].model);
            }
        }
Ejemplo n.º 21
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block, ECSWorld world)
        {
            var cameras   = block.GetReadOnlyComponentData <CameraFollow>();
            var positions = block.GetComponentData <Position>();

            for (int i = 0; i < block.length; i++)
            {
                var followTarget = cameras[i].entityToFollow;
                try
                {
                    if (world.EntityExists(followTarget))
                    {
                        var pos = world.ComponentManager.GetComponent <Position>(followTarget);
                        positions[i].value = pos.value - vec3.UnitZ * cameras[i].zDistance;
                    }
                }
                catch (ComponentNotFoundException) { }
            }
        }
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var position = block.GetReadOnlyComponentData <Position>();
            var scale    = block.GetReadOnlyComponentData <Scale>();
            var oToW     = block.GetComponentData <ObjectToWorld>();

            for (int i = 0; i < block.length; i++)
            {
                vec3 pos = position[i].value;
                vec3 scl = scale[i].value;

                var p = mat4.Translate(pos);
                var s = mat4.Scale(scl);

                var matrix = p * s;
                oToW[i].model = matrix;
                var inverse      = matrix.Inverse;
                var normalMatrix = new mat3(inverse.Transposed);
                oToW[i].normal = normalMatrix;
            }
        }
Ejemplo n.º 23
0
        private void UpdateVoxelChunk(Entity voxelChunk)
        {
            var blockIdLookup     = GetBufferFromEntity <BlockIdentityComponent>(true);
            var blockMatLookup    = GetBufferFromEntity <BlockMaterialIdentityComponent>();
            var blockSubMatLookup = GetBufferFromEntity <BlockSubMaterialIdentityComponent>();


            var blockIdArray     = blockIdLookup[voxelChunk];
            var blockMatArray    = blockMatLookup[voxelChunk];
            var blockSubMatArray = blockSubMatLookup[voxelChunk];


            for (var blockIndex = 0; blockIndex < UnivoxDefine.CubeSize; blockIndex++)
            {
                Profiler.BeginSample("Process Block");
                var blockId = blockIdArray[blockIndex];

                if (GameManager.Registry.Blocks.TryGetValue(blockId, out var blockRef))
                {
                    var blockAccessor = new BlockAccessor(blockIndex).AddData(blockMatArray).AddData(blockSubMatArray);

                    Profiler.BeginSample("Perform Pass");
                    blockRef.RenderPass(blockAccessor);
                    Profiler.EndSample();
//                    Profiler.BeginSample("Dirty");
////                    block.Render.Version.Dirty();
//                    Profiler.EndSample();
                }
                else
                {
                    blockMatArray[blockIndex]    = new ArrayMaterialIdentity(0, -1);
                    blockSubMatArray[blockIndex] = FaceSubMaterial.CreateAll(-1);
                }

                Profiler.EndSample();
            }

//            changed.Clear();
        }
Ejemplo n.º 24
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities = block.GetEntityData();
            var aabbs    = block.GetReadOnlyComponentData <BoundingBox>();

            for (int i = 0; i < block.length; i++)
            {
                bool anyCameraSees = false;
                for (int j = 0; j < cameraFrustums.Length; j++)
                {
                    if (!cameraFrustums[j].AabbCull(aabbs[i].value))
                    {
                        anyCameraSees = true;
                        break;
                    }
                }
                if (!anyCameraSees)
                {
                    afterUpdateCommands.AddSharedComponent(entities[i], CulledRenderTag.Instance);
                }
            }
        }
Ejemplo n.º 25
0
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var entities  = block.GetEntityData();
            var colliders = block.GetComponentData <InternalColliderHandle>();
            var pos       = block.GetReadOnlyComponentData <Position>();
            var rot       = block.GetReadOnlyComponentData <Rotation>();

            for (int i = 0; i < block.length; i++)
            {
                TypedIndex shapeIdx = colliders[i].shapeIdx;

                Vector3 p = new Vector3(pos[i].value.x, pos[i].value.y, pos[i].value.z);
                BepuUtilities.Quaternion r = new BepuUtilities.Quaternion(rot[i].value.x, rot[i].value.y, rot[i].value.z, rot[i].value.w);

                int handle;
                afterUpdateCommands.AddComponent(entities[i],
                                                 new InternalStaticBodyHandle()
                {
                    staticBodyHandle = handle =
                        PhysicsSystem.Simulation.Statics.Add(
                            new StaticDescription()
                    {
                        Collidable = new CollidableDescription(
                            shapeIdx, 0.1f,
                            ContinuousDetectionSettings.Passive),
                        Pose = new RigidPose()
                        {
                            Position    = p,
                            Orientation = r
                        }
                    }
                            )
                });

                PhysicsSystem.staticBodyEntityDictionary.Add(handle, entities[i]);
            }
        }
        public void SplitBlock(IEnumerable <BlockSplitData> blockSplits, List <KeyValuePair <int, string> > characters)
        {
            try
            {
                CurrentBlockMatchupChanged -= OnCurrentBlockMatchupChanged;

                // set the character for the first block
                Block currentBlock     = CurrentBlock;
                var   firstCharacterId = characters.First(c => c.Key == 0).Value;
                if (currentBlock.CharacterId != firstCharacterId)
                {
                    if (string.IsNullOrEmpty(firstCharacterId))
                    {
                        currentBlock.CharacterId = CharacterVerseData.kUnexpectedCharacter;
                    }
                    else
                    {
                        Debug.Assert(currentBlock.CharacterIdOverrideForScript == null && firstCharacterId.SplitCharacterId().Length == 1,
                                     "This is a case that needs to be fixed for PG-1143");
                        currentBlock.CharacterId = firstCharacterId;
                        AddPendingProjectCharacterVerseDataIfNeeded(currentBlock, firstCharacterId);
                    }
                    currentBlock.Delivery = null;
                }

                foreach (var groupOfSplits in blockSplits.GroupBy(s => new { s.BlockToSplit }))
                {
                    foreach (var blockSplitData in groupOfSplits.OrderByDescending(s => s,
                                                                                   BlockSplitData.BlockSplitDataVerseAndOffsetComparer))
                    {
                        // get the character selected for this split
                        var characterId = characters.First(c => c.Key == blockSplitData.Id).Value;

                        var originalNextBlock  = BlockAccessor.GetNthNextBlockWithinBook(1, blockSplitData.BlockToSplit);
                        var chipOffTheOldBlock = CurrentBook.SplitBlock(blockSplitData.BlockToSplit, blockSplitData.VerseToSplit,
                                                                        blockSplitData.CharacterOffsetToSplit, true, characterId);
                        if (!string.IsNullOrEmpty(characterId))
                        {
                            AddPendingProjectCharacterVerseDataIfNeeded(chipOffTheOldBlock, characterId);
                        }

                        var isNewBlock = originalNextBlock != chipOffTheOldBlock;
                        if (isNewBlock)
                        {
                            var newBlockIndices            = GetBlockIndices(chipOffTheOldBlock);
                            var blocksIndicesNeedingUpdate = m_relevantBookBlockIndices.Where(
                                r => r.BookIndex == newBlockIndices.BookIndex &&
                                r.BlockIndex >= newBlockIndices.BlockIndex);
                            foreach (var bookBlockIndices in blocksIndicesNeedingUpdate)
                            {
                                bookBlockIndices.BlockIndex++;
                            }
                        }
                        else
                        {
                            // We "split" between existing blocks in a multiblock quote,
                            // so we don't need to do the same kind of cleanup above.
                        }
                        AddToRelevantBlocksIfNeeded(chipOffTheOldBlock, isNewBlock);
                    }
                }

                if (AttemptRefBlockMatchup)
                {
                    // A split will always require the current matchup to be re-constructed.
                    SetBlockMatchupForCurrentVerse();
                }

                // This is basically a hack. All kinds of problems were occurring after splits causing our indices to get off.
                // See https://jira.sil.org/browse/PG-1075. This ensures our state is valid every time.
                SetModeInternal(Mode, true);
            }
            finally
            {
                CurrentBlockMatchupChanged += OnCurrentBlockMatchupChanged;
            }
        }
        public override void ProcessBlock(float deltaTime, BlockAccessor block)
        {
            var rbs  = block.GetComponentData <RigidBody>();
            var pos  = block.GetComponentData <Position>();
            var rot  = block.GetComponentData <Rotation>();
            var vel  = block.GetReadOnlyComponentData <Velocity>();
            var avel = block.GetReadOnlyComponentData <AngularVelocity>();

            if (Fma.IsSupported && Avx.IsSupported)
            {
                unsafe {
                    Vector128 <float> deltaF = Vector128.Create(deltaTime);
                    fixed(float *oldPosFloats = pos.Cast <Position, float>())
                    fixed(float *posFloats = pos.Cast <Position, float>())
                    fixed(float *velFloats = vel.Cast <Velocity, float>())
                    {
                        int i = 0;

                        for (; i < block.length; i += 4)
                        {
                            var op     = Sse.LoadAlignedVector128(&oldPosFloats[i]);
                            var p      = Sse.LoadAlignedVector128(&posFloats[i]);
                            var v      = Sse.LoadAlignedVector128(&velFloats[i]);
                            var result = Fma.MultiplyAdd(deltaF, v, p);
                            var bools  = Sse.CompareEqual(op, p);

                            Avx.MaskStore(&posFloats[i], bools, result);
                        }

                        for (i -= 4; i < block.length; i++)
                        {
                            if (oldPosFloats[i] == posFloats[i])
                            {
                                posFloats[i] = posFloats[i] + velFloats[i] * deltaTime;
                            }
                        }
                    }
                }

                for (int i = 0; i < block.length; i++)
                {
                    if (pos[i].value == rbs[i].lastPosition && rot[i].value == rbs[i].lastRotation)
                    {
                        quat x = quat.FromAxisAngle(avel[i].value.x * deltaTime, vec3.UnitX);
                        quat y = quat.FromAxisAngle(avel[i].value.y * deltaTime, vec3.UnitY);
                        quat z = quat.FromAxisAngle(avel[i].value.z * deltaTime, vec3.UnitZ);
                        rot[i].value = rot[i].value * x * y * z;

                        rbs[i].lastPosition = pos[i].value;
                        rbs[i].lastRotation = rot[i].value;
                    }
                }
            }
            else
            {
                for (int i = 0; i < block.length; i++)
                {
                    if (pos[i].value == rbs[i].lastPosition && rot[i].value == rbs[i].lastRotation)
                    {
                        pos[i].value += vel[i].value * deltaTime;

                        quat x = quat.FromAxisAngle(avel[i].value.x * deltaTime, vec3.UnitX);
                        quat y = quat.FromAxisAngle(avel[i].value.y * deltaTime, vec3.UnitY);
                        quat z = quat.FromAxisAngle(avel[i].value.z * deltaTime, vec3.UnitZ);
                        rot[i].value = rot[i].value * x * y * z;

                        rbs[i].lastPosition = pos[i].value;
                        rbs[i].lastRotation = rot[i].value;
                    }
                }
            }
        }
Ejemplo n.º 28
0
 public ISegmentBlockDecoder makeDecoder(BlockAccessor block)
 {
     return new SegmentBlockBasicDecoder(block);
 }
Ejemplo n.º 29
0
 public void UpdateFilter(BlockAccessor block)
 {
 }
 public void UpdateFilter(BlockAccessor block)
 {
     filter1.UpdateFilter(block);
     filter2.UpdateFilter(block);
 }
 public bool FilterBlock(BlockAccessor block)
 {
     return(filter1.FilterBlock(block) || filter2.FilterBlock(block));
 }