better comment clip_frustrum function
This commit is contained in:
parent
c4638880ae
commit
dd686b1887
|
@ -86,6 +86,7 @@ bool Windmill::object_in_frustrum(Object* object)
|
|||
|
||||
void Windmill::clip_frustrum(WMesh* mesh)
|
||||
{
|
||||
//pour chaque plan
|
||||
for (int p = 0; p<5 ; p++)
|
||||
{
|
||||
Plane plane = camera.frustrum.sides[p];
|
||||
|
@ -110,17 +111,19 @@ void Windmill::clip_frustrum(WMesh* mesh)
|
|||
// pour chaque segment
|
||||
for (int E = 0; E<3; E++)
|
||||
{
|
||||
// 2 vertexs correspondants à chaque segment
|
||||
Vertex vertexE(mesh->v[triangle.v[E]].x, mesh->v[triangle.v[E]].y, mesh->v[triangle.v[E]].z, mesh->t[triangle.t[E]].u,mesh->t[triangle.t[E]].v);
|
||||
Vertex vertexS(mesh->v[triangle.v[S]].x, mesh->v[triangle.v[S]].y, mesh->v[triangle.v[S]].z, mesh->t[triangle.t[S]].u,mesh->t[triangle.t[S]].v);
|
||||
|
||||
// teste si un des deux points du segment est en dehors du frustrum
|
||||
if (inside_frustrum(vertexE, plane) == true)
|
||||
{
|
||||
if (inside_frustrum(vertexS, plane) == false)
|
||||
{
|
||||
// on sauvegarde dans v_ok
|
||||
v_ok[ok_indice] = mesh->v_length;
|
||||
t_ok[ok_indice] = mesh->t_length;
|
||||
ok_indice++;
|
||||
|
||||
// on créée un vertex sécant de notre segment et du bord de l'écran
|
||||
mesh->add_vertex(clip_onto_plane(vertexE, vertexS, plane));
|
||||
}
|
||||
|
||||
|
@ -130,16 +133,19 @@ void Windmill::clip_frustrum(WMesh* mesh)
|
|||
}
|
||||
else if (inside_frustrum(vertexS, plane) == true)
|
||||
{
|
||||
// on sauvegarde dans v_ok
|
||||
v_ok[ok_indice] = mesh->v_length;
|
||||
t_ok[ok_indice] = mesh->t_length;
|
||||
ok_indice++;
|
||||
|
||||
// on créée un vertex sécant de notre segment et du bord de l'écran
|
||||
mesh->add_vertex(clip_onto_plane(vertexE, vertexS, plane));
|
||||
}
|
||||
|
||||
S = E;
|
||||
}
|
||||
|
||||
// maintenant on passe à la génération des faces à partir de nos nouveaux segments
|
||||
|
||||
// aucun point dans le frustrum
|
||||
if (ok_indice == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue