Revision: 47984
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47984
Author:   campbellbarton
Date:     2012-06-16 09:16:24 +0000 (Sat, 16 Jun 2012)
Log Message:
-----------
code cleanup: collada
- when bubble sorting names - dont convert to str::string just to compare 
strings
- use BLI_linklist_index() to check if an item is in the list
- quiet some warnings

Modified Paths:
--------------
    trunk/blender/source/blender/collada/ArmatureExporter.cpp
    trunk/blender/source/blender/collada/ArmatureExporter.h
    trunk/blender/source/blender/collada/DocumentImporter.cpp
    trunk/blender/source/blender/collada/ExportSettings.h
    trunk/blender/source/blender/collada/collada.cpp
    trunk/blender/source/blender/collada/collada.h
    trunk/blender/source/blender/collada/collada_utils.cpp
    trunk/blender/source/blender/collada/collada_utils.h
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/collada/ArmatureExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/ArmatureExporter.cpp   2012-06-16 
06:30:13 UTC (rev 47983)
+++ trunk/blender/source/blender/collada/ArmatureExporter.cpp   2012-06-16 
09:16:24 UTC (rev 47984)
@@ -83,7 +83,7 @@
 
 void ArmatureExporter::write_bone_URLs(COLLADASW::InstanceController &ins, 
Object *ob_arm, Bone *bone)
 {
-       if ( bc_is_root_bone(bone, this->export_settings->deform_bones_only) )
+       if (bc_is_root_bone(bone, this->export_settings->deform_bones_only))
                ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, 
get_joint_id(bone, ob_arm)));
        else {
                for (Bone *child = (Bone *)bone->childbase.first; child; child 
= child->next) {
@@ -187,9 +187,12 @@
                node.setNodeName(node_name);
                node.setNodeSid(node_sid);
 
-               /*if ( bone->childbase.first == NULL || 
BLI_countlist(&(bone->childbase))>=2)
+#if 0
+               if (bone->childbase.first == NULL || 
BLI_countlist(&(bone->childbase)) >= 2) {
                        add_blender_leaf_bone( bone, ob_arm , node );
-                  else{*/
+               }
+               else {
+#endif
                node.start();
 
                add_bone_transform(ob_arm, bone, node);

Modified: trunk/blender/source/blender/collada/ArmatureExporter.h
===================================================================
--- trunk/blender/source/blender/collada/ArmatureExporter.h     2012-06-16 
06:30:13 UTC (rev 47983)
+++ trunk/blender/source/blender/collada/ArmatureExporter.h     2012-06-16 
09:16:24 UTC (rev 47984)
@@ -53,14 +53,14 @@
 // XXX exporter writes wrong data for shared armatures.  A separate
 // controller should be written for each armature-mesh binding how do
 // we make controller ids then?
-class ArmatureExporter: public COLLADASW::LibraryControllers, protected 
TransformWriter, protected InstanceWriter
+class ArmatureExporter : public COLLADASW::LibraryControllers, protected 
TransformWriter, protected InstanceWriter
 {
 public:
        ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings 
*export_settings);
 
        // write bone nodes
-       void add_armature_bones(Object *ob_arm, Scene* sce, SceneExporter* se,
-                                                       std::list<Object*>& 
child_objects);
+       void add_armature_bones(Object *ob_arm, Scene *sce, SceneExporter *se,
+                               std::list<Object *>& child_objects);
 
        bool is_skinned_mesh(Object *ob);
 
@@ -76,7 +76,7 @@
        const ExportSettings *export_settings;
 
 #if 0
-       std::vector<Object*> written_armatures;
+       std::vector<Object *> written_armatures;
 
        bool already_written(Object *ob_arm);
 
@@ -89,8 +89,8 @@
 
        // Scene, SceneExporter and the list of child_objects
        // are required for writing bone parented objects
-       void add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, 
SceneExporter* se,
-                                          std::list<Object*>& child_objects);
+       void add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, 
SceneExporter *se,
+                          std::list<Object *>& child_objects);
 
        void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& 
node);
 
@@ -100,10 +100,10 @@
 
        // ob should be of type OB_MESH
        // both args are required
-       void export_controller(Object* ob, Object *ob_arm);
+       void export_controller(Object *ob, Object *ob_arm);
 
        void add_joints_element(ListBase *defbase,
-                                                       const std::string& 
joints_source_id, const std::string& inv_bind_mat_source_id);
+                               const std::string& joints_source_id, const 
std::string& inv_bind_mat_source_id);
 
        void add_bind_shape_mat(Object *ob);
 
@@ -111,15 +111,15 @@
 
        std::string add_inv_bind_mats_source(Object *ob_arm, ListBase *defbase, 
const std::string& controller_id);
 
-       Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def);
+       Bone *get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def);
 
-       bool is_bone_defgroup(Object *ob_arm, bDeformGroup* def);
+       bool is_bone_defgroup(Object *ob_arm, bDeformGroup *def);
 
        std::string add_weights_source(Mesh *me, const std::string& 
controller_id,
-                                                                  const 
std::list<float>& weights);
+                                      const std::list<float>& weights);
 
        void add_vertex_weights_element(const std::string& weights_source_id, 
const std::string& joints_source_id,
-                                                                       const 
std::list<int>& vcount, const std::list<int>& joints);
+                                       const std::list<int>& vcount, const 
std::list<int>& joints);
 
        void write_bone_URLs(COLLADASW::InstanceController &ins, Object 
*ob_arm, Bone *bone);
 };

Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp   2012-06-16 
06:30:13 UTC (rev 47983)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp   2012-06-16 
09:16:24 UTC (rev 47984)
@@ -386,7 +386,7 @@
                        Object *new_child = NULL;
                        if (inodes.getCount()) { // \todo loop through instance 
nodes
                                const COLLADAFW::UniqueId& id = 
inodes[0]->getInstanciatedObjectId();
-                               fprintf(stderr, "Doing %d child nodes\n", 
node_map.count(id));
+                               fprintf(stderr, "Doing %d child nodes\n", 
(int)node_map.count(id));
                                new_child = 
create_instance_node(object_map.find(id)->second, node_map[id], child_node, 
sce, is_library_node);
                        }
                        else {

Modified: trunk/blender/source/blender/collada/ExportSettings.h
===================================================================
--- trunk/blender/source/blender/collada/ExportSettings.h       2012-06-16 
06:30:13 UTC (rev 47983)
+++ trunk/blender/source/blender/collada/ExportSettings.h       2012-06-16 
09:16:24 UTC (rev 47984)
@@ -31,19 +31,18 @@
 #ifndef __EXPORTSETTINGS_H__
 #define __EXPORTSETTINGS_H__
 
-struct ExportSettings
-{
- public:
- bool apply_modifiers;
- bool selected;
- bool include_children;
- bool include_armatures;
- bool deform_bones_only;
- bool use_object_instantiation;
- bool sort_by_name;
- bool second_life;
- char *filepath;
- LinkNode *export_set;
+struct ExportSettings {
+public:
+       bool apply_modifiers;
+       bool selected;
+       bool include_children;
+       bool include_armatures;
+       bool deform_bones_only;
+       bool use_object_instantiation;
+       bool sort_by_name;
+       bool second_life;
+       char *filepath;
+       LinkNode *export_set;
 };
 
 #endif

Modified: trunk/blender/source/blender/collada/collada.cpp
===================================================================
--- trunk/blender/source/blender/collada/collada.cpp    2012-06-16 06:30:13 UTC 
(rev 47983)
+++ trunk/blender/source/blender/collada/collada.cpp    2012-06-16 09:16:24 UTC 
(rev 47984)
@@ -49,20 +49,19 @@
        return 0;
 }
 
-int collada_export(
-       Scene *sce,
-       const char *filepath,
+int collada_export(Scene *sce,
+                   const char *filepath,
 
-       int apply_modifiers,
+                   int apply_modifiers,
 
-       int selected,
-       int include_children,
-       int include_armatures,
-       int deform_bones_only,
+                   int selected,
+                   int include_children,
+                   int include_armatures,
+                   int deform_bones_only,
 
-       int use_object_instantiation,
-       int sort_by_name,
-       int second_life)
+                   int use_object_instantiation,
+                   int sort_by_name,
+                   int second_life)
 {
        ExportSettings export_settings;
 

Modified: trunk/blender/source/blender/collada/collada.h
===================================================================
--- trunk/blender/source/blender/collada/collada.h      2012-06-16 06:30:13 UTC 
(rev 47983)
+++ trunk/blender/source/blender/collada/collada.h      2012-06-16 09:16:24 UTC 
(rev 47984)
@@ -33,23 +33,22 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-       /*
-        * both return 1 on success, 0 on error
-        */
-       int collada_import(bContext *C, const char *filepath);
-       int collada_export(
-               Scene *sce, 
-               const char *filepath,
-               int apply_modifiers,
+/*
+ * both return 1 on success, 0 on error
+ */
+int collada_import(bContext *C, const char *filepath);
+int collada_export(Scene *sce,
+                   const char *filepath,
+                   int apply_modifiers,
 
-               int selected,
-               int include_children,
-               int include_armatures,
-               int deform_bones_only,
+                   int selected,
+                   int include_children,
+                   int include_armatures,
+                   int deform_bones_only,
 
-               int use_object_instantiation,
-               int sort_by_name,
-               int second_life);
+                   int use_object_instantiation,
+                   int sort_by_name,
+                   int second_life);
 
 
 

Modified: trunk/blender/source/blender/collada/collada_utils.cpp
===================================================================
--- trunk/blender/source/blender/collada/collada_utils.cpp      2012-06-16 
06:30:13 UTC (rev 47983)
+++ trunk/blender/source/blender/collada/collada_utils.cpp      2012-06-16 
09:16:24 UTC (rev 47984)
@@ -193,30 +193,19 @@
 
 bool bc_is_in_Export_set(LinkNode *export_set, Object *ob)
 {
-       LinkNode *node = export_set;
-       
-       while (node) {
-               Object *element = (Object *)node->link;
-       
-               if (element == ob)
-                       return true;
-               
-               node= node->next;
-       }
-       return false;
+       return (BLI_linklist_index(export_set, ob) != -1);
 }
 
 bool bc_has_object_type(LinkNode *export_set, short obtype)
 {
-       LinkNode *node = export_set;
+       LinkNode *node;
        
-       while (node) {
+       for (node = export_set; node; node = node->next) {
                Object *ob = (Object *)node->link;
-                       
+               /* XXX - why is this checking for ob->data? - we could be 
looking for empties */
                if (ob->type == obtype && ob->data) {
                        return true;
                }
-               node= node->next;
        }
        return false;
 }
@@ -236,19 +225,16 @@
 {
        bool sorted = false;
        LinkNode *node;
-       for(node=export_set; node->next && !sorted; node=node->next) {
+       for (node = export_set; node->next && !sorted; node = node->next) {
 
                sorted = true;
                
                LinkNode *current;
-               for (current=export_set; current->next; current = 
current->next) {
+               for (current = export_set; current->next; current = 
current->next) {
                        Object *a = (Object *)current->link;
                        Object *b = (Object *)current->next->link;
 
-                       std::string str_a (a->id.name);
-                       std::string str_b (b->id.name);
-
-                       if (str_a.compare(str_b) > 0) {
+                       if (strcmp(a->id.name, b->id.name) > 0) {
                                current->link       = b;
                                current->next->link = a;
                                sorted = false;
@@ -264,7 +250,7 @@
  * are root bones.
  */
 bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) {
-       if(deform_bones_only) {
+       if (deform_bones_only) {
                Bone *root = NULL;
                Bone *bone = aBone;
                while (bone) {
@@ -272,7 +258,7 @@
                                root = bone;

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to