Merge branch 'master' of https://github.com/supertuxkart/stk-code.git
This commit is contained in:
commit
0058002260
@ -19,20 +19,23 @@
|
|||||||
#include "graphics/mesh_tools.hpp"
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include <IMesh.h>
|
#include <IMesh.h>
|
||||||
#include <IMeshBuffer.h>
|
#include <IMeshBuffer.h>
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) {
|
void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) {
|
||||||
|
|
||||||
Vec3 extend;
|
Vec3 extend;
|
||||||
*min = Vec3( 999999.9f);
|
*min = Vec3( 999999.9f);
|
||||||
*max = Vec3(-999999.9f);
|
*max = Vec3(-999999.9f);
|
||||||
for(unsigned int i=0; i<mesh->getMeshBufferCount(); i++) {
|
for(unsigned int i=0; i<mesh->getMeshBufferCount(); i++)
|
||||||
|
{
|
||||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||||
|
|
||||||
if (mb->getVertexType() == video::EVT_STANDARD)
|
if (mb->getVertexType() == video::EVT_STANDARD)
|
||||||
{
|
{
|
||||||
u16 *mbIndices = mb->getIndices();
|
u16 *mbIndices = mb->getIndices();
|
||||||
video::S3DVertex* mbVertices=(irr::video::S3DVertex*)mb->getVertices();
|
video::S3DVertex* mbVertices=(irr::video::S3DVertex*)mb->getVertices();
|
||||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=1) {
|
for (unsigned int j=0; j<mb->getIndexCount(); j+=1)
|
||||||
|
{
|
||||||
int indx=mbIndices[j];
|
int indx=mbIndices[j];
|
||||||
Vec3 c(mbVertices[indx].Pos.X,
|
Vec3 c(mbVertices[indx].Pos.X,
|
||||||
mbVertices[indx].Pos.Y,
|
mbVertices[indx].Pos.Y,
|
||||||
@ -45,7 +48,22 @@ void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) {
|
|||||||
{
|
{
|
||||||
u16 *mbIndices = mb->getIndices();
|
u16 *mbIndices = mb->getIndices();
|
||||||
video::S3DVertex2TCoords* mbVertices=(irr::video::S3DVertex2TCoords*)mb->getVertices();
|
video::S3DVertex2TCoords* mbVertices=(irr::video::S3DVertex2TCoords*)mb->getVertices();
|
||||||
for(unsigned int j=0; j<mb->getIndexCount(); j+=1) {
|
for (unsigned int j=0; j<mb->getIndexCount(); j+=1)
|
||||||
|
{
|
||||||
|
int indx=mbIndices[j];
|
||||||
|
Vec3 c(mbVertices[indx].Pos.X,
|
||||||
|
mbVertices[indx].Pos.Y,
|
||||||
|
mbVertices[indx].Pos.Z );
|
||||||
|
min->min(c);
|
||||||
|
max->max(c);
|
||||||
|
} // for j
|
||||||
|
}
|
||||||
|
else if (mb->getVertexType() == video::EVT_TANGENTS)
|
||||||
|
{
|
||||||
|
u16 *mbIndices = mb->getIndices();
|
||||||
|
video::S3DVertexTangents* mbVertices=(irr::video::S3DVertexTangents*)mb->getVertices();
|
||||||
|
for (unsigned int j=0; j<mb->getIndexCount(); j+=1)
|
||||||
|
{
|
||||||
int indx=mbIndices[j];
|
int indx=mbIndices[j];
|
||||||
Vec3 c(mbVertices[indx].Pos.X,
|
Vec3 c(mbVertices[indx].Pos.X,
|
||||||
mbVertices[indx].Pos.Y,
|
mbVertices[indx].Pos.Y,
|
||||||
@ -56,8 +74,8 @@ void MeshTools::minMax3D(scene::IMesh* mesh, Vec3 *min, Vec3 *max) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Tools::minMax3D: Ignoring type '%d'!\n",
|
Log::warn("Tools", "minMax3D: Ignoring type '%d'!\n",
|
||||||
mb->getVertexType());
|
mb->getVertexType());
|
||||||
}
|
}
|
||||||
} // for i<getMeshBufferCount
|
} // for i<getMeshBufferCount
|
||||||
} // minMax3D
|
} // minMax3D
|
||||||
|
Loading…
x
Reference in New Issue
Block a user