X3D: Some more reformattings and missing initializations.

pull/1019/head
Kim Kulling 2016-10-04 18:40:58 +02:00
parent 7b9162136f
commit 86dc3f7a79
5 changed files with 137 additions and 130 deletions

View File

@ -68,7 +68,7 @@ std::string def, use;
float endAngle = AI_MATH_HALF_PI_F; float endAngle = AI_MATH_HALF_PI_F;
float radius = 1; float radius = 1;
float startAngle = 0; float startAngle = 0;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -131,7 +131,7 @@ float endAngle = AI_MATH_HALF_PI_F;
float radius = 1; float radius = 1;
bool solid = false; bool solid = false;
float startAngle = 0; float startAngle = 0;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -189,7 +189,7 @@ void X3DImporter::ParseNode_Geometry2D_Circle2D()
{ {
std::string def, use; std::string def, use;
float radius = 1; float radius = 1;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -242,7 +242,7 @@ std::string def, use;
float innerRadius = 0; float innerRadius = 0;
float outerRadius = 1; float outerRadius = 1;
bool solid = false; bool solid = false;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -330,7 +330,7 @@ void X3DImporter::ParseNode_Geometry2D_Polyline2D()
{ {
std::string def, use; std::string def, use;
std::list<aiVector2D> lineSegments; std::list<aiVector2D> lineSegments;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -378,7 +378,7 @@ void X3DImporter::ParseNode_Geometry2D_Polypoint2D()
{ {
std::string def, use; std::string def, use;
std::list<aiVector2D> point; std::list<aiVector2D> point;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -424,7 +424,7 @@ void X3DImporter::ParseNode_Geometry2D_Rectangle2D()
std::string def, use; std::string def, use;
aiVector2D size(2, 2); aiVector2D size(2, 2);
bool solid = false; bool solid = false;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -476,7 +476,7 @@ void X3DImporter::ParseNode_Geometry2D_TriangleSet2D()
std::string def, use; std::string def, use;
bool solid = false; bool solid = false;
std::list<aiVector2D> vertices; std::list<aiVector2D> vertices;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);

View File

@ -67,7 +67,7 @@ void X3DImporter::ParseNode_Geometry3D_Box()
std::string def, use; std::string def, use;
bool solid = true; bool solid = true;
aiVector3D size(2, 2, 2); aiVector3D size(2, 2, 2);
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -116,7 +116,7 @@ float bottomRadius = 1;
float height = 2; float height = 2;
bool side = true; bool side = true;
bool solid = true; bool solid = true;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -188,7 +188,7 @@ float radius = 1;
bool side = true; bool side = true;
bool solid = true; bool solid = true;
bool top = true; bool top = true;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -291,7 +291,7 @@ int32_t xDimension = 0;
float xSpacing = 1; float xSpacing = 1;
int32_t zDimension = 0; int32_t zDimension = 0;
float zSpacing = 1; float zSpacing = 1;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -462,7 +462,6 @@ size_t cur_sz = pCurve.size();
static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed) static aiVector3D GeometryHelper_Extrusion_GetNextY(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed)
{ {
const size_t spine_idx_last = pSpine.size() - 1; const size_t spine_idx_last = pSpine.size() - 1;
aiVector3D tvec; aiVector3D tvec;
if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases
@ -583,7 +582,7 @@ std::vector<float> orientation;
std::vector<aiVector2D> scale; std::vector<aiVector2D> scale;
bool solid = true; bool solid = true;
std::vector<aiVector3D> spine; std::vector<aiVector3D> spine;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -866,7 +865,7 @@ std::list<int32_t> normalIndex;
bool normalPerVertex = true; bool normalPerVertex = true;
bool solid = true; bool solid = true;
std::list<int32_t> texCoordIndex; std::list<int32_t> texCoordIndex;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -945,7 +944,7 @@ void X3DImporter::ParseNode_Geometry3D_Sphere()
std::string use, def; std::string use, def;
float radius = 1; float radius = 1;
bool solid = true; bool solid = true;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);

View File

@ -248,11 +248,13 @@ std::string use, def;
if(an == "scaleOrientation") if(an == "scaleOrientation")
{ {
std::vector<float> tvec; std::vector<float> tvec;
XML_ReadNode_GetAttrVal_AsArrF(idx, tvec); XML_ReadNode_GetAttrVal_AsArrF(idx, tvec);
if(tvec.size() != 4) throw DeadlyImportError("<Transform>: scaleOrientation vector must have 4 elements."); if ( tvec.size() != 4 )
{
throw DeadlyImportError( "<Transform>: scaleOrientation vector must have 4 elements." );
}
memcpy(scale_orientation, tvec.data(), sizeof(scale_orientation)); ::memcpy(scale_orientation, tvec.data(), sizeof(scale_orientation) );
continue; continue;
} }
@ -262,7 +264,7 @@ std::string use, def;
// if "USE" defined then find already defined element. // if "USE" defined then find already defined element.
if(!use.empty()) if(!use.empty())
{ {
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne); MACRO_USE_CHECKANDAPPLY(def, use, ENET_Group, ne);
} }
@ -270,12 +272,15 @@ std::string use, def;
{ {
ParseHelper_Group_Begin();// create new grouping element and go deeper if node has children. ParseHelper_Group_Begin();// create new grouping element and go deeper if node has children.
// at this place new group mode created and made current, so we can name it. // at this place new group mode created and made current, so we can name it.
if(!def.empty()) NodeElement_Cur->ID = def; if ( !def.empty() )
{
NodeElement_Cur->ID = def;
}
// //
// also set values specific to this type of group // also set values specific to this type of group
// //
// calculate tranformation matrix // calculate transformation matrix
aiMatrix4x4::Translation(translation, matr);// T aiMatrix4x4::Translation(translation, matr);// T
aiMatrix4x4::Translation(center, tmatr);// C aiMatrix4x4::Translation(center, tmatr);// C
matr *= tmatr; matr *= tmatr;
@ -294,7 +299,10 @@ std::string use, def;
// in grouping set of nodes check X3DMetadataObject is not needed, because it is done in <Scene> parser function. // in grouping set of nodes check X3DMetadataObject is not needed, because it is done in <Scene> parser function.
// for empty element exit from node in that place // for empty element exit from node in that place
if(mReader->isEmptyElement()) ParseHelper_Node_Exit(); if ( mReader->isEmptyElement() )
{
ParseHelper_Node_Exit();
}
}// if(!use.empty()) else }// if(!use.empty()) else
} }

View File

@ -69,7 +69,7 @@ void X3DImporter::ParseNode_Lighting_DirectionalLight()
bool global = false; bool global = false;
float intensity = 1; float intensity = 1;
bool on = true; bool on = true;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -141,7 +141,7 @@ void X3DImporter::ParseNode_Lighting_PointLight()
aiVector3D location( 0, 0, 0 ); aiVector3D location( 0, 0, 0 );
bool on = true; bool on = true;
float radius = 100; float radius = 100;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -222,7 +222,7 @@ void X3DImporter::ParseNode_Lighting_SpotLight()
aiVector3D location( 0, 0, 0 ); aiVector3D location( 0, 0, 0 );
bool on = true; bool on = true;
float radius = 100; float radius = 100;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);

View File

@ -123,7 +123,7 @@ void X3DImporter::ParseNode_MetadataBoolean()
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
std::list<bool> value; std::list<bool> value;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -147,7 +147,7 @@ void X3DImporter::ParseNode_MetadataDouble()
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
std::list<double> value; std::list<double> value;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -171,7 +171,7 @@ void X3DImporter::ParseNode_MetadataFloat()
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
std::list<float> value; std::list<float> value;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -195,7 +195,7 @@ void X3DImporter::ParseNode_MetadataInteger()
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
std::list<int32_t> value; std::list<int32_t> value;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -217,7 +217,7 @@ void X3DImporter::ParseNode_MetadataSet()
{ {
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@ -258,7 +258,7 @@ void X3DImporter::ParseNode_MetadataString()
std::string def, use; std::string def, use;
std::string name, reference; std::string name, reference;
std::list<std::string> value; std::list<std::string> value;
CX3DImporter_NodeElement* ne; CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG; MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use); MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);