修改水

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 ComputeStretchShearConstraints : ComputeConstraintsImpl<ComputeStretchShearConstraintsBatch>
{
public ComputeShader constraintsShader;
public int projectKernel;
public int applyKernel;
public ComputeStretchShearConstraints(ComputeSolverImpl solver) : base(solver, Oni.ConstraintType.StretchShear)
{
constraintsShader = GameObject.Instantiate(Resources.Load<ComputeShader>("Compute/StretchShearConstraints"));
projectKernel = constraintsShader.FindKernel("Project");
applyKernel = constraintsShader.FindKernel("Apply");
}
public override IConstraintsBatchImpl CreateConstraintsBatch()
{
var dataBatch = new ComputeStretchShearConstraintsBatch(this);
batches.Add(dataBatch);
return dataBatch;
}
public override void RemoveBatch(IConstraintsBatchImpl batch)
{
batches.Remove(batch as ComputeStretchShearConstraintsBatch);
batch.Destroy();
}
}
}

View File

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

View File

@@ -1,91 +0,0 @@
using UnityEngine;
namespace Obi
{
public class ComputeStretchShearConstraintsBatch : ComputeConstraintsBatchImpl, IStretchShearConstraintsBatchImpl
{
GraphicsBuffer orientationIndices;
GraphicsBuffer restLengths;
GraphicsBuffer restOrientations;
GraphicsBuffer stiffnesses;
public ComputeStretchShearConstraintsBatch(ComputeStretchShearConstraints constraints)
{
m_Constraints = constraints;
m_ConstraintType = Oni.ConstraintType.StretchShear;
}
public void SetStretchShearConstraints(ObiNativeIntList particleIndices, ObiNativeIntList orientationIndices, ObiNativeFloatList restLengths, ObiNativeQuaternionList restOrientations, ObiNativeVector3List stiffnesses, ObiNativeFloatList lambdas, int count)
{
this.particleIndices = particleIndices.AsComputeBuffer<int>();
this.orientationIndices = orientationIndices.AsComputeBuffer<int>();
this.restLengths = restLengths.AsComputeBuffer<float>();
this.restOrientations = restOrientations.AsComputeBuffer<Quaternion>();
this.stiffnesses = stiffnesses.AsComputeBuffer<Vector3>();
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 = ((ComputeStretchShearConstraints)m_Constraints).constraintsShader;
int projectKernel = ((ComputeStretchShearConstraints)m_Constraints).projectKernel;
shader.SetBuffer(projectKernel, "particleIndices", particleIndices);
shader.SetBuffer(projectKernel, "orientationIndices", orientationIndices);
shader.SetBuffer(projectKernel, "restLengths", restLengths);
shader.SetBuffer(projectKernel, "restOrientations", restOrientations);
shader.SetBuffer(projectKernel, "stiffnesses", stiffnesses);
shader.SetBuffer(projectKernel, "lambdas", lambdas);
shader.SetBuffer(projectKernel, "positions", solverImplementation.positionsBuffer);
shader.SetBuffer(projectKernel, "orientations", solverImplementation.orientationsBuffer);
shader.SetBuffer(projectKernel, "invMasses", solverImplementation.invMassesBuffer);
shader.SetBuffer(projectKernel, "invRotationalMasses", solverImplementation.invRotationalMassesBuffer);
shader.SetBuffer(projectKernel, "deltasAsInt", solverImplementation.positionDeltasIntBuffer);
shader.SetBuffer(projectKernel, "orientationDeltasAsInt", solverImplementation.orientationDeltasIntBuffer);
shader.SetBuffer(projectKernel, "positionConstraintCounts", solverImplementation.positionConstraintCountBuffer);
shader.SetBuffer(projectKernel, "orientationConstraintCounts", solverImplementation.orientationConstraintCountBuffer);
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 substepTime)
{
if (m_ConstraintCount > 0)
{
var parameters = solverAbstraction.GetConstraintParameters(m_ConstraintType);
var shader = ((ComputeStretchShearConstraints)m_Constraints).constraintsShader;
int applyKernel = ((ComputeStretchShearConstraints)m_Constraints).applyKernel;
shader.SetBuffer(applyKernel, "particleIndices", particleIndices);
shader.SetBuffer(applyKernel, "orientationIndices", orientationIndices);
shader.SetBuffer(applyKernel, "positions", solverImplementation.positionsBuffer);
shader.SetBuffer(applyKernel, "orientations", solverImplementation.orientationsBuffer);
shader.SetBuffer(applyKernel, "deltasAsInt", solverImplementation.positionDeltasIntBuffer);
shader.SetBuffer(applyKernel, "orientationDeltasAsInt", solverImplementation.orientationDeltasIntBuffer);
shader.SetBuffer(applyKernel, "positionConstraintCounts", solverImplementation.positionConstraintCountBuffer);
shader.SetBuffer(applyKernel, "orientationConstraintCounts", solverImplementation.orientationConstraintCountBuffer);
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: f2d0b5dfba06143f5b0a9939a3a2364b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: