~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/addons/space_view3d_math_vis/utils.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#====================== BEGIN GPL LICENSE BLOCK ======================
 
2
#
 
3
#  This program is free software; you can redistribute it and/or
 
4
#  modify it under the terms of the GNU General Public License
 
5
#  as published by the Free Software Foundation; either version 2
 
6
#  of the License, or (at your option) any later version.
 
7
#
 
8
#  This program is distributed in the hope that it will be useful,
 
9
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#  GNU General Public License for more details.
 
12
#
 
13
#  You should have received a copy of the GNU General Public License
 
14
#  along with this program; if not, write to the Free Software Foundation,
 
15
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
#
 
17
#======================= END GPL LICENSE BLOCK ========================
 
18
 
 
19
def console_namespace():
 
20
    import console_python
 
21
    get_consoles = console_python.get_console
 
22
    consoles = getattr(get_consoles, "consoles", None)
 
23
    if consoles:
 
24
        for console, stdout, stderr in get_consoles.consoles.values():
 
25
            return console.locals
 
26
    return {}
 
27
 
 
28
def console_math_data():
 
29
    from mathutils import Matrix, Vector, Quaternion, Euler
 
30
 
 
31
    data_matrix = {}
 
32
    data_quat = {}
 
33
    data_euler = {}
 
34
    data_vector = {}
 
35
    data_vector_array = {}
 
36
 
 
37
    for key, var in console_namespace().items():
 
38
        if key[0] == "_":
 
39
            continue
 
40
 
 
41
        var_type = type(var)
 
42
 
 
43
        if var_type is Matrix:
 
44
            if len(var.col) != 4 or len(var.row) != 4:
 
45
                if len(var.col) == len(var.row):
 
46
                    var = var.to_4x4() 
 
47
                else:  # todo, support 4x3 matrix
 
48
                    continue
 
49
            data_matrix[key] = var
 
50
        elif var_type is Vector:
 
51
            if len(var) < 3:
 
52
                var = var.to_3d()
 
53
            data_vector[key] = var
 
54
        elif var_type is Quaternion:
 
55
            data_quat[key] = var
 
56
        elif var_type is Euler:
 
57
            data_euler[key] = var
 
58
        elif var_type in {list, tuple}:
 
59
            if var:
 
60
                ok = True
 
61
                for item in var:
 
62
                    if type(item) is not Vector:
 
63
                        ok = False
 
64
                        break
 
65
                if ok:
 
66
                    data_vector_array[key] = var
 
67
 
 
68
    return data_matrix, data_quat, data_euler, data_vector, data_vector_array
 
69