NLA SoC: Merge from 2.5
authorJoshua Leung <aligorith@gmail.com>
Sun, 21 Jun 2009 00:01:37 +0000 (00:01 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 21 Jun 2009 00:01:37 +0000 (00:01 +0000)
21021 to 21042

19 files changed:
release/io/export_ply.py [new file with mode: 0644]
release/scripts/ply_export.py [deleted file]
release/ui/space_logic.py [new file with mode: 0644]
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/intern/context.c
source/blender/blenlib/intern/BLI_dynstr.c
source/blender/editors/screen/screen_context.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/makesdna/DNA_brush_types.h
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_object.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_ui.c

diff --git a/release/io/export_ply.py b/release/io/export_ply.py
new file mode 100644 (file)
index 0000000..ed983c2
--- /dev/null
@@ -0,0 +1,286 @@
+import bpy
+
+__author__ = "Bruce Merry"
+__version__ = "0.93"
+__bpydoc__ = """\
+This script exports Stanford PLY files from Blender. It supports normals, 
+colours, and texture coordinates per face or per vertex.
+Only one mesh can be exported at a time.
+"""
+
+# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# Vector rounding se we can use as keys
+#
+# Updated on Aug 11, 2008 by Campbell Barton
+#    - added 'comment' prefix to comments - Needed to comply with the PLY spec.
+#
+# Updated on Jan 1, 2007 by Gabe Ghearing
+#    - fixed normals so they are correctly smooth/flat
+#    - fixed crash when the model doesn't have uv coords or vertex colors
+#    - fixed crash when the model has vertex colors but doesn't have uv coords
+#    - changed float32 to float and uint8 to uchar for compatibility
+# Errata/Notes as of Jan 1, 2007
+#    - script exports texture coords if they exist even if TexFace isn't selected (not a big deal to me)
+#    - ST(R) should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
+#
+# Updated on Jan 3, 2007 by Gabe Ghearing
+#    - fixed "sticky" vertex UV exporting
+#    - added pupmenu to enable/disable exporting normals, uv coords, and colors
+# Errata/Notes as of Jan 3, 2007
+#    - ST(R) coords should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
+#    - edges should be exported since PLY files support them
+#    - code is getting spaghettish, it should be refactored...
+#
+
+
+def rvec3d(v): return round(v[0], 6), round(v[1], 6), round(v[2], 6)
+def rvec2d(v): return round(v[0], 6), round(v[1], 6)
+
+def write(filename, scene, ob, \
+               EXPORT_APPLY_MODIFIERS= True,\
+               EXPORT_NORMALS= True,\
+               EXPORT_UV= True,\
+               EXPORT_COLORS= True\
+       ):
+       
+       if not filename.lower().endswith('.ply'):
+               filename += '.ply'
+       
+       if not ob:
+               raise Exception("Error, Select 1 active object")
+               return
+       
+       file = open(filename, 'wb')
+       
+       
+       #EXPORT_EDGES = Draw.Create(0)
+       """
+       is_editmode = Blender.Window.EditMode()
+       if is_editmode:
+               Blender.Window.EditMode(0, '', 0)
+       
+       Window.WaitCursor(1)
+       """
+       
+       #mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn) # XXX
+       if EXPORT_APPLY_MODIFIERS:
+               mesh = ob.create_render_mesh(scene)
+       else:
+               mesh = ob.data
+       
+       if not mesh:
+               raise ("Error, could not get mesh data from active object")
+               return
+       
+       # mesh.transform(ob.matrixWorld) # XXX
+       
+       faceUV = len(mesh.uv_layers) > 0
+       vertexUV = len(mesh.sticky) > 0
+       vertexColors = len(mesh.vcol_layers) > 0
+       
+       if (not faceUV) and (not vertexUV):     EXPORT_UV = False
+       if not vertexColors:                                    EXPORT_COLORS = False
+       
+       if not EXPORT_UV:                                               faceUV = vertexUV = False
+       if not EXPORT_COLORS:                                   vertexColors = False
+               
+       if faceUV:
+               active_uv_layer = None
+               for lay in mesh.uv_layers:
+                       if lay.active:
+                               active_uv_layer= lay.data
+                               break
+               if not active_uv_layer:
+                       EXPORT_UV = False
+                       faceUV = None
+       
+       if vertexColors:
+               active_col_layer = None
+               for lay in mesh.vcol_layers:
+                       if lay.active:
+                               active_col_layer= lay.data
+               if not active_col_layer:
+                       EXPORT_COLORS = False
+                       vertexColors = None
+       
+       # incase
+       color = uvcoord = uvcoord_key = normal = normal_key = None
+       
+       mesh_verts = mesh.verts # save a lookup
+       ply_verts = [] # list of dictionaries
+       # vdict = {} # (index, normal, uv) -> new index
+       vdict = [{} for i in xrange(len(mesh_verts))]
+       ply_faces = [[] for f in xrange(len(mesh.faces))]
+       vert_count = 0
+       for i, f in enumerate(mesh.faces):
+               
+               
+               smooth = f.smooth
+               # XXX need face normals
+               """
+               if not smooth:
+                       normal = tuple(f.no)
+                       normal_key = rvec3d(normal)
+               """
+               if faceUV:
+                       uv = active_uv_layer[i]
+                       uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/
+               if vertexColors:
+                       col = active_col_layer[i]
+                       col = col.color1, col.color2, col.color3, col.color4
+               
+               f_verts= list(f.verts)
+               if not f_verts[3]: f_verts.pop() # XXX face length should be 3/4, not always 4
+               
+               pf= ply_faces[i]
+               for j, vidx in enumerate(f_verts):
+                       v = mesh_verts[vidx]
+                       """
+                       if smooth:
+                               normal=         tuple(v.no)
+                               normal_key = rvec3d(normal)
+                       """
+                       normal_key = None # XXX
+                       
+                       if faceUV:
+                               uvcoord=        uv[j][0], 1.0-uv[j][1]
+                               uvcoord_key = rvec2d(uvcoord)
+                       elif vertexUV:
+                               uvcoord=        v.uvco[0], 1.0-v.uvco[1]
+                               uvcoord_key = rvec2d(uvcoord)
+                       
+                       if vertexColors:
+                               color=          col[j]
+                               color= int(color[0]*255.0), int(color[1]*255.0), int(color[2]*255.0)
+                       
+                       
+                       key = normal_key, uvcoord_key, color
+                       
+                       vdict_local = vdict[vidx]
+                       pf_vidx = vdict_local.get(key) # Will be None initially
+                       
+                       if pf_vidx == None: # same as vdict_local.has_key(key)
+                               pf_vidx = vdict_local[key] = vert_count;
+                               ply_verts.append((vidx, normal, uvcoord, color))
+                               vert_count += 1
+                       
+                       pf.append(pf_vidx)
+       
+       file.write('ply\n')
+       file.write('format ascii 1.0\n')
+       version = "2.5" # Blender.Get('version')
+       file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
+       
+       file.write('element vertex %d\n' % len(ply_verts))
+       
+       file.write('property float x\n')
+       file.write('property float y\n')
+       file.write('property float z\n')
+       
+       # XXX 
+       """
+       if EXPORT_NORMALS:
+               file.write('property float nx\n')
+               file.write('property float ny\n')
+               file.write('property float nz\n')
+       """
+       if EXPORT_UV:
+               file.write('property float s\n')
+               file.write('property float t\n')
+       if EXPORT_COLORS:
+               file.write('property uchar red\n')
+               file.write('property uchar green\n')
+               file.write('property uchar blue\n')
+       
+       file.write('element face %d\n' % len(mesh.faces))
+       file.write('property list uchar uint vertex_indices\n')
+       file.write('end_header\n')
+
+       for i, v in enumerate(ply_verts):
+               file.write('%.6f %.6f %.6f ' % tuple(mesh_verts[v[0]].co)) # co
+               """
+               if EXPORT_NORMALS:
+                       file.write('%.6f %.6f %.6f ' % v[1]) # no
+               """
+               if EXPORT_UV:                   file.write('%.6f %.6f ' % v[2]) # uv
+               if EXPORT_COLORS:               file.write('%u %u %u' % v[3]) # col
+               file.write('\n')
+       
+       for pf in ply_faces:
+               if len(pf)==3:          file.write('3 %d %d %d\n' % tuple(pf))
+               else:                           file.write('4 %d %d %d %d\n' % tuple(pf))
+       
+       file.close()
+       print("writing", filename, "done")
+       
+       if EXPORT_APPLY_MODIFIERS:
+               bpy.data.remove_mesh(mesh)
+       
+       # XXX
+       """
+       if is_editmode:
+               Blender.Window.EditMode(1, '', 0)
+       """
+
+class EXPORT_OT_ply(bpy.types.Operator):
+       '''
+       Operator documentatuon text, will be used for the operator tooltip and python docs.
+       '''
+       __label__ = "Export PLY"
+       
+       # List of operator properties, the attributes will be assigned
+       # to the class instance from the operator settings before calling.
+       
+       __props__ = [
+               bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the PLY file", maxlen= 1024, default= ""),
+               bpy.props.BoolProperty(attr="use_modifiers", name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default= True),
+               bpy.props.BoolProperty(attr="use_normals", name="Export Normals", description="Export Normals for smooth and hard shaded faces", default= True),
+               bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", description="Exort the active UV layer", default= True),
+               bpy.props.BoolProperty(attr="use_colors", name="Export Vertex Colors", description="Exort the active vertex color layer", default= True)
+       ]
+       
+       def poll(self, context):
+               print("Poll")
+               return context.active_object != None
+       
+       def execute(self, context):
+               # print("Selected: " + context.active_object.name)
+
+               if not self.filename:
+                       raise Exception("filename not set")
+                       
+               write(self.filename, context.scene, context.active_object,\
+                       EXPORT_APPLY_MODIFIERS = self.use_modifiers,
+                       EXPORT_NORMALS = self.use_normals,
+                       EXPORT_UV = self.use_uvs,
+                       EXPORT_COLORS = self.use_colors,
+               )
+
+               return ('FINISHED',)
+       
+       def invoke(self, context, event):       
+               wm = context.manager
+               wm.add_fileselect(self.__operator__)
+               return ('RUNNING_MODAL',)
+
+
+bpy.ops.add(EXPORT_OT_ply)
+
+if __name__ == "__main__":
+       bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
+
+
diff --git a/release/scripts/ply_export.py b/release/scripts/ply_export.py
deleted file mode 100644 (file)
index 46d0805..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-#!BPY
-
-"""
-Name: 'Stanford PLY (*.ply)...'
-Blender: 241
-Group: 'Export'
-Tooltip: 'Export active object to Stanford PLY format'
-"""
-
-import bpy
-import Blender
-from Blender import Mesh, Scene, Window, sys, Image, Draw
-import BPyMesh
-
-__author__ = "Bruce Merry"
-__version__ = "0.93"
-__bpydoc__ = """\
-This script exports Stanford PLY files from Blender. It supports normals, 
-colours, and texture coordinates per face or per vertex.
-Only one mesh can be exported at a time.
-"""
-
-# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-# Vector rounding se we can use as keys
-#
-# Updated on Aug 11, 2008 by Campbell Barton
-#    - added 'comment' prefix to comments - Needed to comply with the PLY spec.
-#
-# Updated on Jan 1, 2007 by Gabe Ghearing
-#    - fixed normals so they are correctly smooth/flat
-#    - fixed crash when the model doesn't have uv coords or vertex colors
-#    - fixed crash when the model has vertex colors but doesn't have uv coords
-#    - changed float32 to float and uint8 to uchar for compatibility
-# Errata/Notes as of Jan 1, 2007
-#    - script exports texture coords if they exist even if TexFace isn't selected (not a big deal to me)
-#    - ST(R) should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
-#
-# Updated on Jan 3, 2007 by Gabe Ghearing
-#    - fixed "sticky" vertex UV exporting
-#    - added pupmenu to enable/disable exporting normals, uv coords, and colors
-# Errata/Notes as of Jan 3, 2007
-#    - ST(R) coords should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
-#    - edges should be exported since PLY files support them
-#    - code is getting spaghettish, it should be refactored...
-#
-
-
-def rvec3d(v): return round(v[0], 6), round(v[1], 6), round(v[2], 6)
-def rvec2d(v): return round(v[0], 6), round(v[1], 6)
-
-def file_callback(filename):
-       
-       if not filename.lower().endswith('.ply'):
-               filename += '.ply'
-       
-       scn= bpy.data.scenes.active
-       ob= scn.objects.active
-       if not ob:
-               Blender.Draw.PupMenu('Error%t|Select 1 active object')
-               return
-       
-       file = open(filename, 'wb')
-       
-       EXPORT_APPLY_MODIFIERS = Draw.Create(1)
-       EXPORT_NORMALS = Draw.Create(1)
-       EXPORT_UV = Draw.Create(1)
-       EXPORT_COLORS = Draw.Create(1)
-       #EXPORT_EDGES = Draw.Create(0)
-       
-       pup_block = [\
-       ('Apply Modifiers', EXPORT_APPLY_MODIFIERS, 'Use transformed mesh data.'),\
-       ('Normals', EXPORT_NORMALS, 'Export vertex normal data.'),\
-       ('UVs', EXPORT_UV, 'Export texface UV coords.'),\
-       ('Colors', EXPORT_COLORS, 'Export vertex Colors.'),\
-       #('Edges', EXPORT_EDGES, 'Edges not connected to faces.'),\
-       ]
-       
-       if not Draw.PupBlock('Export...', pup_block):
-               return
-       
-       is_editmode = Blender.Window.EditMode()
-       if is_editmode:
-               Blender.Window.EditMode(0, '', 0)
-       
-       Window.WaitCursor(1)
-       
-       EXPORT_APPLY_MODIFIERS = EXPORT_APPLY_MODIFIERS.val
-       EXPORT_NORMALS = EXPORT_NORMALS.val
-       EXPORT_UV = EXPORT_UV.val
-       EXPORT_COLORS = EXPORT_COLORS.val
-       #EXPORT_EDGES = EXPORT_EDGES.val
-       
-       mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn)
-       
-       if not mesh:
-               Blender.Draw.PupMenu('Error%t|Could not get mesh data from active object')
-               return
-       
-       mesh.transform(ob.matrixWorld)
-       
-       faceUV = mesh.faceUV
-       vertexUV = mesh.vertexUV
-       vertexColors = mesh.vertexColors
-       
-       if (not faceUV) and (not vertexUV):             EXPORT_UV = False
-       if not vertexColors:                                    EXPORT_COLORS = False
-       
-       if not EXPORT_UV:                                               faceUV = vertexUV = False
-       if not EXPORT_COLORS:                                   vertexColors = False
-       
-       # incase
-       color = uvcoord = uvcoord_key = normal = normal_key = None
-       
-       verts = [] # list of dictionaries
-       # vdict = {} # (index, normal, uv) -> new index
-       vdict = [{} for i in xrange(len(mesh.verts))]
-       vert_count = 0
-       for i, f in enumerate(mesh.faces):
-               smooth = f.smooth
-               if not smooth:
-                       normal = tuple(f.no)
-                       normal_key = rvec3d(normal)
-                       
-               if faceUV:                      uv = f.uv
-               if vertexColors:        col = f.col
-               for j, v in enumerate(f):
-                       if smooth:
-                               normal=         tuple(v.no)
-                               normal_key = rvec3d(normal)
-                       
-                       if faceUV:
-                               uvcoord=        uv[j][0], 1.0-uv[j][1]
-                               uvcoord_key = rvec2d(uvcoord)
-                       elif vertexUV:
-                               uvcoord=        v.uvco[0], 1.0-v.uvco[1]
-                               uvcoord_key = rvec2d(uvcoord)
-                       
-                       if vertexColors:        color=          col[j].r, col[j].g, col[j].b
-                       
-                       
-                       key = normal_key, uvcoord_key, color
-                       
-                       vdict_local = vdict[v.index]
-                       
-                       if (not vdict_local) or (not vdict_local.has_key(key)):
-                               vdict_local[key] = vert_count;
-                               verts.append( (tuple(v.co), normal, uvcoord, color) )
-                               vert_count += 1
-       
-       
-       file.write('ply\n')
-       file.write('format ascii 1.0\n')
-       file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (Blender.Get('version'), Blender.Get('filename').split('/')[-1].split('\\')[-1] ))
-       
-       file.write('element vertex %d\n' % len(verts))
-       
-       file.write('property float x\n')
-       file.write('property float y\n')
-       file.write('property float z\n')
-       if EXPORT_NORMALS:
-               file.write('property float nx\n')
-               file.write('property float ny\n')
-               file.write('property float nz\n')
-       
-       if EXPORT_UV:
-               file.write('property float s\n')
-               file.write('property float t\n')
-       if EXPORT_COLORS:
-               file.write('property uchar red\n')
-               file.write('property uchar green\n')
-               file.write('property uchar blue\n')
-       
-       file.write('element face %d\n' % len(mesh.faces))
-       file.write('property list uchar uint vertex_indices\n')
-       file.write('end_header\n')
-
-       for i, v in enumerate(verts):
-               file.write('%.6f %.6f %.6f ' % v[0]) # co
-               if EXPORT_NORMALS:
-                       file.write('%.6f %.6f %.6f ' % v[1]) # no
-               
-               if EXPORT_UV:
-                       file.write('%.6f %.6f ' % v[2]) # uv
-               if EXPORT_COLORS:
-                       file.write('%u %u %u' % v[3]) # col
-               file.write('\n')
-       
-       for (i, f) in enumerate(mesh.faces):
-               file.write('%d ' % len(f))
-               smooth = f.smooth
-               if not smooth: no = rvec3d(f.no)
-               
-               if faceUV:                      uv = f.uv
-               if vertexColors:        col = f.col
-               for j, v in enumerate(f):
-                       if f.smooth:            normal=         rvec3d(v.no)
-                       else:                           normal=         no
-                       if faceUV:                      uvcoord=        rvec2d((uv[j][0], 1.0-uv[j][1]))
-                       elif vertexUV:          uvcoord=        rvec2d((v.uvco[0], 1.0-v.uvco[1]))
-                       if vertexColors:        color=          col[j].r, col[j].g, col[j].b
-                       
-                       file.write('%d ' % vdict[v.index][normal, uvcoord, color])
-                       
-               file.write('\n')
-       file.close()
-       
-       if is_editmode:
-               Blender.Window.EditMode(1, '', 0)
-
-def main():
-       Blender.Window.FileSelector(file_callback, 'PLY Export', Blender.sys.makename(ext='.ply'))
-
-if __name__=='__main__':
-       main()
diff --git a/release/ui/space_logic.py b/release/ui/space_logic.py
new file mode 100644 (file)
index 0000000..71d94c8
--- /dev/null
@@ -0,0 +1,80 @@
+import bpy
+
+class LOGIC_PT_physics(bpy.types.Panel):
+       __space_type__ = "LOGIC_EDITOR"
+       __region_type__ = "UI"
+       __label__ = "Physics"
+
+       def draw(self, context):
+               layout = self.layout
+               ob = context.active_object
+               
+               game = ob.game
+
+               flow = layout.column_flow()
+               flow.active = True
+               flow.itemR(game, "physics_type")
+               flow.itemR(game, "actor")
+               
+               row = layout.row()
+               row.itemR(game, "ghost")
+               row.itemR(ob, "restrict_render", text="Invisible") # out of place but useful
+               
+               flow = layout.column_flow()
+               flow.itemR(game, "mass")
+               flow.itemR(game, "radius")
+               flow.itemR(game, "no_sleeping")
+               flow.itemR(game, "damping")
+               flow.itemR(game, "rotation_damping")
+               flow.itemR(game, "minimum_velocity")
+               flow.itemR(game, "maximum_velocity")
+               
+               row = layout.row()
+               row.itemR(game, "do_fh")
+               row.itemR(game, "rotation_fh")
+               
+               flow = layout.column_flow()
+               flow.itemR(game, "form_factor")
+               flow.itemR(game, "anisotropic_friction")
+               
+               flow = layout.column_flow()
+               flow.active = game.anisotropic_friction
+               flow.itemR(game, "friction_coefficients")
+               
+               split = layout.split()
+               sub = split.column()
+               sub.itemR(game, "lock_x_axis")
+               sub.itemR(game, "lock_y_axis")
+               sub.itemR(game, "lock_z_axis")
+               sub = split.column()
+               sub.itemR(game, "lock_x_rot_axis")
+               sub.itemR(game, "lock_y_rot_axis")
+               sub.itemR(game, "lock_z_rot_axis")
+
+
+class LOGIC_PT_collision_bounds(bpy.types.Panel):
+       __space_type__ = "LOGIC_EDITOR"
+       __region_type__ = "UI"
+       __label__ = "Collision Bounds"
+       
+       def draw_header(self, context):
+               layout = self.layout
+               ob = context.active_object
+               game = ob.game
+
+               layout.itemR(game, "use_collision_bounds", text="")
+       
+       def draw(self, context):
+               layout = self.layout
+               
+               ob = context.scene.objects[0]
+               game = ob.game
+               
+               flow = layout.column_flow()
+               flow.active = game.use_collision_bounds
+               flow.itemR(game, "collision_bounds")
+               flow.itemR(game, "collision_compound")
+               flow.itemR(game, "collision_margin")
+
+bpy.types.register(LOGIC_PT_physics)
+bpy.types.register(LOGIC_PT_collision_bounds)
index 6a43f4ca25c99b0e91efb8e205bc4e3328aeeee1..898b84ecdc3cab9560e8631f8eeabd1e9000a503 100644 (file)
@@ -126,12 +126,14 @@ void CTX_wm_menu_set(bContext *C, struct ARegion *menu);
 
 /* Data Context
 
-   - note: listbases consist of LinkData items and must be
-     freed with BLI_freelistN! */
+   - listbases consist of CollectionPointerLink items and must be
+     freed with BLI_freelistN!
+   - the dir listbase consits of LinkData items */
 
-PointerRNA CTX_data_pointer_get(bContext *C, const char *member);
-ListBase CTX_data_collection_get(bContext *C, const char *member);
-void CTX_data_get(bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb);
+PointerRNA CTX_data_pointer_get(const bContext *C, const char *member);
+ListBase CTX_data_collection_get(const bContext *C, const char *member);
+ListBase CTX_data_dir_get(const bContext *C);
+void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb);
 
 void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id);
 void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data);
@@ -139,7 +141,10 @@ void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *
 void CTX_data_id_list_add(bContextDataResult *result, struct ID *id);
 void CTX_data_list_add(bContextDataResult *result, struct ID *id, StructRNA *type, void *data);
 
+void CTX_data_dir_set(bContextDataResult *result, const char **member);
+
 int CTX_data_equals(const char *member, const char *str);
+int CTX_data_dir(const char *member);
 
 /*void CTX_data_pointer_set(bContextDataResult *result, void *data);
 void CTX_data_list_add(bContextDataResult *result, void *data);*/
index ae541365b1ebd5a384e529da08240724a0629a48..12deec838a8bd9ce6bf757a7e2c0d164592df2a5 100644 (file)
@@ -280,6 +280,7 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu)
 struct bContextDataResult {
        PointerRNA ptr;
        ListBase list;
+       const char **dir;
 };
 
 static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
@@ -360,7 +361,7 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
        return 0;
 }
 
-PointerRNA CTX_data_pointer_get(bContext *C, const char *member)
+PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
 {
        bContextDataResult result;
 
@@ -375,7 +376,7 @@ PointerRNA CTX_data_pointer_get(bContext *C, const char *member)
 
 }
 
-ListBase CTX_data_collection_get(bContext *C, const char *member)
+ListBase CTX_data_collection_get(const bContext *C, const char *member)
 {
        bContextDataResult result;
 
@@ -389,7 +390,7 @@ ListBase CTX_data_collection_get(bContext *C, const char *member)
        }
 }
 
-void CTX_data_get(bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb)
+void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb)
 {
        bContextDataResult result;
 
@@ -403,11 +404,75 @@ void CTX_data_get(bContext *C, const char *member, PointerRNA *r_ptr, ListBase *
        }
 }
 
+static void data_dir_add(ListBase *lb, const char *member)
+{
+       LinkData *link;
+
+       if(strcmp(member, "scene") == 0) /* exception */
+               return;
+
+       for(link=lb->first; link; link=link->next)
+               if(strcmp(link->data, member) == 0)
+                       return;
+       
+       link= MEM_callocN(sizeof(LinkData), "LinkData");
+       link->data= (void*)member;
+       BLI_addtail(lb, link);
+}
+
+ListBase CTX_data_dir_get(const bContext *C)
+{
+       bContextDataResult result;
+       ListBase lb;
+       int a;
+
+       memset(&lb, 0, sizeof(lb));
+
+       if(C->wm.store) {
+               bContextStoreEntry *entry;
+
+               for(entry=C->wm.store->entries.first; entry; entry=entry->next)
+                       data_dir_add(&lb, entry->name);
+       }
+       if(C->wm.region && C->wm.region->type && C->wm.region->type->context) {
+               memset(&result, 0, sizeof(result));
+               C->wm.region->type->context(C, "", &result);
+
+               if(result.dir)
+                       for(a=0; result.dir[a]; a++)
+                               data_dir_add(&lb, result.dir[a]);
+       }
+       if(C->wm.area && C->wm.area->type && C->wm.area->type->context) {
+               memset(&result, 0, sizeof(result));
+               C->wm.area->type->context(C, "", &result);
+
+               if(result.dir)
+                       for(a=0; result.dir[a]; a++)
+                               data_dir_add(&lb, result.dir[a]);
+       }
+       if(C->wm.screen && C->wm.screen->context) {
+               bContextDataCallback cb= C->wm.screen->context;
+               memset(&result, 0, sizeof(result));
+               cb(C, "", &result);
+
+               if(result.dir)
+                       for(a=0; result.dir[a]; a++)
+                               data_dir_add(&lb, result.dir[a]);
+       }
+
+       return lb;
+}
+
 int CTX_data_equals(const char *member, const char *str)
 {
        return (strcmp(member, str) == 0);
 }
 
+int CTX_data_dir(const char *member)
+{
+       return (strcmp(member, "") == 0);
+}
+
 void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
 {
        RNA_id_pointer_create(id, &result->ptr);
@@ -451,6 +516,11 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase
                return 0;
 }
 
+void CTX_data_dir_set(bContextDataResult *result, const char **dir)
+{
+       result->dir= dir;
+}
+
 /* data context */
 
 Main *CTX_data_main(const bContext *C)
index 04388ea946fda81c58a62d352b3e79bc2e6f23dd..dd10d898a7f34ece492238600ec365d0c2df4211 100644 (file)
@@ -92,7 +92,7 @@ void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
                if(len == sizeof(fixedmessage))
                        message= fixedmessage;
                else
-                       message= MEM_callocN(sizeof(char)*len+1, "BLI_dynstr_appendf");
+                       message= MEM_callocN(sizeof(char)*(len+1), "BLI_dynstr_appendf");
 
                retval= vsnprintf(message, len, format, args);
 
@@ -132,10 +132,54 @@ void BLI_dynstr_vappendf(DynStr *ds, const char *format, va_list args)
 void BLI_dynstr_appendf(DynStr *ds, const char *format, ...)
 {
        va_list args;
+       char *message, fixedmessage[256];
+       int len= 256, maxlen= 65536, retval;
+
+       /* note that it's tempting to just call BLI_dynstr_vappendf here
+        * and avoid code duplication, that crashes on some system because
+        * va_start/va_end have to be called for each vsnprintf call */
 
-       va_start(args, format);
-       BLI_dynstr_vappendf(ds, format, args);
-       va_end(args);
+       while(1) {
+               if(len == sizeof(fixedmessage))
+                       message= fixedmessage;
+               else
+                       message= MEM_callocN(sizeof(char)*(len+1), "BLI_dynstr_appendf");
+
+               va_start(args, format);
+               retval= vsnprintf(message, len, format, args);
+               va_end(args);
+
+               if(retval == -1) {
+                       /* -1 means not enough space, but on windows it may also mean
+                        * there is a formatting error, so we impose a maximum length */
+                       if(message != fixedmessage)
+                               MEM_freeN(message);
+                       message= NULL;
+
+                       len *= 2;
+                       if(len > maxlen) {
+                               fprintf(stderr, "BLI_dynstr_append text too long or format error.\n");
+                               break;
+                       }
+               }
+               else if(retval > len) {
+                       /* in C99 the actual length required is returned */
+                       if(message != fixedmessage)
+                               MEM_freeN(message);
+                       message= NULL;
+
+                       len= retval;
+               }
+               else
+                       break;
+       }
+
+       if(message) {
+               BLI_dynstr_append(ds, message);
+
+               if(message != fixedmessage)
+                       MEM_freeN(message);
+       }
 }
 
 int BLI_dynstr_get_len(DynStr *ds) {
index 11d1d019005a641824f720212903c9703b5b5650..1ea6f8baceb05e1e4a2b48989541b39fd0d21fff 100644 (file)
@@ -42,7 +42,15 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
        Scene *scene= sc->scene;
        Base *base;
 
-       if(CTX_data_equals(member, "scene")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {
+                       "scene", "selected_objects", "selected_bases", "active_base",
+                       "active_object", "edit_object", NULL};
+
+               CTX_data_dir_set(result, dir);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "scene")) {
                CTX_data_id_pointer_set(result, &scene->id);
                return 1;
        }
index 7703dc0c303275513a2958d17853afb16e3b60b4..fa33e214737eb661667dce45f5c3982dc60aa4be 100644 (file)
@@ -248,8 +248,9 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
        switch(sd->brush->sculpt_tool){
        case SCULPT_TOOL_DRAW:
        case SCULPT_TOOL_INFLATE:
-               return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */;
+       case SCULPT_TOOL_CLAY:
        case SCULPT_TOOL_FLATTEN:
+               return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */;
        case SCULPT_TOOL_SMOOTH:
                return alpha * 4 * pressure;
        case SCULPT_TOOL_PINCH:
@@ -552,7 +553,7 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3]
        VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE);
 }
 
-static void do_flatten_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts)
+static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts, int clay)
 {
        ActiveData *node= active_verts->first;
        /* area_normal and cntr define the plane towards which vertices are squashed */
@@ -575,16 +576,23 @@ static void do_flatten_brush(Sculpt *sd, SculptSession *ss, const ListBase *acti
                VecAddf(intr, intr, p1);
                
                VecSubf(val, intr, co);
-               VecMulf(val, node->Fade);
+               VecMulf(val, fabs(node->Fade));
                VecAddf(val, val, co);
                
+               if(clay) {
+                       /* Clay brush displaces after flattening */
+                       float tmp[3];
+                       VecCopyf(tmp, area_normal);
+                       VecMulf(tmp, ss->cache->radius * node->Fade * 0.1);
+                       VecAddf(val, val, tmp);
+               }
+
                sculpt_clip(ss->cache, co, val);
                
                node= node->next;
        }
 }
-
-
 /* Uses symm to selectively flip any axis of a coordinate. */
 static void flip_coord(float out[3], float in[3], const char symm)
 {
@@ -852,8 +860,10 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
                        do_layer_brush(sd, ss, &active_verts);
                        break;
                case SCULPT_TOOL_FLATTEN:
-                       do_flatten_brush(sd, ss, &active_verts);
+                       do_flatten_clay_brush(sd, ss, &active_verts, 0);
                        break;
+               case SCULPT_TOOL_CLAY:
+                       do_flatten_clay_brush(sd, ss, &active_verts, 1);
                }
        
                /* Copy the modified vertices from mesh to the active key */
index fc280d9b5515ce65a90b22a6b8a760cd3f56241d..d97b4acdb96540797e0a1beb6e74e3c790de92f0 100644 (file)
@@ -492,8 +492,17 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
                return 0;
 
        /* here we handle context, getting data from precomputed path */
-
-       if(CTX_data_equals(member, "world")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {
+                       "world", "object", "meshe", "armature", "lattice", "curve",
+                       "meta_ball", "lamp", "camera", "material", "material_slot",
+                       "texture", "texture_slot", "bone", "edit_bone", "particle_system",
+                       "cloth", "soft_body", "fluid", NULL};
+
+               CTX_data_dir_set(result, dir);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "world")) {
                set_pointer_type(path, result, &RNA_World);
                return 1;
        }
index e12f3bfe3578ef914043258021637cd64c47fa48..49f950fe67b8ebee18cb4680ab0e45e4c2cfdca1 100644 (file)
@@ -301,7 +301,11 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
 {
        SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
 
-       if(CTX_data_equals(member, "edit_image")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {"edit_image", NULL};
+               CTX_data_dir_set(result, dir);
+       }
+       else if(CTX_data_equals(member, "edit_image")) {
                CTX_data_id_pointer_set(result, (ID*)ED_space_image(sima));
                return 1;
        }
index 775f46b8e04f9e338023b38502039a4377e034d4..ac3a884c5f822aa54f326cd7d9b80ac3100f06bb 100644 (file)
@@ -283,7 +283,12 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
 {
        SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
        
-       if(CTX_data_equals(member, "selected_nodes")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {"selected_nodes", NULL};
+               CTX_data_dir_set(result, dir);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "selected_nodes")) {
                bNode *node;
                
                for(next_node(snode->edittree); (node=next_node(NULL));) {
index d3c3b78cc504f6e46476e20592d4779fb71cdb48..8759fd00f74481e9c197471f218e735584bd3285 100644 (file)
@@ -293,7 +293,12 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
 {
        SpaceText *st= CTX_wm_space_text(C);
 
-       if(CTX_data_equals(member, "edit_text")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {"edit_text", NULL};
+               CTX_data_dir_set(result, dir);
+               return 1;
+       }
+       else if(CTX_data_equals(member, "edit_text")) {
                CTX_data_id_pointer_set(result, &st->text->id);
                return 1;
        }
index eaff77aabe92511d7da1de517bbe43812563e1fb..0cb0fd90860c6228a67fd263fbcedc6ea37f1c00 100644 (file)
@@ -564,7 +564,17 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes
 
        if(v3d==NULL) return 0;
 
-       if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
+       if(CTX_data_dir(member)) {
+               static const char *dir[] = {
+                       "selected_objects", "selected_bases" "selected_editable_objects",
+                       "selected_editable_bases" "visible_objects", "visible_bases",
+                       "active_base", "active_object", "visible_bones", "editable_bones",
+                       "selected_bones", "selected_editable_bones" "visible_pchans",
+                       "selected_pchans", "active_bone", "active_pchan", NULL};
+
+               CTX_data_dir_set(result, dir);
+       }
+       else if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
                int selected_objects= CTX_data_equals(member, "selected_objects");
 
                for(base=scene->base.first; base; base=base->next) {
index 3146b8b45ae5bd24983cbd3c3b3f645eb1bdbc4a..b6e9e05b120a8323f021fa7b091766e44e4563a0 100644 (file)
@@ -1132,9 +1132,10 @@ static void view3d_panel_brush(const bContext *C, Panel *pa)
                uiDefButC(block,ROW,B_REDR,"Pinch",cx+134,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_PINCH,0,0,"Interactively pinch areas of the model");
                uiDefButC(block,ROW,B_REDR,"Inflate",cx+201,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_INFLATE,0,0,"Push vertices along the direction of their normals");
                cy-= 20;
-               uiDefButC(block,ROW,B_REDR,"Grab", cx,cy,89,19,&br->sculpt_tool,14,SCULPT_TOOL_GRAB,0,0,"Grabs a group of vertices and moves them with the mouse");
-               uiDefButC(block,ROW,B_REDR,"Layer", cx+89,cy,89,19,&br->sculpt_tool,14, SCULPT_TOOL_LAYER,0,0,"Adds a layer of depth");
-               uiDefButC(block,ROW,B_REDR,"Flatten", cx+178,cy,90,19,&br->sculpt_tool,14, SCULPT_TOOL_FLATTEN,0,0,"Interactively flatten areas of the model");
+               uiDefButC(block,ROW,B_REDR,"Grab", cx,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_GRAB,0,0,"Grabs a group of vertices and moves them with the mouse");
+               uiDefButC(block,ROW,B_REDR,"Layer", cx+67,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_LAYER,0,0,"Adds a layer of depth");
+               uiDefButC(block,ROW,B_REDR,"Flatten", cx+134,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_FLATTEN,0,0,"Interactively flatten areas of the model");
+               uiDefButC(block,ROW,B_REDR,"Clay", cx+201,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_CLAY,0,0,"Build up depth quickly");
                cy-= 25;
                uiBlockEndAlign(block);
        }
index 88520a12e758b66a7003b21664758a827fdb62dd..8ce0b439b29cc75c0e6a419ef1d8f8e6965389df 100644 (file)
@@ -108,6 +108,7 @@ typedef struct Brush {
 #define SCULPT_TOOL_GRAB    5
 #define SCULPT_TOOL_LAYER   6
 #define SCULPT_TOOL_FLATTEN 7
+#define SCULPT_TOOL_CLAY    8
 
 #define PAINT_TOOL_DRAW                0
 #define PAINT_TOOL_SOFTEN      1
index 653f9d61fa5154a33b9617129f4e5c23a12e4f2c..da90b9f4c76dd153d500302cc2fffad2da84a13d 100644 (file)
 
 #ifdef RNA_RUNTIME
 
-/*static float rna_MeshVertex_no_get(PointerRNA *ptr, int index)
+static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
 {
        MVert *mvert= (MVert*)ptr->data;
-       return mvert->no[index]/32767.0f;
-}*/
+
+       value[0]= mvert->no[0]/32767.0f;
+       value[1]= mvert->no[1]/32767.0f;
+       value[2]= mvert->no[2]/32767.0f;
+}
 
 static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
 {
@@ -80,76 +83,77 @@ static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
        medge->crease= (char)(CLAMPIS(value*255.0f, 0, 255));
 }
 
+/* notice red and blue are swapped */
 static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       values[0]= (&mcol[0].r)[0]/255.0f;
+       values[2]= (&mcol[0].r)[0]/255.0f;
        values[1]= (&mcol[0].r)[1]/255.0f;
-       values[2]= (&mcol[0].r)[2]/255.0f;
+       values[0]= (&mcol[0].r)[2]/255.0f;
 }
 
 static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       (&mcol[0].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
+       (&mcol[0].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
        (&mcol[0].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
-       (&mcol[0].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
+       (&mcol[0].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
 }
 
 static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       values[0]= (&mcol[1].r)[0]/255.0f;
+       values[2]= (&mcol[1].r)[0]/255.0f;
        values[1]= (&mcol[1].r)[1]/255.0f;
-       values[2]= (&mcol[1].r)[2]/255.0f;
+       values[0]= (&mcol[1].r)[2]/255.0f;
 }
 
 static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       (&mcol[1].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
+       (&mcol[1].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
        (&mcol[1].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
-       (&mcol[1].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
+       (&mcol[1].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
 }
 
 static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       values[0]= (&mcol[2].r)[0]/255.0f;
+       values[2]= (&mcol[2].r)[0]/255.0f;
        values[1]= (&mcol[2].r)[1]/255.0f;
-       values[2]= (&mcol[2].r)[2]/255.0f;
+       values[0]= (&mcol[2].r)[2]/255.0f;
 }
 
 static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       (&mcol[2].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
+       (&mcol[2].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
        (&mcol[2].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
-       (&mcol[2].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
+       (&mcol[2].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
 }
 
 static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       values[0]= (&mcol[3].r)[0]/255.0f;
+       values[2]= (&mcol[3].r)[0]/255.0f;
        values[1]= (&mcol[3].r)[1]/255.0f;
-       values[2]= (&mcol[3].r)[2]/255.0f;
+       values[0]= (&mcol[3].r)[2]/255.0f;
 }
 
 static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
 {
        MCol *mcol= (MCol*)ptr->data;
 
-       (&mcol[3].r)[0]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
+       (&mcol[3].r)[2]= (char)(CLAMPIS(values[0]*255.0f, 0, 255));
        (&mcol[3].r)[1]= (char)(CLAMPIS(values[1]*255.0f, 0, 255));
-       (&mcol[3].r)[2]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
+       (&mcol[3].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255));
 }
 
 static int rna_Mesh_texspace_editable(PointerRNA *ptr)
@@ -628,10 +632,11 @@ static void rna_def_mvert(BlenderRNA *brna)
        prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
        RNA_def_property_ui_text(prop, "Location", "");
 
-       /*prop= RNA_def_property(srna, "no", PROP_FLOAT, PROP_VECTOR);
-       RNA_def_property_float_funcs(prop, "rna_MeshVertex_no_get", NULL, NULL);
+       prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_VECTOR);
+       RNA_def_property_float_sdna(prop, NULL, "no");
+       RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", NULL, NULL);
        RNA_def_property_ui_text(prop, "Normal", "Vertex Normal");
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
@@ -907,21 +912,25 @@ static void rna_def_mcol(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_array(prop, 3);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_float_funcs(prop, "rna_MeshColor_color1_get", "rna_MeshColor_color1_set", NULL);
        RNA_def_property_ui_text(prop, "Color 1", "");
 
        prop= RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_array(prop, 3);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_float_funcs(prop, "rna_MeshColor_color2_get", "rna_MeshColor_color2_set", NULL);
        RNA_def_property_ui_text(prop, "Color 2", "");
 
        prop= RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_array(prop, 3);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_float_funcs(prop, "rna_MeshColor_color3_get", "rna_MeshColor_color3_set", NULL);
        RNA_def_property_ui_text(prop, "Color 3", "");
 
        prop= RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_array(prop, 3);
+       RNA_def_property_range(prop, 0.0f, 1.0f);
        RNA_def_property_float_funcs(prop, "rna_MeshColor_color4_get", "rna_MeshColor_color4_set", NULL);
        RNA_def_property_ui_text(prop, "Color 4", "");
 }
index a17cc1aca3df376d2661d1f0cae199c63976ebf4..85e68ec4877dfd968a7fc12eff2b5ccd3638acc5 100644 (file)
@@ -92,7 +92,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
                ob->data= id;
                test_object_materials(id);
 
-               if(GS(id->name)==ID_CU )
+               if(GS(id->name)==ID_CU)
                        test_curve_type(ob);
                else if(ob->type==OB_ARMATURE)
                        armature_rebuild_pose(ob, ob->data);
@@ -522,6 +522,49 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
        RNA_def_property_range(prop, 0.0, 1.0);
        RNA_def_property_ui_text(prop, "Rotation Damping", "General rotation damping.");
 
+       prop= RNA_def_property(srna, "minimum_velocity", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "min_vel");
+       RNA_def_property_range(prop, 0.0, 1000.0);
+       RNA_def_property_ui_text(prop, "Velocity Min", "Clamp velocity to this minimum speed (except when totally still).");
+
+       prop= RNA_def_property(srna, "maximum_velocity", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "max_vel");
+       RNA_def_property_range(prop, 0.0, 1000.0);
+       RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed.");
+
+       /* lock position */
+       prop= RNA_def_property(srna, "lock_x_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS);
+       RNA_def_property_ui_text(prop, "Lock X Axis", "Disable simulation of linear motion along the X axis.");
+       
+       prop= RNA_def_property(srna, "lock_y_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_AXIS);
+       RNA_def_property_ui_text(prop, "Lock Y Axis", "Disable simulation of linear motion along the Y axis.");
+       
+       prop= RNA_def_property(srna, "lock_z_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_AXIS);
+       RNA_def_property_ui_text(prop, "Lock Z Axis", "Disable simulation of linear motion along the Z axis.");
+       
+       
+       /* lock rotation */
+       prop= RNA_def_property(srna, "lock_x_rot_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_ROT_AXIS);
+       RNA_def_property_ui_text(prop, "Lock X Rotation Axis", "Disable simulation of angular  motion along the X axis.");
+       
+       prop= RNA_def_property(srna, "lock_y_rot_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Y_ROT_AXIS);
+       RNA_def_property_ui_text(prop, "Lock Y Rotation Axis", "Disable simulation of angular  motion along the Y axis.");
+       
+       prop= RNA_def_property(srna, "lock_z_rot_axis", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_Z_ROT_AXIS);
+       RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular  motion along the Z axis.");
+       
+       /* is this used anywhere ? */
+       prop= RNA_def_property(srna, "use_activity_culling", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "gameflag2", OB_NEVER_DO_ACTIVITY_CULLING);
+       RNA_def_property_ui_text(prop, "Lock Z Rotation Axis", "Disable simulation of angular  motion along the Z axis.");      
+       
+
        prop= RNA_def_property(srna, "do_fh", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_DO_FH);
        RNA_def_property_ui_text(prop, "Do Fh", "Use Fh settings in materials.");
index 5727bb97483b9e55a461e415280df93513f24a2c..f28f00e9c0254397eeac3ee10ef7aab366012cee 100644 (file)
@@ -875,6 +875,19 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA * self)
 
                RNA_property_collection_end(&iter);
        }
+
+       if(self->ptr.type == &RNA_Context) {
+               ListBase lb = CTX_data_dir_get(self->ptr.data);
+               LinkData *link;
+
+               for(link=lb.first; link; link=link->next) {
+                       pystring = PyUnicode_FromString(link->data);
+                       PyList_Append(ret, pystring);
+                       Py_DECREF(pystring);
+               }
+
+               BLI_freelistN(&lb);
+       }
        
        return ret;
 }
@@ -1011,22 +1024,30 @@ PyObject *pyrna_prop_items(BPy_PropertyRNA *self)
                CollectionPropertyIterator iter;
                PropertyRNA *nameprop;
                char name[256], *nameptr;
+               int i= 0;
 
                ret = PyList_New(0);
                
                RNA_property_collection_begin(&self->ptr, self->prop, &iter);
                for(; iter.valid; RNA_property_collection_next(&iter)) {
-                       if(iter.ptr.data && (nameprop = RNA_struct_name_property(iter.ptr.type))) {
-                               nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
-                               
+                       if(iter.ptr.data) {
                                /* add to python list */
-                               item = Py_BuildValue("(NN)", PyUnicode_FromString( nameptr ), pyrna_struct_CreatePyObject(&iter.ptr));
+                               item= PyTuple_New(2);
+                               if(nameprop = RNA_struct_name_property(iter.ptr.type)) {
+                                       nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
+                                       PyTuple_SET_ITEM(item, 0, PyUnicode_FromString( nameptr ));
+                                       if ((char *)&name != nameptr)
+                                               MEM_freeN(nameptr);
+                               }
+                               else {
+                                       PyTuple_SET_ITEM(item, 0, PyLong_FromSsize_t(i)); /* a bit strange but better then returning an empty list */
+                               }
+                               PyTuple_SET_ITEM(item, 1, pyrna_struct_CreatePyObject(&iter.ptr));
+                               
                                PyList_Append(ret, item);
                                Py_DECREF(item);
-                               /* done */
                                
-                               if ((char *)&name != nameptr)
-                                       MEM_freeN(nameptr);
+                               i++;
                        }
                }
                RNA_property_collection_end(&iter);
@@ -1039,23 +1060,22 @@ PyObject *pyrna_prop_items(BPy_PropertyRNA *self)
 PyObject *pyrna_prop_values(BPy_PropertyRNA *self)
 {
        PyObject *ret;
+       
        if (RNA_property_type(self->prop) != PROP_COLLECTION) {
                PyErr_SetString( PyExc_TypeError, "values() is only valid for collection types" );
                ret = NULL;
        } else {
                PyObject *item;
                CollectionPropertyIterator iter;
-               PropertyRNA *nameprop;
-               
+               PropertyRNA *iterprop;
                ret = PyList_New(0);
                
+               //iterprop= RNA_struct_iterator_property(self->ptr.type);
                RNA_property_collection_begin(&self->ptr, self->prop, &iter);
                for(; iter.valid; RNA_property_collection_next(&iter)) {
-                       if(iter.ptr.data && (nameprop = RNA_struct_name_property(iter.ptr.type))) {
-                               item = pyrna_struct_CreatePyObject(&iter.ptr);
-                               PyList_Append(ret, item);
-                               Py_DECREF(item);
-                       }
+                       item = pyrna_struct_CreatePyObject(&iter.ptr);
+                       PyList_Append(ret, item);
+                       Py_DECREF(item);
                }
                RNA_property_collection_end(&iter);
        }
index c15315ca350ce9f54d6b9e022eab473438744779..088fe436c69d2ebb44d67ffc6f4dbe74f8c7bc21 100644 (file)
@@ -373,7 +373,7 @@ static struct PyMethodDef ui_methods[] = {
 #if PY_VERSION_HEX >= 0x03000000
 static struct PyModuleDef ui_module = {
        PyModuleDef_HEAD_INIT,
-       "bpyui",
+       "bpy.ui",
        "",
        -1,/* multiple "initialization" just copies the module dict. */
        ui_methods,