modernize casting, resolve warnings

resolves #3 Windows pathing issue in Utility
master
poikilos 2019-04-11 02:30:48 -04:00
parent 34d07b3d18
commit 5b0dcc46dc
6 changed files with 47 additions and 41 deletions

View File

@ -1,3 +1,5 @@
#include <string>
#include "Engine.h"
#include "UserInterface.h"
@ -35,7 +37,7 @@ void Engine::setupScene()
m_CamPos = vector3df( 4.5, 3, 9 );
m_CamTarget = vector3df(0, 3, 0);
ICameraSceneNode *camera = m_Scene->addCameraSceneNode(nullptr, m_CamPos, m_CamTarget); // this will be overridden by View m_Yaw and m_Pitch--see "calculate m_Yaw" further down
camera->setAspectRatio((f32)m_Driver->getScreenSize().Width / m_Driver->getScreenSize().Height);
camera->setAspectRatio(static_cast<f32>(m_Driver->getScreenSize().Width) / static_cast<f32>(m_Driver->getScreenSize().Height));
}
IGUIEnvironment * Engine::getGUIEnvironment() const
@ -60,7 +62,7 @@ void Engine::drawAxisLines()
m_Driver->setMaterial( *lineX );
m_Driver->draw3DLine( vector3df(), vector3df( 5, 0, 0 ), SColor( 255, 255, 0, 0 ));
position2d<s32> textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 5.2, 0, 0 ));
position2d<s32> textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 5.2f, 0, 0 ));
dimension2d<u32> textSize;
if (m_AxisFont != nullptr) {
textSize = m_AxisFont->getDimension( L"X+" );
@ -68,14 +70,14 @@ void Engine::drawAxisLines()
}
m_Driver->setMaterial( *lineY );
m_Driver->draw3DLine( vector3df(), vector3df( 0, 5, 0 ), SColor( 255, 0, 255, 0 ));
textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 0, 5.2, 0 ));
textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 0, 5.2f, 0 ));
if (m_AxisFont != nullptr) {
textSize = m_AxisFont->getDimension( L"Y+" );
m_AxisFont->draw( L"Y+", rect<s32>( textPos, textSize ), SColor( 255, 0, 255, 0 ), true, true );
}
m_Driver->setMaterial( *lineZ );
m_Driver->draw3DLine( vector3df(), vector3df( 0, 0, 5 ), SColor( 255, 0, 0, 255 ));
textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 0, 0, 5.2 ));
textPos = m_Scene->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition( vector3df( 0, 0, 5.2f ));
if (m_AxisFont != nullptr) {
textSize = m_AxisFont->getDimension( L"Z+" );
m_AxisFont->draw( L"Z+", rect<s32>( textPos, textSize ), SColor( 255, 0, 0, 255 ), true, true );
@ -88,7 +90,7 @@ void Engine::drawAxisLines()
void Engine::drawBackground()
{
dimension2d<u32> screenSize = m_Driver->getScreenSize();
m_Driver->draw2DRectangle( rect<s32>( 0, 0, screenSize.Width, screenSize.Height ),
m_Driver->draw2DRectangle( rect<s32>( 0, 0, static_cast<s32>(screenSize.Width), static_cast<s32>(screenSize.Height) ),
SColor( 255, 128, 128, 255 ),
SColor( 255, 128, 128, 255 ),
SColor( 255, 224, 224, 255 ),
@ -108,8 +110,8 @@ void Engine::checkResize()
SEvent event;
event.EventType = EET_USER_EVENT;
event.UserEvent.UserData1 = UEI_WINDOWSIZECHANGED;
eventReceiver->OnEvent( event );
//m_UserInterface->
}
}
@ -118,7 +120,7 @@ s32 Engine::getNumberOfVertices()
IMesh *mesh = m_LoadedMesh->getMesh()->getMesh( 0, 255, -1, -1 );
int vertices = 0;
for( int bufferIndex = 0; bufferIndex < mesh->getMeshBufferCount(); bufferIndex ++ )
for( irr::u32 bufferIndex = 0; bufferIndex < mesh->getMeshBufferCount(); bufferIndex ++ )
vertices += mesh->getMeshBuffer( bufferIndex )->getVertexCount();
cout << vertices << endl;
@ -228,7 +230,7 @@ void Engine::loadMesh( const wstring &fileName )
if (m_LoadedMesh != nullptr) {
ICameraSceneNode *camera = this->m_Scene->getActiveCamera();
aabbox3d<f32> box = m_LoadedMesh->getTransformedBoundingBox();
vector3d<float> extents = box.getExtent();
//vector3d<float> extents = box.getExtent();
if (m_View->zUp()) {
float oldDist = m_CamPos.getDistanceFrom(m_CamTarget);
float newDist = oldDist;
@ -281,7 +283,7 @@ void Engine::reloadMesh()
void Engine::reloadTexture()
{
if (this->m_PrevTexturePath.length() > 0) {
if (this->m_UserInterface->texturePathEditBox->getText() != L"")
if (wcslen(this->m_UserInterface->texturePathEditBox->getText()) == 0)
loadTexture(this->m_UserInterface->texturePathEditBox->getText());
else
loadTexture(this->m_PrevTexturePath);
@ -304,7 +306,7 @@ bool Engine::loadTexture(const wstring &fileName)
void Engine::setMeshDisplayMode( bool wireframe, bool lighting, bool textureInterpolation)
{
if (m_LoadedMesh != nullptr) {
for( int materialIndex = 0; materialIndex < m_LoadedMesh->getMaterialCount(); materialIndex ++ )
for( u32 materialIndex = 0; materialIndex < m_LoadedMesh->getMaterialCount(); materialIndex ++ )
{
// Set Wireframe display
m_LoadedMesh->getMaterial(materialIndex).Wireframe = wireframe;
@ -417,7 +419,7 @@ void Engine::run()
{
u32 timePerFrame = 1000.0f;
if (this->worldFPS > 0) {
timePerFrame = ( u32 ) ( 1000.0f / this->worldFPS );
timePerFrame = static_cast<u32>( 1000.0f / this->worldFPS );
}
ITimer *timer = m_Device->getTimer();

View File

@ -47,7 +47,7 @@ void UserInterface::setupUserInterface()
// Playback Control Window
dimension2d<u32> windowSize = m_Engine->m_Driver->getScreenSize();
IGUIWindow *playbackWindow = m_Gui->addWindow(
playbackWindow = m_Gui->addWindow(
rect<s32>( vector2d<s32>( windowSize.Width - 4 - 160, 28 ), dimension2d<s32>( 160, 300 )), false, L"Playback", nullptr, UIE_PLAYBACKWINDOW );
playbackWindow->getCloseButton()->setVisible( false );
s32 spacing_x = 4;
@ -197,9 +197,9 @@ void UserInterface::handleMenuItemPressed( IGUIContextMenu *menu )
// PUBLIC
UserInterface::UserInterface( Engine *engine )
{
INDEX_VIEW_TEXTURE_INTERPOLATION = -1;
INDEX_VIEW_WIREFRAME_MESH = -1;
INDEX_VIEW_LIGHTING = -1;
INDEX_VIEW_TEXTURE_INTERPOLATION = 0;
INDEX_VIEW_WIREFRAME_MESH = 0;
INDEX_VIEW_LIGHTING = 0;
this->playbackStartStopButton = nullptr;
m_Engine = engine;
@ -208,6 +208,7 @@ UserInterface::UserInterface( Engine *engine )
m_WireframeDisplay = false;
m_Lighting = true;
m_TextureInterpolation = true;
playbackWindow = nullptr;
setupUserInterface();
}

View File

@ -9,18 +9,20 @@ class Engine;
enum UserInterfaceElements
{
UIE_PLAYBACKWINDOW = 1000,
UIE_LOADBUTTON = 1001,
UIE_LOADFILEDIALOG = 1002,
UIE_FILEMENU = 1003,
UIE_PLAYBACKSTARTSTOPBUTTON = 1004,
UIE_VIEWMENU = 1005,
UIE_LOADTEXTUREDIALOG = 1006,
UIE_PLAYBACKINCREASEBUTTON = 1007,
UIE_PLAYBACKDECREASEBUTTON = 1008,
UIE_PLAYBACKSETFRAMEEDITBOX = 1009,
UIE_TEXTUREPATHSTATICTEXT = 1010,
UIE_TEXTUREPATHEDITBOX = 1011
UIE_LOADFILEDIALOG = 1100,
// UIE_LOADBUTTON = 1101,
UIE_LOADTEXTUREDIALOG = 1200,
UIE_VIEWMENU = 2000,
UIE_PLAYBACKWINDOW = 3000,
UIE_PLAYBACKSTARTSTOPBUTTON = 3001,
UIE_PLAYBACKINCREASEBUTTON = 3002,
UIE_PLAYBACKDECREASEBUTTON = 3003,
UIE_PLAYBACKSETFRAMEEDITBOX = 3004,
UIE_TEXTUREPATHSTATICTEXT = 3005,
UIE_TEXTUREPATHEDITBOX = 3006
};
enum UserInterfaceCommands
@ -28,9 +30,9 @@ enum UserInterfaceCommands
UIC_FILE_LOAD = 1000,
UIC_FILE_QUIT = 1001,
UIC_FILE_LOAD_TEXTURE = 1002,
UIC_VIEW_WIREFRAME = 2000,
UIC_VIEW_LIGHTING = 2001,
UIC_VIEW_TEXTURE_INTERPOLATION = 2002
UIC_VIEW_WIREFRAME = 2001,
UIC_VIEW_LIGHTING = 2002,
UIC_VIEW_TEXTURE_INTERPOLATION = 2003
};
class UserInterface : public irr::IEventReceiver
@ -49,7 +51,7 @@ private:
bool m_WireframeDisplay;
bool m_Lighting;
bool m_TextureInterpolation;
irr::gui::IGUIWindow *playbackWindow;
public:
irr::gui::IGUIContextMenu *menu;
irr::gui::IGUIContextMenu *fileMenu;

View File

@ -157,9 +157,10 @@ bool View::OnEvent( const SEvent &event )
if( event.EventType == EET_USER_EVENT && event.UserEvent.UserData1 == UEI_WINDOWSIZECHANGED )
{
dimension2d<u32> windowSize = m_Engine->m_Driver->getScreenSize();
f32 aspectRatio = (f32) windowSize.Width / windowSize.Height;
f32 aspectRatio = static_cast<f32>(windowSize.Width) / static_cast<f32>(windowSize.Height);
debug() << "Setting aspect to: " << aspectRatio << endl;
m_Engine->m_Scene->getActiveCamera()->setAspectRatio( aspectRatio );
}
// Handle mouse event

View File

@ -57,13 +57,13 @@ if [ "@$PROFILE_ENABLE" = "@true" ]; then
dest_bin_dir="$HOME/.local/bin"
echo "installing to '$dest_bin_dir'."
echo "Press Ctrl C to cancel..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
#sleep 1
#echo "3..."
#sleep 1
#echo "2..."
#sleep 1
#echo "1..."
#sleep 1
else
echo "Successfully installed as '$try_dest_bin'"
fi

View File

@ -60,10 +60,10 @@ int main( int argc, char **argv )
wchar_t * getWideCharString( char *str )
{
wchar_t *dest = ( wchar_t * ) malloc( sizeof( wchar_t ) * ( strlen( str ) + 1 ));
wchar_t *dest = static_cast<wchar_t *>(malloc(sizeof(wchar_t) * (strlen(str) + 1)));
int resultSize = mbstowcs( nullptr, str, strlen( str ));
mbstowcs( dest, str, strlen( str ));
size_t resultSize = mbstowcs(nullptr, str, strlen(str));
mbstowcs(dest, str, strlen(str));
dest[resultSize] = '\0';