22
33#include " ../math/Vector3.h"
44#include " ../common/Color.h"
5+ #include " ../extras/Utils.h"
56#include " VertexProfile.h"
67#include " Enums.h"
78#include < vector>
@@ -10,44 +11,49 @@ namespace Forth
1011{
1112 struct Buffer3
1213 {
13- std::vector<Vector3> vertices;
14- std::vector< int > indices;
14+ FORTH_ARRAY ( vertices, Vector3) ;
15+ FORTH_ARRAY ( indices, int ) ;
1516 Forth::SimplexMode simplex;
1617
1718 Buffer3 () { simplex = SM_Triangle; }
1819
1920 ~Buffer3 (void )
2021 {
21- Clear ();
22+ delete[] vertices;
23+ delete[] indices;
2224 }
2325
2426 void Clear (void )
2527 {
26- vertices. clear () ;
27- indices. clear () ;
28+ vertices_count = 0 ;
29+ indices_count = 0 ;
2830 }
2931
3032 void AddVert (const Vector3 &v)
3133 {
32- vertices.push_back (v);
34+ EnsureCapacity (&vertices, vertices_count, &vertices_cap, vertices_count + 1 );
35+ vertices[vertices_count++] = v;
3336 }
3437
3538 void AddTris (const int a)
3639 {
37- indices.push_back (a);
40+ EnsureCapacity (&indices, indices_count, &indices_cap, indices_count + 1 );
41+ indices[indices_count++] = a;
3842 }
3943
4044 void AddTris (const int a, const int b)
4145 {
42- indices.push_back (a);
43- indices.push_back (b);
46+ EnsureCapacity (&indices, indices_count, &indices_cap, indices_count + 2 );
47+ indices[indices_count++] = a;
48+ indices[indices_count++] = b;
4449 }
4550
4651 void AddTris (const int a, const int b, const int c)
4752 {
48- indices.push_back (a);
49- indices.push_back (b);
50- indices.push_back (c);
53+ EnsureCapacity (&indices, indices_count, &indices_cap, indices_count + 3 );
54+ indices[indices_count++] = a;
55+ indices[indices_count++] = b;
56+ indices[indices_count++] = c;
5157 }
5258
5359 };
0 commit comments