[Git][debian-gis-team/libcitygml][upstream] New upstream version 2.5.1
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Thu May 11 11:14:54 BST 2023
Bas Couwenberg pushed to branch upstream at Debian GIS Project / libcitygml
Commits:
126eeaf3 by Bas Couwenberg at 2023-05-11T11:24:23+02:00
New upstream version 2.5.1
- - - - -
2 changed files:
- sources/include/citygml/tesselator.h
- sources/src/citygml/tesselator.cpp
Changes:
=====================================
sources/include/citygml/tesselator.h
=====================================
@@ -57,6 +57,8 @@ public:
void compute() override;
private:
+ void processContours();
+
typedef void (APIENTRY *GLU_TESS_CALLBACK)();
static void CALLBACK beginCallback( GLenum, void* );
static void CALLBACK vertexDataCallback( GLvoid*, void* );
@@ -65,9 +67,18 @@ private:
static void CALLBACK errorCallback(GLenum, void*);
private:
+ //
+ struct ContourRef {
+ ContourRef(unsigned int index, unsigned int length) : index(index), length(length) {}
+ unsigned int index;
+ unsigned int length;
+ };
+
GLUtesselator *_tobj;
- GLenum _curMode;
+ GLenum _curMode;
GLenum _windingRule;
+ std::vector<TVec3d> _originalVertices;
+ std::vector<ContourRef> _contourQueue;
};
#endif // __TESSELATOR_H__
=====================================
sources/src/citygml/tesselator.cpp
=====================================
@@ -61,6 +61,7 @@ Tesselator::~Tesselator()
void Tesselator::compute()
{
+ processContours();
gluTessEndPolygon( _tobj );
}
@@ -69,15 +70,30 @@ void Tesselator::addContour(const std::vector<TVec3d>& pts, std::vector<std::vec
unsigned int pos = _vertices.size();
TesselatorBase::addContour(pts, textureCoordinatesLists);
- gluTessBeginContour( _tobj );
-
unsigned int len = pts.size();
- for ( unsigned int i = 0; i < len; i++ )
+ // Add contour to queue, and process later.
+ ContourRef contour(pos, len);
+ _contourQueue.push_back(contour);
+}
+
+void Tesselator::processContours()
+{
+ _originalVertices = _vertices;
+
+ for (const ContourRef& contour : _contourQueue)
{
- gluTessVertex( _tobj, &(_vertices[pos + i][0]), &_indices[pos + i] );
- }
+ gluTessBeginContour( _tobj );
- gluTessEndContour( _tobj );
+ for ( unsigned int i = 0; i < contour.length; i++ )
+ {
+ void* data = reinterpret_cast<void*>(static_cast<uintptr_t>(_indices[contour.index + i]));
+ gluTessVertex( _tobj, &(_originalVertices[contour.index + i][0]), data );
+ }
+
+ gluTessEndContour( _tobj );
+ }
+ _contourQueue.clear();
+ _originalVertices.clear();
}
void CALLBACK Tesselator::beginCallback( GLenum which, void* userData )
@@ -89,7 +105,7 @@ void CALLBACK Tesselator::beginCallback( GLenum which, void* userData )
void CALLBACK Tesselator::vertexDataCallback( GLvoid *data, void* userData )
{
Tesselator *tess = static_cast<Tesselator*>(userData);
- unsigned int index = *reinterpret_cast<unsigned int*>(data);
+ unsigned int index = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(data));
assert(index < tess->_vertices.size());
@@ -113,8 +129,8 @@ void CALLBACK Tesselator::combineCallback( GLdouble coords[3], void* vertex_data
TVec2f newTexCoord(0,0);
for (int i = 0; i < 4; i++) {
- if (vertex_data[i] != nullptr) {
- unsigned int vertexIndex = *reinterpret_cast<unsigned int*>(vertex_data[i]);
+ if (weight[i] > 0.0f) {
+ unsigned int vertexIndex = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(vertex_data[i]));
newTexCoord = newTexCoord + weight[i] * texcords.at(vertexIndex);
}
}
@@ -126,7 +142,7 @@ void CALLBACK Tesselator::combineCallback( GLdouble coords[3], void* vertex_data
}
}
- *outData = &tess->_indices.back();
+ *outData = reinterpret_cast<void*>(static_cast<uintptr_t>(tess->_indices.back()));
}
void CALLBACK Tesselator::endCallback( void* userData )
View it on GitLab: https://salsa.debian.org/debian-gis-team/libcitygml/-/commit/126eeaf34ebe6747611944bbf1701741ebfca9c6
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/libcitygml/-/commit/126eeaf34ebe6747611944bbf1701741ebfca9c6
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20230511/52065113/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list