Commit 17d5f8a3 authored by hybrid's avatar hybrid

Merged from 1.4 branch revisions 1368:1422.

This fixes wrong child handling in AnimatedMesh SceneNode, 2dimage clipping in d3d drivers, and a string handling issue in example 16.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1423 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 47121936
...@@ -66,15 +66,8 @@ class CScreenShotFactory : public IEventReceiver ...@@ -66,15 +66,8 @@ class CScreenShotFactory : public IEventReceiver
public: public:
CScreenShotFactory( IrrlichtDevice *device, const c8 * templateName ) CScreenShotFactory( IrrlichtDevice *device, const c8 * templateName )
: Device(device), Number(0), FilenameTemplate(templateName)
{ {
// store pointer to device so we can use it
Device = device;
// start with zero
Number = 0;
Filename.reserve ( 256 );
FilenameTemplate = templateName;
FilenameTemplate.replace ( '/', '_' ); FilenameTemplate.replace ( '/', '_' );
FilenameTemplate.replace ( '\\', '_' ); FilenameTemplate.replace ( '\\', '_' );
} }
...@@ -104,8 +97,7 @@ public: ...@@ -104,8 +97,7 @@ public:
private: private:
IrrlichtDevice *Device; IrrlichtDevice *Device;
u32 Number; u32 Number;
core::stringc Filename; const core::stringc FilenameTemplate;
core::stringc FilenameTemplate;
}; };
......
...@@ -192,10 +192,6 @@ void CAnimatedMeshSceneNode::OnRegisterSceneNode() ...@@ -192,10 +192,6 @@ void CAnimatedMeshSceneNode::OnRegisterSceneNode()
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT);
ISceneNode::OnRegisterSceneNode(); ISceneNode::OnRegisterSceneNode();
for (u32 j=0; j<JointChildSceneNodes.size(); ++j)
if (JointChildSceneNodes[j])
JointChildSceneNodes[j]->OnRegisterSceneNode();
} }
} }
...@@ -1026,6 +1022,7 @@ void CAnimatedMeshSceneNode::beginTransition() ...@@ -1026,6 +1022,7 @@ void CAnimatedMeshSceneNode::beginTransition()
Transiting = core::reciprocal((f32)TransitionTime); Transiting = core::reciprocal((f32)TransitionTime);
} }
TransitingBlend = 0.f;
} }
......
...@@ -1024,14 +1024,36 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::rect<s ...@@ -1024,14 +1024,36 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::rect<s
tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width;
tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height;
core::rect<s32> clippedRect(destRect);
if (clipRect)
{
clippedRect.clipAgainst(*clipRect);
//tcoords must be clipped by the same factors
const f32 tcWidth = tcoords.getWidth();
const f32 tcHeight = tcoords.getHeight();
const f32 invDestRectWidth = 1.f / (f32)(destRect.getWidth());
f32 scale = (f32)(clippedRect.UpperLeftCorner.X - destRect.UpperLeftCorner.X) * invDestRectWidth;
tcoords.UpperLeftCorner.X += scale * tcWidth;
scale = (f32)(destRect.LowerRightCorner.X - clippedRect.LowerRightCorner.X) * invDestRectWidth;
tcoords.LowerRightCorner.X -= scale * tcWidth;
const f32 invDestRectHeight = 1.f / (f32)(destRect.getHeight());
scale = (f32)(clippedRect.UpperLeftCorner.Y - destRect.UpperLeftCorner.Y) * invDestRectHeight;
tcoords.UpperLeftCorner.Y += scale * tcHeight;
scale = (f32)(destRect.LowerRightCorner.Y - clippedRect.LowerRightCorner.Y) * invDestRectHeight;
tcoords.LowerRightCorner.Y -= scale * tcHeight;
}
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize(); const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
core::rect<f32> npos; core::rect<f32> npos;
f32 xFact = 2.0f / ( renderTargetSize.Width ); f32 xFact = 2.0f / ( renderTargetSize.Width );
f32 yFact = 2.0f / ( renderTargetSize.Height ); f32 yFact = 2.0f / ( renderTargetSize.Height );
npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; npos.UpperLeftCorner.X = ( clippedRect.UpperLeftCorner.X * xFact ) - 1.0f;
npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); npos.UpperLeftCorner.Y = 1.0f - ( clippedRect.UpperLeftCorner.Y * yFact );
npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; npos.LowerRightCorner.X = ( clippedRect.LowerRightCorner.X * xFact ) - 1.0f;
npos.LowerRightCorner.Y = 1.0f - ( destRect.LowerRightCorner.Y * yFact ); npos.LowerRightCorner.Y = 1.0f - ( clippedRect.LowerRightCorner.Y * yFact );
video::SColor temp[4] = video::SColor temp[4] =
{ {
...@@ -2162,3 +2184,4 @@ IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWN ...@@ -2162,3 +2184,4 @@ IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWN
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr
...@@ -1235,9 +1235,22 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rect<s ...@@ -1235,9 +1235,22 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rect<s
setVertexShader(EVT_STANDARD); setVertexShader(EVT_STANDARD);
if (clipRect)
{
pID3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
RECT scissor;
scissor.left = clipRect->UpperLeftCorner.X;
scissor.top = clipRect->UpperLeftCorner.Y;
scissor.right = clipRect->LowerRightCorner.X;
scissor.bottom = clipRect->LowerRightCorner.Y;
pID3DDevice->SetScissorRect(&scissor);
}
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex)); D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex));
if (clipRect)
pID3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
} }
...@@ -2539,7 +2552,3 @@ IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWN ...@@ -2539,7 +2552,3 @@ IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWN
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment