More Related Content Similar to 【Unite Tokyo 2019】たのしいDOTS〜初級から上級まで〜 (11) More from UnityTechnologiesJapan002 (20) 【Unite Tokyo 2019】たのしいDOTS〜初級から上級まで〜70. データに注目
Update
{
if (position.y > 0f)
{
rotation = objA.func(1f);
return;
}
else if (position.y > 4f)
{
if (position.z > 0f)
{
m_C = objB.func(2f);
}
else
m_C = objB.func(-1f);
}
rotation = m_C;
}
D
System
System
B
A
System
Rotation
いつもの書き方
Native
Container
71. Update
{
if (position.y > 0f)
{
rotation = objA.func(1f);
return;
}
else if (position.y > 4f)
{
if (position.z > 0f)
{
m_C = objB.func(2f);
}
else
m_C = objB.func(-1f);
}
rotation = m_C;
}
D
System
System
B
A
System
Rotation
いつもの書き方
Native
Container
テストが
容易!
72. Update
{
if (position.y > 0f)
{
rotation = objA.func(1f);
return;
}
else if (position.y > 4f)
{
if (position.z > 0f)
{
m_C = objB.func(2f);
}
else
m_C = objB.func(-1f);
}
rotation = m_C;
}
D
System
System
B
A
System
Rotation
いつもの書き方
Native
Container
テストが
容易!
73. データに注目
Update
{
if (position.y > 0f)
{
rotation = objA.func(1f);
return;
}
else if (position.y > 4f)
{
if (position.z > 0f)
{
m_C = objB.func(2f);
}
else
m_C = objB.func(-1f);
}
rotation = m_C;
}
D
System
System
B
A
System
Rotation
いつもの書き方
Native
Container
97. public static void ApplyLinearImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Linear += impulse * massData.InverseMass;
}
実装の確認は避けられない(現時点では)
dv = Fdt
1
m
つまり
98. public static void ApplyLinearImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Linear += impulse * massData.InverseMass;
}
実装の確認は避けられない(現時点では)
Force velocityData.ApplyLinearImpulse(force*deltaTime);
Impulse velocityData.ApplyLinearImpulse(impulse);
Acceleration
VelocityChange
velocityData.Linear += acceleration*deltaTime;
velocityData.Linear += velocity;
ForceModeの対応:
dv = Fdt
1
m
つまり
99. public static void ApplyAngularImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Angular += impulse * massData.InverseInertia;
}
注意点その3
massData.InverseInertiaは行列ではなくベクトル
AddTorqueは?
100. public static void ApplyAngularImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Angular += impulse * massData.InverseInertia;
}
注意点その3
massData.InverseInertiaは行列ではなくベクトル
直交座標系の回転要素がない慣性テンソル
AddTorqueは?
(対角化された状態)
101. public static void ApplyAngularImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Angular += impulse * massData.InverseInertia;
}
注意点その3
慣性テンソル空間でトルクを与える必要
massData.InverseInertiaは行列ではなくベクトル
AddTorqueは?
(対角化された状態)
直交座標系の回転要素がない慣性テンソル
102. public static void ApplyAngularImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Angular += impulse * massData.InverseInertia;
}
注意点その3
慣性テンソル空間でトルクを与える必要
特殊な形状でなければAddRelativeTorqueと考えて良い
massData.InverseInertiaは行列ではなくベクトル
AddTorqueは?
(対角化された状態)
直交座標系の回転要素がない慣性テンソル
106. 物体の位置・姿勢の更新は
すべてApply*Impulse経由
InverseInertia
public static void ApplyAngularImpulse(ref this PhysicsVelocity velocityData, PhysicsMass massData, float3 impulse)
{
velocityData.Angular += impulse * massData.InverseInertia;
}
の設定で回転拘束を実現
例: new PhysicsMass {
…
InverseInertia = new float3(0, 1, 0);
…
}
Y軸以外の角速度を
発生させない
という実装になってるので
慣性テンソルに回転がある場合は注意