Apply clang-format to files
parent
6f3bfb5b60
commit
537b445a59
|
@ -239,7 +239,7 @@ void IRRImporter::CopyMaterial(std::vector<aiMaterial *> &materials,
|
|||
// Do we have a default material? If not we need to create one
|
||||
if (UINT_MAX == defMatIdx) {
|
||||
defMatIdx = (unsigned int)materials.size();
|
||||
//TODO: add this materials to someone?
|
||||
// TODO: add this materials to someone?
|
||||
/*aiMaterial* mat = new aiMaterial();
|
||||
|
||||
aiString s;
|
||||
|
@ -380,7 +380,6 @@ void IRRImporter::ComputeAnimations(Node *root, aiNode *real, std::vector<aiNode
|
|||
if (360 == lcm)
|
||||
break;
|
||||
|
||||
|
||||
// find out how many time units we'll need for the finest
|
||||
// track (in seconds) - this defines the number of output
|
||||
// keys (fps * seconds)
|
||||
|
@ -609,7 +608,7 @@ void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
|||
std::vector<aiMaterial *> &materials,
|
||||
unsigned int &defMatIdx) {
|
||||
unsigned int oldMeshSize = (unsigned int)meshes.size();
|
||||
//unsigned int meshTrafoAssign = 0;
|
||||
// unsigned int meshTrafoAssign = 0;
|
||||
|
||||
// Now determine the type of the node
|
||||
switch (root->type) {
|
||||
|
@ -797,7 +796,7 @@ void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
|||
// Now compute the final local transformation matrix of the
|
||||
// node from the given translation, rotation and scaling values.
|
||||
// (the rotation is given in Euler angles, XYZ order)
|
||||
//std::swap((float&)root->rotation.z,(float&)root->rotation.y);
|
||||
// std::swap((float&)root->rotation.z,(float&)root->rotation.y);
|
||||
rootOut->mTransformation.FromEulerAnglesXYZ(AI_DEG_TO_RAD(root->rotation));
|
||||
|
||||
// apply scaling
|
||||
|
@ -848,7 +847,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
|
||||
// Construct the irrXML parser
|
||||
XmlParser st;
|
||||
if (!st.parse( file.get() )) {
|
||||
if (!st.parse(file.get())) {
|
||||
throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
|
||||
}
|
||||
pugi::xml_node rootElement = st.getRootNode();
|
||||
|
@ -872,7 +871,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
|
||||
// Batch loader used to load external models
|
||||
BatchLoader batch(pIOHandler);
|
||||
//batch.SetBasePath(pFile);
|
||||
// batch.SetBasePath(pFile);
|
||||
|
||||
cameras.reserve(5);
|
||||
lights.reserve(5);
|
||||
|
@ -882,7 +881,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
|
||||
// Parse the XML file
|
||||
|
||||
//while (reader->read()) {
|
||||
// while (reader->read()) {
|
||||
for (pugi::xml_node child : rootElement.children())
|
||||
switch (child.type()) {
|
||||
case pugi::node_element:
|
||||
|
@ -907,7 +906,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
* materials assigned (except lights, cameras and dummies, of course).
|
||||
*/
|
||||
// ***********************************************************************
|
||||
//const char *sz = reader->getAttributeValueSafe("type");
|
||||
// const char *sz = reader->getAttributeValueSafe("type");
|
||||
pugi::xml_attribute attrib = child.attribute("type");
|
||||
Node *nd;
|
||||
if (!ASSIMP_stricmp(attrib.name(), "mesh") || !ASSIMP_stricmp(attrib.name(), "octTree")) {
|
||||
|
@ -998,8 +997,8 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
// while (reader->read()) {
|
||||
for (pugi::xml_node attrib : child.children()) {
|
||||
if (attrib.type() == pugi::node_element) {
|
||||
//if (reader->getNodeType() == EXN_ELEMENT) {
|
||||
//if (!ASSIMP_stricmp(reader->getNodeName(), "vector3d")) {
|
||||
// if (reader->getNodeType() == EXN_ELEMENT) {
|
||||
// if (!ASSIMP_stricmp(reader->getNodeName(), "vector3d")) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "vector3d")) {
|
||||
VectorProperty prop;
|
||||
ReadVectorProperty(prop);
|
||||
|
|
|
@ -71,13 +71,13 @@ public:
|
|||
/** Returns whether the class can handle the format of the given file.
|
||||
* See BaseImporter::CanRead() for details.
|
||||
*/
|
||||
bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
||||
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
||||
bool checkSig) const override;
|
||||
|
||||
protected:
|
||||
const aiImporterDesc* GetInfo () const override;
|
||||
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) override;
|
||||
void SetupProperties(const Importer* pImp) override;
|
||||
const aiImporterDesc *GetInfo() const override;
|
||||
void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) override;
|
||||
void SetupProperties(const Importer *pImp) override;
|
||||
|
||||
private:
|
||||
/** Data structure for a scene-graph node animator
|
||||
|
@ -94,18 +94,10 @@ private:
|
|||
|
||||
} type;
|
||||
|
||||
explicit Animator(AT t = UNKNOWN)
|
||||
: type (t)
|
||||
, speed ( ai_real( 0.001 ) )
|
||||
, direction ( ai_real( 0.0 ), ai_real( 1.0 ), ai_real( 0.0 ) )
|
||||
, circleRadius ( ai_real( 1.0) )
|
||||
, tightness ( ai_real( 0.5 ) )
|
||||
, loop (true)
|
||||
, timeForWay (100)
|
||||
{
|
||||
explicit Animator(AT t = UNKNOWN) :
|
||||
type(t), speed(ai_real(0.001)), direction(ai_real(0.0), ai_real(1.0), ai_real(0.0)), circleRadius(ai_real(1.0)), tightness(ai_real(0.5)), loop(true), timeForWay(100) {
|
||||
}
|
||||
|
||||
|
||||
// common parameters
|
||||
ai_real speed;
|
||||
aiVector3D direction;
|
||||
|
@ -128,11 +120,9 @@ private:
|
|||
|
||||
/** Data structure for a scene-graph node in an IRR file
|
||||
*/
|
||||
struct Node
|
||||
{
|
||||
struct Node {
|
||||
// Type of the node
|
||||
enum ET
|
||||
{
|
||||
enum ET {
|
||||
LIGHT,
|
||||
CUBE,
|
||||
MESH,
|
||||
|
@ -144,21 +134,20 @@ private:
|
|||
ANIMMESH
|
||||
} type;
|
||||
|
||||
explicit Node(ET t)
|
||||
: type (t)
|
||||
, scaling (1.0,1.0,1.0) // assume uniform scaling by default
|
||||
, parent()
|
||||
, framesPerSecond (0.0)
|
||||
, id()
|
||||
, sphereRadius (1.0)
|
||||
, spherePolyCountX (100)
|
||||
, spherePolyCountY (100)
|
||||
{
|
||||
explicit Node(ET t) :
|
||||
type(t), scaling(1.0, 1.0, 1.0) // assume uniform scaling by default
|
||||
,
|
||||
parent(),
|
||||
framesPerSecond(0.0),
|
||||
id(),
|
||||
sphereRadius(1.0),
|
||||
spherePolyCountX(100),
|
||||
spherePolyCountY(100) {
|
||||
|
||||
// Generate a default name for the node
|
||||
char buffer[128];
|
||||
static int cnt;
|
||||
ai_snprintf(buffer, 128, "IrrNode_%i",cnt++);
|
||||
ai_snprintf(buffer, 128, "IrrNode_%i", cnt++);
|
||||
name = std::string(buffer);
|
||||
|
||||
// reserve space for up to 5 materials
|
||||
|
@ -175,10 +164,10 @@ private:
|
|||
std::string name;
|
||||
|
||||
// List of all child nodes
|
||||
std::vector<Node*> children;
|
||||
std::vector<Node *> children;
|
||||
|
||||
// Parent node
|
||||
Node* parent;
|
||||
Node *parent;
|
||||
|
||||
// Animated meshes: frames per second
|
||||
// 0.f if not specified
|
||||
|
@ -190,13 +179,13 @@ private:
|
|||
|
||||
// Meshes: List of materials to be assigned
|
||||
// along with their corresponding material flags
|
||||
std::vector< std::pair<aiMaterial*, unsigned int> > materials;
|
||||
std::vector<std::pair<aiMaterial *, unsigned int>> materials;
|
||||
|
||||
// Spheres: radius of the sphere to be generates
|
||||
ai_real sphereRadius;
|
||||
|
||||
// Spheres: Number of polygons in the x,y direction
|
||||
unsigned int spherePolyCountX,spherePolyCountY;
|
||||
unsigned int spherePolyCountX, spherePolyCountY;
|
||||
|
||||
// List of all animators assigned to the node
|
||||
std::list<Animator> animators;
|
||||
|
@ -204,8 +193,7 @@ private:
|
|||
|
||||
/** Data structure for a vertex in an IRR skybox
|
||||
*/
|
||||
struct SkyboxVertex
|
||||
{
|
||||
struct SkyboxVertex {
|
||||
SkyboxVertex() = default;
|
||||
|
||||
//! Construction from single vertex components
|
||||
|
@ -213,31 +201,28 @@ private:
|
|||
ai_real nx, ai_real ny, ai_real nz,
|
||||
ai_real uvx, ai_real uvy)
|
||||
|
||||
: position (px,py,pz)
|
||||
, normal (nx,ny,nz)
|
||||
, uv (uvx,uvy,0.0)
|
||||
{}
|
||||
:
|
||||
position(px, py, pz), normal(nx, ny, nz), uv(uvx, uvy, 0.0) {}
|
||||
|
||||
aiVector3D position, normal, uv;
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// Fill the scene-graph recursively
|
||||
void GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene,
|
||||
BatchLoader& batch,
|
||||
std::vector<aiMesh*>& meshes,
|
||||
std::vector<aiNodeAnim*>& anims,
|
||||
std::vector<AttachmentInfo>& attach,
|
||||
std::vector<aiMaterial*>& materials,
|
||||
unsigned int& defaultMatIdx);
|
||||
void GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
||||
BatchLoader &batch,
|
||||
std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiNodeAnim *> &anims,
|
||||
std::vector<AttachmentInfo> &attach,
|
||||
std::vector<aiMaterial *> &materials,
|
||||
unsigned int &defaultMatIdx);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// Generate a mesh that consists of just a single quad
|
||||
aiMesh* BuildSingleQuadMesh(const SkyboxVertex& v1,
|
||||
const SkyboxVertex& v2,
|
||||
const SkyboxVertex& v3,
|
||||
const SkyboxVertex& v4);
|
||||
aiMesh *BuildSingleQuadMesh(const SkyboxVertex &v1,
|
||||
const SkyboxVertex &v2,
|
||||
const SkyboxVertex &v3,
|
||||
const SkyboxVertex &v4);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// Build a sky-box
|
||||
|
@ -245,8 +230,8 @@ private:
|
|||
/// @param meshes Receives 6 output meshes
|
||||
/// @param materials The last 6 materials are assigned to the newly
|
||||
/// created meshes. The names of the materials are adjusted.
|
||||
void BuildSkybox(std::vector<aiMesh*>& meshes,
|
||||
std::vector<aiMaterial*> materials);
|
||||
void BuildSkybox(std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiMaterial *> materials);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Copy a material for a mesh to the output material list
|
||||
|
@ -256,10 +241,10 @@ private:
|
|||
* @param defMatIdx Default material index - UINT_MAX if not present
|
||||
* @param mesh Mesh to work on
|
||||
*/
|
||||
void CopyMaterial(std::vector<aiMaterial*>& materials,
|
||||
std::vector< std::pair<aiMaterial*, unsigned int> >& inmaterials,
|
||||
unsigned int& defMatIdx,
|
||||
aiMesh* mesh);
|
||||
void CopyMaterial(std::vector<aiMaterial *> &materials,
|
||||
std::vector<std::pair<aiMaterial *, unsigned int>> &inmaterials,
|
||||
unsigned int &defMatIdx,
|
||||
aiMesh *mesh);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Compute animations for a specific node
|
||||
|
@ -267,8 +252,8 @@ private:
|
|||
* @param root Node to be processed
|
||||
* @param anims The list of output animations
|
||||
*/
|
||||
void ComputeAnimations(Node* root, aiNode* real,
|
||||
std::vector<aiNodeAnim*>& anims);
|
||||
void ComputeAnimations(Node *root, aiNode *real,
|
||||
std::vector<aiNodeAnim *> &anims);
|
||||
|
||||
private:
|
||||
/// Configuration option: desired output FPS
|
||||
|
|
|
@ -121,7 +121,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
|||
|
||||
// Construct the irrXML parser
|
||||
XmlParser parser;
|
||||
if (!parser.parse( file.get() )) {
|
||||
if (!parser.parse(file.get())) {
|
||||
throw DeadlyImportError("XML parse error while loading IRRMESH file ", pFile);
|
||||
}
|
||||
XmlNode root = parser.getRootNode();
|
||||
|
@ -181,7 +181,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
|||
/* no else here! */ if (!ASSIMP_stricmp(child.name(), "vertices")) {
|
||||
pugi::xml_attribute attr = child.attribute("vertexCount");
|
||||
int num = attr.as_int();
|
||||
//int num = reader->getAttributeValueAsInt("vertexCount");
|
||||
// int num = reader->getAttributeValueAsInt("vertexCount");
|
||||
|
||||
if (!num) {
|
||||
// This is possible ... remove the mesh from the list and skip further reading
|
||||
|
@ -199,7 +199,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
|||
curUVs.reserve(num);
|
||||
|
||||
// Determine the file format
|
||||
//const char *t = reader->getAttributeValueSafe("type");
|
||||
// const char *t = reader->getAttributeValueSafe("type");
|
||||
pugi::xml_attribute t = child.attribute("type");
|
||||
if (!ASSIMP_stricmp("2tcoords", t.name())) {
|
||||
curUV2s.reserve(num);
|
||||
|
@ -294,9 +294,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
|||
curMesh->mTextureCoords[1] = new aiVector3D[curMesh->mNumVertices];
|
||||
}
|
||||
}
|
||||
//break;
|
||||
// break;
|
||||
|
||||
//case EXN_TEXT: {
|
||||
// case EXN_TEXT: {
|
||||
const char *sz = child.child_value();
|
||||
if (textMeaning == 1) {
|
||||
textMeaning = 0;
|
||||
|
|
|
@ -43,19 +43,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* @brief Shared utilities for the IRR and IRRMESH loaders
|
||||
*/
|
||||
|
||||
//This section should be excluded only if both the Irrlicht AND the Irrlicht Mesh importers were omitted.
|
||||
// This section should be excluded only if both the Irrlicht AND the Irrlicht Mesh importers were omitted.
|
||||
#if !(defined(ASSIMP_BUILD_NO_IRR_IMPORTER) && defined(ASSIMP_BUILD_NO_IRRMESH_IMPORTER))
|
||||
|
||||
#include "IRRShared.h"
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/material.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// Transformation matrix to convert from Assimp to IRR space
|
||||
const aiMatrix4x4 Assimp::AI_TO_IRR_MATRIX = aiMatrix4x4 (
|
||||
const aiMatrix4x4 Assimp::AI_TO_IRR_MATRIX = aiMatrix4x4(
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
|
@ -63,11 +63,11 @@ const aiMatrix4x4 Assimp::AI_TO_IRR_MATRIX = aiMatrix4x4 (
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a property in hexadecimal format (i.e. ffffffff)
|
||||
void IrrlichtBase::ReadHexProperty(HexProperty &out ) {
|
||||
void IrrlichtBase::ReadHexProperty(HexProperty &out) {
|
||||
for (pugi::xml_attribute attrib : mNode->attributes()) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")) {
|
||||
out.name = std::string( attrib.value() );
|
||||
} else if (!ASSIMP_stricmp(attrib.name(),"value")) {
|
||||
out.name = std::string(attrib.value());
|
||||
} else if (!ASSIMP_stricmp(attrib.name(), "value")) {
|
||||
// parse the hexadecimal value
|
||||
out.value = strtoul16(attrib.name());
|
||||
}
|
||||
|
@ -76,11 +76,11 @@ void IrrlichtBase::ReadHexProperty(HexProperty &out ) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a decimal property
|
||||
void IrrlichtBase::ReadIntProperty(IntProperty & out) {
|
||||
void IrrlichtBase::ReadIntProperty(IntProperty &out) {
|
||||
for (pugi::xml_attribute attrib : mNode->attributes()) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")) {
|
||||
out.name = std::string(attrib.value());
|
||||
} else if (!ASSIMP_stricmp(attrib.value(),"value")) {
|
||||
} else if (!ASSIMP_stricmp(attrib.value(), "value")) {
|
||||
// parse the int value
|
||||
out.value = strtol10(attrib.name());
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void IrrlichtBase::ReadIntProperty(IntProperty & out) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a string property
|
||||
void IrrlichtBase::ReadStringProperty( StringProperty& out) {
|
||||
void IrrlichtBase::ReadStringProperty(StringProperty &out) {
|
||||
for (pugi::xml_attribute attrib : mNode->attributes()) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")) {
|
||||
out.name = std::string(attrib.value());
|
||||
|
@ -104,7 +104,7 @@ void IrrlichtBase::ReadStringProperty( StringProperty& out) {
|
|||
// read a boolean property
|
||||
void IrrlichtBase::ReadBoolProperty(BoolProperty &out) {
|
||||
for (pugi::xml_attribute attrib : mNode->attributes()) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")){
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")) {
|
||||
out.name = std::string(attrib.value());
|
||||
} else if (!ASSIMP_stricmp(attrib.name(), "value")) {
|
||||
// true or false, case insensitive
|
||||
|
@ -128,7 +128,7 @@ void IrrlichtBase::ReadFloatProperty(FloatProperty &out) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// read a vector property
|
||||
void IrrlichtBase::ReadVectorProperty( VectorProperty &out ) {
|
||||
void IrrlichtBase::ReadVectorProperty(VectorProperty &out) {
|
||||
for (pugi::xml_attribute attrib : mNode->attributes()) {
|
||||
if (!ASSIMP_stricmp(attrib.name(), "name")) {
|
||||
out.name = std::string(attrib.value());
|
||||
|
@ -137,28 +137,28 @@ void IrrlichtBase::ReadVectorProperty( VectorProperty &out ) {
|
|||
const char *ptr = attrib.value();
|
||||
|
||||
SkipSpaces(&ptr);
|
||||
ptr = fast_atoreal_move<float>( ptr,(float&)out.value.x );
|
||||
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.x);
|
||||
SkipSpaces(&ptr);
|
||||
if (',' != *ptr) {
|
||||
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
|
||||
} else {
|
||||
SkipSpaces(ptr + 1, &ptr);
|
||||
}
|
||||
ptr = fast_atoreal_move<float>( ptr,(float&)out.value.y );
|
||||
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.y);
|
||||
SkipSpaces(&ptr);
|
||||
if (',' != *ptr) {
|
||||
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
|
||||
} else {
|
||||
SkipSpaces(ptr + 1, &ptr);
|
||||
}
|
||||
ptr = fast_atoreal_move<float>( ptr,(float&)out.value.z );
|
||||
ptr = fast_atoreal_move<float>(ptr, (float &)out.value.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert a string to a proper aiMappingMode
|
||||
int ConvertMappingMode(const std::string& mode) {
|
||||
int ConvertMappingMode(const std::string &mode) {
|
||||
if (mode == "texture_clamp_repeat") {
|
||||
return aiTextureMapMode_Wrap;
|
||||
} else if (mode == "texture_clamp_mirror") {
|
||||
|
@ -170,8 +170,8 @@ int ConvertMappingMode(const std::string& mode) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Parse a material from the XML file
|
||||
aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) {
|
||||
aiMaterial* mat = new aiMaterial();
|
||||
aiMaterial *IrrlichtBase::ParseMaterial(unsigned int &matFlags) {
|
||||
aiMaterial *mat = new aiMaterial();
|
||||
aiColor4D clr;
|
||||
aiString s;
|
||||
|
||||
|
@ -337,7 +337,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//break;
|
||||
// break;
|
||||
/*case EXN_ELEMENT_END:
|
||||
|
||||
// Assume there are no further nested nodes in <material> elements
|
||||
|
|
Loading…
Reference in New Issue