From 1dbab53e5a03fc0faffbc0449a8c037ca495d32f Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 8 Jan 2022 18:22:20 +0000 Subject: [PATCH] Prefer static_cast to reinterpret_cast where possible. Just safer. Could probably do in a lot more places... another time. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6293 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/CMeshBuffer.h | 4 ++-- source/Irrlicht/CAnimatedMeshSceneNode.cpp | 4 ++-- source/Irrlicht/CD3D9Driver.cpp | 12 ++++++------ source/Irrlicht/CIrrDeviceWin32.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/CMeshBuffer.h b/include/CMeshBuffer.h index b5cbcb25..9f7e2154 100644 --- a/include/CMeshBuffer.h +++ b/include/CMeshBuffer.h @@ -193,8 +193,8 @@ namespace scene Vertices.reallocate(vertexCount+numVertices); for (i=0; i(vertices)[i]); - BoundingBox.addInternalPoint(reinterpret_cast(vertices)[i].Pos); + Vertices.push_back(static_cast(vertices)[i]); + BoundingBox.addInternalPoint(static_cast(vertices)[i].Pos); } Indices.reallocate(getIndexCount()+numIndices); diff --git a/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/source/Irrlicht/CAnimatedMeshSceneNode.cpp index de96749b..e5c7f80e 100644 --- a/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -206,7 +206,7 @@ IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame() // As multiple scene nodes may be sharing the same skinned mesh, we have to // re-animate it every frame to ensure that this node gets the mesh that it needs. - CSkinnedMesh* skinnedMesh = reinterpret_cast(Mesh); + CSkinnedMesh* skinnedMesh = static_cast(Mesh); if (JointMode == EJUOR_CONTROL)//write to mesh skinnedMesh->transferJointsToMesh(JointChildSceneNodes); @@ -949,7 +949,7 @@ void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions) checkJoints(); const f32 frame = getFrameNr(); //old? - CSkinnedMesh* skinnedMesh=reinterpret_cast(Mesh); + CSkinnedMesh* skinnedMesh=static_cast(Mesh); skinnedMesh->transferOnlyJointsHintsToMesh( JointChildSceneNodes ); skinnedMesh->animateMesh(frame, 1.0f); diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 1ac33c13..73f9e61a 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -1192,7 +1192,7 @@ void CD3D9Driver::removeOcclusionQuery(scene::ISceneNode* node) if (index != -1) { if (OcclusionQueries[index].PID != 0) - reinterpret_cast(OcclusionQueries[index].PID)->Release(); + static_cast(OcclusionQueries[index].PID)->Release(); CNullDriver::removeOcclusionQuery(node); } } @@ -1210,10 +1210,10 @@ void CD3D9Driver::runOcclusionQuery(scene::ISceneNode* node, bool visible) if (index != -1) { if (OcclusionQueries[index].PID) - reinterpret_cast(OcclusionQueries[index].PID)->Issue(D3DISSUE_BEGIN); + static_cast(OcclusionQueries[index].PID)->Issue(D3DISSUE_BEGIN); CNullDriver::runOcclusionQuery(node,visible); if (OcclusionQueries[index].PID) - reinterpret_cast(OcclusionQueries[index].PID)->Issue(D3DISSUE_END); + static_cast(OcclusionQueries[index].PID)->Issue(D3DISSUE_END); } } @@ -1232,12 +1232,12 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block) bool available = block?true:false; int tmp=0; if (!block) - available=(reinterpret_cast(OcclusionQueries[index].PID)->GetData(&tmp, sizeof(DWORD), 0)==S_OK); + available=(static_cast(OcclusionQueries[index].PID)->GetData(&tmp, sizeof(DWORD), 0)==S_OK); else { do { - HRESULT hr = reinterpret_cast(OcclusionQueries[index].PID)->GetData(&tmp, sizeof(DWORD), D3DGETDATA_FLUSH); + HRESULT hr = static_cast(OcclusionQueries[index].PID)->GetData(&tmp, sizeof(DWORD), D3DGETDATA_FLUSH); available = (hr == S_OK); if (hr!=S_FALSE) break; @@ -2945,7 +2945,7 @@ bool CD3D9Driver::reset() { if (OcclusionQueries[i].PID) { - reinterpret_cast(OcclusionQueries[i].PID)->Release(); + static_cast(OcclusionQueries[i].PID)->Release(); OcclusionQueries[i].PID=0; } } diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 2afec41b..631f670f 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -1304,7 +1304,7 @@ bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect(windowId); + hwnd = static_cast(windowId); HDC dc = GetDC(hwnd);