2
2
3
3
#include " ../math/Vector3.h"
4
4
#include " ../common/Color.h"
5
+ #include " ../extras/Utils.h"
5
6
#include " VertexProfile.h"
6
7
#include " Enums.h"
7
8
#include < vector>
@@ -10,44 +11,49 @@ namespace Forth
10
11
{
11
12
struct Buffer3
12
13
{
13
- std::vector<Vector3> vertices;
14
- std::vector< int > indices;
14
+ FORTH_ARRAY ( vertices, Vector3) ;
15
+ FORTH_ARRAY ( indices, int ) ;
15
16
Forth::SimplexMode simplex;
16
17
17
18
Buffer3 () { simplex = SM_Triangle; }
18
19
19
20
~Buffer3 (void )
20
21
{
21
- Clear ();
22
+ delete[] vertices;
23
+ delete[] indices;
22
24
}
23
25
24
26
void Clear (void )
25
27
{
26
- vertices. clear () ;
27
- indices. clear () ;
28
+ vertices_count = 0 ;
29
+ indices_count = 0 ;
28
30
}
29
31
30
32
void AddVert (const Vector3 &v)
31
33
{
32
- vertices.push_back (v);
34
+ EnsureCapacity (&vertices, vertices_count, &vertices_cap, vertices_count + 1 );
35
+ vertices[vertices_count++] = v;
33
36
}
34
37
35
38
void AddTris (const int a)
36
39
{
37
- indices.push_back (a);
40
+ EnsureCapacity (&indices, indices_count, &indices_cap, indices_count + 1 );
41
+ indices[indices_count++] = a;
38
42
}
39
43
40
44
void AddTris (const int a, const int b)
41
45
{
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;
44
49
}
45
50
46
51
void AddTris (const int a, const int b, const int c)
47
52
{
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;
51
57
}
52
58
53
59
};
0 commit comments