Further work on removing assertions from constructors

This commit is contained in:
Jonas Strandstedt
2014-12-12 11:46:10 +01:00
parent 93a34fa985
commit 5c666a0175
3 changed files with 20 additions and 14 deletions

View File

@@ -57,15 +57,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _geometry(nullptr)
{
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
assert(success);
std::string path;
success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
assert(success);
dictionary.getValue(constants::scenegraphnode::keyName, name);
dictionary.getValue(constants::scenegraph::keyPathModule, path);
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(
bool success = dictionary.getValue(
constants::renderablemodel::keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
@@ -83,10 +80,8 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
bool b1 = dictionary.getValue(keySource, _source);
bool b2 = dictionary.getValue(keyDestination, _destination);
assert(b1 == true);
assert(b2 == true);
dictionary.getValue(keySource, _source);
dictionary.getValue(keyDestination, _destination);
}
@@ -108,8 +103,11 @@ bool RenderableModel::initialize(){
&= OsEng.ref().configurationManager().getValue("pscShader", _programObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
completeSuccess &= _geometry->initialize(this);
completeSuccess &= !_source.empty();
completeSuccess &= !_destination.empty();
return completeSuccess;
}
@@ -166,6 +164,10 @@ void RenderableModel::render(const RenderData& data)
}
void RenderableModel::update(const UpdateData& data){
#ifndef NDEBUG
if (_source.empty() || _destination.empty())
return;
#endif
// set spice-orientation in accordance to timestamp
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _destination, data.time, _stateMatrix);

View File

@@ -47,7 +47,6 @@ WavefrontGeometry::WavefrontGeometry(const ghoul::Dictionary& dictionary)
// The name is passed down from the SceneGraphNode
std::string name;
bool success = dictionary.getValue(keyName, name);
assert(success);
std::string file;
success = dictionary.getValue(constants::modelgeometry::keyObjFile, file);
@@ -114,9 +113,9 @@ void WavefrontGeometry::loadObj(const char *filename){
_vsize = indicesSize;
// float arrays
float *tempVertexArray = new float[vertexSize];
float *tempVertexNormalArray = new float[vertexNormalSize];
float *tempVertexTextureArray = new float[vertexTextureSize];
float* tempVertexArray = new float[vertexSize];
float* tempVertexNormalArray = new float[vertexNormalSize];
float* tempVertexTextureArray = new float[vertexTextureSize];
_varray = new Vertex[_vsize];
// int arrays

View File

@@ -78,6 +78,11 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary)
#endif
// get path if available
bool success = dictionary.getValue(constants::scenegraph::keyPathModule, _relativePath);
#ifndef NDEBUG
ghoul_assert(success,
"Scenegraphnode need to specify '" << constants::scenegraph::keyPathModule
<< "' because renderables is going to use this for debugging!");
#endif
if (success)
_relativePath += ghoul::filesystem::FileSystem::PathSeparator;