Commit 8d02b73f authored by hybrid's avatar hybrid

Simplify wave function.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2546 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0cd12d1d
...@@ -67,7 +67,7 @@ void CWaterSurfaceSceneNode::OnAnimate(u32 timeMs) ...@@ -67,7 +67,7 @@ void CWaterSurfaceSceneNode::OnAnimate(u32 timeMs)
const u32 vtxCnt = Mesh->getMeshBuffer(b)->getVertexCount(); const u32 vtxCnt = Mesh->getMeshBuffer(b)->getVertexCount();
for (u32 i=0; i<vtxCnt; ++i) for (u32 i=0; i<vtxCnt; ++i)
addWave(Mesh->getMeshBuffer(b)->getPosition(i), Mesh->getMeshBuffer(b)->getPosition(i).Y = addWave(
OriginalMesh->getMeshBuffer(b)->getPosition(i), OriginalMesh->getMeshBuffer(b)->getPosition(i),
time); time);
}// end for all mesh buffers }// end for all mesh buffers
...@@ -129,11 +129,11 @@ void CWaterSurfaceSceneNode::deserializeAttributes(io::IAttributes* in, io::SAtt ...@@ -129,11 +129,11 @@ void CWaterSurfaceSceneNode::deserializeAttributes(io::IAttributes* in, io::SAtt
} }
void CWaterSurfaceSceneNode::addWave(core::vector3df& dest, const core::vector3df &source, f32 time) const f32 CWaterSurfaceSceneNode::addWave(const core::vector3df &source, f32 time) const
{ {
dest.Y = source.Y + return source.Y +
(sinf(((source.X/WaveLength) + time)) * WaveHeight) + (sinf(((source.X/WaveLength) + time)) * WaveHeight) +
(cosf(((source.Z/WaveLength) + time)) * WaveHeight); (cosf(((source.Z/WaveLength) + time)) * WaveHeight);
} }
} // end namespace scene } // end namespace scene
......
...@@ -46,7 +46,7 @@ namespace scene ...@@ -46,7 +46,7 @@ namespace scene
private: private:
inline void addWave(core::vector3df& dest, const core::vector3df &source, f32 time) const; inline f32 addWave(const core::vector3df &source, f32 time) const;
f32 WaveLength; f32 WaveLength;
f32 WaveSpeed; f32 WaveSpeed;
......
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