修改水
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
public class ComputeBendTwistConstraints : ComputeConstraintsImpl<ComputeBendTwistConstraintsBatch>
|
||||
{
|
||||
public ComputeShader constraintsShader;
|
||||
public int projectKernel;
|
||||
public int applyKernel;
|
||||
|
||||
public ComputeBendTwistConstraints(ComputeSolverImpl solver) : base(solver, Oni.ConstraintType.BendTwist)
|
||||
{
|
||||
constraintsShader = GameObject.Instantiate(Resources.Load<ComputeShader>("Compute/BendTwistConstraints"));
|
||||
projectKernel = constraintsShader.FindKernel("Project");
|
||||
applyKernel = constraintsShader.FindKernel("Apply");
|
||||
}
|
||||
|
||||
public override IConstraintsBatchImpl CreateConstraintsBatch()
|
||||
{
|
||||
var dataBatch = new ComputeBendTwistConstraintsBatch(this);
|
||||
batches.Add(dataBatch);
|
||||
return dataBatch;
|
||||
}
|
||||
|
||||
public override void RemoveBatch(IConstraintsBatchImpl batch)
|
||||
{
|
||||
batches.Remove(batch as ComputeBendTwistConstraintsBatch);
|
||||
batch.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 442edc2bc0aec4bf181b4332f0c8dd46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,81 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
public class ComputeBendTwistConstraintsBatch : ComputeConstraintsBatchImpl, IBendTwistConstraintsBatchImpl
|
||||
{
|
||||
GraphicsBuffer orientationIndices;
|
||||
GraphicsBuffer restDarboux;
|
||||
GraphicsBuffer stiffnesses;
|
||||
GraphicsBuffer plasticity;
|
||||
|
||||
public ComputeBendTwistConstraintsBatch(ComputeBendTwistConstraints constraints)
|
||||
{
|
||||
m_Constraints = constraints;
|
||||
m_ConstraintType = Oni.ConstraintType.BendTwist;
|
||||
}
|
||||
|
||||
public void SetBendTwistConstraints(ObiNativeIntList orientationIndices, ObiNativeQuaternionList restDarboux, ObiNativeVector3List stiffnesses, ObiNativeVector2List plasticity, ObiNativeFloatList lambdas, int count)
|
||||
{
|
||||
this.orientationIndices = orientationIndices.AsComputeBuffer<int>();
|
||||
this.restDarboux = restDarboux.AsComputeBuffer<Quaternion>();
|
||||
this.stiffnesses = stiffnesses.AsComputeBuffer<Vector3>();
|
||||
this.plasticity = plasticity.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 = ((ComputeBendTwistConstraints)m_Constraints).constraintsShader;
|
||||
int projectKernel = ((ComputeBendTwistConstraints)m_Constraints).projectKernel;
|
||||
|
||||
shader.SetBuffer(projectKernel, "orientationIndices", orientationIndices);
|
||||
shader.SetBuffer(projectKernel, "restDarboux", restDarboux);
|
||||
shader.SetBuffer(projectKernel, "stiffnesses", stiffnesses);
|
||||
shader.SetBuffer(projectKernel, "plasticity", plasticity);
|
||||
shader.SetBuffer(projectKernel, "lambdas", lambdas);
|
||||
|
||||
shader.SetBuffer(projectKernel, "orientations", solverImplementation.orientationsBuffer);
|
||||
shader.SetBuffer(projectKernel, "invRotationalMasses", solverImplementation.invRotationalMassesBuffer);
|
||||
|
||||
shader.SetBuffer(projectKernel, "orientationDeltasAsInt", solverImplementation.orientationDeltasIntBuffer);
|
||||
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 = ((ComputeBendTwistConstraints)m_Constraints).constraintsShader;
|
||||
int applyKernel = ((ComputeBendTwistConstraints)m_Constraints).applyKernel;
|
||||
|
||||
shader.SetBuffer(applyKernel, "orientationIndices", orientationIndices);
|
||||
shader.SetBuffer(applyKernel, "orientations", solverImplementation.orientationsBuffer);
|
||||
|
||||
shader.SetBuffer(applyKernel, "orientationDeltasAsInt", solverImplementation.orientationDeltasIntBuffer);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5806beebf896460d87156df3e045b57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user