public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // For all chunks where currentTrans is newer than previousTrans // Copy currentTrans to previous trans if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(curRotationType), simStartComponentVersion)) { var curRot = chunk.GetNativeArray(curRotationType); var prevRot = chunk.GetNativeArray(prevRotationType); // FIXME: use a memcopy since size and layout must be identical for (int ent = 0; ent < curRot.Length; ++ent) { prevRot[ent] = new PreviousSimulatedRotation { Value = curRot[ent].Value }; } } // For all chunks where transform has changed since end of last simulation // Copy currentTargs to trans if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(rotationType), simEndComponentVersion)) { // Transform was interpolated by the rendering system var curRot = chunk.GetNativeArray(curRotationType); var rot = chunk.GetNativeArray(rotationType); // FIXME: use a memcopy since size and layout must be identical for (int ent = 0; ent < curRot.Length; ++ent) { rot[ent] = new Rotation { Value = curRot[ent].Value }; } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // If current was written after copying it to prev we need to interpolate, otherwise they must be identical if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(curRotationType), chunk.GetChangeVersion(prevRotationType))) { var prevRot = chunk.GetNativeArray(prevRotationType); var curRot = chunk.GetNativeArray(curRotationType); var rot = chunk.GetNativeArray(rotationType); for (var ent = 0; ent < rot.Length; ++ent) { var a = math.slerp(prevRot[ent].Value, curRot[ent].Value, curWeight); rot[ent] = new Rotation { Value = a }; } } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // If current was written after copying it to prev we need to interpolate, otherwise they must be identical if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(curPositionType), chunk.GetChangeVersion(prevPositionType))) { var prevPos = chunk.GetNativeArray(prevPositionType); var curPos = chunk.GetNativeArray(curPositionType); var pos = chunk.GetNativeArray(positionType); for (var ent = 0; ent < pos.Length; ++ent) { var p = curPos[ent].Value * curWeight + prevPos[ent].Value * prevWeight; pos[ent] = new Translation { Value = p }; } } }
internal static uint GetComponentVersionHash(this ArchetypeChunk self, uint seed) { var hash = seed; var typeCount = self.GetTypeCount(); for (int i = 0; i < typeCount; i++) { var changeVersion = self.GetChangeVersion(i); hash = math.hash(new uint2(changeVersion, hash)); } return(hash); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { // For all chunks where trans has changed since start of simulation // Copy trans to currentTrans if (ChangeVersionUtility.DidChange(chunk.GetChangeVersion(rotationType), simStartComponentVersion)) { // Transform was interpolated by the rendering system var curRot = chunk.GetNativeArray(curRotationType); var rot = chunk.GetNativeArray(rotationType); // FIXME: use a memcopy since size and layout must be identical for (int ent = 0; ent < curRot.Length; ++ent) { curRot[ent] = new CurrentSimulatedRotation { Value = rot[ent].Value }; } } }