Round 6 fixes: held tools, headlamp glare, ladder openings, level horizon, roof hulls, rain hits, idle motion, belt packs, meadow variety

- Held tools sit lower and further right; the hammer faces forward and strikes about the camera's right
- Headlamp leaves held items, treats and vending machines alone (rendering layer NoLamp); other lights keep lighting them
- Hay grounded on the floor in world space (it floated)
- Deck fence opens at each ladder, rail colliders split around it; ladders moved to 2 m off the edge middle, clear of the intakes; climbing goes over a rail only if one is in the way
- Crew stand to the soil's up (Planet.Level): flat round the base, the ball's up past it, so the horizon stays level on a small planet
- Convex roof hulls for the crew cabin, garage, pitched roof and windmill tower; cabin box lowered to the eaves
- Rain and acid rain hits differ by surface: soil, grass, wood, metal
- Idle motion: dishes pan, sways sway, sensors turn, eyes blink, windmill turns in the breeze, reels and parked rotors tick over
- Belt: take tools off at the supply wall; hold E at a vending machine for a pack of 3 on the belt, LMB has one
- New meadow pieces: boulders, slab stones, crystals, mushrooms, stump, bulb plants
- -demofix checks for all of the above; loc rows in all 11 tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-12-01 22:52:05 +06:00
parent fd20af06ae
commit 36e4bb2a10
88 changed files with 7588 additions and 4926 deletions

View File

@ -256,6 +256,8 @@ namespace GrassCutter.EditorTools
case PieceId.Garage:
go.AddComponent<Garage>();
ShedParts(go, model, d.scale);
// the roof as it is drawn, above the bays: the walls and posts are boxes, the door opens
Hull(go.transform, model, "Hull_Garage", 2.75f * d.scale, "SM_Bld_Garage_01_Door");
break;
case PieceId.UnloadBay:
{
@ -329,6 +331,8 @@ namespace GrassCutter.EditorTools
{
plinth.transform.localPosition = new Vector3(0f, 1.6f, 0f);
plinth.size = new Vector3(d.sizeX - 0.2f, 3.2f, d.sizeZ - 0.2f);
// the tower and its cap above the plinth, as drawn; the sails turn, so they stay out of it
Hull(go.transform, model, "Hull_Windmill", 3.0f, "Spin");
}
var machine = go.AddComponent<Machine>();
machine.lamp = Part<Renderer>(model, "Lamp");
@ -380,6 +384,8 @@ namespace GrassCutter.EditorTools
// one slope from the eave at the front (+Z) to the ridge 1.5 m up at the back
var slope = Box(go.transform, "Slope", new Vector3(0f, 0.75f, 0f), new Vector3(3.2f, 0.16f, 3.4f), null);
slope.transform.localRotation = Quaternion.Euler(Mathf.Atan2(1.5f, 3f) * Mathf.Rad2Deg, 0f, 0f);
// and the roof as drawn, eaves and overhang and all: the slab alone let a body into the roof's underside
Hull(go.transform, model, "Hull_Roof");
break;
}
case PieceId.Stairs:
@ -516,6 +522,61 @@ namespace GrassCutter.EditorTools
// ───────────────────────── helpers ─────────────────────────
const string HullDir = "Assets/Art/Colliders";
/// <summary>
/// A collider in the model's own shape, for what boxes don't follow: a roof's slopes and overhang, a windmill's
/// tower above its plinth, a cabin's gable. Only triangles reaching above minY (in root space) are kept, and parts
/// named in skip (sails that turn, doors that open) are left out. The mesh is saved beside the prefabs.
/// </summary>
public static MeshCollider Hull(Transform root, Transform model, string asset, float minY = float.NegativeInfinity, params string[] skip) => Hull(root, model, asset, minY, float.PositiveInfinity, skip);
/// <summary>Only triangles lying wholly below maxY too: a chimney left out of a roof's convex hull.</summary>
public static MeshCollider Hull(Transform root, Transform model, string asset, float minY, float maxY, params string[] skip)
{
var verts = new List<Vector3>();
var tris = new List<int>();
var toRoot = root.worldToLocalMatrix;
foreach (var mf in model.GetComponentsInChildren<MeshFilter>(true))
{
if (!mf.sharedMesh) continue;
bool skipped = false;
for (var t = mf.transform; t && t != root; t = t.parent)
if (skip.Contains(t.name)) { skipped = true; break; }
if (skipped) continue;
var m = mf.sharedMesh;
var to = toRoot * mf.transform.localToWorldMatrix;
int b = verts.Count;
foreach (var v in m.vertices) verts.Add(to.MultiplyPoint3x4(v));
var tr = m.triangles;
for (int i = 0; i < tr.Length; i += 3)
{
int i0 = b + tr[i], i1 = b + tr[i + 1], i2 = b + tr[i + 2];
if (Mathf.Max(verts[i0].y, Mathf.Max(verts[i1].y, verts[i2].y)) < minY || Mathf.Max(verts[i0].y, Mathf.Max(verts[i1].y, verts[i2].y)) > maxY) continue;
tris.Add(i0); tris.Add(i1); tris.Add(i2);
}
}
if (tris.Count == 0) return null;
var mesh = new Mesh { name = asset };
if (verts.Count > 65000) mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
mesh.SetVertices(verts);
mesh.SetTriangles(tris, 0);
mesh.RecalculateBounds();
if (!AssetDatabase.IsValidFolder(HullDir)) AssetDatabase.CreateFolder("Assets/Art", "Colliders");
var path = HullDir + "/" + asset + ".asset";
var old = AssetDatabase.LoadAssetAtPath<Mesh>(path);
if (old) { EditorUtility.CopySerialized(mesh, old); mesh = old; EditorUtility.SetDirty(old); }
else AssetDatabase.CreateAsset(mesh, path);
var go = new GameObject("Hull");
go.transform.SetParent(root, false);
var mc = go.AddComponent<MeshCollider>();
mc.sharedMesh = mesh;
// convex: a body pushed out of a bare triangle mesh can be pushed out the wrong side (through the roof); a roof,
// a gable and a tower above its plinth are all near enough convex for that
mc.convex = true;
return mc;
}
static PhysicsMaterial PhysMat(string name, float stat, float dyn, float bounce)
{
var path = Prefabs + name + ".physicMaterial";