Improved box generation speed

Former-commit-id: a76d97becdd8e41146a01c9970b358eaf6096623
This commit is contained in:
Lynix 2014-07-08 11:56:27 +02:00
parent a0c2d81114
commit c79047bd16
1 changed files with 6 additions and 8 deletions

View File

@ -732,48 +732,46 @@ void NzGenerateBox(const NzVector3f& lengths, const NzVector3ui& subdivision, co
// Face +X // Face +X
transform.MakeTransform(NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, -90.f)); transform.MakeTransform(NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, -90.f));
NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += xVertexCount; indexOffset += xVertexCount;
indices += xIndexCount; indices += xIndexCount;
vertices += xVertexCount; vertices += xVertexCount;
// Face +Y // Face +Y
transform.MakeTransform(NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 0.f)); transform.MakeTransform(NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 0.f));
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += yVertexCount; indexOffset += yVertexCount;
indices += yIndexCount; indices += yIndexCount;
vertices += yVertexCount; vertices += yVertexCount;
// Face +Z // Face +Z
transform.MakeTransform(NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, 90.f, 90.f)); transform.MakeTransform(NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, 90.f, 90.f));
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += zVertexCount; indexOffset += zVertexCount;
indices += zIndexCount; indices += zIndexCount;
vertices += zVertexCount; vertices += zVertexCount;
// Face -X // Face -X
transform.MakeTransform(-NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, 90.f)); transform.MakeTransform(-NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, 90.f));
NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += xVertexCount; indexOffset += xVertexCount;
indices += xIndexCount; indices += xIndexCount;
vertices += xVertexCount; vertices += xVertexCount;
// Face -Y // Face -Y
transform.MakeTransform(-NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 180.f)); transform.MakeTransform(-NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 180.f));
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += yVertexCount; indexOffset += yVertexCount;
indices += yIndexCount; indices += yIndexCount;
vertices += yVertexCount; vertices += yVertexCount;
// Face -Z // Face -Z
transform.MakeTransform(-NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, -90.f, 90.f)); transform.MakeTransform(-NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, -90.f, 90.f));
NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), transform, textureCoords, vertices, indices, nullptr, indexOffset); NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), matrix.ConcatenateAffine(transform), textureCoords, vertices, indices, nullptr, indexOffset);
indexOffset += zVertexCount; indexOffset += zVertexCount;
indices += zIndexCount; indices += zIndexCount;
vertices += zVertexCount; vertices += zVertexCount;
NzTransformVertices(oldVertices, vertices-oldVertices, matrix);
if (aabb) if (aabb)
{ {
aabb->Set(-halfLengths, halfLengths); aabb->Set(-halfLengths, halfLengths);