Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-13 02:05:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-13 02:05:33 +0400
commit2e8a2f7668e5687a0a9a5087e76eeb739c818b2b (patch)
tree75aa5fe8746df4cd369afff88c4fd367cb78f72c /source/blender/collada/MeshImporter.cpp
parent46c95d37c6fae2268a7f39f90ef46e9c3c696e3f (diff)
style cleanup
Diffstat (limited to 'source/blender/collada/MeshImporter.cpp')
-rw-r--r--source/blender/collada/MeshImporter.cpp316
1 files changed, 159 insertions, 157 deletions
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index bcfec7a8056..59927e961bf 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -72,24 +72,24 @@ static const char *bc_get_dae_name(T *node)
static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type)
{
switch (type) {
- case COLLADAFW::MeshPrimitive::LINES:
- return "LINES";
- case COLLADAFW::MeshPrimitive::LINE_STRIPS:
- return "LINESTRIPS";
- case COLLADAFW::MeshPrimitive::POLYGONS:
- return "POLYGONS";
- case COLLADAFW::MeshPrimitive::POLYLIST:
- return "POLYLIST";
- case COLLADAFW::MeshPrimitive::TRIANGLES:
- return "TRIANGLES";
- case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
- return "TRIANGLE_FANS";
- case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
- return "TRIANGLE_FANS";
- case COLLADAFW::MeshPrimitive::POINTS:
- return "POINTS";
- case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
- return "UNDEFINED_PRIMITIVE_TYPE";
+ case COLLADAFW::MeshPrimitive::LINES:
+ return "LINES";
+ case COLLADAFW::MeshPrimitive::LINE_STRIPS:
+ return "LINESTRIPS";
+ case COLLADAFW::MeshPrimitive::POLYGONS:
+ return "POLYGONS";
+ case COLLADAFW::MeshPrimitive::POLYLIST:
+ return "POLYLIST";
+ case COLLADAFW::MeshPrimitive::TRIANGLES:
+ return "TRIANGLES";
+ case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
+ return "TRIANGLE_FANS";
+ case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
+ return "TRIANGLE_FANS";
+ case COLLADAFW::MeshPrimitive::POINTS:
+ return "POINTS";
+ case COLLADAFW::MeshPrimitive::UNDEFINED_PRIMITIVE_TYPE:
+ return "UNDEFINED_PRIMITIVE_TYPE";
}
return "UNKNOWN";
}
@@ -97,43 +97,44 @@ static const char *bc_primTypeToStr(COLLADAFW::MeshPrimitive::PrimitiveType type
static const char *bc_geomTypeToStr(COLLADAFW::Geometry::GeometryType type)
{
switch (type) {
- case COLLADAFW::Geometry::GEO_TYPE_MESH:
- return "MESH";
- case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
- return "SPLINE";
- case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
- return "CONVEX_MESH";
- case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
- default:
- return "UNKNOWN";
+ case COLLADAFW::Geometry::GEO_TYPE_MESH:
+ return "MESH";
+ case COLLADAFW::Geometry::GEO_TYPE_SPLINE:
+ return "SPLINE";
+ case COLLADAFW::Geometry::GEO_TYPE_CONVEX_MESH:
+ return "CONVEX_MESH";
+ case COLLADAFW::Geometry::GEO_TYPE_UNKNOWN:
+ default:
+ return "UNKNOWN";
}
}
UVDataWrapper::UVDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata)
-{}
+{
+}
#ifdef COLLADA_DEBUG
void WVDataWrapper::print()
{
fprintf(stderr, "UVs:\n");
switch (mVData->getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
- fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i+1]);
+ fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i + 1]);
}
}
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
- fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i+1]);
+ fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i + 1]);
}
}
}
@@ -146,30 +147,30 @@ void WVDataWrapper::print()
void UVDataWrapper::getUV(int uv_index, float *uv)
{
int stride = mVData->getStride(0);
- if (stride==0) stride = 2;
+ if (stride == 0) stride = 2;
switch (mVData->getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->empty()) return;
- uv[0] = (*values)[uv_index*stride];
- uv[1] = (*values)[uv_index*stride + 1];
+ uv[0] = (*values)[uv_index * stride];
+ uv[1] = (*values)[uv_index * stride + 1];
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->empty()) return;
- uv[0] = (float)(*values)[uv_index*stride];
- uv[1] = (float)(*values)[uv_index*stride + 1];
+ uv[0] = (float)(*values)[uv_index * stride];
+ uv[1] = (float)(*values)[uv_index * stride + 1];
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
- default:
- fprintf(stderr, "MeshImporter.getUV(): unknown data type\n");
+ case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
+ default:
+ fprintf(stderr, "MeshImporter.getUV(): unknown data type\n");
}
}
@@ -198,7 +199,7 @@ void MeshImporter::rotate_face_indices(MFace *mface)
#endif
void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
- COLLADAFW::IndexList& index_list, unsigned int *tris_indices)
+ COLLADAFW::IndexList& index_list, unsigned int *tris_indices)
{
// per face vertex indices, this means for quad we have 4 indices, not 8
COLLADAFW::UIntValuesArray& indices = index_list.getIndices();
@@ -209,7 +210,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
}
void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
- COLLADAFW::IndexList& index_list, int index, bool quad)
+ COLLADAFW::IndexList& index_list, int index, bool quad)
{
// per face vertex indices, this means for quad we have 4 indices, not 8
COLLADAFW::UIntValuesArray& indices = index_list.getIndices();
@@ -223,31 +224,31 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs,
#ifdef COLLADA_DEBUG
if (quad) {
fprintf(stderr, "face uv:\n"
- "((%d, %d, %d, %d))\n"
- "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
-
- indices[index + 0],
- indices[index + 1],
- indices[index + 2],
- indices[index + 3],
-
- mtface->uv[0][0], mtface->uv[0][1],
- mtface->uv[1][0], mtface->uv[1][1],
- mtface->uv[2][0], mtface->uv[2][1],
- mtface->uv[3][0], mtface->uv[3][1]);
+ "((%d, %d, %d, %d))\n"
+ "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
+
+ indices[index + 0],
+ indices[index + 1],
+ indices[index + 2],
+ indices[index + 3],
+
+ mtface->uv[0][0], mtface->uv[0][1],
+ mtface->uv[1][0], mtface->uv[1][1],
+ mtface->uv[2][0], mtface->uv[2][1],
+ mtface->uv[3][0], mtface->uv[3][1]);
}
else {
fprintf(stderr, "face uv:\n"
- "((%d, %d, %d))\n"
- "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
+ "((%d, %d, %d))\n"
+ "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n",
- indices[index + 0],
- indices[index + 1],
- indices[index + 2],
+ indices[index + 0],
+ indices[index + 1],
+ indices[index + 2],
- mtface->uv[0][0], mtface->uv[0][1],
- mtface->uv[1][0], mtface->uv[1][1],
- mtface->uv[2][0], mtface->uv[2][1]);
+ mtface->uv[0][0], mtface->uv[0][1],
+ mtface->uv[1][0], mtface->uv[1][1],
+ mtface->uv[2][0], mtface->uv[2][1]);
}
#endif
}
@@ -263,7 +264,7 @@ void MeshImporter::print_index_list(COLLADAFW::IndexList& index_list)
}
#endif
-bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
+bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has supported primitive types: lines, polylist, triangles, triangle_fans
{
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
@@ -279,26 +280,26 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has sup
// OpenCollada passes POLYGONS type for <polylist>
if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vca = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < vca.getCount(); j++) {
int count = vca[j];
if (count < 3) {
fprintf(stderr, "Primitive %s in %s has at least one face with vertex count < 3\n",
- type_str, name);
+ type_str, name);
return false;
}
}
}
- else if ( type == COLLADAFW::MeshPrimitive::LINES )
+ else if (type == COLLADAFW::MeshPrimitive::LINES)
{
// TODO: Add Checker for line syntax here
}
- else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type!= COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
+ else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type != COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
fprintf(stderr, "Primitive type %s is not supported.\n", type_str);
return false;
}
@@ -317,10 +318,10 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
// vertices
COLLADAFW::MeshVertexData& pos = mesh->getPositions();
int stride = pos.getStride(0);
- if (stride==0) stride = 3;
+ if (stride == 0) stride = 3;
me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
- me->mvert = (MVert*)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
+ me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
MVert *mvert;
int i;
@@ -339,12 +340,12 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
dispbase.first = dispbase.last = NULL;
- dl = (DispList*)MEM_callocN(sizeof(DispList), "poly disp");
+ dl = (DispList *)MEM_callocN(sizeof(DispList), "poly disp");
dl->nr = totvert;
dl->type = DL_POLY;
dl->parts = 1;
- dl->verts = vert = (float*)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
- dl->index = (int*)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
+ dl->verts = vert = (float *)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
+ dl->index = (int *)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
BLI_addtail(&dispbase, dl);
@@ -356,14 +357,14 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
BKE_displist_fill(&dispbase, &dispbase, 0);
int tottri = 0;
- dl= (DispList*)dispbase.first;
+ dl = (DispList *)dispbase.first;
if (dl->type == DL_INDEX3) {
tottri = dl->parts;
int *index = dl->index;
- for (i= 0; i < tottri; i++) {
- int t[3]= {*index, *(index + 1), *(index + 2)};
+ for (i = 0; i < tottri; i++) {
+ int t[3] = {*index, *(index + 1), *(index + 2)};
std::sort(t, t + 3);
@@ -394,9 +395,9 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
if (type == COLLADAFW::MeshPrimitive::POLYLIST ||
- type == COLLADAFW::MeshPrimitive::POLYGONS) {
-
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ type == COLLADAFW::MeshPrimitive::POLYGONS)
+ {
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@@ -433,8 +434,8 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
has_useable_normals = true;
else {
fprintf(stderr,
- "Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
- normals_count, index_count );
+ "Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
+ normals_count, index_count);
}
}
@@ -496,7 +497,7 @@ void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_t
// allocate space for faces
if (total_facecount > 0) {
me->totface = total_facecount + new_tris;
- me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
+ me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
}
}
@@ -566,7 +567,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
{
unsigned int loose_edge_count = get_loose_edge_count(mesh);
- if(loose_edge_count > 0) {
+ if (loose_edge_count > 0) {
unsigned int face_edge_count = me->totedge;
unsigned int total_edge_count = loose_edge_count + face_edge_count;
@@ -587,11 +588,11 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
for (int i = 0; i < edge_count; i++, med++) {
- med->bweight= 0;
- med->crease = 0;
- med->flag = 0;
- med->v1 = indices[ 2*i ];
- med->v2 = indices[ 2*i + 1];
+ med->bweight = 0;
+ med->crease = 0;
+ med->flag = 0;
+ med->v1 = indices[2 * i];
+ med->v2 = indices[2 * i + 1];
}
}
}
@@ -630,7 +631,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
// activate the first uv map
- if (totuvset) me->mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
+ if (totuvset) me->mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
UVDataWrapper uvs(mesh->getUVCoords());
@@ -669,11 +670,11 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
#ifdef COLLADA_DEBUG
/*
- fprintf(stderr, "Primitive %d:\n", i);
- for (unsigned int j = 0; j < totuvset; j++) {
- print_index_list(*index_list_array[j]);
- }
- */
+ fprintf(stderr, "Primitive %d:\n", i);
+ for (unsigned int j = 0; j < totuvset; j++) {
+ print_index_list(*index_list_array[j]);
+ }
+ */
#endif
if (type == COLLADAFW::MeshPrimitive::TRIANGLES) {
@@ -686,14 +687,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, false);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, false);
}
#endif
@@ -725,24 +726,24 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
// For each triangle store indeces of its 3 vertices
- unsigned int triangle_vertex_indices[3]={first_vertex, indices[1], indices[2]};
+ unsigned int triangle_vertex_indices[3] = {first_vertex, indices[1], indices[2]};
set_face_indices(mface, triangle_vertex_indices, false);
test_index_face(mface, &me->fdata, face_index, 3);
if (mp_has_normals) { // vertex normals, same inplementation as for the triangles
// the same for vertces normals
- unsigned int vertex_normal_indices[3]={first_normal, nind[1], nind[2]};
+ unsigned int vertex_normal_indices[3] = {first_normal, nind[1], nind[2]};
if (!flat_face(vertex_normal_indices, nor, 3))
mface->flag |= ME_SMOOTH;
- nind++;
- }
-
- mface++; // same inplementation as for the triangles
- indices++;
- face_index++;
- prim.totface++;
+ nind++;
}
+ mface++; // same inplementation as for the triangles
+ indices++;
+ face_index++;
+ prim.totface++;
+ }
+
// Moving cursor to the next triangle fan.
if (mp_has_normals)
nind += 2;
@@ -751,7 +752,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
}
else if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
- COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
+ COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@@ -769,14 +770,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, mface->v4 != 0);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4);
}
#endif
@@ -819,7 +820,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int l = 0; l < totuvset; l++) {
if (!index_list_array.empty() && index_list_array[l]) {
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
set_face_uv(&mtface[face_index], uvs, l, *index_list_array[l], uv_indices);
}
}
@@ -828,7 +829,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
int uvset_index = index_list_array[l]->getSetIndex();
// get mtface by face index and uv set index
- MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
+ MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
set_face_uv(&mtface[face_index], uvs, *index_list_array[l], uv_indices);
}
#endif
@@ -873,9 +874,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
i *= stride;
switch (arr.getType()) {
- case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
- COLLADAFW::ArrayPrimitiveType<float>* values = arr.getFloatValues();
+ COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
if (values->empty()) return;
v[0] = (*values)[i++];
@@ -884,9 +885,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
}
break;
- case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
+ case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
- COLLADAFW::ArrayPrimitiveType<double>* values = arr.getDoubleValues();
+ COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
if (values->empty()) return;
v[0] = (float)(*values)[i++];
@@ -894,8 +895,8 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
v[2] = (float)(*values)[i];
}
break;
- default:
- break;
+ default:
+ break;
}
}
@@ -921,12 +922,13 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor,
return true;
}
-MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {}
+MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {
+}
void MeshImporter::bmeshConversion()
{
- for (std::map<COLLADAFW::UniqueId, Mesh*>::iterator m = uid_mesh_map.begin();
- m != uid_mesh_map.end(); ++m)
+ for (std::map<COLLADAFW::UniqueId, Mesh *>::iterator m = uid_mesh_map.begin();
+ m != uid_mesh_map.end(); ++m)
{
if ((*m).second) {
Mesh *me = (*m).second;
@@ -947,21 +949,21 @@ Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid
}
MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture,
- Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
- MTex *color_texture)
+ Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
+ MTex *color_texture)
{
const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId();
size_t setindex = ctexture.getSetIndex();
std::string uvname = ctexture.getSemantic();
- if (setindex==-1) return NULL;
+ if (setindex == -1) return NULL;
const CustomData *data = &me->fdata;
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
if (layer_index == -1) return NULL;
- CustomDataLayer *cdl = &data->layers[layer_index+setindex];
+ CustomDataLayer *cdl = &data->layers[layer_index + setindex];
/* set uvname to bind_vertex_input semantic */
BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name));
@@ -972,9 +974,9 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
return color_texture;
}
- std::vector<MTex*> textures = texindex_texarray_map[texture_index];
+ std::vector<MTex *> textures = texindex_texarray_map[texture_index];
- std::vector<MTex*>::iterator it;
+ std::vector<MTex *>::iterator it;
for (it = textures.begin(); it != textures.end(); it++) {
@@ -989,12 +991,12 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
}
MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial,
- std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
- Object *ob, const COLLADAFW::UniqueId *geom_uid,
- MTex **color_texture, char *layername, MTFace *texture_face,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
+ std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
+ Object *ob, const COLLADAFW::UniqueId *geom_uid,
+ MTex **color_texture, char *layername, MTFace *texture_face,
+ std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
{
- Mesh *me = (Mesh*)ob->data;
+ Mesh *me = (Mesh *)ob->data;
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
// do we know this material?
@@ -1008,9 +1010,9 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
// again. Make sure we don't overwrite them on the next occurrences, so keep list of
// what we already have handled.
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it;
- it=materials_mapped_to_geom.find(*geom_uid);
- while (it!=materials_mapped_to_geom.end()) {
- if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
+ it = materials_mapped_to_geom.find(*geom_uid);
+ while (it != materials_mapped_to_geom.end()) {
+ if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
it++;
}
// first time we get geom_uid, ma_uid pair. Save for later check.
@@ -1020,22 +1022,22 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
assign_material(ob, ma, ob->totcol + 1);
COLLADAFW::TextureCoordinateBindingArray& tex_array =
- cmaterial.getTextureCoordinateBindingArray();
+ cmaterial.getTextureCoordinateBindingArray();
TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma];
unsigned int i;
// loop through <bind_vertex_inputs>
for (i = 0; i < tex_array.getCount(); i++) {
*color_texture = assign_textures_to_uvlayer(tex_array[i], me, texindex_texarray_map,
- *color_texture);
+ *color_texture);
}
// set texture face
if (*color_texture &&
- strlen((*color_texture)->uvname) &&
- strcmp(layername, (*color_texture)->uvname) != 0) {
- texture_face = (MTFace*)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
- (*color_texture)->uvname);
+ strlen((*color_texture)->uvname) &&
+ strcmp(layername, (*color_texture)->uvname) != 0) {
+ texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
+ (*color_texture)->uvname);
strcpy(layername, (*color_texture)->uvname);
}
@@ -1057,7 +1059,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
mface->mat_nr = mat_index;
// bind texture images to faces
if (texture_face && (*color_texture)) {
- texture_face->tpage = (Image*)(*color_texture)->tex->ima;
+ texture_face->tpage = (Image *)(*color_texture)->tex->ima;
texture_face++;
}
}
@@ -1068,9 +1070,9 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
}
Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
- bool isController,
- std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
- std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map)
+ bool isController,
+ std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
+ std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map)
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
@@ -1097,7 +1099,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
// name Object
const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
- const char *name = (id.length())? id.c_str(): NULL;
+ const char *name = (id.length()) ? id.c_str() : NULL;
// add object
Object *ob = bc_add_object(scene, OB_MESH, name);
@@ -1106,7 +1108,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
uid_object_map[*geom_uid] = ob;
// replace ob->data freeing the old one
- Mesh *old_mesh = (Mesh*)ob->data;
+ Mesh *old_mesh = (Mesh *)ob->data;
set_mesh(ob, uid_mesh_map[*geom_uid]);
@@ -1118,15 +1120,15 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
MTex *color_texture = NULL;
COLLADAFW::MaterialBindingArray& mat_array =
- geom->getMaterialBindings();
+ geom->getMaterialBindings();
// loop through geom's materials
- for (unsigned int i = 0; i < mat_array.getCount(); i++) {
+ for (unsigned int i = 0; i < mat_array.getCount(); i++) {
if (mat_array[i].getReferencedMaterial().isValid()) {
texture_face = assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid,
- &color_texture, layername, texture_face,
- material_texture_mapping_map, i);
+ &color_texture, layername, texture_face,
+ material_texture_mapping_map, i);
}
else {
fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str());
@@ -1137,7 +1139,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
}
// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
-bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
+bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
{
// TODO: import also uvs, normals
// XXX what to do with normal indices?
@@ -1150,7 +1152,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
return true;
}
- COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh*)geom;
+ COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
if (!is_nice_mesh(mesh)) {
fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh));
@@ -1158,7 +1160,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
}
const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
- Mesh *me = BKE_mesh_add((char*)str_geom_id.c_str());
+ Mesh *me = BKE_mesh_add((char *)str_geom_id.c_str());
me->id.us--; // is already 1 here, but will be set later in set_mesh
// store the Mesh pointer to link it later with an Object