修改水
This commit is contained in:
@@ -10,52 +10,18 @@ using System.Collections;
|
||||
namespace Obi
|
||||
{
|
||||
[BurstCompile]
|
||||
struct CalculateSimplexBoundsJob : IJobParallelFor
|
||||
struct ParticleToBoundsJob : IJobParallelFor
|
||||
{
|
||||
[ReadOnly] public NativeArray<float4> radii;
|
||||
[ReadOnly] public NativeArray<float4> fluidMaterials;
|
||||
[ReadOnly] public NativeArray<int> activeParticles;
|
||||
[ReadOnly] public NativeArray<float4> positions;
|
||||
[ReadOnly] public NativeArray<float4> velocities;
|
||||
[ReadOnly] public NativeArray<float4> radii;
|
||||
|
||||
// simplex arrays:
|
||||
[ReadOnly] public NativeArray<int> simplices;
|
||||
[ReadOnly] public SimplexCounts simplexCounts;
|
||||
|
||||
[ReadOnly] public NativeArray<int> particleMaterialIndices;
|
||||
[ReadOnly] public NativeArray<BurstCollisionMaterial> collisionMaterials;
|
||||
public NativeArray<BurstAabb> simplexBounds;
|
||||
public NativeArray<BurstAabb> reducedBounds;
|
||||
|
||||
[ReadOnly] public Oni.SolverParameters parameters;
|
||||
[ReadOnly] public float dt;
|
||||
public NativeArray<BurstAabb> bounds;
|
||||
|
||||
public void Execute(int i)
|
||||
{
|
||||
int simplexStart = simplexCounts.GetSimplexStartAndSize(i, out int simplexSize);
|
||||
|
||||
var sxBounds = new BurstAabb(float.MaxValue, float.MinValue);
|
||||
var soBounds = new BurstAabb(float.MaxValue, float.MinValue);
|
||||
|
||||
for (int j = 0; j < simplexSize; ++j)
|
||||
{
|
||||
int p = simplices[simplexStart + j];
|
||||
|
||||
int m = particleMaterialIndices[p];
|
||||
float solidRadius = radii[p].x + (m >= 0 ? collisionMaterials[m].stickDistance : 0);
|
||||
|
||||
// Expand simplex bounds, using both the particle's original position and its velocity.
|
||||
// Add collision margin for both fluid neighborhood too (prevents explosions at high pressures due to neighborhood deficiency)
|
||||
sxBounds.EncapsulateParticle(positions[p],
|
||||
BurstIntegration.IntegrateLinear(positions[p], velocities[p], dt * parameters.particleCCD),
|
||||
math.max(solidRadius, fluidMaterials[p].x * 0.5f) + parameters.collisionMargin);
|
||||
|
||||
soBounds.EncapsulateParticle(positions[p],
|
||||
BurstIntegration.IntegrateLinear(positions[p], velocities[p], dt),
|
||||
solidRadius);
|
||||
}
|
||||
|
||||
simplexBounds[i] = sxBounds;
|
||||
reducedBounds[i] = soBounds;
|
||||
int p = activeParticles[i];
|
||||
bounds[i] = new BurstAabb(positions[p] - radii[p].x, positions[p] + radii[p].x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user