Merged from 1.6 branch, revisions 2665:2683. External creation of CSkinnedMesh. Texture matrix bug fixed. obj loader fixed. Divide by zero checks. Some API methods renamed. Strict aliasing fixes. Collada loader fixed.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2684 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-09-09 14:30:44 +00:00
parent 34d47c1cff
commit 64ad07a38e
45 changed files with 408 additions and 325 deletions

View File

@ -1,6 +1,6 @@
Changes in 1.6 (??.??.2009)
- Fix cursor problems found by buffer and by rvl2 as described in http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=34823&highlight=
- Renamed some methods in ISkinnedMesh to match the official Irrlicht naming scheme according to createXXX()
- Change debug data to draw using lines instead of arrows, which is much faster. Patch by pc0de
@ -647,6 +647,8 @@ Changes in 1.6 (??.??.2009)
-------------------------------------
Changes in version 1.5.1 (??.?? 2009)
- Fix cursor problems found by buffer and by rvl2 as described in http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=34823&highlight=
- Make sure a missing font does not corrupt the skin.
- Fix getAngle in vector2d as suggested by xray. This has only a minor impact on s32 vectors.

View File

@ -18,6 +18,7 @@
#include "EMeshWriterEnums.h"
#include "SceneParameters.h"
#include "IGeometryCreator.h"
#include "ISkinnedMesh.h"
namespace irr
{
@ -1440,6 +1441,11 @@ namespace scene
for details. */
virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) = 0;
//! Get a skinned mesh, which is not available as header-only code
/** Note: You need to drop() the pointer after use again, see IReferenceCounted::drop()
for details. */
virtual ISkinnedMesh* createSkinnedMesh() = 0;
//! Sets ambient color of the scene
virtual void setAmbientLight(const video::SColorf &ambientColor) = 0;

View File

@ -34,33 +34,35 @@ namespace scene
public:
//! Gets joint count.
//! \return Returns amount of joints in the skeletal animated mesh.
/** \return Amount of joints in the skeletal animated mesh. */
virtual u32 getJointCount() const = 0;
//! Gets the name of a joint.
//! \param number: Zero based index of joint. The last joint
//! has the number getJointCount()-1;
//! \return Returns name of joint and null if an error happened.
/** \param number: Zero based index of joint. The last joint
has the number getJointCount()-1;
\return Name of joint and null if an error happened. */
virtual const c8* getJointName(u32 number) const = 0;
//! Gets a joint number from its name
//! \param name: Name of the joint.
//! \return Returns the number of the joint or -1 if not found.
/** \param name: Name of the joint.
\return Number of the joint or -1 if not found. */
virtual s32 getJointNumber(const c8* name) const = 0;
//! uses animation from another mesh
//! the animation is linked (not copied) based on joint names (so make sure they are unique)
//! \return Returns true if all joints in this mesh were
//! matched up (empty names will not be matched, and it's case
//! sensitive). Unmatched joints will not be animated.
//! Use animation from another mesh
/** The animation is linked (not copied) based on joint names
so make sure they are unique.
\return True if all joints in this mesh were
matched up (empty names will not be matched, and it's case
sensitive). Unmatched joints will not be animated. */
virtual bool useAnimationFrom(const ISkinnedMesh *mesh) = 0;
//!Update Normals when Animating
//!False= Don't animate, faster
//!True= Update normals
//! Update Normals when Animating
/** \param on If false don't animate, which is faster.
Else update normals, which allows for proper lighting of
animated meshes. */
virtual void updateNormalsWhenAnimating(bool on) = 0;
//!Sets Interpolation Mode
//! Sets Interpolation Mode
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode) = 0;
//! Animates this mesh's joints based on frame input
@ -69,10 +71,12 @@ namespace scene
//! Preforms a software skin on this mesh based of joint positions
virtual void skinMesh() = 0;
//! converts the vertex type of all meshbuffers to tangents. eg for bumpmapping
//! converts the vertex type of all meshbuffers to tangents.
/** E.g. used for bump mapping. */
virtual void convertMeshToTangents() = 0;
//! (This feature is not implementated in irrlicht yet)
//! Allows to enable hardware skinning.
/* This feature is not implementated in Irrlicht yet */
virtual bool setHardwareSkinning(bool on) = 0;
//! A vertex weight
@ -179,26 +183,34 @@ namespace scene
//these functions will use the needed arrays, set values, etc to help the loaders
//! exposed for loaders: to add mesh buffers
virtual core::array<SSkinMeshBuffer*> &getMeshBuffers() = 0;
virtual core::array<SSkinMeshBuffer*>& getMeshBuffers() = 0;
//! exposed for loaders: joints list
virtual core::array<SJoint*> &getAllJoints() = 0;
virtual core::array<SJoint*>& getAllJoints() = 0;
//! exposed for loaders: joints list
virtual const core::array<SJoint*> &getAllJoints() const = 0;
virtual const core::array<SJoint*>& getAllJoints() const = 0;
//! loaders should call this after populating the mesh
virtual void finalize() = 0;
virtual SSkinMeshBuffer *createBuffer() = 0;
//! Adds a new meshbuffer to the mesh, access it as last one
virtual SSkinMeshBuffer* addMeshBuffer() = 0;
virtual SJoint *createJoint(SJoint *parent=0) = 0;
virtual SWeight *createWeight(SJoint *joint) = 0;
//! Adds a new joint to the mesh, access it as last one
virtual SJoint* addJoint(SJoint *parent=0) = 0;
virtual SPositionKey *createPositionKey(SJoint *joint) = 0;
virtual SScaleKey *createScaleKey(SJoint *joint) = 0;
virtual SRotationKey *createRotationKey(SJoint *joint) = 0;
//! Adds a new weight to the mesh, access it as last one
virtual SWeight* addWeight(SJoint *joint) = 0;
//! Adds a new position key to the mesh, access it as last one
virtual SPositionKey* addPositionKey(SJoint *joint) = 0;
//! Adds a new scale key to the mesh, access it as last one
virtual SScaleKey* addScaleKey(SJoint *joint) = 0;
//! Adds a new rotation key to the mesh, access it as last one
virtual SRotationKey* addRotationKey(SJoint *joint) = 0;
//! Check if the mesh is non-animated
virtual bool isStatic()=0;
};

View File

@ -979,7 +979,7 @@ namespace video
\param flag Texture creation flag.
\param enabled Specifies if the given flag should be enabled or
disabled. */
virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) =0;
virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
//! Returns if a texture creation flag is enabled or disabled.
/** You can change this value using setTextureCreationMode().

View File

@ -8,6 +8,7 @@
#include "SColor.h"
#include "matrix4.h"
#include "irrArray.h"
#include "irrMath.h"
#include "EMaterialTypes.h"
#include "EMaterialFlags.h"
#include "SMaterialLayer.h"
@ -100,7 +101,7 @@ namespace video
inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate=EMFN_MODULATE_1X, const u32 alphaSource=EAS_TEXTURE )
{
const u32 tmp = (alphaSource << 24) | (modulate << 16) | (srcFact << 8) | dstFact;
return *((f32*)&tmp);
return FR(tmp);
}
//! EMT_ONETEXTURE_BLEND: unpack srcFact & dstFact and Modulo to MaterialTypeParam
@ -108,7 +109,7 @@ namespace video
inline void unpack_texureBlendFunc ( E_BLEND_FACTOR &srcFact, E_BLEND_FACTOR &dstFact,
E_MODULATE_FUNC &modulo, u32& alphaSource, const f32 param )
{
const u32 state = *((u32*)&param);
const u32 state = IR(param);
alphaSource = (state & 0xFF000000) >> 24;
modulo = E_MODULATE_FUNC( ( state & 0x00FF0000 ) >> 16 );
srcFact = E_BLEND_FACTOR ( ( state & 0x0000FF00 ) >> 8 );

View File

@ -450,6 +450,7 @@ namespace core
// calculate: 1 / x
REALINLINE f32 reciprocal( const f32 f )
{
_IRR_DEBUG_BREAK_IF(f==0.f); //divide by zero
#if defined (IRRLICHT_FAST_MATH)
// SSE Newton-Raphson reciprocal estimate, accurate to 23 significant
@ -483,6 +484,7 @@ namespace core
// calculate: 1 / x
REALINLINE f64 reciprocal ( const f64 f )
{
_IRR_DEBUG_BREAK_IF(f==0.); //divide by zero
return 1.0 / f;
}
@ -490,6 +492,7 @@ namespace core
// calculate: 1 / x, low precision allowed
REALINLINE f32 reciprocal_approxim ( const f32 f )
{
_IRR_DEBUG_BREAK_IF(f==0.f); //divide by zero
#if defined( IRRLICHT_FAST_MATH)
// SSE Newton-Raphson reciprocal estimate, accurate to 23 significant
@ -639,5 +642,10 @@ namespace core
} // end namespace core
} // end namespace irr
#ifndef IRRLICHT_FAST_MATH
using irr::core::IR;
using irr::core::FR;
#endif
#endif

View File

@ -69,6 +69,7 @@
#include "IEventReceiver.h"
#include "IFileList.h"
#include "IFileSystem.h"
#include "IGeometryCreator.h"
#include "IGPUProgrammingServices.h"
#include "IGUIButton.h"
#include "IGUICheckBox.h"

View File

@ -1407,9 +1407,11 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
{
const f64 h = 1.0/tan(fieldOfViewRadians/2.0);
const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
_IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero
const T w = h / aspectRatio;
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = w;
M[1] = 0;
M[2] = 0;
@ -1444,9 +1446,11 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH(
f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
{
const f64 h = 1.0/tan(fieldOfViewRadians/2.0);
const f64 h = reciprocal(tan(fieldOfViewRadians*0.5));
_IRR_DEBUG_BREAK_IF(aspectRatio==0.f); //divide by zero
const T w = (T)(h / aspectRatio);
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = w;
M[1] = 0;
M[2] = 0;
@ -1479,6 +1483,9 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoLH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
{
_IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
@ -1511,6 +1518,9 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoRH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
{
_IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
@ -1543,6 +1553,9 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveRH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
{
_IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2*zNear/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
@ -1575,6 +1588,9 @@ namespace core
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveLH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
{
_IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2*zNear/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
@ -1775,11 +1791,11 @@ namespace core
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildNDCToDCMatrix( const core::rect<s32>& viewport, f32 zScale)
{
const f32 scaleX = (viewport.getWidth() - 0.75f ) / 2.0f;
const f32 scaleY = -(viewport.getHeight() - 0.75f ) / 2.0f;
const f32 scaleX = (viewport.getWidth() - 0.75f ) * 0.5f;
const f32 scaleY = -(viewport.getHeight() - 0.75f ) * 0.5f;
const f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) / 2.0f );
const f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) / 2.0f );
const f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) * 0.5f );
const f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) * 0.5f );
makeIdentity();
M[12] = (T)dx;

View File

@ -23,9 +23,10 @@ namespace scene
{
namespace
{
enum e3DSChunk
{
// Primary chunk
C3DS_MAIN3DS = 0x4D4D,
@ -120,6 +121,7 @@ enum e3DSChunk
C3DS_CHUNK_MAX = 0xFFFF
};
}
//! Constructor

View File

@ -152,13 +152,13 @@ bool CB3DMeshFileLoader::load()
}
bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint)
{
CSkinnedMesh::SJoint *Joint = AnimatedMesh->createJoint(InJoint);
readString(Joint->Name);
CSkinnedMesh::SJoint *joint = AnimatedMesh->addJoint(inJoint);
readString(joint->Name);
#ifdef _B3D_READER_DEBUG
os::Printer::log("read ChunkNODE", Joint->Name.c_str());
os::Printer::log("read ChunkNODE", joint->Name.c_str());
#endif
f32 position[3], scale[3], rotation[4];
@ -167,24 +167,24 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
readFloats(scale, 3);
readFloats(rotation, 4);
Joint->Animatedposition = core::vector3df(position[0],position[1],position[2]) ;
Joint->Animatedscale = core::vector3df(scale[0],scale[1],scale[2]);
Joint->Animatedrotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]);
joint->Animatedposition = core::vector3df(position[0],position[1],position[2]) ;
joint->Animatedscale = core::vector3df(scale[0],scale[1],scale[2]);
joint->Animatedrotation = core::quaternion(rotation[1], rotation[2], rotation[3], rotation[0]);
//Build LocalMatrix:
core::matrix4 positionMatrix;
positionMatrix.setTranslation( Joint->Animatedposition );
positionMatrix.setTranslation( joint->Animatedposition );
core::matrix4 scaleMatrix;
scaleMatrix.setScale( Joint->Animatedscale );
core::matrix4 rotationMatrix = Joint->Animatedrotation.getMatrix();
scaleMatrix.setScale( joint->Animatedscale );
core::matrix4 rotationMatrix = joint->Animatedrotation.getMatrix();
Joint->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix;
joint->LocalMatrix = positionMatrix * rotationMatrix * scaleMatrix;
if (InJoint)
Joint->GlobalMatrix = InJoint->GlobalMatrix * Joint->LocalMatrix;
if (inJoint)
joint->GlobalMatrix = inJoint->GlobalMatrix * joint->LocalMatrix;
else
Joint->GlobalMatrix = Joint->LocalMatrix;
joint->GlobalMatrix = joint->LocalMatrix;
while(B3dStack.getLast().startposition + B3dStack.getLast().length > B3DFile->getPos()) // this chunk repeats
{
@ -198,22 +198,22 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
if ( strncmp( B3dStack.getLast().name, "NODE", 4 ) == 0 )
{
if (!readChunkNODE(Joint))
if (!readChunkNODE(joint))
return false;
}
else if ( strncmp( B3dStack.getLast().name, "MESH", 4 ) == 0 )
{
if (!readChunkMESH(Joint))
if (!readChunkMESH(joint))
return false;
}
else if ( strncmp( B3dStack.getLast().name, "BONE", 4 ) == 0 )
{
if (!readChunkBONE(Joint))
if (!readChunkBONE(joint))
return false;
}
else if ( strncmp( B3dStack.getLast().name, "KEYS", 4 ) == 0 )
{
if(!readChunkKEYS(Joint))
if(!readChunkKEYS(joint))
return false;
}
else if ( strncmp( B3dStack.getLast().name, "ANIM", 4 ) == 0 )
@ -235,7 +235,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *InJoint)
}
bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *InJoint)
bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
{
#ifdef _B3D_READER_DEBUG
os::Printer::log("read ChunkMESH");
@ -263,41 +263,41 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *InJoint)
if ( strncmp( B3dStack.getLast().name, "VRTS", 4 ) == 0 )
{
if (!readChunkVRTS(InJoint))
if (!readChunkVRTS(inJoint))
return false;
}
else if ( strncmp( B3dStack.getLast().name, "TRIS", 4 ) == 0 )
{
scene::SSkinMeshBuffer *MeshBuffer = AnimatedMesh->createBuffer();
scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer();
if (brush_id!=-1)
{
loadTextures(Materials[brush_id]);
MeshBuffer->Material=Materials[brush_id].Material;
meshBuffer->Material=Materials[brush_id].Material;
}
if(readChunkTRIS(MeshBuffer,AnimatedMesh->getMeshBuffers().size()-1, vertices_Start)==false)
if(readChunkTRIS(meshBuffer,AnimatedMesh->getMeshBuffers().size()-1, vertices_Start)==false)
return false;
if (!NormalsInFile)
{
s32 i;
for ( i=0; i<(s32)MeshBuffer->Indices.size(); i+=3)
for ( i=0; i<(s32)meshBuffer->Indices.size(); i+=3)
{
core::plane3df p(MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Pos,
MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Pos,
MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Pos);
core::plane3df p(meshBuffer->getVertex(meshBuffer->Indices[i+0])->Pos,
meshBuffer->getVertex(meshBuffer->Indices[i+1])->Pos,
meshBuffer->getVertex(meshBuffer->Indices[i+2])->Pos);
MeshBuffer->getVertex(MeshBuffer->Indices[i+0])->Normal += p.Normal;
MeshBuffer->getVertex(MeshBuffer->Indices[i+1])->Normal += p.Normal;
MeshBuffer->getVertex(MeshBuffer->Indices[i+2])->Normal += p.Normal;
meshBuffer->getVertex(meshBuffer->Indices[i+0])->Normal += p.Normal;
meshBuffer->getVertex(meshBuffer->Indices[i+1])->Normal += p.Normal;
meshBuffer->getVertex(meshBuffer->Indices[i+2])->Normal += p.Normal;
}
for ( i = 0; i<(s32)MeshBuffer->getVertexCount(); ++i )
for ( i = 0; i<(s32)meshBuffer->getVertexCount(); ++i )
{
MeshBuffer->getVertex(i)->Normal.normalize();
BaseVertices[vertices_Start+i].Normal=MeshBuffer->getVertex(i)->Normal;
meshBuffer->getVertex(i)->Normal.normalize();
BaseVertices[vertices_Start+i].Normal=meshBuffer->getVertex(i)->Normal;
}
}
}
@ -328,7 +328,7 @@ VRTS:
float tex_coords[tex_coord_sets][tex_coord_set_size] ;tex coords
}
*/
bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *InJoint)
bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *inJoint)
{
#ifdef _B3D_READER_DEBUG
os::Printer::log("read ChunkVRTS");
@ -412,8 +412,8 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *InJoint)
tu, tv, tu2, tv2);
// Transform the Vertex position by nested node...
InJoint->GlobalMatrix.transformVect(Vertex.Pos);
InJoint->GlobalMatrix.rotateVect(Vertex.Normal);
inJoint->GlobalMatrix.transformVect(Vertex.Pos);
inJoint->GlobalMatrix.rotateVect(Vertex.Normal);
//Add it...
BaseVertices.push_back(Vertex);
@ -428,7 +428,7 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *InJoint)
}
bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 MeshBufferID, s32 vertices_Start)
bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 meshBufferID, s32 vertices_Start)
{
#ifdef _B3D_READER_DEBUG
os::Printer::log("read ChunkTRIS");
@ -448,13 +448,13 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 M
{
loadTextures(Materials[triangle_brush_id]);
B3dMaterial = &Materials[triangle_brush_id];
MeshBuffer->Material = B3dMaterial->Material;
meshBuffer->Material = B3dMaterial->Material;
}
else
B3dMaterial = 0;
const s32 memoryNeeded = B3dStack.getLast().length / sizeof(s32);
MeshBuffer->Indices.reallocate(memoryNeeded + MeshBuffer->Indices.size() + 1);
meshBuffer->Indices.reallocate(memoryNeeded + meshBuffer->Indices.size() + 1);
while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats
{
@ -482,7 +482,7 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 M
if (AnimatedVertices_VertexID[ vertex_id[i] ] != -1)
{
if ( AnimatedVertices_BufferID[ vertex_id[i] ] != (s32)MeshBufferID ) //If this vertex is linked in a different meshbuffer
if ( AnimatedVertices_BufferID[ vertex_id[i] ] != (s32)meshBufferID ) //If this vertex is linked in a different meshbuffer
{
AnimatedVertices_VertexID[ vertex_id[i] ] = -1;
AnimatedVertices_BufferID[ vertex_id[i] ] = -1;
@ -493,22 +493,22 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 M
{
//Check for lightmapping:
if (BaseVertices[ vertex_id[i] ].TCoords2 != core::vector2df(0.f,0.f))
MeshBuffer->MoveTo_2TCoords(); //Will only affect the meshbuffer the first time this is called
meshBuffer->MoveTo_2TCoords(); //Will only affect the meshbuffer the first time this is called
//Add the vertex to the meshbuffer:
if (MeshBuffer->VertexType == video::EVT_STANDARD)
MeshBuffer->Vertices_Standard.push_back( BaseVertices[ vertex_id[i] ] );
if (meshBuffer->VertexType == video::EVT_STANDARD)
meshBuffer->Vertices_Standard.push_back( BaseVertices[ vertex_id[i] ] );
else
MeshBuffer->Vertices_2TCoords.push_back(BaseVertices[ vertex_id[i] ] );
meshBuffer->Vertices_2TCoords.push_back(BaseVertices[ vertex_id[i] ] );
//create vertex id to meshbuffer index link:
AnimatedVertices_VertexID[ vertex_id[i] ] = MeshBuffer->getVertexCount()-1;
AnimatedVertices_BufferID[ vertex_id[i] ] = MeshBufferID;
AnimatedVertices_VertexID[ vertex_id[i] ] = meshBuffer->getVertexCount()-1;
AnimatedVertices_BufferID[ vertex_id[i] ] = meshBufferID;
if (B3dMaterial)
{
// Apply Material/Color/etc...
video::S3DVertex *Vertex=MeshBuffer->getVertex(MeshBuffer->getVertexCount()-1);
video::S3DVertex *Vertex=meshBuffer->getVertex(meshBuffer->getVertexCount()-1);
if (Vertex->Color.getAlpha() == 255)
Vertex->Color.setAlpha( (s32)(B3dMaterial->alpha * 255.0f) );
@ -530,9 +530,9 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 M
}
}
MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[0] ] );
MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[1] ] );
MeshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[2] ] );
meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[0] ] );
meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[1] ] );
meshBuffer->Indices.push_back( AnimatedVertices_VertexID[ vertex_id[2] ] );
}
B3dStack.erase(B3dStack.size()-1);
@ -544,7 +544,7 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *MeshBuffer, u32 M
}
bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *InJoint)
bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint)
{
#ifdef _B3D_READER_DEBUG
os::Printer::log("read ChunkBONE");
@ -554,7 +554,7 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *InJoint)
{
while((B3dStack.getLast().startposition + B3dStack.getLast().length) > B3DFile->getPos()) // this chunk repeats
{
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(InJoint);
CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(inJoint);
u32 globalVertexID;
@ -572,7 +572,7 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *InJoint)
}
else
{
//Find the MeshBuffer and Vertex index from the Global Vertex ID:
//Find the meshbuffer and Vertex index from the Global Vertex ID:
weight->vertex_id = AnimatedVertices_VertexID[globalVertexID];
weight->buffer_id = AnimatedVertices_BufferID[globalVertexID];
}
@ -584,7 +584,7 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *InJoint)
}
bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *InJoint)
bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *inJoint)
{
#ifdef _B3D_READER_DEBUG
// os::Printer::log("read ChunkKEYS");
@ -610,21 +610,21 @@ bool CB3DMeshFileLoader::readChunkKEYS(CSkinnedMesh::SJoint *InJoint)
if (flags & 1)
{
readFloats(data, 3);
CSkinnedMesh::SPositionKey *Key=AnimatedMesh->createPositionKey(InJoint);
CSkinnedMesh::SPositionKey *Key=AnimatedMesh->addPositionKey(inJoint);
Key->frame = (f32)frame-1;
Key->position.set(data[0], data[1], data[2]);
}
if (flags & 2)
{
readFloats(data, 3);
CSkinnedMesh::SScaleKey *Key=AnimatedMesh->createScaleKey(InJoint);
CSkinnedMesh::SScaleKey *Key=AnimatedMesh->addScaleKey(inJoint);
Key->frame = (f32)frame-1;
Key->scale.set(data[0], data[1], data[2]);
}
if (flags & 4)
{
readFloats(data, 4);
CSkinnedMesh::SRotationKey *Key=AnimatedMesh->createRotationKey(InJoint);
CSkinnedMesh::SRotationKey *Key=AnimatedMesh->addRotationKey(inJoint);
Key->frame = (f32)frame-1;
// meant to be in this order since b3d stores W first
Key->rotation.set(data[1], data[2], data[3], data[0]);

View File

@ -28,9 +28,10 @@
namespace irr
{
namespace scene
{
namespace
{
// currently supported COLLADA tag names
const core::stringc colladaSectionName = "COLLADA";
const core::stringc librarySectionName = "library";
const core::stringc libraryNodesSectionName = "library_nodes";
@ -122,6 +123,7 @@ namespace scene
const char* const inputSemanticNames[] = {"POSITION", "VERTEX", "NORMAL", "TEXCOORD",
"UV", "TANGENT", "IMAGE", "TEXTURE", 0};
}
//! following class is for holding and creating instances of library
//! objects, named prefabs in this loader.
@ -1859,6 +1861,8 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader,
core::stringc polygonType = reader->getNodeName();
const int polygonCount = reader->getAttributeValueAsInt("count"); // Not useful because it only determines the number of primitives, which have arbitrary vertices in case of polygon
core::array<SPolygon> polygons;
if (polygonType == polygonsSectionName)
polygons.reallocate(polygonCount);
core::array<int> vCounts;
bool parsePolygonOK = false;
bool parseVcountOK = false;
@ -1976,6 +1980,9 @@ void CColladaFileLoader::readPolygonSection(io::IXMLReaderUTF8* reader,
data.trim();
const c8* p = &data[0];
SPolygon& poly = polygons.getLast();
if (polygonType == polygonsSectionName)
poly.Indices.reallocate((maxOffset+1)*3);
else
poly.Indices.reallocate(polygonCount*(maxOffset+1)*3);
if (vCounts.empty())

View File

@ -615,15 +615,15 @@ void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state,
pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer()));
Transformation3DChanged = true;
break;
case ETS_TEXTURE_0:
case ETS_TEXTURE_1:
case ETS_TEXTURE_2:
case ETS_TEXTURE_3:
case ETS_COUNT:
return;
default:
if (state-ETS_TEXTURE_0 < MATERIAL_MAX_TEXTURES)
{
pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )),
(D3DMATRIX*)((void*)mat.pointer()));
break;
case ETS_COUNT:
}
break;
}

View File

@ -650,10 +650,11 @@ void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state,
case ETS_PROJECTION:
pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)mat.pointer()));
break;
case ETS_TEXTURE_0:
case ETS_TEXTURE_1:
case ETS_TEXTURE_2:
case ETS_TEXTURE_3:
case ETS_COUNT:
return;
default:
if (state-ETS_TEXTURE_0 < MATERIAL_MAX_TEXTURES)
{
if (mat.isIdentity())
pID3DDevice->SetTextureStageState( state - ETS_TEXTURE_0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
else
@ -662,8 +663,7 @@ void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state,
pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+ ( state - ETS_TEXTURE_0 )),
(D3DMATRIX*)((void*)mat.pointer()));
}
break;
case ETS_COUNT:
}
break;
}
@ -3085,7 +3085,7 @@ void CD3D9Driver::checkDepthBuffer(ITexture* tex)
else
{
char buffer[128];
sprintf(buffer,"Could not create DepthBuffer of %ix%i",destSize.Width,destSize.Height);
sprintf(buffer,"Could not create DepthBuffer of %ix%i",optSize.Width,optSize.Height);
os::Printer::log(buffer,ELL_ERROR);
}
DepthBuffers.erase(DepthBuffers.size()-1);

View File

@ -19,7 +19,6 @@
#include <Windowsx.h>
#endif
namespace irr
{
class CIrrDeviceWin32 : public CIrrDeviceStub, video::IImagePresenter

View File

@ -229,8 +229,6 @@ namespace irr
p.y = GET_Y_LPARAM(xy);
}
RECT rect;
if (UseReferenceRect)
{
CursorPos.X = p.x - ReferenceRect.UpperLeftCorner.X;
@ -238,6 +236,7 @@ namespace irr
}
else
{
RECT rect;
if (GetWindowRect(HWnd, &rect))
{
CursorPos.X = p.x-rect.left-BorderX;

View File

@ -340,7 +340,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
if(numMaterials == 0)
{
// if there are no materials, add at least one buffer
AnimatedMesh->createBuffer();
AnimatedMesh->addMeshBuffer();
}
for (i=0; i<numMaterials; ++i)
@ -366,7 +366,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
return false;
}
scene::SSkinMeshBuffer *tmpBuffer = AnimatedMesh->createBuffer();
scene::SSkinMeshBuffer *tmpBuffer = AnimatedMesh->addMeshBuffer();
tmpBuffer->Material.MaterialType = video::EMT_SOLID;
@ -451,7 +451,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
return false;
}
ISkinnedMesh::SJoint *jnt = AnimatedMesh->createJoint();
ISkinnedMesh::SJoint *jnt = AnimatedMesh->addJoint();
jnt->Name = pJoint->Name;
#ifdef _IRR_DEBUG_MS3D_LOADER_
@ -496,7 +496,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
return false;
}
ISkinnedMesh::SRotationKey *k=AnimatedMesh->createRotationKey(jnt);
ISkinnedMesh::SRotationKey *k=AnimatedMesh->addRotationKey(jnt);
k->frame = kf->Time * framesPerSecond-1;
core::matrix4 tmpMatrix;
@ -532,7 +532,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
return false;
}
ISkinnedMesh::SPositionKey *k=AnimatedMesh->createPositionKey(jnt);
ISkinnedMesh::SPositionKey *k=AnimatedMesh->addPositionKey(jnt);
k->frame = kf->Time * framesPerSecond-1;
k->position = core::vector3df
@ -713,7 +713,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
const s32 boneid = vertices[vertidx].BoneID;
if ((u32)boneid < AnimatedMesh->getAllJoints().size())
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
w->strength = 1.0f;
w->vertex_id = index;
@ -725,7 +725,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
s32 boneid = vertices[vertidx].BoneID;
if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[0] != 0))
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
sum -= (w->strength = vertexWeights[vertidx].weights[0]/100.f);
w->vertex_id = index;
@ -733,7 +733,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
boneid = vertexWeights[vertidx].boneIds[0];
if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[1] != 0))
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
sum -= (w->strength = vertexWeights[vertidx].weights[1]/100.f);
w->vertex_id = index;
@ -741,7 +741,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
boneid = vertexWeights[vertidx].boneIds[1];
if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (vertexWeights[vertidx].weights[2] != 0))
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
sum -= (w->strength = vertexWeights[vertidx].weights[2]/100.f);
w->vertex_id = index;
@ -749,7 +749,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
boneid = vertexWeights[vertidx].boneIds[2];
if (((u32)boneid < AnimatedMesh->getAllJoints().size()) && (sum > 0.f))
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
w->strength = sum;
w->vertex_id = index;
@ -758,7 +758,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
boneid = vertices[vertidx].BoneID;
if ((sum == 1.f) && ((u32)boneid < AnimatedMesh->getAllJoints().size()))
{
ISkinnedMesh::SWeight *w=AnimatedMesh->createWeight(AnimatedMesh->getAllJoints()[boneid]);
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx;
w->strength = 1.f;
w->vertex_id = index;

View File

@ -324,10 +324,11 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf
u8 type=0; // map_Kd - diffuse color texture map
// map_Ks - specular color texture map
// map_Ka - ambient color texture map
// map_Ns - shininess texture map
if ((!strncmp(bufPtr,"map_bump",8)) || (!strncmp(bufPtr,"bump",4)))
type=1; // normal map
else if (!strncmp(bufPtr,"map_d",5))
type=2; // opactity map
else if ((!strncmp(bufPtr,"map_d",5)) || (!strncmp(bufPtr,"map_opacity",11)))
type=2; // opacity map
else if (!strncmp(bufPtr,"map_refl",8))
type=3; // reflection map
// extract new material's name
@ -422,11 +423,14 @@ const c8* COBJMeshFileLoader::readTextures(const c8* bufPtr, const c8* const buf
texname.replace('\\', '/');
video::ITexture * texture = 0;
if (texname.size())
{
if (FileSystem->existFile(texname))
texture = SceneManager->getVideoDriver()->getTexture(texname);
else
// try to read in the relative path, the .obj is loaded from
texture = SceneManager->getVideoDriver()->getTexture( relPath + texname );
}
if ( texture )
{
if (type==0)

View File

@ -781,12 +781,14 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
glLoadMatrixf(glmat);
}
break;
case ETS_TEXTURE_0:
case ETS_TEXTURE_1:
case ETS_TEXTURE_2:
case ETS_TEXTURE_3:
case ETS_COUNT:
return;
default:
{
const u32 i = state - ETS_TEXTURE_0;
if (i >= MATERIAL_MAX_TEXTURES)
break;
const bool isRTT = Material.getTexture(i) && Material.getTexture(i)->isRenderTarget();
if (MultiTextureExtension)
@ -807,8 +809,6 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
}
break;
}
default:
break;
}
}

View File

@ -2523,6 +2523,12 @@ const video::SColorf& CSceneManager::getAmbientLight() const
}
//! Get a skinned mesh, which is not available as header-only code
ISkinnedMesh* CSceneManager::createSkinnedMesh()
{
return new CSkinnedMesh();
}
//! Returns a mesh writer implementation if available
IMeshWriter* CSceneManager::createMeshWriter(EMESH_WRITER_TYPE type)
{

View File

@ -473,6 +473,9 @@ namespace scene
//! Returns a mesh writer implementation if available
virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type);
//! Get a skinned mesh, which is not available as header-only code
virtual ISkinnedMesh* createSkinnedMesh();
//! Sets ambient color of the scene
virtual void setAmbientLight(const video::SColorf &ambientColor);

View File

@ -1124,7 +1124,7 @@ void CSkinnedMesh::updateBoundingBox(void)
}
scene::SSkinMeshBuffer *CSkinnedMesh::createBuffer()
scene::SSkinMeshBuffer *CSkinnedMesh::addMeshBuffer()
{
scene::SSkinMeshBuffer *buffer=new scene::SSkinMeshBuffer();
LocalBuffers.push_back(buffer);
@ -1132,7 +1132,7 @@ scene::SSkinMeshBuffer *CSkinnedMesh::createBuffer()
}
CSkinnedMesh::SJoint *CSkinnedMesh::createJoint(SJoint *parent)
CSkinnedMesh::SJoint *CSkinnedMesh::addJoint(SJoint *parent)
{
SJoint *joint=new SJoint;
@ -1151,7 +1151,7 @@ CSkinnedMesh::SJoint *CSkinnedMesh::createJoint(SJoint *parent)
}
CSkinnedMesh::SPositionKey *CSkinnedMesh::createPositionKey(SJoint *joint)
CSkinnedMesh::SPositionKey *CSkinnedMesh::addPositionKey(SJoint *joint)
{
if (!joint)
return 0;
@ -1161,7 +1161,7 @@ CSkinnedMesh::SPositionKey *CSkinnedMesh::createPositionKey(SJoint *joint)
}
CSkinnedMesh::SScaleKey *CSkinnedMesh::createScaleKey(SJoint *joint)
CSkinnedMesh::SScaleKey *CSkinnedMesh::addScaleKey(SJoint *joint)
{
if (!joint)
return 0;
@ -1171,7 +1171,7 @@ CSkinnedMesh::SScaleKey *CSkinnedMesh::createScaleKey(SJoint *joint)
}
CSkinnedMesh::SRotationKey *CSkinnedMesh::createRotationKey(SJoint *joint)
CSkinnedMesh::SRotationKey *CSkinnedMesh::addRotationKey(SJoint *joint)
{
if (!joint)
return 0;
@ -1181,7 +1181,7 @@ CSkinnedMesh::SRotationKey *CSkinnedMesh::createRotationKey(SJoint *joint)
}
CSkinnedMesh::SWeight *CSkinnedMesh::createWeight(SJoint *joint)
CSkinnedMesh::SWeight *CSkinnedMesh::addWeight(SJoint *joint)
{
if (!joint)
return 0;

View File

@ -134,15 +134,15 @@ namespace scene
//! loaders should call this after populating the mesh
virtual void finalize();
virtual SSkinMeshBuffer *createBuffer();
virtual SSkinMeshBuffer *addMeshBuffer();
virtual SJoint *createJoint(SJoint *parent=0);
virtual SJoint *addJoint(SJoint *parent=0);
virtual SPositionKey *createPositionKey(SJoint *joint);
virtual SRotationKey *createRotationKey(SJoint *joint);
virtual SScaleKey *createScaleKey(SJoint *joint);
virtual SPositionKey *addPositionKey(SJoint *joint);
virtual SRotationKey *addRotationKey(SJoint *joint);
virtual SScaleKey *addScaleKey(SJoint *joint);
virtual SWeight *createWeight(SJoint *joint);
virtual SWeight *addWeight(SJoint *joint);
virtual void updateBoundingBox(void);

View File

@ -261,11 +261,13 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
if ( a->Pos.y > c->Pos.y ) swapVertexPointer(&a, &c);
if ( b->Pos.y > c->Pos.y ) swapVertexPointer(&b, &c);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
@ -274,11 +276,11 @@ void CTRGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4D
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -272,25 +272,26 @@ void CTRGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,cons
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -274,25 +274,26 @@ void CTRGouraudAlphaNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,c
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -2000,25 +2000,26 @@ void CTRTextureBlend::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -278,11 +278,13 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
@ -291,11 +293,11 @@ void CTRTextureDetailMap2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -290,25 +290,26 @@ void CTRTextureGouraud2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,co
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -298,21 +298,23 @@ void CTRTextureGouraudAdd2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -266,11 +266,13 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
@ -279,11 +281,11 @@ void CTRTextureGouraudAddNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -359,25 +359,26 @@ void CTRTextureGouraudAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -359,25 +359,26 @@ void CTRTextureGouraudAlphaNoZ::drawTriangle ( const s4DVertex *a,const s4DVerte
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -262,25 +262,26 @@ void CTRTextureGouraudNoZ2::drawTriangle ( const s4DVertex *a,const s4DVertex *b
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -305,25 +305,26 @@ void CTRTextureVertexAlpha2::drawTriangle ( const s4DVertex *a,const s4DVertex *
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -286,25 +286,26 @@ void CTRTextureLightMap2_Add::drawTriangle ( const s4DVertex *a,const s4DVertex
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -256,25 +256,26 @@ void CTRTextureLightMap2_M1::drawTriangle ( const s4DVertex *a,const s4DVertex *
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -256,25 +256,26 @@ void CTRTextureLightMap2_M2::drawTriangle ( const s4DVertex *a,const s4DVertex *
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -584,11 +584,13 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
@ -598,11 +600,11 @@ void CTRTextureLightMap2_M4::drawTriangle_Min ( const s4DVertex *a,const s4DVert
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge
@ -956,25 +958,26 @@ void CTRTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex *
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -300,26 +300,26 @@ void CTRGTextureLightMap2_M4::drawTriangle ( const s4DVertex *a,const s4DVertex
if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c);
if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b);
const f32 ca = c->Pos.y - a->Pos.y;
const f32 ba = b->Pos.y - a->Pos.y;
const f32 cb = c->Pos.y - b->Pos.y;
// calculate delta y of the edges
scan.invDeltaY[0] = core::reciprocal ( c->Pos.y - a->Pos.y );
scan.invDeltaY[1] = core::reciprocal ( b->Pos.y - a->Pos.y );
scan.invDeltaY[2] = core::reciprocal ( c->Pos.y - b->Pos.y );
scan.invDeltaY[0] = (ca != 0.f)?core::reciprocal ( ca ):0.f;
scan.invDeltaY[1] = (ba != 0.f)?core::reciprocal ( ba ):0.f;
scan.invDeltaY[2] = (cb != 0.f)?core::reciprocal ( cb ):0.f;
if ( F32_LOWER_0 ( scan.invDeltaY[0] ) )
return;
// find if the major edge is left or right aligned
f32 temp[4];
temp[0] = a->Pos.x - c->Pos.x;
temp[1] = a->Pos.y - c->Pos.y;
temp[1] = -ca;
temp[2] = b->Pos.x - a->Pos.x;
temp[3] = b->Pos.y - a->Pos.y;
temp[3] = ba;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > (f32) 0.0 ? 0 : 1;
scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1;
scan.right = 1 - scan.left;
// calculate slopes for the major edge

View File

@ -132,7 +132,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
#endif
for (i=0; i<mesh->Materials.size(); ++i)
{
mesh->Buffers.push_back( AnimatedMesh->createBuffer() );
mesh->Buffers.push_back( AnimatedMesh->addMeshBuffer() );
mesh->Buffers.getLast()->Material = mesh->Materials[i];
if (!mesh->HasSkinning)
@ -256,7 +256,7 @@ bool CXMeshFileLoader::load(io::IReadFile* file)
{
for (u32 k=1; k < verticesLinkBuffer[id].size(); ++k)
{
ISkinnedMesh::SWeight* WeightClone = AnimatedMesh->createWeight(joint);
ISkinnedMesh::SWeight* WeightClone = AnimatedMesh->addWeight(joint);
WeightClone->strength = weight.strength;
WeightClone->vertex_id = verticesLinkIndex[id][k];
WeightClone->buffer_id = verticesLinkBuffer[id][k];
@ -491,11 +491,11 @@ bool CXMeshFileLoader::parseDataObject()
if (objectName == "Mesh")
{
// some meshes have no frames at all
//CurFrame = AnimatedMesh->createJoint(0);
//CurFrame = AnimatedMesh->addJoint(0);
SXMesh *mesh=new SXMesh;
//mesh->Buffer=AnimatedMesh->createBuffer();
//mesh->Buffer=AnimatedMesh->addMeshBuffer();
Meshes.push_back(mesh);
return parseDataObjectMesh(*mesh);
@ -605,7 +605,7 @@ bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
#ifdef _XREADER_DEBUG
os::Printer::log("creating joint ", name.c_str());
#endif
joint=AnimatedMesh->createJoint(Parent);
joint=AnimatedMesh->addJoint(Parent);
joint->Name=name;
JointID=AnimatedMesh->getAllJoints().size()-1;
}
@ -1110,7 +1110,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
os::Printer::log("creating joint for skinning ", TransformNodeName.c_str());
#endif
n = AnimatedMesh->getAllJoints().size();
joint=AnimatedMesh->createJoint(0);
joint=AnimatedMesh->addJoint(0);
joint->Name=TransformNodeName;
}
@ -1131,7 +1131,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
mesh.WeightJoint.push_back(n);
mesh.WeightNum.push_back(joint->Weights.size());
CSkinnedMesh::SWeight *weight=AnimatedMesh->createWeight(joint);
CSkinnedMesh::SWeight *weight=AnimatedMesh->addWeight(joint);
weight->buffer_id=0;
weight->vertex_id=readInt();
@ -1705,7 +1705,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
#ifdef _XREADER_DEBUG
os::Printer::log("creating joint for animation ", FrameName.c_str());
#endif
joint=AnimatedMesh->createJoint(0);
joint=AnimatedMesh->addJoint(0);
joint->Name=FrameName;
}
@ -1797,7 +1797,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
}
ISkinnedMesh::SRotationKey *key=AnimatedMesh->createRotationKey(joint);
ISkinnedMesh::SRotationKey *key=AnimatedMesh->addRotationKey(joint);
key->frame=time;
key->rotation.set(X,Y,Z,W);
}
@ -1826,13 +1826,13 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (keyType==2)
{
ISkinnedMesh::SPositionKey *key=AnimatedMesh->createPositionKey(joint);
ISkinnedMesh::SPositionKey *key=AnimatedMesh->addPositionKey(joint);
key->frame=time;
key->position=vector;
}
else
{
ISkinnedMesh::SScaleKey *key=AnimatedMesh->createScaleKey(joint);
ISkinnedMesh::SScaleKey *key=AnimatedMesh->addScaleKey(joint);
key->frame=time;
key->scale=vector;
}
@ -1865,12 +1865,12 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
//core::vector3df rotation = mat.getRotationDegrees();
ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->createRotationKey(joint);
ISkinnedMesh::SRotationKey *keyR=AnimatedMesh->addRotationKey(joint);
keyR->frame=time;
keyR->rotation= core::quaternion(mat);
ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->createPositionKey(joint);
ISkinnedMesh::SPositionKey *keyP=AnimatedMesh->addPositionKey(joint);
keyP->frame=time;
keyP->position=mat.getTranslation();
@ -1883,7 +1883,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
scale.Y=1;
if (scale.Z==0)
scale.Z=1;
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->createScaleKey(joint);
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->addScaleKey(joint);
keyS->frame=time;
keyS->scale=scale;
*/

View File

@ -52,7 +52,7 @@ LINKOBJ = $(IRRMESHOBJ) $(IRROBJ) $(IRRPARTICLEOBJ) $(IRRANIMOBJ) \
#Compiler flags
CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng
CPPFLAGS = $(CXXINCS) -DIRRLICHT_EXPORTS=1
CXXFLAGS = -Wall -pipe -fno-exceptions -fno-rtti
CXXFLAGS = -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing
ifndef NDEBUG
CXXFLAGS += -g -D_DEBUG
else

View File

@ -120,12 +120,7 @@ REALINLINE void memcpy32_small ( void * dest, const void *source, u32 bytesize )
// integer log2 of a float ieee 754. TODO: non ieee floating point
static inline s32 s32_log2_f32( f32 f)
{
#ifdef IRRLICHT_FAST_MATH
u32 x = IR ( f );
#else
u32 x = core::IR ( f );
#endif
return ((x & 0x7F800000) >> 23) - 127;
}

View File

@ -45,7 +45,7 @@ bool terrainSceneNode(void)
driver->endScene();
// Note that this has to be a slightly fuzzier than usual compare to satisfy multiple OpenGL environments
bool result = takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-1.png", 98.3f);
bool result = takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-1.png", 98.24f);
if(!result)
{
logTestString("Small camera up rotation caused bad recalc.\n");
@ -60,7 +60,7 @@ bool terrainSceneNode(void)
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-2.png", 98.9f);
result &= takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-2.png", 98.84f);
if(!result)
{
logTestString("Large camera up rotation caused bad recalc.\n");

View File

@ -48,7 +48,7 @@ bool testGeometryCreator(void)
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-testGeometryCreator.png", 100);
result = takeScreenshotAndCompareAgainstReference(driver, "-testGeometryCreator.png", 99.999f);
}
device->drop();

View File

@ -1,2 +1,2 @@
Test suite pass at GMT Wed Aug 19 23:13:32 2009
Test suite pass at GMT Wed Sep 9 14:11:32 2009