67 #ifndef _graphicsproceduralweldverticesmodifier_cpp
68 #define _graphicsproceduralweldverticesmodifier_cpp
70 #include "Graphics/Procedural/Mesh/weldverticesmodifier.h"
90 std::map<Vector3, size_t, Vector3LengthCompare> MapExistingVertices;
94 size_t NewSize = Vertices.size();
95 for(
VertexIterator VertIt = Vertices.begin() ; VertIt != Vertices.end() ; ++VertIt )
97 size_t CurrentIndex = VertIt - Vertices.begin();
98 if( CurrentIndex >= NewSize )
100 if( MapExistingVertices.find(VertIt->Position) == MapExistingVertices.end() ) {
101 MapExistingVertices[VertIt->Position] = CurrentIndex;
103 size_t ExistingIndex = MapExistingVertices[VertIt->Position];
105 if( CurrentIndex == NewSize ) {
106 for(
IndexIterator IndexIt = Indices.begin() ; IndexIt != Indices.end() ; ++IndexIt )
108 if( (*IndexIt) == CurrentIndex ) {
109 (*IndexIt) = ExistingIndex;
113 size_t LastIndex = NewSize;
114 (*VertIt) = Vertices[LastIndex];
115 for(
IndexIterator IndexIt = Indices.begin() ; IndexIt != Indices.end() ; ++IndexIt )
117 if( (*IndexIt) == CurrentIndex ) {
118 (*IndexIt) = ExistingIndex;
119 }
else if( (*IndexIt) == LastIndex ) {
120 (*IndexIt) = CurrentIndex;
126 Vertices.resize(NewSize);
130 {
return "WeldVerticesModifier"; }
std::vector< Vertex > VertexContainer
Basic container type for Vertex storage.
Real WeldTolerance
The distance vertices have to be within to be combined.
IndexContainer & GetIndices()
Gets a modifiable reference to Indices.
VertexContainer::iterator VertexIterator
Iterator type for Vertex instances in a VertexContainer.
A modifier that will combine vertices together that are close to each other.
A convenience buffer that stores vertices and indices of a mesh to be generated.
virtual String GetName() const
Gets the name of this modifier.
VertexContainer & GetVertices()
Gets a modifiable reference to Vertices.
float Real
A Datatype used to represent a real floating point number.
std::vector< Integer > IndexContainer
A container of Integers used to represent the indicies of a shape.
WeldVerticesModifier & SetTolerance(const Real Tolerance)
Sets the distance within which vertices will be combined.
virtual ~WeldVerticesModifier()
Class destructor.
virtual void Modify(TriangleBuffer &Buffer)
Alters the generated pixels in a TriangleBuffer.
WeldVerticesModifier()
Blank constructor.
The bulk of the engine components go in this namspace.
IndexContainer::iterator IndexIterator
Iterator type for a IndexContainer.
std::string String
A datatype used to a series of characters.