propagating precision requirments into operations

This commit is contained in:
Chris Russ
2016-07-15 15:38:29 +10:00
parent 5adb0e899c
commit fa1d6d8c55
36 changed files with 437 additions and 411 deletions

View File

@@ -163,13 +163,13 @@ static aiColor3D ReadColor(StreamReaderLE* stream)
static void UnknownChunk(StreamReaderLE* stream, const SIBChunk& chunk)
{
char temp[5] = {
char temp[5] = {
static_cast<char>(( chunk.Tag>>24 ) & 0xff),
static_cast<char>(( chunk.Tag>>16 ) & 0xff),
static_cast<char>(( chunk.Tag>>8 ) & 0xff),
static_cast<char>(chunk.Tag & 0xff), '\0'
};
DefaultLogger::get()->warn((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk."));
}
@@ -373,7 +373,7 @@ static void ConnectFaces(SIBMesh* mesh)
uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
uint32_t numPoints = *idx++;
uint32_t prev = idx[(numPoints-1)*N+POS];
for (uint32_t i=0;i<numPoints;i++,idx+=N)
{
uint32_t next = idx[POS];
@@ -398,7 +398,7 @@ static void ConnectFaces(SIBMesh* mesh)
static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_t pos,
const std::vector<aiVector3D>& faceNormals)
{
// Creased edges complicate this. We need to find the start/end range of the
// Creased edges complicate this. We need to find the start/end range of the
// ring of faces that touch this position.
// We do this in two passes. The first pass is to find the end of the range,
// the second is to work backwards to the start and calculate the final normal.
@@ -449,7 +449,7 @@ static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_
prevFaceIdx = faceIdx;
faceIdx = nextFaceIdx;
}
}
}
// Normalize it.
@@ -610,7 +610,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
obj.name = name;
obj.axis = smesh.axis;
obj.meshIdx = sib->meshes.size();
// Now that we know the size of everything,
// we can build the final one-material-per-mesh data.
for (size_t n=0;n<meshes.size();n++)
@@ -697,8 +697,8 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
light->mColorDiffuse = ReadColor(stream);
light->mColorAmbient = ReadColor(stream);
light->mColorSpecular = ReadColor(stream);
float spotExponent = stream->GetF4();
float spotCutoff = stream->GetF4();
ai_real spotExponent = stream->GetF4();
ai_real spotCutoff = stream->GetF4();
light->mAttenuationConstant = stream->GetF4();
light->mAttenuationLinear = stream->GetF4();
light->mAttenuationQuadratic = stream->GetF4();
@@ -709,9 +709,9 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
// 99% and 1% percentiles.
// OpenGL: I = cos(angle)^E
// Solving: angle = acos(I^(1/E))
float E = 1.0f / std::max(spotExponent, 0.00001f);
float inner = acosf(powf(0.99f, E));
float outer = acosf(powf(0.01f, E));
ai_real E = 1.0 / std::max(spotExponent, (ai_real)0.00001);
ai_real inner = acos(pow((ai_real)0.99, E));
ai_real outer = acos(pow((ai_real)0.01, E));
// Apply the cutoff.
outer = std::min(outer, AI_DEG_TO_RAD(spotCutoff));