X3D: Some more reformattings and missing initializations.

This commit is contained in:
Kim Kulling
2016-10-04 18:40:58 +02:00
parent 7b9162136f
commit 86dc3f7a79
5 changed files with 137 additions and 130 deletions
+34 -34
View File
@@ -64,11 +64,11 @@ namespace Assimp
// angle base unit has been specified). If startAngle and endAngle have the same value, a circle is specified.
void X3DImporter::ParseNode_Geometry2D_Arc2D()
{
std::string def, use;
float endAngle = AI_MATH_HALF_PI_F;
float radius = 1;
float startAngle = 0;
CX3DImporter_NodeElement* ne;
std::string def, use;
float endAngle = AI_MATH_HALF_PI_F;
float radius = 1;
float startAngle = 0;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -125,13 +125,13 @@ CX3DImporter_NodeElement* ne;
// viewed from the +Z-axis, the texture is mapped onto each face with the same orientation as if the image were displayed normally in 2D.
void X3DImporter::ParseNode_Geometry2D_ArcClose2D()
{
std::string def, use;
std::string closureType("PIE");
float endAngle = AI_MATH_HALF_PI_F;
float radius = 1;
bool solid = false;
float startAngle = 0;
CX3DImporter_NodeElement* ne;
std::string def, use;
std::string closureType("PIE");
float endAngle = AI_MATH_HALF_PI_F;
float radius = 1;
bool solid = false;
float startAngle = 0;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -187,9 +187,9 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry2D_Circle2D()
{
std::string def, use;
float radius = 1;
CX3DImporter_NodeElement* ne;
std::string def, use;
float radius = 1;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -238,11 +238,11 @@ CX3DImporter_NodeElement* ne;
// the Disk2D, when viewed from the +Z-axis, the texture is mapped onto each face with the same orientation as if the image were displayed normally in 2D.
void X3DImporter::ParseNode_Geometry2D_Disk2D()
{
std::string def, use;
float innerRadius = 0;
float outerRadius = 1;
bool solid = false;
CX3DImporter_NodeElement* ne;
std::string def, use;
float innerRadius = 0;
float outerRadius = 1;
bool solid = false;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -328,9 +328,9 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry2D_Polyline2D()
{
std::string def, use;
std::list<aiVector2D> lineSegments;
CX3DImporter_NodeElement* ne;
std::string def, use;
std::list<aiVector2D> lineSegments;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -376,9 +376,9 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry2D_Polypoint2D()
{
std::string def, use;
std::list<aiVector2D> point;
CX3DImporter_NodeElement* ne;
std::string def, use;
std::list<aiVector2D> point;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -421,10 +421,10 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry2D_Rectangle2D()
{
std::string def, use;
aiVector2D size(2, 2);
bool solid = false;
CX3DImporter_NodeElement* ne;
std::string def, use;
aiVector2D size(2, 2);
bool solid = false;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -473,10 +473,10 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry2D_TriangleSet2D()
{
std::string def, use;
bool solid = false;
std::list<aiVector2D> vertices;
CX3DImporter_NodeElement* ne;
std::string def, use;
bool solid = false;
std::list<aiVector2D> vertices;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
+65 -66
View File
@@ -64,10 +64,10 @@ namespace Assimp
// respectively and each component value shall be greater than zero.
void X3DImporter::ParseNode_Geometry3D_Box()
{
std::string def, use;
bool solid = true;
aiVector3D size(2, 2, 2);
CX3DImporter_NodeElement* ne;
std::string def, use;
bool solid = true;
aiVector3D size(2, 2, 2);
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -110,13 +110,13 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry3D_Cone()
{
std::string use, def;
bool bottom = true;
float bottomRadius = 1;
float height = 2;
bool side = true;
bool solid = true;
CX3DImporter_NodeElement* ne;
std::string use, def;
bool bottom = true;
float bottomRadius = 1;
float height = 2;
bool side = true;
bool solid = true;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -181,14 +181,14 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry3D_Cylinder()
{
std::string use, def;
bool bottom = true;
float height = 2;
float radius = 1;
bool side = true;
bool solid = true;
bool top = true;
CX3DImporter_NodeElement* ne;
std::string use, def;
bool bottom = true;
float height = 2;
float radius = 1;
bool side = true;
bool solid = true;
bool top = true;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -280,18 +280,18 @@ CX3DImporter_NodeElement* ne;
// If either the xDimension or the zDimension is less than two, the ElevationGrid contains no quadrilaterals.
void X3DImporter::ParseNode_Geometry3D_ElevationGrid()
{
std::string use, def;
bool ccw = true;
bool colorPerVertex = true;
float creaseAngle = 0;
std::list<float> height;
bool normalPerVertex = true;
bool solid = true;
int32_t xDimension = 0;
float xSpacing = 1;
int32_t zDimension = 0;
float zSpacing = 1;
CX3DImporter_NodeElement* ne;
std::string use, def;
bool ccw = true;
bool colorPerVertex = true;
float creaseAngle = 0;
std::list<float> height;
bool normalPerVertex = true;
bool solid = true;
int32_t xDimension = 0;
float xSpacing = 1;
int32_t zDimension = 0;
float zSpacing = 1;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -418,7 +418,7 @@ CX3DImporter_NodeElement* ne;
template<typename TVector>
static void GeometryHelper_Extrusion_CurveIsClosed(std::vector<TVector>& pCurve, const bool pDropTail, const bool pRemoveLastPoint, bool& pCurveIsClosed)
{
size_t cur_sz = pCurve.size();
size_t cur_sz = pCurve.size();
pCurveIsClosed = false;
// for curve with less than four points checking is have no sense,
@@ -461,9 +461,8 @@ 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)
{
const size_t spine_idx_last = pSpine.size() - 1;
aiVector3D tvec;
const size_t spine_idx_last = pSpine.size() - 1;
aiVector3D tvec;
if((pSpine_PointIdx == 0) || (pSpine_PointIdx == spine_idx_last))// at first special cases
{
@@ -495,10 +494,10 @@ aiVector3D tvec;
static aiVector3D GeometryHelper_Extrusion_GetNextZ(const size_t pSpine_PointIdx, const std::vector<aiVector3D>& pSpine, const bool pSpine_Closed,
const aiVector3D pVecZ_Prev)
{
const aiVector3D zero_vec(0);
const size_t spine_idx_last = pSpine.size() - 1;
const aiVector3D zero_vec(0);
const size_t spine_idx_last = pSpine.size() - 1;
aiVector3D tvec;
aiVector3D tvec;
// at first special cases
if(pSpine.size() < 3)// spine have not enough points for vector calculations.
@@ -572,18 +571,18 @@ aiVector3D tvec;
// />
void X3DImporter::ParseNode_Geometry3D_Extrusion()
{
std::string use, def;
bool beginCap = true;
bool ccw = true;
bool convex = true;
float creaseAngle = 0;
std::vector<aiVector2D> crossSection;
bool endCap = true;
std::vector<float> orientation;
std::vector<aiVector2D> scale;
bool solid = true;
std::vector<aiVector3D> spine;
CX3DImporter_NodeElement* ne;
std::string use, def;
bool beginCap = true;
bool ccw = true;
bool convex = true;
float creaseAngle = 0;
std::vector<aiVector2D> crossSection;
bool endCap = true;
std::vector<float> orientation;
std::vector<aiVector2D> scale;
bool solid = true;
std::vector<aiVector3D> spine;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -855,18 +854,18 @@ CX3DImporter_NodeElement* ne;
// </IndexedFaceSet>
void X3DImporter::ParseNode_Geometry3D_IndexedFaceSet()
{
std::string use, def;
bool ccw = true;
std::list<int32_t> colorIndex;
bool colorPerVertex = true;
bool convex = true;
std::list<int32_t> coordIndex;
float creaseAngle = 0;
std::list<int32_t> normalIndex;
bool normalPerVertex = true;
bool solid = true;
std::list<int32_t> texCoordIndex;
CX3DImporter_NodeElement* ne;
std::string use, def;
bool ccw = true;
std::list<int32_t> colorIndex;
bool colorPerVertex = true;
bool convex = true;
std::list<int32_t> coordIndex;
float creaseAngle = 0;
std::list<int32_t> normalIndex;
bool normalPerVertex = true;
bool solid = true;
std::list<int32_t> texCoordIndex;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -942,10 +941,10 @@ CX3DImporter_NodeElement* ne;
// />
void X3DImporter::ParseNode_Geometry3D_Sphere()
{
std::string use, def;
float radius = 1;
bool solid = true;
CX3DImporter_NodeElement* ne;
std::string use, def;
float radius = 1;
bool solid = true;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
+26 -18
View File
@@ -65,7 +65,7 @@ namespace Assimp
// A Group node contains children nodes without introducing a new transformation. It is equivalent to a Transform node containing an identity transform.
void X3DImporter::ParseNode_Grouping_Group()
{
std::string def, use;
std::string def, use;
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -111,7 +111,7 @@ void X3DImporter::ParseNode_Grouping_GroupEnd()
// contain any USE references outside the StaticGroup.
void X3DImporter::ParseNode_Grouping_StaticGroup()
{
std::string def, use;
std::string def, use;
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -159,8 +159,8 @@ void X3DImporter::ParseNode_Grouping_StaticGroupEnd()
// is chosen.
void X3DImporter::ParseNode_Grouping_Switch()
{
std::string def, use;
int32_t whichChoice = -1;
std::string def, use;
int32_t whichChoice = -1;
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -220,13 +220,13 @@ void X3DImporter::ParseNode_Grouping_SwitchEnd()
// P' = T * C * R * SR * S * -SR * -C * P
void X3DImporter::ParseNode_Grouping_Transform()
{
aiVector3D center(0, 0, 0);
float rotation[4] = {0, 0, 1, 0};
aiVector3D scale(1, 1, 1);// A value of zero indicates that any child geometry shall not be displayed
float scale_orientation[4] = {0, 0, 1, 0};
aiVector3D translation(0, 0, 0);
aiMatrix4x4 matr, tmatr;
std::string use, def;
aiVector3D center(0, 0, 0);
float rotation[4] = {0, 0, 1, 0};
aiVector3D scale(1, 1, 1);// A value of zero indicates that any child geometry shall not be displayed
float scale_orientation[4] = {0, 0, 1, 0};
aiVector3D translation(0, 0, 0);
aiMatrix4x4 matr, tmatr;
std::string use, def;
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -248,11 +248,13 @@ std::string use, def;
if(an == "scaleOrientation")
{
std::vector<float> 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;
}
@@ -262,7 +264,7 @@ std::string use, def;
// if "USE" defined then find already defined element.
if(!use.empty())
{
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
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.
// 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
//
// calculate tranformation matrix
// calculate transformation matrix
aiMatrix4x4::Translation(translation, matr);// T
aiMatrix4x4::Translation(center, tmatr);// C
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.
// 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
}
+3 -3
View File
@@ -69,7 +69,7 @@ void X3DImporter::ParseNode_Lighting_DirectionalLight()
bool global = false;
float intensity = 1;
bool on = true;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -141,7 +141,7 @@ void X3DImporter::ParseNode_Lighting_PointLight()
aiVector3D location( 0, 0, 0 );
bool on = true;
float radius = 100;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -222,7 +222,7 @@ void X3DImporter::ParseNode_Lighting_SpotLight()
aiVector3D location( 0, 0, 0 );
bool on = true;
float radius = 100;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
+9 -9
View File
@@ -123,7 +123,7 @@ void X3DImporter::ParseNode_MetadataBoolean()
std::string def, use;
std::string name, reference;
std::list<bool> value;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -147,7 +147,7 @@ void X3DImporter::ParseNode_MetadataDouble()
std::string def, use;
std::string name, reference;
std::list<double> value;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -168,10 +168,10 @@ void X3DImporter::ParseNode_MetadataDouble()
// />
void X3DImporter::ParseNode_MetadataFloat()
{
std::string def, use;
std::string name, reference;
std::list<float> value;
CX3DImporter_NodeElement* ne;
std::string def, use;
std::string name, reference;
std::list<float> value;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -195,7 +195,7 @@ void X3DImporter::ParseNode_MetadataInteger()
std::string def, use;
std::string name, reference;
std::list<int32_t> value;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -217,7 +217,7 @@ void X3DImporter::ParseNode_MetadataSet()
{
std::string def, use;
std::string name, reference;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
@@ -258,7 +258,7 @@ void X3DImporter::ParseNode_MetadataString()
std::string def, use;
std::string name, reference;
std::list<std::string> value;
CX3DImporter_NodeElement* ne;
CX3DImporter_NodeElement* ne( nullptr );
MACRO_ATTRREAD_LOOPBEG;
MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);