More eigen fixes

pull/874/head
Levin Li 2020-11-17 18:18:39 +08:00
parent b8caa691f4
commit 0a891c4a11
2 changed files with 9 additions and 7 deletions

View File

@ -97,7 +97,7 @@ class M3DTriangleMesh
private:
std::vector<Eigen::Vector3f> points;
std::vector<Eigen::Vector2f> texCoords;
std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f>> texCoords;
std::vector<uint16_t> faces;
std::vector<uint32_t> smoothingGroups;
std::vector<M3DMeshMaterialGroup*> meshMaterialGroups;

View File

@ -295,18 +295,20 @@ struct GalaxyVertex
Matrix<GLshort, 4, 1> texCoord; // texCoord.x = x, texCoord.y = y, texCoord.z = color index, texCoord.w = alpha
};
static void draw(const GalaxyVertex *v, size_t count, const GLushort *indices)
typedef vector<GalaxyVertex, aligned_allocator<GalaxyVertex>> AlignedGalaxyVertices;
static void draw(const AlignedGalaxyVertices& v, size_t count, const GLushort *indices)
{
glVertexAttribPointer(CelestiaGLProgram::VertexCoordAttributeIndex,
4, GL_FLOAT, GL_FALSE,
sizeof(GalaxyVertex), v->position.data());
sizeof(GalaxyVertex), v[0].position.data());
glVertexAttribPointer(CelestiaGLProgram::TextureCoord0AttributeIndex,
4, GL_SHORT, GL_FALSE,
sizeof(GalaxyVertex), v->texCoord.data());
sizeof(GalaxyVertex), v[0].texCoord.data());
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, indices);
}
static GalaxyVertex *g_vertices = nullptr;
static AlignedGalaxyVertices g_vertices;
static GLushort *g_indices = nullptr;
constexpr const size_t maxPoints = 8192; // 256k buffer
@ -409,8 +411,8 @@ void Galaxy::renderGalaxyPointSprites(const Vector3f& offset,
glEnableVertexAttribArray(CelestiaGLProgram::VertexCoordAttributeIndex);
glEnableVertexAttribArray(CelestiaGLProgram::TextureCoord0AttributeIndex);
if (g_vertices == nullptr)
g_vertices = new GalaxyVertex[maxPoints];
if (g_vertices.empty())
g_vertices.reserve(maxPoints);
if (g_indices == nullptr)
g_indices = new GLushort[(maxPoints / 4 + 1) * 6];