void IJobParallelForTransform.Execute(int index, TransformAccess transform) { transform.localPosition += Vector3.up * velocitys[index]; }
public void Execute(int i, TransformAccess transform) { transform.rotation = math.slerp(m_SourceRotations[i * 2], m_SourceRotations[i * 2 + 1], 0.5f); }
unsafe void IJobParallelForTransform.Execute(int index, TransformAccess trsAccess) { var entity = this.Entities[index]; // フィールドが無いものについては回転値参照用のダミーなので無視 var fieldsPtr = this.SpringBoneBlittableFieldsPtr[entity].Value; if (fieldsPtr == null) { return; } var fields = *fieldsPtr; var vecLength = this.Lengths[entity].Value; var localRotation = this.LocalRotations[entity].Value; var boneAxis = this.BoneAxes[entity].Value; float3 position = trsAccess.position; var parentRotation = quaternion.identity; if (this.ParentEntities.Exists(entity)) { var parentEntity = this.ParentEntities[entity].Entity; parentRotation = this.Rotations[parentEntity].Value; } // 物理演算で用いるパラメータの事前計算 var stiffnessForce = fields.StiffnessForce * this.DeltaTime; var dragForce = fields.DragForce; var external = fields.GravityDir * (fields.GravityPower * this.DeltaTime); var centerMatrix = float4x4.identity; var centerInvertMatrix = float4x4.identity; if (this.CenterEntities.Exists(entity)) { var centerEntity = this.CenterEntities[entity].Entity; if (this.Centers.Exists(centerEntity)) { centerMatrix = this.Centers[centerEntity].Value; centerInvertMatrix = math.inverse(centerMatrix); } } var currentTail = math.transform(centerMatrix, this.CurrentTails[entity].Value); var prevTail = math.transform(centerMatrix, this.PrevTails[entity].Value); // verlet積分で次の位置を計算 var nextTail = currentTail // 前フレームの移動を継続する(減衰もあるよ) + (currentTail - prevTail) * (1.0f - dragForce) // 親の回転による子ボーンの移動目標 + math.mul(math.mul(parentRotation, localRotation), boneAxis) * stiffnessForce // 外力による移動量 + external; // 長さをboneLengthに強制 nextTail = position + math.normalize(nextTail - position) * vecLength; // Collisionで移動 this.Collision(ref nextTail, ref position, ref vecLength, ref fields); this.CurrentTails[entity] = new CurrentTail { Value = math.transform(centerInvertMatrix, nextTail) }; this.PrevTails[entity] = new PrevTail { Value = math.transform(centerInvertMatrix, currentTail) }; // 回転を適用 trsAccess.rotation = this.ApplyRotation(ref nextTail, ref parentRotation, ref localRotation, ref position, ref boneAxis); }
public void Execute(int i, TransformAccess transform) { m_SourceRotations[i] = transform.rotation; }
// 復元ボーンごと public void Execute(int index, TransformAccess transform) { transform.localPosition = localPosList[index]; transform.localRotation = localRotList[index]; }
public void PushTo(TransformAccess transform) { transform.localPosition = _localPosition; transform.localRotation = _localRotation; }
public void Execute(int index, TransformAccess transform) { if (!ChangedIndices.TryGetValue(index, out var selfChanged)) { return; } int id = Hierarchy.GetInstanceIdForIndex(index); var iter = ConvertedEntities.GetEntities(id); bool isFirst = true; while (iter.MoveNext()) { var e = iter.Current; if (!LocalToWorld.HasComponent(e)) { continue; } // check whether this is a primary entity or needs to have its transform copied from the primary if (!isFirst && !CopyTransformFromRoot.HasComponent(e)) { continue; } isFirst = false; LocalToWorld[e] = new LocalToWorld { Value = transform.localToWorldMatrix }; if (selfChanged) { if (!Translation.HasComponent(e)) { // static entity continue; } Translation[e] = new Translation { Value = transform.localPosition }; if (Rotation.HasComponent(e)) { Rotation[e] = new Rotation { Value = transform.localRotation } } ; float3 scale; if (Parent.HasComponent(e)) { scale = CalculateLossyScale(transform.localToWorldMatrix, transform.rotation); } else { scale = transform.localScale; } if (math.any(scale != new float3(1))) { var scaleComponent = new NonUniformScale { Value = transform.localScale }; if (NonUniformScale.HasComponent(e)) { NonUniformScale[e] = scaleComponent; } else { Ecb.AddComponent(index, e, scaleComponent); } } else { if (NonUniformScale.HasComponent(e)) { Ecb.RemoveComponent <NonUniformScale>(index, e); } } } } }
public void Execute(int i, TransformAccess access) { access.position += offset; }