@@ -12,6 +12,7 @@ ofVboMesh::ofVboMesh(){
12
12
vboNumColors = 0 ;
13
13
vboNumTexCoords = 0 ;
14
14
vboNumNormals = 0 ;
15
+ updateSet = false ;
15
16
}
16
17
17
18
ofVboMesh::ofVboMesh (const ofMesh & mom)
@@ -47,34 +48,42 @@ void ofVboMesh::setUsage(int _usage){
47
48
48
49
void ofVboMesh::enableColors (){
49
50
vbo.enableColors ();
51
+ ofMesh::enableColors ();
50
52
}
51
53
52
54
void ofVboMesh::enableTextures (){
53
55
vbo.enableTexCoords ();
56
+ ofMesh::enableTextures ();
54
57
}
55
58
56
59
void ofVboMesh::enableNormals (){
57
60
vbo.enableNormals ();
61
+ ofMesh::enableNormals ();
58
62
}
59
63
60
64
void ofVboMesh::enableIndices (){
61
65
vbo.enableIndices ();
66
+ ofMesh::enableIndices ();
62
67
}
63
68
64
69
void ofVboMesh::disableColors (){
65
70
vbo.disableColors ();
71
+ ofMesh::disableColors ();
66
72
}
67
73
68
74
void ofVboMesh::disableTextures (){
69
75
vbo.disableTexCoords ();
76
+ ofMesh::disableTextures ();
70
77
}
71
78
72
79
void ofVboMesh::disableNormals (){
73
80
vbo.disableNormals ();
81
+ ofMesh::disableNormals ();
74
82
}
75
83
76
84
void ofVboMesh::disableIndices (){
77
85
vbo.disableIndices ();
86
+ ofMesh::disableIndices ();
78
87
}
79
88
80
89
bool ofVboMesh::usingColors () const {
@@ -156,7 +165,7 @@ void ofVboMesh::updateVbo(){
156
165
if (getNumVertices ()==0 ){
157
166
vbo.clearVertices ();
158
167
vboNumVerts = getNumVertices ();
159
- }else if (vboNumVerts<getNumVertices ()){
168
+ }else if (vboNumVerts<getNumVertices () || updateSet ){
160
169
vbo.setVertexData (getVerticesPointer (),getNumVertices (),usage);
161
170
vboNumVerts = getNumVertices ();
162
171
}else {
@@ -168,7 +177,7 @@ void ofVboMesh::updateVbo(){
168
177
if (getNumColors ()==0 ){
169
178
vbo.clearColors ();
170
179
vboNumColors = getNumColors ();
171
- }else if (vboNumColors<getNumColors ()){
180
+ }else if (vboNumColors<getNumColors () || updateSet ){
172
181
vbo.setColorData (getColorsPointer (),getNumColors (),usage);
173
182
vboNumColors = getNumColors ();
174
183
}else {
@@ -180,7 +189,7 @@ void ofVboMesh::updateVbo(){
180
189
if (getNumNormals ()==0 ){
181
190
vbo.clearNormals ();
182
191
vboNumNormals = getNumNormals ();
183
- }else if (vboNumNormals<getNumNormals ()){
192
+ }else if (vboNumNormals<getNumNormals () || updateSet ){
184
193
vbo.setNormalData (getNormalsPointer (),getNumNormals (),usage);
185
194
vboNumNormals = getNumNormals ();
186
195
}else {
@@ -192,7 +201,7 @@ void ofVboMesh::updateVbo(){
192
201
if (getNumTexCoords ()==0 ){
193
202
vbo.clearTexCoords ();
194
203
vboNumTexCoords = getNumTexCoords ();
195
- }else if (vboNumTexCoords<getNumTexCoords ()){
204
+ }else if (vboNumTexCoords<getNumTexCoords () || updateSet ){
196
205
vbo.setTexCoordData (getTexCoordsPointer (),getNumTexCoords (),usage);
197
206
vboNumTexCoords = getNumTexCoords ();
198
207
}else {
@@ -204,12 +213,39 @@ void ofVboMesh::updateVbo(){
204
213
if (getNumIndices ()==0 ){
205
214
vbo.clearIndices ();
206
215
vboNumIndices = getNumIndices ();
207
- }else if (vboNumIndices<getNumIndices ()){
216
+ }else if (vboNumIndices<getNumIndices () || updateSet ){
208
217
vbo.setIndexData (getIndexPointer (),getNumIndices (),usage);
209
218
vboNumIndices = getNumIndices ();
210
219
}else {
211
220
vbo.updateIndexData (getIndexPointer (),getNumIndices ());
212
221
}
213
222
}
223
+ if (updateSet) updateSet = false ;
214
224
}
215
225
}
226
+
227
+ void ofVboMesh::removeVertex (ofIndexType index) {
228
+ ofMesh::removeVertex (index);
229
+ vboNumVerts = getNumVertices ();
230
+ updateSet = true ;
231
+ }
232
+
233
+ void ofVboMesh::removeVertex (ofIndexType startIndex, ofIndexType endIndex) {
234
+ ofMesh::removeVertices (startIndex, endIndex);
235
+ vboNumVerts = getNumVertices ();
236
+ updateSet = true ;
237
+ }
238
+
239
+ void ofVboMesh::removeColor (ofIndexType index) {
240
+ ofMesh::removeColor (index);
241
+ vboNumColors = getNumColors ();
242
+ updateSet = true ;
243
+ }
244
+
245
+ void ofVboMesh::removeColor (ofIndexType startIndex, ofIndexType endIndex) {
246
+ ofMesh::removeColors (startIndex, endIndex);
247
+ vboNumColors = getNumColors ();
248
+ updateSet = true ;
249
+ }
250
+
251
+
0 commit comments