MeshPainter: Rückseiten-Abweisung über Flächen-Normale bei großem Brush
Zusätzlich zum Kugel-Test wird die Oberflächen-Normale jedes Texels gegen die Brush-Normale geprüft (CPU/GPU/Preview). Neues Inspector-Feld "Brush Max Surface Angle" (90-180°, Default 120°). Bei fehlenden Mesh-Normalen Degradation zur reinen Kugel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d17baee85
commit
cdd9fa9532
7 files changed
+68
-8
No files matched your search
@@ -42,6 +42,7 @@ public partial class MeshPainter
|
||||
// BuildMeshCaches scratch: refilled per bake without allocating (with updateColliderEveryFrame this
|
||||
// runs per frame while painting; mesh.vertices/.triangles/.uv return fresh arrays per call).
|
||||
private readonly System.Collections.Generic.List<Vector3> _vertScratch = new System.Collections.Generic.List<Vector3>();
|
||||
private readonly System.Collections.Generic.List<Vector3> _normalScratch = new System.Collections.Generic.List<Vector3>();
|
||||
private int _meshCacheId; // mesh instance the topology/UV caches were built for (0 = none)
|
||||
|
||||
/// <summary>Reads vertices/triangles/UVs of the collider mesh and computes culling data.
|
||||
@@ -56,6 +57,16 @@ public partial class MeshPainter
|
||||
if (_verts == null || _verts.Length != vCount) _verts = new Vector3[vCount];
|
||||
_vertScratch.CopyTo(_verts);
|
||||
|
||||
// Per-vertex normals for the brush's back-face rejection (opposite side of thin geometry).
|
||||
// Re-baked each frame for skinned meshes; falls back to null (test disabled) if absent.
|
||||
m.GetNormals(_normalScratch);
|
||||
if (_normalScratch.Count == vCount)
|
||||
{
|
||||
if (_normals == null || _normals.Length != vCount) _normals = new Vector3[vCount];
|
||||
_normalScratch.CopyTo(_normals);
|
||||
}
|
||||
else _normals = null;
|
||||
|
||||
if (_meshCacheId != m.GetInstanceID())
|
||||
{
|
||||
_meshCacheId = m.GetInstanceID();
|
||||
|
||||
Reference in new issue
Block a user