text
stringlengths
0
234
use GL.Buffer.vertex, GL.Geometry, GL.Geometry.vbo;
the_Geometry : GL.geometry.vbo.vbo_Geometry renames GL.geometry.vbo.vbo_Geometry (self.skinned_geometry.Geometry.all);
begin
the_Geometry.Vertices := to_Buffer (To, usage => GL.static_draw); -- tbd : check usage
the_Geometry.vertex_Count := GL.SizeI (To'Length);
the_Geometry.Bounds := Bounds (To.all);
Function Definition: procedure Skin_is (o : in out tri_Mesh; Now : in GL.skins.p_Skin)
Function Body: is
begin
o.skinned_Geometry.Skin := Now;
o.skinned_Geometry.Veneer := Now.all.new_Veneer (for_geometry => o.skinned_Geometry.Geometry.all);
Function Definition: procedure dummy is begin null; end;
Function Body: -- 'vertex_cache_optimise' is based on algorithm descibed here . .. http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html
--
procedure vertex_cache_optimise (Vertices : in out GL.geometry.GL_Vertex_array; Indices : in out GL.geometry.vertex_Id_array)
is
use GL, GL.Geometry;
--subtype vertex_Id is Positive;
subtype triangle_Id is positive_uInt;
type triangle_Indices is array (Positive range <>) of triangle_Id;
function Indices_Index (the_Face : in positive_uInt; the_Vertex : in positive_uInt) return positive_uInt
is
begin
return 3 * (the_Face - 1) + the_Vertex;
Function Definition: procedure free is new ada.unchecked_deallocation (vco_vertex_Array, access_vco_vertex_Array);
Function Body: num_Faces : constant positive_uInt := indices'Length / 3;
vco_Vertices : access_vco_vertex_Array := new vco_vertex_Array; -- can be very large, so create in the heap
vco_Triangles : array (1 .. num_Faces) of vco_Triangle;
type LRU_Cache is array (Natural range <>) of GL.geometry.vertex_Id;
the_LRU_Cache : LRU_Cache (0 .. MaxSizeVertexCache - 1);
LRU_Cache_last : Integer := - 1;
procedure add_recent_Vertices_to_LRU_Cache (v1, v2, v3 : in GL.geometry.vertex_Id)
is
prior_Cache : LRU_Cache := the_LRU_Cache (0 .. LRU_Cache_last);
begin
the_LRU_Cache (0) := v1;
the_LRU_Cache (1) := v2;
the_LRU_Cache (2) := v3;
LRU_Cache_last := 2;
for Each in prior_Cache'Range loop
if not (prior_Cache (Each) = v1
or else prior_Cache (Each) = v2
or else prior_Cache (Each) = v3)
then
LRU_Cache_last := LRU_Cache_last + 1;
the_LRU_Cache (LRU_Cache_last) := prior_Cache (Each);
end if;
end loop;
end add_recent_Vertices_to_LRU_Cache;
function tri_Score_of (triangle_Id : in positive_uInt) return GL.Double
is
use GL;
the_Triangle : vco_Triangle renames vco_Triangles (triangle_Id);
Base : positive_uInt := positive_uInt (triangle_Id - 1) * 3;
v1_Id : GL.geometry.vertex_Id renames Indices (base + 1);
v2_Id : GL.geometry.vertex_Id renames Indices (base + 2);
v3_Id : GL.geometry.vertex_Id renames Indices (base + 3);
Score : GL.Double;
begin
Score := vco_Vertices (v1_Id).Score;
Score := Score + vco_Vertices (v2_Id).Score;
Score := Score + vco_Vertices (v3_Id).Score;
return Score;
end tri_Score_of;
best_Triangle : triangle_Id;
best_Triangle_score : GL.Double := GL.Double'First;
new_face_Indices : GL.geometry.vertex_Id_array (Indices'Range); -- the resulting optimised triangle indices.
-- new_face_Indices : triangle_vertex_Indices (o.Face_Indices'Range); -- the resulting optimised triangle indices.
-- -- new_face_Indices_last : Natural := new_face_Indices'first - 1;
begin
--put_Line ("start optimise !");
-- combined pass's : - increments the counter of the number of triangles that use each vertex
-- - adds the triangle to the vertex's triangle list, for each vertex.
--
for Each in 1 .. num_Faces loop
declare
procedure add_face_Vertex (which_vertex : positive_uInt)