升级水插件

This commit is contained in:
2026-01-08 22:30:55 +08:00
parent febff82d24
commit ca68084264
415 changed files with 18138 additions and 7134 deletions

View File

@@ -3,22 +3,22 @@
using UnityEngine;
using WaveHarmonic.Crest.Internal;
using WaveHarmonic.Crest.Utility;
namespace WaveHarmonic.Crest
{
/// <summary>
/// Different physics models for <see cref="FloatingObject"/>
/// </summary>
[@GenerateDoc]
public enum FloatingObjectModel
{
/// <summary>
/// A simple model which aligns the object with the wave normal.
/// </summary>
/// <inheritdoc cref="Generated.FloatingObjectModel.AlignNormal"/>
[Tooltip("A simple model which aligns the object with the wave normal.")]
AlignNormal,
/// <summary>
/// A more advanced model which samples water at the probes positions.
/// </summary>
/// <inheritdoc cref="Generated.FloatingObjectModel.Probes"/>
[Tooltip("A more advanced model which samples water at the probes positions.")]
Probes,
}
@@ -165,6 +165,10 @@ namespace WaveHarmonic.Crest
internal bool _DrawQueries = false;
}
internal const string k_FixedUpdateMarker = "Crest.FloatingObject.FixedUpdate";
static readonly Unity.Profiling.ProfilerMarker s_FixedUpdateMarker = new(k_FixedUpdateMarker);
/// <summary>
/// Is any part of this object in water.
/// </summary>
@@ -204,7 +208,7 @@ namespace WaveHarmonic.Crest
private protected override System.Action<WaterRenderer> OnFixedUpdateMethod => OnFixedUpdate;
void OnFixedUpdate(WaterRenderer water)
{
UnityEngine.Profiling.Profiler.BeginSample("Buoyancy.FixedUpdate");
s_FixedUpdateMarker.Begin(this);
var points = Advanced ? _Probes : _Probe;
@@ -232,7 +236,7 @@ namespace WaveHarmonic.Crest
{
var query = _QueryPoints[i];
query.y = water.SeaLevel + _QueryResultDisplacements[i].y;
CollisionAreaVisualizer.DebugDrawCross(query, 1f, Color.magenta);
DebugUtility.DrawCross(Debug.DrawLine, query, 1f, Color.magenta);
}
}
}
@@ -276,7 +280,7 @@ namespace WaveHarmonic.Crest
if (!InWater)
{
UnityEngine.Profiling.Profiler.EndSample();
s_FixedUpdateMarker.End();
return;
}
}
@@ -290,13 +294,13 @@ namespace WaveHarmonic.Crest
{
var surfPos = transform.position;
surfPos.y = height;
CollisionAreaVisualizer.DebugDrawCross(surfPos, normal, 1f, Color.red);
DebugUtility.DrawCross(Debug.DrawLine, surfPos, normal, 1f, Color.red);
}
InWater = bottomDepth > 0f;
if (!InWater)
{
UnityEngine.Profiling.Profiler.EndSample();
s_FixedUpdateMarker.End();
return;
}
@@ -366,7 +370,7 @@ namespace WaveHarmonic.Crest
_RigidBody.AddForceAtPosition(_Drag.z * Vector3.Dot(transform.forward, -velocityRelativeToWater) * transform.forward, forcePosition, ForceMode.Acceleration);
}
UnityEngine.Profiling.Profiler.EndSample();
s_FixedUpdateMarker.End();
}
}
}