修改水

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

@@ -1,32 +0,0 @@
using System;
using UnityEngine;
namespace Obi
{
public class ComputeBendConstraints : ComputeConstraintsImpl<ComputeBendConstraintsBatch>
{
public ComputeShader constraintsShader;
public int projectKernel;
public int applyKernel;
public ComputeBendConstraints(ComputeSolverImpl solver) : base(solver, Oni.ConstraintType.Bending)
{
constraintsShader = GameObject.Instantiate(Resources.Load<ComputeShader>("Compute/BendConstraints"));
projectKernel = constraintsShader.FindKernel("Project");
applyKernel = constraintsShader.FindKernel("Apply");
}
public override IConstraintsBatchImpl CreateConstraintsBatch()
{
var dataBatch = new ComputeBendConstraintsBatch(this);
batches.Add(dataBatch);
return dataBatch;
}
public override void RemoveBatch(IConstraintsBatchImpl batch)
{
batches.Remove(batch as ComputeBendConstraintsBatch);
batch.Destroy();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ac9c52f073f794c47a6cbb7b41cf023c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,75 +0,0 @@
using UnityEngine;
namespace Obi
{
public class ComputeBendConstraintsBatch : ComputeConstraintsBatchImpl, IBendConstraintsBatchImpl
{
GraphicsBuffer restBends;
GraphicsBuffer stiffnesses;
public ComputeBendConstraintsBatch(ComputeBendConstraints constraints)
{
m_Constraints = constraints;
m_ConstraintType = Oni.ConstraintType.Bending;
}
public void SetBendConstraints(ObiNativeIntList particleIndices, ObiNativeFloatList restBends, ObiNativeVector2List bendingStiffnesses, ObiNativeVector2List plasticity, ObiNativeFloatList lambdas, int count)
{
this.particleIndices = particleIndices.AsComputeBuffer<int>();
this.restBends = restBends.AsComputeBuffer<float>();
this.stiffnesses = bendingStiffnesses.AsComputeBuffer<Vector2>();
this.lambdas = lambdas.AsComputeBuffer<float>();
this.lambdasList = lambdas;
m_ConstraintCount = count;
}
public override void Evaluate(float stepTime, float substepTime, int steps, float timeLeft)
{
if (m_ConstraintCount > 0)
{
var shader = ((ComputeBendConstraints)m_Constraints).constraintsShader;
int projectKernel = ((ComputeBendConstraints)m_Constraints).projectKernel;
shader.SetBuffer(projectKernel, "particleIndices", particleIndices);
shader.SetBuffer(projectKernel, "restBends", restBends);
shader.SetBuffer(projectKernel, "stiffnesses", stiffnesses);
shader.SetBuffer(projectKernel, "lambdas", lambdas);
shader.SetBuffer(projectKernel, "positions", solverImplementation.positionsBuffer);
shader.SetBuffer(projectKernel, "invMasses", solverImplementation.invMassesBuffer);
shader.SetBuffer(projectKernel, "deltasAsInt", solverImplementation.positionDeltasIntBuffer);
shader.SetBuffer(projectKernel, "positionConstraintCounts", solverImplementation.positionConstraintCountBuffer);
shader.SetInt("activeConstraintCount", m_ConstraintCount);
shader.SetFloat("deltaTime", substepTime);
int threadGroups = ComputeMath.ThreadGroupCount(m_ConstraintCount, 128);
shader.Dispatch(projectKernel, threadGroups, 1, 1);
}
}
public override void Apply(float deltaTime)
{
if (m_ConstraintCount > 0)
{
var parameters = solverAbstraction.GetConstraintParameters(m_ConstraintType);
var shader = ((ComputeBendConstraints)m_Constraints).constraintsShader;
int applyKernel = ((ComputeBendConstraints)m_Constraints).applyKernel;
shader.SetBuffer(applyKernel, "particleIndices", particleIndices);
shader.SetBuffer(applyKernel, "positions", solverImplementation.positionsBuffer);
shader.SetBuffer(applyKernel, "deltasAsInt", solverImplementation.positionDeltasIntBuffer);
shader.SetBuffer(applyKernel, "positionConstraintCounts", solverImplementation.positionConstraintCountBuffer);
shader.SetInt("activeConstraintCount", m_ConstraintCount);
shader.SetFloat("sorFactor", parameters.SORFactor);
int threadGroups = ComputeMath.ThreadGroupCount(m_ConstraintCount, 128);
shader.Dispatch(applyKernel, threadGroups, 1, 1);
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 49d201b7a15f44e17b27019b972e9844
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: