Phases 30-31 (PC, 11-12/10) : rochers visibles, builds separes, densite, demo candidate
Travail local non commite jusqu'ici, sauvegarde avant fusion avec la branche cloud. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
84a72fe30c
révision
5cb99fa5f2
10 fichiers modifiés
+1517
-51
Aucun fichier ne correspond à votre recherche
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
@@ -21,8 +22,12 @@ const glm::vec3 kLimestone{0.63f, 0.62f, 0.58f};
|
||||
using Face = std::array<uint32_t, 3>;
|
||||
using EdgeKey = std::pair<uint32_t, uint32_t>;
|
||||
|
||||
// PHASE 30 (Agent B) : `top` = sommet visible de la piece (y > 0, repere du
|
||||
// mesh). Chaque SOMMET recoit l'ombre de contact a sa hauteur (voir
|
||||
// rockContactShade) : la couleur est interpolee d'un sommet a l'autre, d'ou un
|
||||
// degrade du pied assombri vers le haut clair, sans toucher au shader.
|
||||
void appendFacet(MeshData& mesh, const glm::vec3& a, const glm::vec3& b,
|
||||
const glm::vec3& c, const glm::vec3& color) {
|
||||
const glm::vec3& c, const glm::vec3& color, float top) {
|
||||
const glm::vec3 raw = glm::cross(b - a, c - a);
|
||||
const float length = glm::length(raw);
|
||||
if (length < 1e-9f) {
|
||||
@@ -33,7 +38,7 @@ void appendFacet(MeshData& mesh, const glm::vec3& a, const glm::vec3& b,
|
||||
for (const glm::vec3& p : { a, b, c }) {
|
||||
Vertex v{};
|
||||
v.pos = p;
|
||||
v.color = color;
|
||||
v.color = color * rockContactShade(p.y, top);
|
||||
v.normal = normal;
|
||||
mesh.vertices.push_back(v);
|
||||
}
|
||||
@@ -76,11 +81,36 @@ void unitSphere(int levels, std::vector<glm::vec3>& points, std::vector<Face>& f
|
||||
}
|
||||
}
|
||||
|
||||
// PHASE 30 (Agent B) : icosaedre sur la sphere unite (20 faces), orientees vers
|
||||
// l'exterieur. Sert aux cailloux de la pierraille : l'octaedre (8 faces) se lit
|
||||
// comme une petite pyramide a 10-25 cm, l'octaedre subdivise (32 faces) coutait
|
||||
// +0,5 ms par image a 361 plaques (mesure entrelacee, RAPPORT Phase 30).
|
||||
void unitIcosahedron(std::vector<glm::vec3>& points, std::vector<Face>& faces) {
|
||||
const float t = 1.6180339887f;
|
||||
points = { { -1, t, 0 }, { 1, t, 0 }, { -1, -t, 0 }, { 1, -t, 0 },
|
||||
{ 0, -1, t }, { 0, 1, t }, { 0, -1, -t }, { 0, 1, -t },
|
||||
{ t, 0, -1 }, { t, 0, 1 }, { -t, 0, -1 }, { -t, 0, 1 } };
|
||||
for (glm::vec3& p : points) {
|
||||
p = glm::normalize(p);
|
||||
}
|
||||
faces = { {0, 11, 5}, {0, 5, 1}, {0, 1, 7}, {0, 7, 10}, {0, 10, 11},
|
||||
{1, 5, 9}, {5, 11, 4}, {11, 10, 2}, {10, 7, 6}, {7, 1, 8},
|
||||
{3, 9, 4}, {3, 4, 2}, {3, 2, 6}, {3, 6, 8}, {3, 8, 9},
|
||||
{4, 9, 5}, {2, 4, 11}, {6, 2, 10}, {8, 6, 7}, {9, 8, 1} };
|
||||
// Orientation verifiee plutot que supposee : normale sortante (convexe).
|
||||
for (Face& f : faces) {
|
||||
const glm::vec3 n = glm::cross(points[f[1]] - points[f[0]], points[f[2]] - points[f[0]]);
|
||||
if (glm::dot(n, points[f[0]] + points[f[1]] + points[f[2]]) < 0.0f) {
|
||||
std::swap(f[1], f[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Un caillou irregulier : sphere bosselee puis TRONQUEE par `cuts` plans
|
||||
// aleatoires - chaque plan aplatit une calotte et donne une face de fracture
|
||||
// franche, ce qui distingue un bloc d'eboulis d'un galet roule.
|
||||
struct RockShape {
|
||||
int levels = 1;
|
||||
int levels = 1; // subdivisions de l'octaedre ; < 0 : icosaedre (20 faces)
|
||||
float bumpMin = 0.78f;
|
||||
int cuts = 5;
|
||||
float cutDepth = 0.72f; // distance du plan au centre (sphere unite)
|
||||
@@ -94,7 +124,11 @@ struct RockShape {
|
||||
void appendRock(MeshData& mesh, const RockShape& shape) {
|
||||
std::vector<glm::vec3> points;
|
||||
std::vector<Face> faces;
|
||||
unitSphere(shape.levels, points, faces);
|
||||
if (shape.levels < 0) {
|
||||
unitIcosahedron(points, faces);
|
||||
} else {
|
||||
unitSphere(shape.levels, points, faces);
|
||||
}
|
||||
|
||||
std::mt19937 rng(shape.seed);
|
||||
std::uniform_real_distribution<float> unit(0.0f, 1.0f);
|
||||
@@ -123,11 +157,15 @@ void appendRock(MeshData& mesh, const RockShape& shape) {
|
||||
p.z += shape.offset.y;
|
||||
p.y += shape.yOffset;
|
||||
}
|
||||
float top = 0.0f;
|
||||
for (const glm::vec3& p : points) {
|
||||
top = std::max(top, p.y);
|
||||
}
|
||||
// Legere variation de teinte par face (patine, lichen) : sans elle un bloc a
|
||||
// facettes planes a l'air d'un solide de synthese uniforme.
|
||||
for (const Face& f : faces) {
|
||||
const float shade = 0.90f + 0.14f * unit(rng);
|
||||
appendFacet(mesh, points[f[0]], points[f[1]], points[f[2]], shape.color * shade);
|
||||
appendFacet(mesh, points[f[0]], points[f[1]], points[f[2]], shape.color * shade, top);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +182,11 @@ MeshData boulderMeshData() {
|
||||
// Hauteur totale 2 x 0,475 = 0,95 : 0,70 visibles, 0,25 enterres.
|
||||
shape.halfSize = { 0.52f, 0.475f, 0.44f };
|
||||
shape.yOffset = kRockVisibleHeight - 0.475f;
|
||||
// PHASE 30 (Agent B) : patine grise, albedo ~0,53 au lieu de 0,63. Le gros
|
||||
// bloc etait deja 36 % plus sombre que le sol rendu (Weber -0,36, mesure) ;
|
||||
// on CREUSE cet ecart, on ne l'inverse surtout pas : eclaircir "pour coller
|
||||
// au calcaire" fondrait le bloc dans un sol rendu tres clair (~224).
|
||||
shape.color = kLimestone * 0.85f;
|
||||
shape.seed = 0xB01DE5u;
|
||||
appendRock(mesh, shape);
|
||||
return mesh;
|
||||
@@ -175,15 +218,26 @@ MeshData gravelMeshData() {
|
||||
// Disque de rayon 0,5, repartition en racine pour ne pas tasser au centre.
|
||||
const float angle = 6.28318530718f * unit(rng);
|
||||
const float radius = 0.44f * std::sqrt(unit(rng));
|
||||
const float size = 0.05f + 0.07f * unit(rng); // demi-largeur 5 a 12 cm
|
||||
// PHASE 30 (Agent B) : des CAILLOUX et non du gravier. Demi-largeur 5-12 cm
|
||||
// -> 10-25 cm : a 5-12 cm, enterres a 60 %, il en depassait 2 a 5 cm, soit
|
||||
// 2 a 3 px a 10 m (mesure, build-phase30gentA\DIAGNOSTIC.md). Meme
|
||||
// nombre de tirages qu'avant : la disposition des cailloux est conservee.
|
||||
const float size = 0.10f + 0.15f * unit(rng);
|
||||
RockShape shape;
|
||||
shape.levels = 0; // 8 faces : un caillou de quelques cm n'en montre pas plus
|
||||
shape.bumpMin = 0.65f;
|
||||
shape.cuts = 2;
|
||||
// PHASE 30 : icosaedre, 20 faces (etait l'octaedre, 8). A 10-25 cm de
|
||||
// demi-largeur, l'octaedre se lisait comme une petite PYRAMIDE (vu sur
|
||||
// capture). L'octaedre subdivise (32 faces) etait plus rond mais coutait
|
||||
// +0,5 ms de drawFrame a 361 plaques (mesure entrelacee) ; l'icosaedre +
|
||||
// trois coupes donne un caillou anguleux et trapu pour 20 faces.
|
||||
shape.levels = -1;
|
||||
shape.bumpMin = 0.72f;
|
||||
shape.cuts = 3;
|
||||
shape.cutDepth = 0.55f;
|
||||
shape.halfSize = { size, 0.6f * size, 0.8f * size };
|
||||
// A moitie enterre : 0,4 x hauteur au-dessus du sol.
|
||||
shape.yOffset = -0.2f * shape.halfSize.y;
|
||||
// PHASE 30 : centre a +0,1 demi-hauteur (etait -0,2) : ~55 % de la
|
||||
// hauteur hors sol au lieu de 40 %, le pied reste enfoui de 0,9 demi-
|
||||
// hauteur (voir le controle de pose sur le DTM reel, RAPPORT Phase 30).
|
||||
shape.yOffset = 0.1f * shape.halfSize.y;
|
||||
shape.offset = { radius * std::cos(angle), radius * std::sin(angle) };
|
||||
shape.color = kLimestone * (0.85f + 0.2f * unit(rng));
|
||||
shape.seed = 0x9E11u + static_cast<uint32_t>(i) * 7919u;
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur