STL-Exporter: fix division by zero in normalize method during update
This commit is contained in:
@@ -115,8 +115,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief The class constructor.
|
||||
*/
|
||||
Exporter();
|
||||
|
||||
/**
|
||||
* @brief The class destructor.
|
||||
*/
|
||||
~Exporter();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -46,15 +46,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include "Hash.h"
|
||||
#include <map>
|
||||
|
||||
#include <map>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& value)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
inline
|
||||
bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& value) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
||||
@@ -63,20 +63,22 @@ inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||
return false;
|
||||
}
|
||||
(*it).second = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& errorReturn)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
inline
|
||||
const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& errorReturn) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||
if (it == list.end())
|
||||
if (it == list.end()) {
|
||||
return errorReturn;
|
||||
}
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
@@ -85,16 +87,17 @@ inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||
// Special version for pointer types - they will be deleted when replaced with another value
|
||||
// passing NULL removes the whole property
|
||||
template <class T>
|
||||
inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||
const char* szName, T* value, bool* bWasExisting = NULL)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
inline
|
||||
void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||
const char* szName, T* value, bool* bWasExisting = nullptr ) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
if (bWasExisting)
|
||||
if (bWasExisting) {
|
||||
*bWasExisting = false;
|
||||
}
|
||||
|
||||
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
||||
return;
|
||||
@@ -106,20 +109,23 @@ inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||
if (!value) {
|
||||
list.erase(it);
|
||||
}
|
||||
if (bWasExisting)
|
||||
if (bWasExisting) {
|
||||
*bWasExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
inline
|
||||
bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||
if (it == list.end()) return false;
|
||||
if (it == list.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user