From c132b13f55d878a67c2ac24453d32451c117d908 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 14 Oct 2019 11:56:42 +0200 Subject: [PATCH] Bug when coordinates are NULL --- src/ISceneManager.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/ISceneManager.cpp b/src/ISceneManager.cpp index 4222505..e88bd00 100644 --- a/src/ISceneManager.cpp +++ b/src/ISceneManager.cpp @@ -33,15 +33,21 @@ extern "C" { irr_core_vector3df* scale, int alsoAddIfMeshPointerZero) { - const irr::core::vector3df& iPosition = irr::core::vector3df(position->x, - position->y, - position->z); - const irr::core::vector3df& iRotation = irr::core::vector3df(rotation->x, - rotation->y, - rotation->z); - const irr::core::vector3df& iScale = irr::core::vector3df(scale->x, - scale->y, - scale->z); + const irr::core::vector3df iPosition = + position ? + irr::core::vector3df(position->x, position->y, position->z) : + irr::core::vector3df(0, 0, 0); + + const irr::core::vector3df iRotation = + rotation ? + irr::core::vector3df(rotation->x, rotation->y, rotation->z) : + irr::core::vector3df(0, 0, 0); + + const irr::core::vector3df& iScale = + scale ? + irr::core::vector3df(scale->x, scale->y, scale->z) : + irr::core::vector3df(1, 1, 1); + return (irr_scene_IAnimatedMeshSceneNode*) ((irr::scene::ISceneManager*)smgr)->addAnimatedMeshSceneNode((irr::scene::IAnimatedMesh*)mesh, (irr::scene::ISceneNode*)parent, @@ -60,12 +66,16 @@ extern "C" { int id, int makeActive) { - const irr::core::vector3df& iPosition = irr::core::vector3df(position->x, - position->y, - position->z); - const irr::core::vector3df& iLookat = irr::core::vector3df(lookat->x, - lookat->y, - lookat->z); + const irr::core::vector3df& iPosition = + position ? + irr::core::vector3df(position->x, position->y, position->z) : + irr::core::vector3df(0, 0, 0); + + const irr::core::vector3df& iLookat = + lookat ? + irr::core::vector3df(lookat->x, lookat->y, lookat->z) : + irr::core::vector3df(0, 0, 100); + return (irr_scene_ICameraSceneNode*) ((irr::scene::ISceneManager*)smgr)->addCameraSceneNode((irr::scene::ISceneNode*)parent, iPosition, -- 2.39.5