Revision: 19725
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19725
Author:   campbellbarton
Date:     2009-04-15 09:00:11 +0200 (Wed, 15 Apr 2009)

Log Message:
-----------
[#7789] 3DS Import , Mesh not correct since Blender 2.44

There is a problem importing 3ds files where I cant find a way to check if the 
transforms are applied to the vertex locations or not.
Since 2.44 I made the importer assume they were not since you can manually 
remove transformations, but not reverse.

Nevertheless most 3ds files have the matrix applied, better not give a bad 
import by default.
Did some research and other 3ds importers (lib3ds for eg), have the same 
problem and just assume the transformations applied.

3dsMax imports both correctly so there must be a way to tell but I could not 
link it to the 3ds version or other mesh options.
Added an option to workaround this problem in rare cases where its needed.

- KX_GameObject.cpp & KX_Scene.cpp, clear the dict before removing the 
reference in case there is a circular reference.

Modified Paths:
--------------
    trunk/blender/release/scripts/3ds_import.py
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp

Modified: trunk/blender/release/scripts/3ds_import.py
===================================================================
--- trunk/blender/release/scripts/3ds_import.py 2009-04-15 04:34:27 UTC (rev 
19724)
+++ trunk/blender/release/scripts/3ds_import.py 2009-04-15 07:00:11 UTC (rev 
19725)
@@ -844,11 +844,13 @@
        # IMPORT_AS_INSTANCE= Blender.Draw.Create(0)
        IMPORT_CONSTRAIN_BOUNDS= Blender.Draw.Create(10.0)
        IMAGE_SEARCH= Blender.Draw.Create(1)
+       APPLY_MATRIX= Blender.Draw.Create(0)
        
        # Get USER Options
        pup_block= [\
        ('Size Constraint:', IMPORT_CONSTRAIN_BOUNDS, 0.0, 1000.0, 'Scale the 
model by 10 until it reacehs the size constraint. Zero Disables.'),\
        ('Image Search', IMAGE_SEARCH, 'Search subdirs for any assosiated 
images (Warning, may be slow)'),\
+       ('Transform Fix', APPLY_MATRIX, 'Workaround for object transformations 
importing incorrectly'),\
        #('Group Instance', IMPORT_AS_INSTANCE, 'Import objects into a new 
scene and group, creating an instance in the current scene.'),\
        ]
        
@@ -861,6 +863,7 @@
        IMPORT_CONSTRAIN_BOUNDS= IMPORT_CONSTRAIN_BOUNDS.val
        # IMPORT_AS_INSTANCE= IMPORT_AS_INSTANCE.val
        IMAGE_SEARCH = IMAGE_SEARCH.val
+       APPLY_MATRIX = APPLY_MATRIX.val
        
        if IMPORT_CONSTRAIN_BOUNDS:
                BOUNDS_3DS[:]= [1<<30, 1<<30, 1<<30, -1<<30, -1<<30, -1<<30]
@@ -887,6 +890,8 @@
                if ob.type=='Mesh':
                        me= ob.getData(mesh=1)
                        me.verts.delete([me.verts[0],])
+                       if not APPLY_MATRIX:
+                               me.transform(ob.matrixWorld.copy().invert())
        
        # Done DUMMYVERT
        """

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp    2009-04-15 
04:34:27 UTC (rev 19724)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp    2009-04-15 
07:00:11 UTC (rev 19725)
@@ -143,6 +143,7 @@
        }
        
        if (m_attrlist) {
+               PyDict_Clear(m_attrlist); /* incase of circular refs or other 
weired cases */
                Py_DECREF(m_attrlist);
        }
 }

Modified: trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp 2009-04-15 04:34:27 UTC 
(rev 19724)
+++ trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp 2009-04-15 07:00:11 UTC 
(rev 19725)
@@ -250,6 +250,7 @@
        {
                delete m_bucketmanager;
        }
+       PyDict_Clear(m_attrlist);
        Py_DECREF(m_attrlist);
 }
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to