@@ -12,6 +12,7 @@ ofVboMesh::ofVboMesh(){
1212 vboNumColors = 0 ;
1313 vboNumTexCoords = 0 ;
1414 vboNumNormals = 0 ;
15+ updateSet = false ;
1516}
1617
1718ofVboMesh::ofVboMesh (const ofMesh & mom)
@@ -47,34 +48,42 @@ void ofVboMesh::setUsage(int _usage){
4748
4849void ofVboMesh::enableColors (){
4950 vbo.enableColors ();
51+ ofMesh::enableColors ();
5052}
5153
5254void ofVboMesh::enableTextures (){
5355 vbo.enableTexCoords ();
56+ ofMesh::enableTextures ();
5457}
5558
5659void ofVboMesh::enableNormals (){
5760 vbo.enableNormals ();
61+ ofMesh::enableNormals ();
5862}
5963
6064void ofVboMesh::enableIndices (){
6165 vbo.enableIndices ();
66+ ofMesh::enableIndices ();
6267}
6368
6469void ofVboMesh::disableColors (){
6570 vbo.disableColors ();
71+ ofMesh::disableColors ();
6672}
6773
6874void ofVboMesh::disableTextures (){
6975 vbo.disableTexCoords ();
76+ ofMesh::disableTextures ();
7077}
7178
7279void ofVboMesh::disableNormals (){
7380 vbo.disableNormals ();
81+ ofMesh::disableNormals ();
7482}
7583
7684void ofVboMesh::disableIndices (){
7785 vbo.disableIndices ();
86+ ofMesh::disableIndices ();
7887}
7988
8089bool ofVboMesh::usingColors () const {
@@ -156,7 +165,7 @@ void ofVboMesh::updateVbo(){
156165 if (getNumVertices ()==0 ){
157166 vbo.clearVertices ();
158167 vboNumVerts = getNumVertices ();
159- }else if (vboNumVerts<getNumVertices ()){
168+ }else if (vboNumVerts<getNumVertices () || updateSet ){
160169 vbo.setVertexData (getVerticesPointer (),getNumVertices (),usage);
161170 vboNumVerts = getNumVertices ();
162171 }else {
@@ -168,7 +177,7 @@ void ofVboMesh::updateVbo(){
168177 if (getNumColors ()==0 ){
169178 vbo.clearColors ();
170179 vboNumColors = getNumColors ();
171- }else if (vboNumColors<getNumColors ()){
180+ }else if (vboNumColors<getNumColors () || updateSet ){
172181 vbo.setColorData (getColorsPointer (),getNumColors (),usage);
173182 vboNumColors = getNumColors ();
174183 }else {
@@ -180,7 +189,7 @@ void ofVboMesh::updateVbo(){
180189 if (getNumNormals ()==0 ){
181190 vbo.clearNormals ();
182191 vboNumNormals = getNumNormals ();
183- }else if (vboNumNormals<getNumNormals ()){
192+ }else if (vboNumNormals<getNumNormals () || updateSet ){
184193 vbo.setNormalData (getNormalsPointer (),getNumNormals (),usage);
185194 vboNumNormals = getNumNormals ();
186195 }else {
@@ -192,7 +201,7 @@ void ofVboMesh::updateVbo(){
192201 if (getNumTexCoords ()==0 ){
193202 vbo.clearTexCoords ();
194203 vboNumTexCoords = getNumTexCoords ();
195- }else if (vboNumTexCoords<getNumTexCoords ()){
204+ }else if (vboNumTexCoords<getNumTexCoords () || updateSet ){
196205 vbo.setTexCoordData (getTexCoordsPointer (),getNumTexCoords (),usage);
197206 vboNumTexCoords = getNumTexCoords ();
198207 }else {
@@ -204,12 +213,39 @@ void ofVboMesh::updateVbo(){
204213 if (getNumIndices ()==0 ){
205214 vbo.clearIndices ();
206215 vboNumIndices = getNumIndices ();
207- }else if (vboNumIndices<getNumIndices ()){
216+ }else if (vboNumIndices<getNumIndices () || updateSet ){
208217 vbo.setIndexData (getIndexPointer (),getNumIndices (),usage);
209218 vboNumIndices = getNumIndices ();
210219 }else {
211220 vbo.updateIndexData (getIndexPointer (),getNumIndices ());
212221 }
213222 }
223+ if (updateSet) updateSet = false ;
214224 }
215225}
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