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:
-rw-r--r--release/scripts/export_cal3d.py290
-rw-r--r--source/blender/blenkernel/intern/verse_session.c1
-rw-r--r--source/blender/python/api2_2x/Bone.c19
-rw-r--r--source/blender/python/api2_2x/Draw.c107
-rw-r--r--source/blender/python/api2_2x/doc/Draw.py32
-rw-r--r--source/blender/src/buttons_logic.c1
-rw-r--r--source/blender/src/editface.c1
7 files changed, 244 insertions, 207 deletions
diff --git a/release/scripts/export_cal3d.py b/release/scripts/export_cal3d.py
index c417ac4d978..113b20b4bc3 100644
--- a/release/scripts/export_cal3d.py
+++ b/release/scripts/export_cal3d.py
@@ -293,10 +293,115 @@ class Cal3DMaterial:
class Cal3DMesh:
- def __init__(self, name):
- self.name = name
+ def __init__(self, ob, blend_mesh):
+ self.name = ob.name
self.submeshes = []
- self.next_submesh_id = 0
+
+ matrix = ob.matrixWorld
+ #if BASE_MATRIX:
+ # matrix = matrix_multiply(BASE_MATRIX, matrix)
+
+ faces = list(blend_mesh.faces)
+ while faces:
+ image = faces[0].image
+ image_filename = image and image.filename
+ material = MATERIALS.get(image_filename) or Cal3DMaterial(image_filename)
+ outputuv = len(material.maps_filenames) > 0
+
+ # TODO add material color support here
+ submesh = Cal3DSubMesh(self, material, len(self.submeshes))
+ self.submeshes.append(submesh)
+ vertices = {}
+ for face in faces[:]:
+ if (face.image and face.image.filename) == image_filename:
+ faces.remove(face)
+
+ if not face.smooth:
+ normal = face.no * matrix
+ normal.normalize()
+
+ face_vertices = []
+ face_v = face.v
+ for i, blend_vert in enumerate(face_v):
+ vertex = vertices.get(blend_vert.index)
+ if not vertex:
+ #coord = blend_vert.co * matrix
+ coord = blend_vert.co
+ if face.smooth:
+ #normal = blend_vert.no * matrix
+ normal = blend_vert.no
+ #normal.normalize()
+
+ vertex = vertices[blend_vert.index] = Cal3DVertex(coord, normal, len(submesh.vertices))
+ submesh.vertices.append(vertex)
+
+ influences = blend_mesh.getVertexInfluences(blend_vert.index)
+ # should this really be a warning? (well currently enabled,
+ # because blender has some bugs where it doesn't return
+ # influences in python api though they are set, and because
+ # cal3d<=0.9.1 had bugs where objects without influences
+ # aren't drawn.
+ if not influences:
+ print 'A vertex of object "%s" has no influences.\n(This occurs on objects placed in an invisible layer, you can fix it by using a single layer)' % ob.name
+
+ # sum of influences is not always 1.0 in Blender ?!?!
+ sum = 0.0
+ for bone_name, weight in influences:
+ sum += weight
+
+ for bone_name, weight in influences:
+ if bone_name not in BONES:
+ print 'Couldnt find bone "%s" which influences object "%s"' % (bone_name, ob.name)
+ continue
+ if weight:
+ vertex.influences.append(Influence(BONES[bone_name], weight / sum))
+
+ elif not face.smooth:
+ # We cannot share vertex for non-smooth faces, since Cal3D does not
+ # support vertex sharing for 2 vertices with different normals.
+ # => we must clone the vertex.
+
+ old_vertex = vertex
+ vertex = Cal3DVertex(vertex.loc, normal, len(submesh.vertices))
+ submesh.vertices.append(vertex)
+
+ vertex.cloned_from = old_vertex
+ vertex.influences = old_vertex.influences
+ old_vertex.clones.append(vertex)
+
+ if blend_mesh.faceUV:
+ uv = [face.uv[i][0], 1.0 - face.uv[i][1]]
+ if not vertex.maps:
+ if outputuv: vertex.maps.append(Map(*uv))
+ elif (vertex.maps[0].u != uv[0]) or (vertex.maps[0].v != uv[1]):
+ # This vertex can be shared for Blender, but not for Cal3D !!!
+ # Cal3D does not support vertex sharing for 2 vertices with
+ # different UV texture coodinates.
+ # => we must clone the vertex.
+
+ for clone in vertex.clones:
+ if (clone.maps[0].u == uv[0]) and (clone.maps[0].v == uv[1]):
+ vertex = clone
+ break
+ else: # Not yet cloned...
+ old_vertex = vertex
+ vertex = Cal3DVertex(vertex.loc, vertex.normal, len(submesh.vertices))
+ submesh.vertices.append(vertex)
+
+ vertex.cloned_from = old_vertex
+ vertex.influences = old_vertex.influences
+ if outputuv: vertex.maps.append(Map(*uv))
+ old_vertex.clones.append(vertex)
+
+ face_vertices.append(vertex)
+
+ # Split faces with more than 3 vertices
+ for i in xrange(1, len(face.v) - 1):
+ submesh.faces.append(Face(face_vertices[0], face_vertices[i], face_vertices[i + 1]))
+
+ # Computes LODs info
+ if LODS:
+ submesh.compute_lods()
def writeCal3D(self, file):
file.write('<?xml version="1.0"?>\n')
@@ -307,19 +412,13 @@ class Cal3DMesh:
file.write('</MESH>\n')
class Cal3DSubMesh:
- def __init__(self, mesh, material):
+ def __init__(self, mesh, material, id):
self.material = material
self.vertices = []
self.faces = []
self.nb_lodsteps = 0
self.springs = []
-
- self.next_vertex_id = 0
-
- self.mesh = mesh
- self.id = mesh.next_submesh_id
- mesh.next_submesh_id += 1
- mesh.submeshes.append(self)
+ self.id = id
def compute_lods(self):
"""Computes LODs info for Cal3D (there's no Blender related stuff here)."""
@@ -550,18 +649,18 @@ BONES = {}
POSEBONES= {}
class Cal3DBone(object):
__slots__ = 'head', 'tail', 'name', 'cal3d_parent', 'loc', 'rot', 'children', 'matrix', 'lloc', 'lrot', 'id'
- def __init__(self, skeleton, blen_bone, arm_matrix, cal3d_parent=None):
+ def __init__(self, skeleton, blend_bone, arm_matrix, cal3d_parent=None):
# def treat_bone(b, parent = None):
- head = blen_bone.head['BONESPACE']
- tail = blen_bone.tail['BONESPACE']
+ head = blend_bone.head['BONESPACE']
+ tail = blend_bone.tail['BONESPACE']
#print parent.rot
# Turns the Blender's head-tail-roll notation into a quaternion
- #quat = matrix2quaternion(blender_bone2matrix(head, tail, blen_bone.roll['BONESPACE']))
- quat = matrix2quaternion(blen_bone.matrix['BONESPACE'].copy().resize4x4())
+ #quat = matrix2quaternion(blender_bone2matrix(head, tail, blend_bone.roll['BONESPACE']))
+ quat = matrix2quaternion(blend_bone.matrix['BONESPACE'].copy().resize4x4())
# Pose location
- ploc = POSEBONES[blen_bone.name].loc
+ ploc = POSEBONES[blend_bone.name].loc
if cal3d_parent:
# Compute the translation from the parent bone's head to the child
@@ -573,7 +672,7 @@ class Cal3DBone(object):
parent_invert_transform = matrix_invert(quaternion2matrix(cal3d_parent.rot))
parent_head = vector_by_matrix_3x3(cal3d_parent.head, parent_invert_transform)
parent_tail = vector_by_matrix_3x3(cal3d_parent.tail, parent_invert_transform)
- ploc = vector_add(ploc, blen_bone.head['BONESPACE'])
+ ploc = vector_add(ploc, blend_bone.head['BONESPACE'])
# EDIT!!! FIX BONE OFFSET BE CAREFULL OF THIS PART!!! ??
#diff = vector_by_matrix_3x3(head, parent_invert_transform)
@@ -584,7 +683,7 @@ class Cal3DBone(object):
# hmm this should be handled by the IPos, but isn't for non-animated
# bones which are transformed in the pose mode...
#loc = vector_add(ploc, parentheadtotail)
- #rot = quaternion_multiply(blender2cal3dquat(blen_bone.getQuat()), quat)
+ #rot = quaternion_multiply(blender2cal3dquat(blend_bone.getQuat()), quat)
loc = parentheadtotail
rot = quat
@@ -594,8 +693,8 @@ class Cal3DBone(object):
tail = point_by_matrix(tail, arm_matrix)
quat = matrix2quaternion(matrix_multiply(arm_matrix, quaternion2matrix(quat))) # Probably not optimal
- # loc = vector_add(head, blen_bone.getLoc())
- # rot = quaternion_multiply(blender2cal3dquat(blen_bone.getQuat()), quat)
+ # loc = vector_add(head, blend_bone.getLoc())
+ # rot = quaternion_multiply(blender2cal3dquat(blend_bone.getQuat()), quat)
loc = head
rot = quat
@@ -603,7 +702,7 @@ class Cal3DBone(object):
self.tail = tail
self.cal3d_parent = cal3d_parent
- self.name = blen_bone.name
+ self.name = blend_bone.name
self.loc = loc
self.rot = rot
self.children = []
@@ -622,9 +721,9 @@ class Cal3DBone(object):
skeleton.bones.append(self)
BONES[self.name] = self
- if not blen_bone.hasChildren(): return
- for blen_child in blen_bone.children:
- self.children.append(Cal3DBone(skeleton, blen_child, arm_matrix, self))
+ if not blend_bone.hasChildren(): return
+ for blend_child in blend_bone.children:
+ self.children.append(Cal3DBone(skeleton, blend_child, arm_matrix, self))
def writeCal3D(self, file):
@@ -732,143 +831,33 @@ def export_cal3d(filename):
Cal3DBone(skeleton, best_armature_root(blender_armature.getData()), blender_armature.matrixWorld)
-
-
# ---- Export Mesh data ---------------------------------------------------
-
meshes = []
for ob in scene.objects.context:
if ob.type != 'Mesh': continue
- bmesh = ob.getData(mesh=1)
- BPyMesh.meshCalcNormals(bmesh)
+ blend_mesh = ob.getData(mesh=1)
+ BPyMesh.meshCalcNormals(blend_mesh)
- if not bmesh.faces: continue
- mesh = Cal3DMesh(bmesh.name)
- mesh_name = ob.name
- meshes.append(mesh)
+ if not blend_mesh.faces: continue
+ meshes.append( Cal3DMesh(ob, blend_mesh) )
- matrix = ob.matrixWorld
- #if BASE_MATRIX:
- # matrix = matrix_multiply(BASE_MATRIX, matrix)
-
- faces = list(bmesh.faces)
- while faces:
- image = faces[0].image
- image_filename = image and image.filename
- material = MATERIALS.get(image_filename) or Cal3DMaterial(image_filename)
- outputuv = len(material.maps_filenames) > 0
-
- # TODO add material color support here
- submesh = Cal3DSubMesh(mesh, material)
- vertices = {}
- for face in faces[:]:
- if (face.image and face.image.filename) == image_filename:
- faces.remove(face)
-
- if not face.smooth:
- normal = face.no * matrix
- normal.normalize()
-
- face_vertices = []
- face_v = face.v
- for i, blen_vert in enumerate(face_v):
- vertex = vertices.get(blen_vert.index)
- if not vertex:
- #coord = blen_vert.co * matrix
- coord = blen_vert.co
- if face.smooth:
- #normal = blen_vert.no * matrix
- normal = blen_vert.no
- #normal.normalize()
-
- vertex = vertices[blen_vert.index] = Cal3DVertex(coord, normal, len(submesh.vertices))
- submesh.vertices.append(vertex)
-
- influences = bmesh.getVertexInfluences(blen_vert.index)
- # should this really be a warning? (well currently enabled,
- # because blender has some bugs where it doesn't return
- # influences in python api though they are set, and because
- # cal3d<=0.9.1 had bugs where objects without influences
- # aren't drawn.
- if not influences:
- print 'A vertex of object "%s" has no influences.\n(This occurs on objects placed in an invisible layer, you can fix it by using a single layer)' % ob.name
-
- # sum of influences is not always 1.0 in Blender ?!?!
- sum = 0.0
- for bone_name, weight in influences:
- sum += weight
-
- for bone_name, weight in influences:
- if bone_name not in BONES:
- print 'Couldnt find bone "%s" which influences object "%s"' % (bone_name, ob.name)
- continue
- if weight:
- vertex.influences.append(Influence(BONES[bone_name], weight / sum))
-
- elif not face.smooth:
- # We cannot share vertex for non-smooth faces, since Cal3D does not
- # support vertex sharing for 2 vertices with different normals.
- # => we must clone the vertex.
-
- old_vertex = vertex
- vertex = Cal3DVertex(vertex.loc, normal, len(submesh.vertices))
- submesh.vertices.append(vertex)
-
- vertex.cloned_from = old_vertex
- vertex.influences = old_vertex.influences
- old_vertex.clones.append(vertex)
-
- if bmesh.faceUV:
- uv = [face.uv[i][0], 1.0 - face.uv[i][1]]
- if not vertex.maps:
- if outputuv: vertex.maps.append(Map(*uv))
- elif (vertex.maps[0].u != uv[0]) or (vertex.maps[0].v != uv[1]):
- # This vertex can be shared for Blender, but not for Cal3D !!!
- # Cal3D does not support vertex sharing for 2 vertices with
- # different UV texture coodinates.
- # => we must clone the vertex.
-
- for clone in vertex.clones:
- if (clone.maps[0].u == uv[0]) and (clone.maps[0].v == uv[1]):
- vertex = clone
- break
- else: # Not yet cloned...
- old_vertex = vertex
- vertex = Cal3DVertex(vertex.loc, vertex.normal, len(submesh.vertices))
- submesh.vertices.append(vertex)
-
- vertex.cloned_from = old_vertex
- vertex.influences = old_vertex.influences
- if outputuv: vertex.maps.append(Map(*uv))
- old_vertex.clones.append(vertex)
-
- face_vertices.append(vertex)
-
- # Split faces with more than 3 vertices
- for i in xrange(1, len(face.v) - 1):
- submesh.faces.append(Face(face_vertices[0], face_vertices[i], face_vertices[i + 1]))
-
- # Computes LODs info
- if LODS:
- submesh.compute_lods()
-
# ---- Export animations --------------------------------------------------
ANIMATIONS = {}
SUPPORTED_IPOS = "QuatW", "QuatX", "QuatY", "QuatZ", "LocX", "LocY", "LocZ"
- for a in Blender.Armature.NLA.GetActions().iteritems():
- #for blen_action in [blender_armature.action]:
+ for animation_name, blend_action in Blender.Armature.NLA.GetActions().iteritems():
+ #for blend_action in [blender_armature.action]:
#animation_name = a[0]
- animation_name = blen_action.name
+ #animation_name = blend_action.name
animation = Cal3DAnimation(animation_name)
animation.duration = 0.0
# All tracks need to have at least 1 keyframe.
# bones without any keys crash the viewer so we need to find the location for a dummy keyframe.
- blen_action_ipos = blen_action.getAllChannelIpos()
+ blend_action_ipos = blend_action.getAllChannelIpos()
start_frame = 300000 # largest frame
- for bone_name, ipo in blen_action_ipos.iteritems():
+ for bone_name, ipo in blend_action_ipos.iteritems():
if ipo:
for curve in ipo:
if curve.name in SUPPORTED_IPOS:
@@ -882,14 +871,14 @@ def export_cal3d(filename):
# Now we mau have some bones with no channels, easiest to add their names and an empty list here
# this way they are exported with dummy keyfraames at teh first used frame
- blen_action_ipos_items = blen_action_ipos.items()
- action_bone_names = [name for name, ipo in blen_action_ipos_items]
+ blend_action_ipos_items = blend_action_ipos.items()
+ action_bone_names = [name for name, ipo in blend_action_ipos_items]
for bone_name in BONES: # iterkeys
if bone_name not in action_bone_names:
- blen_action_ipos_items.append( (bone_name, []) )
+ blend_action_ipos_items.append( (bone_name, []) )
- for bone_name, ipo in blen_action_ipos_items:
+ for bone_name, ipo in blend_action_ipos_items:
if bone_name not in BONES:
print "\tNo Bone '" + bone_name + "' in (from Animation '" + animation_name + "') ?!?"
continue
@@ -943,10 +932,7 @@ def export_cal3d(filename):
rot = tuple(rot)
Cal3DKeyFrame(track, cal3dtime, loc, rot)
-
-
Cal3DKeyFrame(track, cal3dtime, loc, rot)
- #Cal3DKeyFrame(track, cal3dtime, (0,0,0), (0,0,0,0))
if animation.duration <= 0:
print "Ignoring Animation '" + animation_name + "': duration is 0.\n"
@@ -1004,7 +990,7 @@ def export_cal3d(filename):
if len(animation.tracks) < 2:
Blender.Draw.PupMenu('Warning, the armature has less then 2 tracks, file may not load in Cal3d')
-# import os
+#import os
if __name__ == '__main__':
Blender.Window.FileSelector(export_cal3d, "Cal3D Export", Blender.Get('filename').replace('.blend', '.cfg'))
#export_cal3d('/test' + '.cfg')
diff --git a/source/blender/blenkernel/intern/verse_session.c b/source/blender/blenkernel/intern/verse_session.c
index 1b10a35c364..288bfd01a9d 100644
--- a/source/blender/blenkernel/intern/verse_session.c
+++ b/source/blender/blenkernel/intern/verse_session.c
@@ -39,6 +39,7 @@
#include "BLI_dynamiclist.h"
#include "BLI_blenlib.h"
+#include "BIF_screen.h"
#include "BIF_verse.h"
#include "BKE_global.h"
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index 0d4c0983a67..cd2e3bea099 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -910,16 +910,12 @@ static PyObject *Bone_hasChildren(BPy_Bone *self)
//-------------------------Bone.getAllChildren()
static PyObject *Bone_getAllChildren(BPy_Bone *self)
{
- PyObject *list = NULL;
+ PyObject *list = PyList_New(0);
- if (self->bone->childbase.first){
- list = PyList_New(0);
+ if (self->bone->childbase.first)
if (!PyBone_ChildrenAsList(list, &self->bone->childbase))
return NULL;
- return EXPP_incr_ret(list);
- }else{
- return EXPP_incr_ret(Py_None);
- }
+ EXPP_incr_ret(list);
}
//------------------ATTRIBUTE IMPLEMENTATIONS-----------------------------
//------------------------Bone.name (get)
@@ -1077,12 +1073,11 @@ static int Bone_setParent(BPy_Bone *self, PyObject *value, void *closure)
//------------------------Bone.children (get)
static PyObject *Bone_getChildren(BPy_Bone *self, void *closure)
{
- PyObject *list = NULL;
+ PyObject *list = PyList_New(0);
Bone *bone = NULL;
PyObject *py_bone = NULL;
if (self->bone->childbase.first){
- list = PyList_New(0);
for (bone = self->bone->childbase.first; bone; bone = bone->next){
py_bone = PyBone_FromBone(bone);
if (py_bone == NULL)
@@ -1091,11 +1086,9 @@ static PyObject *Bone_getChildren(BPy_Bone *self, void *closure)
goto RuntimeError;
}
}
- return EXPP_incr_ret(list);
- }else{
- return EXPP_incr_ret(Py_None);
}
-
+ return EXPP_incr_ret(list);
+
RuntimeError:
return EXPP_objError(PyExc_RuntimeError, "%s%s",
sBoneError, "Internal error trying to wrap blender bones!");
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 8baf44ef356..7dbcf79a70c 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -45,7 +45,9 @@
#include "BKE_image.h"
#include "BKE_object.h"
#include "BKE_main.h"
+#include "BKE_utildefines.h"
#include "BIF_gl.h"
+#include "BIF_mywindow.h"
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_interface.h"
@@ -733,14 +735,66 @@ void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event,
}
}
-static void exec_but_callback(PyObject *callback, int event)
+static void exec_but_callback(PyObject *callback, uiBut *but)
{
PyObject *result;
-
+ PyObject * pyvalue;
+ PyObject *arg = PyTuple_New( 2 );
+
+ double value = ui_get_but_val(but);
+
if (callback==NULL || callback == Py_None)
return;
-
- result = PyObject_CallObject( callback, Py_BuildValue( "(i)", event ) );
+
+ /* Button types support
+ case MENU:
+ case TEX:
+ case TOG:
+ case NUMSLI:
+ case NUM:
+ case COL:
+ case BUT_NORMAL:
+ case BUT */
+ switch (but->type) {
+ case TEX:
+ /*printf("TEX\n");*/
+ pyvalue = PyString_FromString( (char *)but->poin );
+ break;
+ case NUM:
+ case NUMSLI:
+ case TOG:
+ case MENU:
+ if (but->pointype==FLO) {
+ /*printf("FLO\n");*/
+ pyvalue = PyFloat_FromDouble( (float)value );
+ } else if (but->pointype==INT) {
+ /*printf("INT\n");*/
+ pyvalue = PyInt_FromLong( (int)value );
+ } else if (but->pointype==SHO) {
+ /*printf("SHO\n");*/
+ pyvalue = PyInt_FromLong( (short)value );
+ }
+ break;
+ case COL:
+ case BUT_NORMAL:
+ {
+ float vec[3];
+ VECCOPY(vec, (float *)but->poin);
+ pyvalue = Py_BuildValue("(fff)", vec[0], vec[1], vec[2]);
+ break;
+ }
+ case BUT:
+ pyvalue = Py_None;
+ break;
+ default:
+ pyvalue = Py_None;
+ printf("Error, no button type matched.");
+ }
+
+ PyTuple_SetItem( arg, 0, PyInt_FromLong(but->retval - EXPP_BUTTON_EVENTS_OFFSET) );
+ PyTuple_SetItem( arg, 1, pyvalue );
+
+ result = PyObject_CallObject( callback, arg );
if (!result) {
PyErr_Print( );
error( "Python script error: check console" );
@@ -748,10 +802,10 @@ static void exec_but_callback(PyObject *callback, int event)
Py_XDECREF( result );
}
-static void set_pycallback(uiBut *ubut, PyObject *callback, int event)
+static void set_pycallback(uiBut *ubut, PyObject *callback)
{
if (!callback || !PyCallable_Check(callback)) return;
- uiButSetFunc(ubut, exec_but_callback, callback, event);
+ uiButSetFunc(ubut, exec_but_callback, callback, ubut);
}
static PyObject *Method_Exit( PyObject * self, PyObject * args )
@@ -764,7 +818,7 @@ static PyObject *Method_Exit( PyObject * self, PyObject * args )
if( curarea->spacetype == SPACE_SCRIPT )
sc = curarea->spacedata.first;
else
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
if( !PyArg_ParseTuple( args, "" ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -777,7 +831,7 @@ static PyObject *Method_Exit( PyObject * self, PyObject * args )
/* remove our lock to the current namespace */
script->flags &= ~SCRIPT_GUI;
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
/* Method_Register (Draw.Register) registers callbacks for drawing, events
@@ -805,7 +859,7 @@ static PyObject *Method_Register( PyObject * self, PyObject * args )
newbuttonc = NULL;
if( !( newdrawc || neweventc || newbuttonc ) )
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
startspace = curarea->spacetype;
@@ -865,7 +919,7 @@ static PyObject *Method_Register( PyObject * self, PyObject * args )
scrarea_queue_redraw( sc->area );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_Redraw( PyObject * self, PyObject * args )
@@ -881,7 +935,7 @@ static PyObject *Method_Redraw( PyObject * self, PyObject * args )
else
scrarea_queue_winredraw( curarea );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_Draw( PyObject * self, PyObject * args )
@@ -889,7 +943,7 @@ static PyObject *Method_Draw( PyObject * self, PyObject * args )
/*@ If forced drawing is disable queue a redraw event instead */
if( EXPP_disable_force_draw ) {
scrarea_queue_winredraw( curarea );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
if( !PyArg_ParseTuple( args, "" ) )
@@ -900,7 +954,7 @@ static PyObject *Method_Draw( PyObject * self, PyObject * args )
screen_swapbuffers( );
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_Create( PyObject * self, PyObject * args )
@@ -1017,7 +1071,7 @@ static PyObject *Method_BeginAlign( PyObject * self, PyObject * args )
if (block)
uiBlockBeginAlign(block);
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_EndAlign( PyObject * self, PyObject * args )
@@ -1027,7 +1081,7 @@ static PyObject *Method_EndAlign( PyObject * self, PyObject * args )
if (block)
uiBlockEndAlign(block);
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_Button( PyObject * self, PyObject * args )
@@ -1048,9 +1102,9 @@ static PyObject *Method_Button( PyObject * self, PyObject * args )
block = Get_uiBlock( );
if( block ) {
uiBut *ubut = uiDefBut( block, BUT, event, name, (short)x, (short)y, (short)w, (short)h, 0, 0, 0, 0, 0, tip );
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
- return EXPP_incr_ret( Py_None );
+ Py_RETURN_NONE;
}
static PyObject *Method_Menu( PyObject * self, PyObject * args )
@@ -1077,7 +1131,7 @@ static PyObject *Method_Menu( PyObject * self, PyObject * args )
if( block ) {
uiBut *ubut = uiDefButI( block, MENU, event, name, (short)x, (short)y, (short)w, (short)h,
&but->val.asint, 0, 0, 0, 0, tip );
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
return ( PyObject * ) but;
}
@@ -1106,7 +1160,7 @@ static PyObject *Method_Toggle( PyObject * self, PyObject * args )
if( block ) {
uiBut *ubut = uiDefButI( block, TOG, event, name, (short)x, (short)y, (short)w, (short)h,
&but->val.asint, 0, 0, 0, 0, tip );
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
return ( PyObject * ) but;
}
@@ -1185,8 +1239,9 @@ static PyObject *Method_Slider( PyObject * self, PyObject * args )
(short)h, &but->val.asfloat, min, max, 0, 0,
tip );
if( realtime )
- uiButSetFunc( ubut, py_slider_update, ubut,
- NULL );
+ uiButSetFunc( ubut, py_slider_update, ubut, NULL );
+ else
+ set_pycallback(ubut, callback);
}
} else {
int ini, min, max;
@@ -1207,7 +1262,7 @@ static PyObject *Method_Slider( PyObject * self, PyObject * args )
if( realtime )
uiButSetFunc( ubut, py_slider_update, ubut, NULL );
else
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
}
return ( PyObject * ) but;
@@ -1311,7 +1366,7 @@ static PyObject *Method_ColorPicker( PyObject * self, PyObject * args )
if( block ) {
uiBut *ubut;
ubut = uiDefButF( block, COL, event, "", x, y, w, h, but->val.asvec, 0, 0, 0, 0, tip);
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
return ( PyObject * ) but;
@@ -1355,7 +1410,7 @@ static PyObject *Method_Normal( PyObject * self, PyObject * args )
if( block ) {
uiBut *ubut;
ubut = uiDefButF( block, BUT_NORMAL, event, "", x, y, w, h, but->val.asvec, 0.0f, 1.0f, 0, 0, tip);
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
return ( PyObject * ) but;
@@ -1421,7 +1476,7 @@ static PyObject *Method_Number( PyObject * self, PyObject * args )
&but->val.asint, (float)min, (float)max, 0, 0, tip );
}
- if (ubut) set_pycallback(ubut, callback, event);
+ if (ubut) set_pycallback(ubut, callback);
return ( PyObject * ) but;
}
@@ -1466,7 +1521,7 @@ static PyObject *Method_String( PyObject * self, PyObject * args )
if( block ) {
uiBut *ubut = uiDefBut( block, TEX, event, info_str, (short)x, (short)y, (short)w, (short)h,
but->val.asstr, 0, (float)len, 0, 0, tip );
- set_pycallback(ubut, callback, event);
+ set_pycallback(ubut, callback);
}
return ( PyObject * ) but;
}
diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py
index 6e9a0ae572c..3b8a0d02eae 100644
--- a/source/blender/python/api2_2x/doc/Draw.py
+++ b/source/blender/python/api2_2x/doc/Draw.py
@@ -204,14 +204,14 @@ have been caused by an ignored return value from one of the button types. To
avoid this, assign created buttons return values to B{global} variables,
instead of ignoring them. Examples::
- # avoid this, it can cause memory leaks:
- Draw.Toggle(...)
- Draw.Number(...)
- Draw.String(...)
- # this is correct -- assuming the variables are globals:
- my_toggle_button = Draw.Toggle(...)
- my_int_button = Draw.Number(...)
- my_str_button = Draw.String(...)
+ # avoid this, it can cause memory leaks:
+ Draw.Toggle(...)
+ Draw.Number(...)
+ Draw.String(...)
+ # this is correct -- assuming the variables are globals:
+ my_toggle_button = Draw.Toggle(...)
+ my_int_button = Draw.Number(...)
+ my_str_button = Draw.String(...)
@warn: Inside the windowing loop (after Draw.Register() has been executed and
@@ -320,7 +320,7 @@ def PushButton(name, event, x, y, width, height, tooltip = None, callback = None
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@note: This function used to be called only "Button". We added an
alternative alias to avoid a name clash with the L{Button} class/type that
caused trouble in this documentation's generation. The old name shouldn't
@@ -521,7 +521,7 @@ def Menu(name, event, x, y, width, height, default, tooltip = None, callback = N
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
"""
@@ -551,7 +551,7 @@ def Toggle(name, event, x, y, width, height, default, tooltip = None, callback =
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
"""
@@ -589,7 +589,7 @@ def Slider(name, event, x, y, width, height, initial, min, max, realtime = 1,
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
@note: slider callbacks will not work if the realtime setting is enabled.
@@ -648,7 +648,7 @@ def ColorPicker(event, x, y, width, height, initial, tooltip = None, callback =
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
@note: The color picker will not work if the Register's event function is None.
@@ -677,7 +677,7 @@ def Normal(event, x, y, width, height, initial, tooltip = None, callback = None)
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
@note: The normal button will not work if the Register's event function is None.
@@ -712,7 +712,7 @@ def Number(name, event, x, y, width, height, initial, min, max, tooltip = None,
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
@@ -757,7 +757,7 @@ def String(name, event, x, y, width, height, initial, length, tooltip = None, ca
@type callback: function
@param callback: an optional argument so this button can have its own
callback function. the function will run whenever this button is pressed.
- This function must accept one argument (the event) as an argument.
+ This function must accept 2 arguments (event, val).
@rtype: Blender Button
@return: The Button created.
"""
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 1a1d7828ef0..ee1b5737410 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -81,6 +81,7 @@
#include "BDR_editcurve.h"
+#include "BDR_editobject.h"
#include "BSE_headerbuttons.h"
#include "BSE_filesel.h"
diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c
index 895a081a18a..2c14e53eff8 100644
--- a/source/blender/src/editface.c
+++ b/source/blender/src/editface.c
@@ -95,6 +95,7 @@
#include "BSE_trans_types.h"
#include "BDR_unwrapper.h"
+#include "BDR_editobject.h"
#include "BPY_extern.h"
#include "BPY_menus.h"