修改水

This commit is contained in:
2026-01-01 22:00:33 +08:00
parent 040a222bd6
commit 9ceffccd39
1800 changed files with 103929 additions and 139495 deletions

View File

@@ -14,7 +14,7 @@ namespace Obi
{
[ReadOnly] public NativeArray<int> activeParticles;
[ReadOnly] public NativeArray<int> phases;
[ReadOnly] public NativeArray<float4> buoyancies;
[ReadOnly] public NativeArray<float> buoyancies;
// linear/position properties:
[ReadOnly] public NativeArray<float4> externalForces;
@@ -48,7 +48,7 @@ namespace Obi
// Adjust gravity for buoyant fluid particles:
if ((phases[i] & (int)ObiUtils.ParticleFlags.Fluid) != 0)
effectiveGravity *= -buoyancies[i].z;
effectiveGravity *= -buoyancies[i];
// apply external forces and gravity:
float4 vel = velocities[i] + (inverseMasses[i] * externalForces[i] + effectiveGravity) * deltaTime;
@@ -63,13 +63,13 @@ namespace Obi
if (inverseRotationalMasses[i] > 0)
{
// apply external torques (simplification: we don't use full inertia tensor here)
float3 angularVel = angularVelocities[i].xyz + inverseRotationalMasses[i] * externalTorques[i].xyz * deltaTime;
float4 angularVel = angularVelocities[i] + inverseRotationalMasses[i] * externalTorques[i] * deltaTime;
// project angular velocity to 2D plane normal if needed:
if (is2D)
angularVel = angularVel.project(new float3(0, 0, 1));
angularVel = angularVel.project(new float4(0, 0, 1, 0));
angularVelocities[i] = new float4(angularVel, angularVelocities[i].w);
angularVelocities[i] = angularVel;
}
// integrate velocities: