Merge from trunk 16031:16122

This commit is contained in:
Ian Thompson 2008-08-15 00:00:27 +00:00
commit bda3e4f8e2
55 changed files with 3271 additions and 3932 deletions

@ -0,0 +1,177 @@
#!/usr/bin/python
# ***** BEGIN GPL LICENSE BLOCK *****
#
# 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.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
HELP_TXT = \
'''
Convert BDF pixmap fonts into C++ files Blender can read.
Use to replace bitmap fonts or add new ones.
Usage
python bdf2bmf.py -name=SomeName myfile.bdf
Blender currently supports fonts with a maximum width of 8 pixels.
'''
# -------- Simple BDF parser
import sys
def parse_bdf(f, MAX_CHARS=256):
lines = [l.strip().upper().split() for l in f.readlines()]
is_bitmap = False
dummy = {'BITMAP':[]}
char_data = [dummy.copy() for i in xrange(MAX_CHARS)]
context_bitmap = []
for l in lines:
if l[0]=='ENCODING': enc = int(l[1])
elif l[0]=='BBX': bbx = [int(c) for c in l[1:]]
elif l[0]=='DWIDTH': dwidth = int(l[1])
elif l[0]=='BITMAP': is_bitmap = True
elif l[0]=='ENDCHAR':
if enc < MAX_CHARS:
char_data[enc]['BBX'] = bbx
char_data[enc]['DWIDTH'] = dwidth
char_data[enc]['BITMAP'] = context_bitmap
context_bitmap = []
enc = bbx = None
is_bitmap = False
else:
# None of the above, Ok, were reading a bitmap
if is_bitmap and enc < MAX_CHARS:
context_bitmap.append( int(l[0], 16) )
return char_data
# -------- end simple BDF parser
def bdf2cpp_name(path):
return path.split('.')[0] + '.cpp'
def convert_to_blender(bdf_dict, font_name, origfilename, MAX_CHARS=256):
# first get a global width/height, also set the offsets
xmin = ymin = 10000000
xmax = ymax = -10000000
bitmap_offsets = [-1] * MAX_CHARS
bitmap_tot = 0
for i, c in enumerate(bdf_dict):
if c.has_key('BBX'):
bbx = c['BBX']
xmax = max(bbx[0], xmax)
ymax = max(bbx[1], ymax)
xmin = min(bbx[2], xmin)
ymin = min(bbx[3], ymin)
bitmap_offsets[i] = bitmap_tot
bitmap_tot += len(c['BITMAP'])
c['BITMAP'].reverse()
# Now we can write. Ok if we have no .'s in the path.
f = open(bdf2cpp_name(origfilename), 'w')
f.write('''
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "BMF_FontData.h"
#include "BMF_Settings.h"
''')
f.write('#if BMF_INCLUDE_%s\n\n' % font_name.upper())
f.write('static unsigned char bitmap_data[]= {')
newline = 8
for i, c in enumerate(bdf_dict):
for cdata in c['BITMAP']:
# Just formatting
newline+=1
if newline >= 8:
newline = 0
f.write('\n\t')
# End formatting
f.write('0x%.2hx,' % cdata) # 0x80 <- format
f.write("\n};\n")
f.write("BMF_FontData BMF_font_%s = {\n" % font_name)
f.write('\t%d, %d,\n' % (xmin, ymin))
f.write('\t%d, %d,\n' % (xmax, ymax))
f.write('\t{\n')
for i, c in enumerate(bdf_dict):
if bitmap_offsets[i] == -1 or c.has_key('BBX') == False:
f.write('\t\t{0,0,0,0,0, -1},\n')
else:
bbx = c['BBX']
f.write('\t\t{%d,%d,%d,%d,%d, %d},\n' % (bbx[0], bbx[1], -bbx[2], -bbx[3], c['DWIDTH'], bitmap_offsets[i]))
f.write('''
},
bitmap_data
};
#endif
''')
def main():
# replace "[-name=foo]" with "[-name] [foo]"
args = []
for arg in sys.argv:
for a in arg.replace('=', ' ').split():
args.append(a)
name = 'untitled'
done_anything = False
for i, arg in enumerate(args):
if arg == '-name':
if i==len(args)-1:
print 'no arg given for -name, aborting'
return
else:
name = args[i+1]
elif arg.lower().endswith('.bdf'):
try:
f = open(arg)
print '...Writing to:', bdf2cpp_name(arg)
except:
print 'could not open "%s", aborting' % arg
bdf_dict = parse_bdf(f)
convert_to_blender(bdf_dict, name, arg)
done_anything = True
if not done_anything:
print HELP_TXT
print '...nothing to do'
if __name__ == '__main__':
main()

@ -1 +1 @@
2.46
2.47

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 50 KiB

@ -13,7 +13,7 @@ from Blender import Mesh, Scene, Window, sys, Image, Draw
import BPyMesh
__author__ = "Bruce Merry"
__version__ = "0.92"
__version__ = "0.93"
__bpydoc__ = """\
This script exports Stanford PLY files from Blender. It supports normals,
colours, and texture coordinates per face or per vertex.
@ -37,6 +37,8 @@ Only one mesh can be exported at a time.
# 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
@ -162,7 +164,7 @@ def file_callback(filename):
file.write('ply\n')
file.write('format ascii 1.0\n')
file.write('Created by Blender3D %s - www.blender.org, source file: %s\n' % (Blender.Get('version'), Blender.Get('filename').split('/')[-1].split('\\')[-1] ))
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))
@ -210,7 +212,6 @@ def file_callback(filename):
if faceUV: uvcoord= rvec2d(uv[j])
elif vertexUV: uvcoord= rvec2d(v.uvco)
if vertexColors: color= col[j].r, col[j].g, col[j].b
co = v.co
file.write('%d ' % vdict[v.index][normal, uvcoord, color])

@ -40,8 +40,8 @@ extern "C" {
struct ListBase;
struct MemFile;
#define BLENDER_VERSION 246
#define BLENDER_SUBVERSION 1
#define BLENDER_VERSION 247
#define BLENDER_SUBVERSION 0
#define BLENDER_MINVERSION 245
#define BLENDER_MINSUBVERSION 15

@ -48,9 +48,6 @@
/* Math stuff for ray casting on mesh faces and for nearest surface */
static float nearest_point_in_tri_surface(const float *point, const float *v0, const float *v1, const float *v2, float *nearest);
#define ISECT_EPSILON 1e-6
static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2)
{
float dist;
@ -79,170 +76,324 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
return FLT_MAX;
}
/*
* This calculates the distance from point to the plane
* Distance is negative if point is on the back side of plane
* Function adapted from David Eberly's distance tools (LGPL)
* http://www.geometrictools.com/LibFoundation/Distance/Distance.html
*/
static float point_plane_distance(const float *point, const float *plane_point, const float *plane_normal)
static float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *d, float *nearest )
{
float pp[3];
VECSUB(pp, point, plane_point);
return INPR(pp, plane_normal);
}
static float choose_nearest(const float v0[2], const float v1[2], const float point[2], float closest[2])
{
float d[2][2], sdist[2];
VECSUB2D(d[0], v0, point);
VECSUB2D(d[1], v1, point);
float diff[3];
float e0[3];
float e1[3];
float A00;
float A01;
float A11;
float B0;
float B1;
float C;
float Det;
float S;
float T;
float sqrDist;
int lv = -1, le = -1;
VECSUB(diff, v0, p);
VECSUB(e0, v1, v0);
VECSUB(e1, v2, v0);
A00 = INPR ( e0, e0 );
A01 = INPR( e0, e1 );
A11 = INPR ( e1, e1 );
B0 = INPR( diff, e0 );
B1 = INPR( diff, e1 );
C = INPR( diff, diff );
Det = fabs( A00 * A11 - A01 * A01 );
S = A01 * B1 - A11 * B0;
T = A01 * B0 - A00 * B1;
sdist[0] = d[0][0]*d[0][0] + d[0][1]*d[0][1];
sdist[1] = d[1][0]*d[1][0] + d[1][1]*d[1][1];
if(sdist[0] < sdist[1])
if ( S + T <= Det )
{
if(closest)
VECCOPY2D(closest, v0);
return sdist[0];
if ( S < 0.0f )
{
if ( T < 0.0f ) // Region 4
{
if ( B0 < 0.0f )
{
T = 0.0f;
if ( -B0 >= A00 )
{
S = (float)1.0;
sqrDist = A00 + 2.0f * B0 + C;
lv = 1;
}
else
{
if(fabs(A00) > FLT_EPSILON)
S = -B0/A00;
else
S = 0.0f;
sqrDist = B0 * S + C;
le = 0;
}
}
else
{
S = 0.0f;
if ( B1 >= 0.0f )
{
T = 0.0f;
sqrDist = C;
lv = 0;
}
else if ( -B1 >= A11 )
{
T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C;
lv = 2;
}
else
{
if(fabs(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0f;
sqrDist = B1 * T + C;
le = 1;
}
}
}
else // Region 3
{
S = 0.0f;
if ( B1 >= 0.0f )
{
T = 0.0f;
sqrDist = C;
lv = 0;
}
else if ( -B1 >= A11 )
{
T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C;
lv = 2;
}
else
{
if(fabs(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0;
sqrDist = B1 * T + C;
le = 1;
}
}
}
else if ( T < 0.0f ) // Region 5
{
T = 0.0f;
if ( B0 >= 0.0f )
{
S = 0.0f;
sqrDist = C;
lv = 0;
}
else if ( -B0 >= A00 )
{
S = 1.0f;
sqrDist = A00 + 2.0f * B0 + C;
lv = 1;
}
else
{
if(fabs(A00) > FLT_EPSILON)
S = -B0 / A00;
else
S = 0.0f;
sqrDist = B0 * S + C;
le = 0;
}
}
else // Region 0
{
// Minimum at interior lv
float invDet;
if(fabs(Det) > FLT_EPSILON)
invDet = 1.0f / Det;
else
invDet = 0.0f;
S *= invDet;
T *= invDet;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
}
}
else
{
if(closest)
VECCOPY2D(closest, v1);
return sdist[1];
}
}
/*
* calculates the closest point between point-tri (2D)
* returns that tri must be right-handed
* Returns square distance
*/
static float closest_point_in_tri2D(const float point[2], /*const*/ float tri[3][2], float closest[2])
{
float edge_di[2];
float v_point[2];
float proj[2]; //point projected over edge-dir, edge-normal (witouth normalized edge)
const float *v0 = tri[2], *v1;
float edge_slen, d; //edge squared length
int i;
const float *nearest_vertex = NULL;
float tmp0, tmp1, numer, denom;
//for each edge
for(i=0, v0=tri[2], v1=tri[0]; i < 3; v0=tri[i++], v1=tri[i])
{
VECSUB2D(edge_di, v1, v0);
VECSUB2D(v_point, point, v0);
proj[1] = v_point[0]*edge_di[1] - v_point[1]*edge_di[0]; //dot product with edge normal
//point inside this edge
if(proj[1] < 0)
continue;
proj[0] = v_point[0]*edge_di[0] + v_point[1]*edge_di[1];
//closest to this edge is v0
if(proj[0] < 0)
if ( S < 0.0f ) // Region 2
{
if(nearest_vertex == NULL || nearest_vertex == v0)
nearest_vertex = v0;
tmp0 = A01 + B0;
tmp1 = A11 + B1;
if ( tmp1 > tmp0 )
{
numer = tmp1 - tmp0;
denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom )
{
S = 1.0f;
T = 0.0f;
sqrDist = A00 + 2.0f * B0 + C;
lv = 1;
}
else
{
if(fabs(denom) > FLT_EPSILON)
S = numer / denom;
else
S = 0.0f;
T = 1.0f - S;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
le = 2;
}
}
else
{
//choose nearest
return choose_nearest(nearest_vertex, v0, point, closest);
S = 0.0f;
if ( tmp1 <= 0.0f )
{
T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C;
lv = 2;
}
else if ( B1 >= 0.0f )
{
T = 0.0f;
sqrDist = C;
lv = 0;
}
else
{
if(fabs(A11) > FLT_EPSILON)
T = -B1 / A11;
else
T = 0.0f;
sqrDist = B1 * T + C;
le = 1;
}
}
i++; //We can skip next edge
continue;
}
edge_slen = edge_di[0]*edge_di[0] + edge_di[1]*edge_di[1]; //squared edge len
//closest to this edge is v1
if(proj[0] > edge_slen)
else if ( T < 0.0f ) // Region 6
{
if(nearest_vertex == NULL || nearest_vertex == v1)
nearest_vertex = v1;
tmp0 = A01 + B1;
tmp1 = A00 + B0;
if ( tmp1 > tmp0 )
{
numer = tmp1 - tmp0;
denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom )
{
T = 1.0f;
S = 0.0f;
sqrDist = A11 + 2.0f * B1 + C;
lv = 2;
}
else
{
if(fabs(denom) > FLT_EPSILON)
T = numer / denom;
else
T = 0.0f;
S = 1.0f - T;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
le = 2;
}
}
else
{
return choose_nearest(nearest_vertex, v1, point, closest);
T = 0.0f;
if ( tmp1 <= 0.0f )
{
S = 1.0f;
sqrDist = A00 + 2.0f * B0 + C;
lv = 1;
}
else if ( B0 >= 0.0f )
{
S = 0.0f;
sqrDist = C;
lv = 0;
}
else
{
if(fabs(A00) > FLT_EPSILON)
S = -B0 / A00;
else
S = 0.0f;
sqrDist = B0 * S + C;
le = 0;
}
}
}
else // Region 1
{
numer = A11 + B1 - A01 - B0;
if ( numer <= 0.0f )
{
S = 0.0f;
T = 1.0f;
sqrDist = A11 + 2.0f * B1 + C;
lv = 2;
}
else
{
denom = A00 - 2.0f * A01 + A11;
if ( numer >= denom )
{
S = 1.0f;
T = 0.0f;
sqrDist = A00 + 2.0f * B0 + C;
lv = 1;
}
else
{
if(fabs(denom) > FLT_EPSILON)
S = numer / denom;
else
S = 0.0f;
T = 1.0f - S;
sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) +
T * ( A01 * S + A11 * T + 2.0f * B1 ) + C;
le = 2;
}
}
continue;
}
//nearest is on this edge
d= proj[1] / edge_slen;
closest[0] = point[0] - edge_di[1] * d;
closest[1] = point[1] + edge_di[0] * d;
return proj[1]*proj[1]/edge_slen;
}
if(nearest_vertex)
// Account for numerical round-off error
if ( sqrDist < FLT_EPSILON )
sqrDist = 0.0f;
{
VECSUB2D(v_point, nearest_vertex, point);
VECCOPY2D(closest, nearest_vertex);
return v_point[0]*v_point[0] + v_point[1]*v_point[1];
float w[3], x[3], y[3], z[3];
VECCOPY(w, v0);
VECCOPY(x, e0);
VecMulf(x, S);
VECCOPY(y, e1);
VecMulf(y, T);
VECADD(z, w, x);
VECADD(z, z, y);
VECSUB(d, p, z);
VECCOPY(nearest, z);
// d = p - ( v0 + S * e0 + T * e1 );
}
else
{
VECCOPY(closest, point); //point is already inside
return 0.0f;
}
}
*v = lv;
*e = le;
/*
* Returns the square of the minimum distance between the point and a triangle surface
* If nearest is not NULL the nearest surface point is written on it
*/
static float nearest_point_in_tri_surface(const float *point, const float *v0, const float *v1, const float *v2, float *nearest)
{
//Lets solve the 2D problem (closest point-tri)
float normal_dist, plane_sdist, plane_offset;
float du[3], dv[3], dw[3]; //orthogonal axis (du=(v0->v1), dw=plane normal)
float p_2d[2], tri_2d[3][2], nearest_2d[2];
CalcNormFloat((float*)v0, (float*)v1, (float*)v2, dw);
//point-plane distance and calculate axis
normal_dist = point_plane_distance(point, v0, dw);
// OPTIMIZATION
// if we are only interested in nearest distance if its closer than some distance already found
// we can:
// if(normal_dist*normal_dist >= best_dist_so_far) return FLOAT_MAX;
//
VECSUB(du, v1, v0);
Normalize(du);
Crossf(dv, dw, du);
plane_offset = INPR(v0, dw);
//project stuff to 2d
tri_2d[0][0] = INPR(du, v0);
tri_2d[0][1] = INPR(dv, v0);
tri_2d[1][0] = INPR(du, v1);
tri_2d[1][1] = INPR(dv, v1);
tri_2d[2][0] = INPR(du, v2);
tri_2d[2][1] = INPR(dv, v2);
p_2d[0] = INPR(du, point);
p_2d[1] = INPR(dv, point);
//we always have a right-handed tri
//this should always happen because of the way normal is calculated
plane_sdist = closest_point_in_tri2D(p_2d, tri_2d, nearest_2d);
//project back to 3d
if(nearest)
{
nearest[0] = du[0]*nearest_2d[0] + dv[0] * nearest_2d[1] + dw[0] * plane_offset;
nearest[1] = du[1]*nearest_2d[0] + dv[1] * nearest_2d[1] + dw[1] * plane_offset;
nearest[2] = du[2]*nearest_2d[0] + dv[2] * nearest_2d[1] + dw[2] * plane_offset;
}
return plane_sdist + normal_dist*normal_dist;
return sqrDist;
}
@ -267,23 +418,16 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co,
do
{
float nearest_tmp[3], dist;
float vec[3][3];
float nearest_tmp[3], col_normal[3], dist;
int vertex, edge;
// only insert valid triangles / quads with area > 0
VECSUB(vec[0], t2, t1);
VECSUB(vec[1], t0, t1);
Crossf(vec[2], vec[0], vec[1]);
if(INPR(vec[2], vec[2]) >= FLT_EPSILON)
dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, col_normal, nearest_tmp);
if(dist < nearest->dist)
{
dist = nearest_point_in_tri_surface(co,t0, t1, t2, nearest_tmp);
if(dist < nearest->dist)
{
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
CalcNormFloat((float*)t0, (float*)t1, (float*)t2, nearest->no); //TODO.. (interpolate normals from the vertexs coordinates?
}
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
VECCOPY(nearest->no, col_normal);
}
t1 = t2;

File diff suppressed because it is too large Load Diff

@ -114,6 +114,7 @@ void setflag_armature(short mode);
void unique_editbone_name (struct ListBase *ebones, char *name);
void auto_align_armature(short mode);
void switch_direction_armature(void);
void create_vgroups_from_armature(struct Object *ob, struct Object *par);
void add_verts_to_dgroups(struct Object *ob, struct Object *par, int heat, int mirror);
@ -135,7 +136,6 @@ void transform_armature_mirror_update(void);
void hide_selected_armature_bones(void);
void hide_unselected_armature_bones(void);
void show_all_armature_bones(void);
void set_locks_armature_bones(short lock);
#define BONESEL_ROOT 0x10000000
#define BONESEL_TIP 0x20000000
@ -144,6 +144,10 @@ void set_locks_armature_bones(short lock);
#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */
/* useful macros */
#define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A))
#define EBONE_EDITABLE(ebone) ((ebone->flag & BONE_SELECTED) && !(ebone->flag & BONE_EDITMODE_LOCKED))
/* used in bone_select_hierachy() */
#define BONE_SELECT_PARENT 0
#define BONE_SELECT_CHILD 1

@ -105,6 +105,10 @@
#define EXPP_TEX_LACUNARITY_MAX 6.0f
#define EXPP_TEX_OCTS_MIN 0.0f
#define EXPP_TEX_OCTS_MAX 8.0f
#define EXPP_TEX_OFST_MIN 0.0f
#define EXPP_TEX_OFST_MAX 6.0f
#define EXPP_TEX_GAIN_MIN 0.0f
#define EXPP_TEX_GAIN_MAX 6.0f
#define EXPP_TEX_ISCALE_MIN 0.0f
#define EXPP_TEX_ISCALE_MAX 10.0f
#define EXPP_TEX_EXP_MIN 0.010f
@ -430,6 +434,8 @@ GETFUNC( getNoiseDepth );
GETFUNC( getNoiseSize );
GETFUNC( getNoiseType );
GETFUNC( getOcts );
GETFUNC( getOffset );
GETFUNC( getGain );
GETFUNC( getRepeat );
GETFUNC( getRGBCol );
GETFUNC( getSType );
@ -478,6 +484,8 @@ SETFUNC( setNoiseDepth );
SETFUNC( setNoiseSize );
SETFUNC( setNoiseType );
SETFUNC( setOcts );
SETFUNC( setOffset );
SETFUNC( setGain );
SETFUNC( setRepeat );
SETFUNC( setRGBCol );
SETFUNC( setSType );
@ -646,6 +654,14 @@ static PyGetSetDef BPy_Texture_getseters[] = {
(getter)Texture_getLacunarity, (setter)Texture_setLacunarity,
"Gap between succesive frequencies (for Musgrave textures)",
NULL},
{"offset",
(getter)Texture_getOffset, (setter)Texture_setOffset,
"Fractal offset (for Musgrave textures)",
NULL},
{"gain",
(getter)Texture_getGain, (setter)Texture_setGain,
"Gain multiplier (for Musgrave textures)",
NULL},
{"noiseBasis",
(getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis,
"Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted noise)",
@ -1837,6 +1853,20 @@ static int Texture_setLacunarity( BPy_Texture * self, PyObject * value )
EXPP_TEX_LACUNARITY_MAX );
}
static int Texture_setOffset( BPy_Texture * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->texture->mg_offset,
EXPP_TEX_OFST_MIN,
EXPP_TEX_OFST_MAX );
}
static int Texture_setGain( BPy_Texture * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->texture->mg_gain,
EXPP_TEX_GAIN_MIN,
EXPP_TEX_GAIN_MAX );
}
static int Texture_setOcts( BPy_Texture * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->texture->mg_octaves,
@ -2168,6 +2198,16 @@ static PyObject *Texture_getOcts( BPy_Texture *self )
return PyFloat_FromDouble( self->texture->mg_octaves );
}
static PyObject *Texture_getOffset( BPy_Texture *self )
{
return PyFloat_FromDouble( self->texture->mg_offset );
}
static PyObject *Texture_getGain( BPy_Texture *self )
{
return PyFloat_FromDouble( self->texture->mg_gain );
}
static PyObject *Texture_getRepeat( BPy_Texture *self )
{
return Py_BuildValue( "(i,i)", self->texture->xrepeat,

@ -170,17 +170,6 @@ def SetRenderWinPos(locationList):
the location of the Render window on the screen.
"""
def EnableEdgeShift():
"""
Globally with the unified renderer enabled the outlines of the render
are shifted a bit.
"""
def EnableEdgeAll():
"""
Globally consider transparent faces for edge-rendering with the unified renderer.
"""
class RenderData:
"""
The RenderData object

@ -344,6 +344,12 @@ class Texture:
@ivar octs: Number of frequencies (for Musgrave textures).
Value is clamped to the range [0.0,8.0].
@type octs: float
@ivar offset: Fractal offset (for hetero terrain and multifractal Musgrave textures).
Value is clamped to the range [0.0,6.0].
@type offset: float
@ivar gain: Gain multiplier (for multifractal Musgrave textures).
Value is clamped to the range [0.0,6.0].
@type gain: float
@ivar repeat: Repetition multiplier (for image textures).
@type repeat: tuple of 2 ints
@ivar rgbCol: RGB color tuple.

@ -263,7 +263,12 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shade_input_set_shade_texco(shi);
if(is->mode==RE_RAY_SHADOW_TRA)
shade_color(shi, shr);
if(shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
}
else
shade_color(shi, shr);
else {
if(shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);

@ -1689,7 +1689,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque");
uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, "");
uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, "");
uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-6106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, "");
uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, "");
}
if ( ob->gameflag & OB_DYNAMIC )

@ -854,6 +854,7 @@ static void separate_armature_bones (Object *ob, short sel)
BLI_freelistN(&edbo);
}
/* separate selected bones into their armature */
void separate_armature (void)
{
Object *oldob, *newob;
@ -1094,13 +1095,13 @@ void armature_select_hierarchy(short direction, short add_to_sel)
arm= (bArmature *)ob->data;
for (curbone= G.edbo.first; curbone; curbone= curbone->next) {
if (arm->layer & curbone->layer) {
if (EBONE_VISIBLE(arm, curbone)) {
if (curbone->flag & (BONE_ACTIVE)) {
if (direction == BONE_SELECT_PARENT) {
if (curbone->parent == NULL) continue;
else pabone = curbone->parent;
if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_A)) {
if (EBONE_VISIBLE(arm, pabone)) {
pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
@ -1109,11 +1110,12 @@ void armature_select_hierarchy(short direction, short add_to_sel)
break;
}
} else { // BONE_SELECT_CHILD
}
else { // BONE_SELECT_CHILD
chbone = editbone_get_child(curbone, 1);
if (chbone == NULL) continue;
if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_A)) {
if (EBONE_VISIBLE(arm, chbone)) {
chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
if (!add_to_sel) {
@ -1159,17 +1161,18 @@ void setflag_armature (short mode)
/* get flag to set (sync these with the ones used in eBone_Flag */
if (mode == 2)
flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
else if (mode == 1)
flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
else
flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
switch (flag) {
case 1: flag = BONE_DRAWWIRE; break;
case 2: flag = BONE_NO_DEFORM; break;
case 3: flag = BONE_MULT_VG_ENV; break;
case 4: flag = BONE_HINGE; break;
case 5: flag = BONE_NO_SCALE; break;
case 6: flag = BONE_EDITMODE_LOCKED; break;
default: return;
}
@ -1725,12 +1728,12 @@ void auto_align_armature(short mode)
float *cursor= give_cursor();
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (arm->flag & ARM_MIRROR_EDIT)
flipbone = armature_bone_get_mirrored(ebone);
if ((ebone->flag & BONE_SELECTED) ||
(flipbone && flipbone->flag & BONE_SELECTED))
(flipbone && (flipbone->flag & BONE_SELECTED)))
{
/* specific method used to calculate roll depends on mode */
if (mode == 1) {
@ -1975,7 +1978,7 @@ void addvert_armature(void)
/* find the active or selected bone */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_ACTIVE|BONE_TIPSEL))
break;
}
@ -1983,7 +1986,7 @@ void addvert_armature(void)
if (ebone==NULL) {
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_ACTIVE|BONE_ROOTSEL))
break;
}
@ -2066,11 +2069,12 @@ static EditBone *get_named_editbone(char *name)
{
EditBone *eBone;
if (name)
if (name) {
for (eBone=G.edbo.first; eBone; eBone=eBone->next) {
if (!strcmp(name, eBone->name))
return eBone;
}
}
return NULL;
}
@ -2136,7 +2140,7 @@ void adduplicate_armature(void)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
for (curBone=G.edbo.first; curBone; curBone=curBone->next) {
if (arm->layer & curBone->layer) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
eBone = armature_bone_get_mirrored(curBone);
if (eBone)
@ -2148,13 +2152,13 @@ void adduplicate_armature(void)
/* Find the selected bones and duplicate them as needed */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
if (arm->layer & curBone->layer) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
eBone=MEM_callocN(sizeof(EditBone), "addup_editbone");
eBone->flag |= BONE_SELECTED;
/* Copy data from old bone to new bone */
memcpy (eBone, curBone, sizeof(EditBone));
memcpy(eBone, curBone, sizeof(EditBone));
curBone->temp = eBone;
eBone->temp = curBone;
@ -2204,7 +2208,7 @@ void adduplicate_armature(void)
/* Run though the list and fix the pointers */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
if (arm->layer & curBone->layer) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
eBone=(EditBone*) curBone->temp;
@ -2236,7 +2240,7 @@ void adduplicate_armature(void)
/* Deselect the old bones and select the new ones */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
if (arm->layer & curBone->layer)
if (EBONE_VISIBLE(arm, curBone))
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE);
}
@ -2373,7 +2377,7 @@ void fill_bones_armature(void)
/* loop over all bones, and only consider if visible */
for (ebo= G.edbo.first; ebo; ebo= ebo->next) {
if ((arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A)) {
if (EBONE_VISIBLE(arm, ebo)) {
if (!(ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL))
fill_add_joint(ebo, 0, &points);
if (ebo->flag & BONE_TIPSEL)
@ -2608,7 +2612,7 @@ void merge_armature(void)
/* only consider bones that are visible and selected */
for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) {
/* check if visible + selected */
if ( (arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A) &&
if ( EBONE_VISIBLE(arm, ebo) &&
((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
(ebo->flag & (BONE_SELECTED|BONE_ACTIVE)) )
{
@ -2659,7 +2663,7 @@ void hide_selected_armature_bones(void)
EditBone *ebone;
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_SELECTED)) {
ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL|BONE_ACTIVE);
ebone->flag |= BONE_HIDDEN_A;
@ -2678,7 +2682,7 @@ void hide_unselected_armature_bones(void)
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
bArmature *arm= G.obedit->data;
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL));
else {
ebone->flag &= ~BONE_ACTIVE;
@ -2711,32 +2715,6 @@ void show_all_armature_bones(void)
BIF_undo_push("Reveal Bones");
}
/* Sets editmode transform locks for bones (adds if lock==1, clears otherwise) */
void set_locks_armature_bones(short lock)
{
bArmature *arm= G.obedit->data;
EditBone *ebone;
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_SELECTED) {
if (lock)
ebone->flag |= BONE_EDITMODE_LOCKED;
else
ebone->flag &= ~BONE_EDITMODE_LOCKED;
}
}
}
countall();
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
if (lock)
BIF_undo_push("Lock Bones");
else
BIF_undo_push("Unlock Bones");
}
/* check for null, before calling! */
static void bone_connect_to_existing_parent(EditBone *bone)
{
@ -2803,7 +2781,7 @@ void make_bone_parent(void)
/* find active bone to parent to */
for (actbone = G.edbo.first; actbone; actbone=actbone->next) {
if (arm->layer & actbone->layer) {
if (EBONE_VISIBLE(arm, actbone)) {
if (actbone->flag & BONE_ACTIVE)
break;
}
@ -2815,7 +2793,7 @@ void make_bone_parent(void)
/* find selected bones */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if ((ebone->flag & BONE_SELECTED) && (ebone != actbone)) {
foundselbone++;
if (ebone->parent != actbone) allchildbones= 1;
@ -2851,7 +2829,7 @@ void make_bone_parent(void)
else {
/* loop through all editbones, parenting all selected bones to the active bone */
for (selbone = G.edbo.first; selbone; selbone=selbone->next) {
if (arm->layer & selbone->layer) {
if (EBONE_VISIBLE(arm, selbone)) {
if ((selbone->flag & BONE_SELECTED) && (selbone!=actbone)) {
/* parent selbone to actbone */
bone_connect_to_new_parent(selbone, actbone, val);
@ -2909,7 +2887,7 @@ void clear_bone_parent(void)
if (val<1) return;
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
if (arm->flag & ARM_MIRROR_EDIT)
flipbone = armature_bone_get_mirrored(ebone);
@ -2959,7 +2937,7 @@ void unique_editbone_name (ListBase *ebones, char *name)
}
for (number = 1; number <=999; number++) {
sprintf (tempname, "%s.%03d", name, number);
sprintf(tempname, "%s.%03d", name, number);
if (!editbone_name_exists(ebones, tempname)) {
BLI_strncpy(name, tempname, 32);
return;
@ -2980,7 +2958,7 @@ void extrude_armature(int forked)
/* since we allow root extrude too, we have to make sure selection is OK */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
if (ebone->parent->flag & BONE_TIPSEL)
@ -2992,7 +2970,7 @@ void extrude_armature(int forked)
/* Duplicate the necessary bones */
for (ebone = G.edbo.first; ((ebone) && (ebone!=first)); ebone=ebone->next) {
if (arm->layer & ebone->layer) {
if (EBONE_VISIBLE(arm, ebone)) {
/* we extrude per definition the tip */
do_extrude= 0;
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED))
@ -3006,7 +2984,7 @@ void extrude_armature(int forked)
if (do_extrude) {
/* we re-use code for mirror editing... */
flipbone= NULL;
if(arm->flag & ARM_MIRROR_EDIT) {
if (arm->flag & ARM_MIRROR_EDIT) {
flipbone= armature_bone_get_mirrored(ebone);
if (flipbone) {
forked= 0; // we extrude 2 different bones
@ -3036,7 +3014,7 @@ void extrude_armature(int forked)
newbone->parent = ebone;
newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
else {
@ -3046,7 +3024,7 @@ void extrude_armature(int forked)
newbone->flag= BONE_TIPSEL;
if (newbone->parent && ebone->flag & BONE_CONNECTED) {
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED;
}
}
@ -3065,8 +3043,8 @@ void extrude_armature(int forked)
BLI_strncpy (newbone->name, ebone->name, 32);
if (flipbone && forked) { // only set if mirror edit
if(strlen(newbone->name)<30) {
if(a==0) strcat(newbone->name, "_L");
if (strlen(newbone->name)<30) {
if (a==0) strcat(newbone->name, "_L");
else strcat(newbone->name, "_R");
}
}
@ -3111,7 +3089,7 @@ void subdivide_armature(int numcuts)
if (numcuts < 1) return;
for (mbone = G.edbo.last; mbone; mbone= mbone->prev) {
if (arm->layer & mbone->layer) {
if (EBONE_VISIBLE(arm, mbone)) {
if (mbone->flag & BONE_SELECTED) {
for (i=numcuts+1; i>1; i--) {
/* compute cut ratio first */
@ -3176,6 +3154,59 @@ void subdivide_armature(int numcuts)
else BIF_undo_push("Subdivide multi");
}
/* switch direction of bone chains */
void switch_direction_armature (void)
{
bArmature *arm= (G.obedit) ? G.obedit->data : NULL;
ListBase chains = {NULL, NULL};
LinkData *chain;
/* error checking paranoia */
if (arm == NULL)
return;
/* get chains of bones (ends on chains) */
chains_find_tips(&chains);
if (chains.first == NULL) return;
/* loop over chains, only considering selected and visible bones */
for (chain= chains.first; chain; chain= chain->next) {
EditBone *ebo, *child=NULL, *parent=NULL;
/* loop over bones in chain */
for (ebo= chain->data; ebo; child= ebo, ebo=parent) {
parent= ebo->parent;
/* only if selected and editable */
if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
/* swap head and tail coordinates */
SWAP(float, ebo->head[0], ebo->tail[0]);
SWAP(float, ebo->head[1], ebo->tail[1]);
SWAP(float, ebo->head[2], ebo->tail[2]);
/* do parent swapping:
* - use 'child' as new parent
* - connected flag is only set if points are coincidental
*/
ebo->parent= child;
if ((child) && VecEqual(ebo->head, child->tail))
ebo->flag |= BONE_CONNECTED;
else
ebo->flag &= ~BONE_CONNECTED;
/* FIXME: other things that need fixing?
* i.e. roll?
*/
}
}
}
/* free chains */
BLI_freelistN(&chains);
BIF_undo_push("Switch Direction");
}
/* ***************** Pose tools ********************* */
void clear_armature(Object *ob, char mode)

@ -2760,7 +2760,7 @@ void special_editmenu(void)
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
}
else if(G.obedit->type==OB_ARMATURE) {
nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6|%l|Lock%x7|Unlock%x8");
nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Switch Direction%x7|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6");
if(nr==1)
subdivide_armature(1);
if(nr==2) {
@ -2773,10 +2773,8 @@ void special_editmenu(void)
else if(ELEM3(nr, 4, 5, 6)) {
armature_autoside_names(nr-4);
}
else if(nr==7)
set_locks_armature_bones(1);
else if(nr==8)
set_locks_armature_bones(0);
else if(nr == 7)
switch_direction_armature();
}
else if(G.obedit->type==OB_LATTICE) {
static float weight= 1.0f;

@ -5139,7 +5139,7 @@ static char *snapmode_pup(void)
static char string[512];
char *str = string;
str += sprintf(str, "%s", "Snap Mode: %t");
str += sprintf(str, "%s", "Snap Element: %t");
str += sprintf(str, "%s", "|Vertex%x0");
str += sprintf(str, "%s", "|Edge%x1");
str += sprintf(str, "%s", "|Face%x2");
@ -5777,7 +5777,7 @@ void view3d_buttons(void)
xco+= XIC;
uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_VERTEXSEL, snapmode_pup(), xco,0,XIC+10,YIC, &(G.scene->snap_mode), 0.0, 0.0, 0, 0, "Snapping mode");
xco+= XIC;
uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2|Active%x3",xco,0,70,YIC, &G.scene->snap_target, 0, 0, 0, 0, "Snap Target Mode");
uiDefButS(block, MENU, B_NOP, "Snap Mode%t|Closest%x0|Center%x1|Median%x2|Active%x3",xco,0,70,YIC, &G.scene->snap_target, 0, 0, 0, 0, "Snap Target Mode");
xco+= 70;
} else {
uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,0,XIC,YIC, &G.scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)");

File diff suppressed because it is too large Load Diff

@ -913,8 +913,8 @@ static void createTransPose(TransInfo *t, Object *ob)
if (arm==NULL || ob->pose==NULL) return;
if (arm->flag & ARM_RESTPOS) {
if(t->mode!=TFM_BONESIZE) {
notice ("Pose edit not possible while Rest Position is enabled");
if(ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) {
notice("Pose edit not possible while Rest Position is enabled");
return;
}
}

@ -484,17 +484,10 @@ char BL_ActionActuator::GetAction_doc[] =
PyObject* BL_ActionActuator::PyGetAction(PyObject* self,
PyObject* args,
PyObject* kwds) {
PyObject *result;
if (m_action){
result = Py_BuildValue("s", m_action->id.name+2);
return PyString_FromString(m_action->id.name+2);
}
else{
Py_INCREF(Py_None);
result = Py_None;
}
return result;
Py_RETURN_NONE;
}
/* getProperty */
@ -640,8 +633,7 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setStart */
@ -662,8 +654,7 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setEnd */
@ -684,8 +675,7 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setBlendin */
@ -707,8 +697,7 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setBlendtime */
@ -735,8 +724,7 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setPriority */
@ -759,8 +747,7 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setFrame */
@ -785,8 +772,7 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setProperty */
@ -808,8 +794,7 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setFrameProperty */
@ -830,8 +815,7 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/*
@ -848,8 +832,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self,
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
*/
@ -934,8 +917,7 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
}
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* getType */

@ -464,17 +464,10 @@ char BL_ShapeActionActuator::GetAction_doc[] =
"\tReturns a string containing the name of the current action.\n";
PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) {
PyObject *result;
if (m_action){
result = Py_BuildValue("s", m_action->id.name+2);
return PyString_FromString(m_action->id.name+2);
}
else{
Py_INCREF(Py_None);
result = Py_None;
}
return result;
Py_RETURN_NONE;
}
/* getProperty */
@ -591,12 +584,10 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self,
}
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setStart */
@ -614,12 +605,10 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self,
m_startframe = start;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setEnd */
@ -637,12 +626,10 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self,
m_endframe = end;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setBlendin */
@ -661,12 +648,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self,
m_blendin = blendin;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setBlendtime */
@ -690,12 +675,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self,
m_blendframe = m_blendin;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setPriority */
@ -715,12 +698,10 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self,
m_priority = priority;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setFrame */
@ -742,12 +723,10 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self,
m_localtime=m_endframe;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* setProperty */
@ -766,12 +745,10 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self,
m_propname = string;
}
else {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
/* getType */
@ -793,7 +770,6 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self,
short typeArg;
if (!PyArg_ParseTuple(args, "h", &typeArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}

@ -540,9 +540,16 @@ void BL_ConvertActuators(char* maggiename,
// does the 'original' for replication exists, and
// is it in a non-active layer ?
SCA_IObject* originalval = NULL;
if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo))
originalval = converter->FindGameObject(editobact->ob);
if (editobact->ob)
{
if (editobact->ob->lay & activeLayerBitInfo)
{
fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
}
else {
originalval = converter->FindGameObject(editobact->ob);
}
}
MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]),
KX_BLENDERTRUNC(editobact->linVelocity[1]),
KX_BLENDERTRUNC(editobact->linVelocity[2]));

@ -631,7 +631,8 @@ void CParser::SetContext(CValue* context)
PyObject* CParserPyMake(PyObject* ignored,PyObject* args)
{
char* txt;
Py_Try(PyArg_ParseTuple(args,"s",&txt));
if (!PyArg_ParseTuple(args,"s",&txt))
return NULL;
CParser parser;
CExpression* expr = parser.ProcessText(txt);
CValue* val = expr->Calculate();
@ -641,7 +642,7 @@ PyObject* CParserPyMake(PyObject* ignored,PyObject* args)
static PyMethodDef CParserMethods[] =
{
{ "calc", CParserPyMake , Py_NEWARGS},
{ "calc", CParserPyMake , METH_VARARGS},
{ NULL,NULL} // Sentinel
};

@ -43,7 +43,7 @@ PyObject* listvalue_buffer_item(PyObject* list,Py_ssize_t index)
return ((CListValue*) list)->GetValue(index)->AddRef();
}
Py_Error(PyExc_IndexError, "Python ListIndex out of range");
PyErr_SetString(PyExc_IndexError, "Python ListIndex out of range");
return NULL;
}
@ -130,9 +130,10 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
}
}
if (error)
Py_Error(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");
if (error) {
PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");
return NULL;
}
} else
{
@ -155,8 +156,8 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
listval->Add(objval);
} else
{
Py_Error(PyExc_SystemError, "Python Error: couldn't add item to a list");
// bad luck
PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add item to a list");
return NULL;
}
}
}

@ -94,7 +94,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor
* PyObjectPlus Methods -- Every class, even the abstract one should have a Methods
------------------------------*/
PyMethodDef PyObjectPlus::Methods[] = {
{"isA", (PyCFunction) sPy_isA, Py_NEWARGS},
{"isA", (PyCFunction) sPy_isA, METH_VARARGS},
{NULL, NULL} /* Sentinel */
};
@ -134,7 +134,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
------------------------------*/
PyObject *PyObjectPlus::_repr(void)
{
Py_Error(PyExc_SystemError, "Representation not overridden by object.");
PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");
return NULL;
}
/*------------------------------
@ -164,11 +165,12 @@ bool PyObjectPlus::isA(const char *mytypename) // check typename of each parent
PyObject *PyObjectPlus::Py_isA(PyObject *args) // Python wrapper for isA
{
char *mytypename;
Py_Try(PyArg_ParseTuple(args, "s", &mytypename));
if (!PyArg_ParseTuple(args, "s", &mytypename))
return NULL;
if(isA(mytypename))
{Py_INCREF(Py_True); return Py_True;}
Py_RETURN_TRUE;
else
{Py_INCREF(Py_False); return Py_False;};
Py_RETURN_FALSE;
}
#endif //NO_EXP_PYTHON_EMBEDDING

@ -44,22 +44,7 @@
------------------------------*/
// some basic python macros
#define Py_NEWARGS 1
#define Py_Return { Py_INCREF(Py_None); return Py_None;}
static inline PyObject* Py_Success(bool truth)
{
if (truth)
{
Py_INCREF(Py_True);
return Py_True;
}
Py_INCREF(Py_False);
return Py_False;
}
#define Py_Error(E, M) {PyErr_SetString(E, M); return NULL;}
#define Py_Try(F) {if (!(F)) return NULL;}
#define Py_Assert(A,E,M) {if (!(A)) {PyErr_SetString(E, M); return NULL;}}
static inline void Py_Fatal(char *M) {
//cout << M << endl;
@ -136,6 +121,13 @@ static inline void Py_Fatal(char *M) {
}; \
static char method_name##_doc[]; \
#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
PyObject* Py##method_name(PyObject* self, PyObject* args); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
return ((class_name*) self)->Py##method_name(self, args); \
}; \
static char method_name##_doc[]; \
#define KX_PYMETHOD_DOC_O(class_name, method_name) \
PyObject* Py##method_name(PyObject* self, PyObject* value); \
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \

@ -158,15 +158,14 @@ PyParentObject CValue::Parents[] = {
};
PyMethodDef CValue::Methods[] = {
// { "printHello", (PyCFunction) CValue::sPyPrintHello, Py_NEWARGS},
{ "getName", (PyCFunction) CValue::sPyGetName, Py_NEWARGS},
// { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS},
{ "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS},
{NULL,NULL} //Sentinel
};
PyObject* CValue::PyGetName(PyObject* self,PyObject* args,PyObject* kwds)
PyObject* CValue::PyGetName(PyObject* self)
{
PyObject* pyname = PyString_FromString(this->GetName());
return pyname;
return PyString_FromString(this->GetName());
}
/*#define CVALUE_DEBUG*/
@ -662,7 +661,7 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername)
static PyMethodDef CValueMethods[] =
{
//{ "new", CValue::PyMake , Py_NEWARGS},
//{ "new", CValue::PyMake , METH_VARARGS},
{ NULL,NULL} // Sentinel
};
@ -700,9 +699,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
CValue* vallie = NULL;
PyTypeObject* type = pyobj->ob_type;
if (type == &PyList_Type)
if (PyList_Check(pyobj))
{
CListValue* listval = new CListValue();
bool error = false;
@ -732,26 +729,25 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
}
} else
if (type == &PyFloat_Type)
if (PyFloat_Check(pyobj))
{
float fl;
PyArg_Parse(pyobj,"f",&fl);
vallie = new CFloatValue(fl);
vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) );
} else
if (type==&PyInt_Type)
if (PyInt_Check(pyobj))
{
int innie;
PyArg_Parse(pyobj,"i",&innie);
vallie = new CIntValue(innie);
vallie = new CIntValue( (int)PyInt_AS_LONG(pyobj) );
} else
if (type==&PyString_Type)
if (PyString_Check(pyobj))
{
vallie = new CStringValue(PyString_AsString(pyobj),"");
} else
if (type==&CValue::Type || type==&CListValue::Type)
if (pyobj->ob_type==&CValue::Type || pyobj->ob_type==&CListValue::Type)
{
vallie = ((CValue*) pyobj)->AddRef();
} else
{
/* return an error value from the caller */
PyErr_SetString(PyExc_TypeError, "This python value could not be assigned to a game engine property");
}
return vallie;
@ -778,6 +774,9 @@ int CValue::_setattr(const STR_String& attr,PyObject* pyobj)
SetProperty(attr,vallie);
}
vallie->Release();
} else
{
return 1; /* ConvertPythonToValue sets the error message */
}
//PyObjectPlus::_setattr(attr,value);
@ -806,9 +805,8 @@ PyObject* CValue::ConvertKeysToPython( void )
PyObject* CValue::PyMake(PyObject* ignored,PyObject* args)
{
//Py_Try(PyArg_ParseTuple(args,"s",&name));
Py_INCREF(Py_None);
return Py_None;//new CValue();
//if (!PyArg_ParseTuple(args,"s",&name)) return NULL;
Py_RETURN_NONE;//new CValue();
}
*/

@ -255,7 +255,7 @@ public:
virtual PyObject* ConvertKeysToPython( void );
KX_PYMETHOD(CValue,GetName);
KX_PYMETHOD_NOARGS(CValue,GetName);
#else
CValue();

@ -180,7 +180,6 @@ PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyOb
char *actNameArg = NULL;
if (!PyArg_ParseTuple(args, "s", &actNameArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}

@ -271,8 +271,7 @@ PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self)
}
printf("ERROR: Python scriptblock without owner\n");
Py_INCREF(Py_None);
return Py_None;//Int_FromLong(IsPositiveTrigger());
Py_RETURN_NONE; //Int_FromLong(IsPositiveTrigger());
}

@ -273,36 +273,16 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* break it by hand, then DECREF (which in this case
* should always ensure excdict is cleared).
*/
/* PyObject *excdict= myPyDict_Copy(m_pythondictionary);
struct _object* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
excdict,
excdict
);
PyDict_Clear(excdict);
Py_DECREF(excdict);*/
#if 1
PyObject *excdict= PyDict_Copy(m_pythondictionary);
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
excdict,
excdict
);
PyDict_Clear(excdict);
Py_DECREF(excdict);
#else
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
m_pythondictionary,
m_pythondictionary
);
#endif
excdict, excdict);
if (resultobj)
{
Py_DECREF(resultobj);
} else
}
else
{
// something is wrong, tell the user what went wrong
printf("PYTHON SCRIPT ERROR:\n");
@ -310,6 +290,11 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
//PyRun_SimpleString(m_scriptText.Ptr());
}
// clear after PyErrPrint - seems it can be using
// something in this dictionary and crash?
PyDict_Clear(excdict);
Py_DECREF(excdict);
m_sCurrentController = NULL;
}

@ -846,8 +846,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
if(mShader==0) {
PyErr_Format(PyExc_TypeError, "invalid shader object");
@ -877,8 +876,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
@ -900,7 +898,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
//else
// spit("Invalid texture sample index: " << index);
}
Py_Return;
Py_RETURN_NONE;
}
return NULL;
}
@ -919,8 +917,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
@ -945,8 +942,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
float array[2]={ 0,0 };
@ -970,8 +966,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
float array[3]={0,0,0};
@ -996,8 +991,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
float array[4]={0,0,0,0};
@ -1021,8 +1015,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) "
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
int value=0;
@ -1046,8 +1039,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
int array[2]={ 0,0 };
@ -1071,8 +1063,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
@ -1096,8 +1087,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";
int array[4]={0,0,0, 0};
@ -1120,8 +1110,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) "
KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char*uniform = "";
PyObject *listPtr =0;
@ -1190,8 +1179,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis
KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )")
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char*uniform = "";
PyObject *listPtr =0;
@ -1263,8 +1251,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4,
"setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
float matr[16] = {
@ -1306,8 +1293,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
"setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
float matr[9] = {
@ -1347,8 +1333,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
int attr=0;
if(PyArg_ParseTuple(args, "i", &attr )) {
@ -1368,8 +1353,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" )
{
if(mError) {
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
char *uniform="";

@ -395,8 +395,8 @@ PyParentObject KX_CameraActuator::Parents[] = {
};
PyMethodDef KX_CameraActuator::Methods[] = {
{"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_VARARGS, SetObject_doc},
{"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_NOARGS, GetObject_doc},
{"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, SetObject_doc},
{"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
{"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc},
{"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc},
{"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc},
@ -413,50 +413,43 @@ PyObject* KX_CameraActuator::_getattr(const STR_String& attr) {
}
/* get obj ---------------------------------------------------------- */
char KX_CameraActuator::GetObject_doc[] =
"getObject\n"
"getObject(name_only = 1)\n"
"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the object this sensor reacts to.\n";
PyObject* KX_CameraActuator::PyGetObject(PyObject* self,
PyObject* args,
PyObject* kwds)
PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args)
{
return PyString_FromString(m_ob->GetName());
int ret_name_only = 1;
if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
return NULL;
if (!m_ob)
Py_RETURN_NONE;
if (ret_name_only)
return PyString_FromString(m_ob->GetName());
else
return m_ob->AddRef();
}
/* set obj ---------------------------------------------------------- */
char KX_CameraActuator::SetObject_doc[] =
"setObject\n"
"setObject(object)\n"
"\t- object: KX_GameObject, string or None\n"
"\tSets the object this sensor reacts to.\n";
PyObject* KX_CameraActuator::PySetObject(PyObject* self,
PyObject* args,
PyObject* kwds)
PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value)
{
PyObject* gameobj;
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
{
if (m_ob)
m_ob->UnregisterActuator(this);
m_ob = (SCA_IObject*)gameobj;
if (m_ob)
m_ob->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
KX_GameObject *gameobj;
char* objectname;
if (PyArg_ParseTuple(args, "s", &objectname))
{
SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));
if(object)
{
if (m_ob != NULL)
m_ob->UnregisterActuator(this);
m_ob = object;
m_ob->RegisterActuator(this);
Py_Return;
}
}
if (!ConvertPythonToGameObject(value, &gameobj, true))
return NULL; // ConvertPythonToGameObject sets the error
return NULL;
if (m_ob != NULL)
m_ob->UnregisterActuator(this);
m_ob = (SCA_IObject*)gameobj;
if (m_ob)
m_ob->RegisterActuator(this);
Py_RETURN_NONE;
}
/* get min ---------------------------------------------------------- */

@ -123,9 +123,9 @@ private :
virtual PyObject* _getattr(const STR_String& attr);
/* set object to look at */
KX_PYMETHOD_DOC(KX_CameraActuator,SetObject);
KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
/* get current object */
KX_PYMETHOD_DOC(KX_CameraActuator,GetObject);
KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,GetObject);
KX_PYMETHOD_DOC(KX_CameraActuator,SetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,GetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,SetMax);

@ -476,7 +476,6 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self,
PyObject* kwds) {
int dampArg;
if(!PyArg_ParseTuple(args, "i", &dampArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -504,7 +503,6 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self,
PyObject* kwds) {
int dampArg;
if(!PyArg_ParseTuple(args, "i", &dampArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -534,7 +532,6 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self,
MT_Vector3 dir;
if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
dir[0] = x;
@ -577,7 +574,6 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self,
PyObject* kwds) {
int option;
if(!PyArg_ParseTuple(args, "i", &option)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -605,7 +601,6 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self,
PyObject* kwds) {
int t;
if(!PyArg_ParseTuple(args, "i", &t)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -634,7 +629,6 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self,
PyObject* kwds) {
char *property;
if (!PyArg_ParseTuple(args, "s", &property)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
if (property == NULL) {
@ -670,7 +664,6 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self,
PyObject* kwds) {
float minArg;
if(!PyArg_ParseTuple(args, "f", &minArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -716,7 +709,6 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self,
PyObject* kwds){
float maxArg;
if(!PyArg_ParseTuple(args, "f", &maxArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -770,7 +762,6 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self,
PyObject* kwds) {
int locrotArg;
if(!PyArg_ParseTuple(args, "i", &locrotArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}

@ -53,8 +53,7 @@ PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* self,
PyObject* kwds)
{
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self,

@ -942,7 +942,7 @@ PyObject* KX_GameObject::PyEndObject(PyObject* self)
KX_Scene *scene = PHY_GetActiveScene();
scene->DelayedRemoveObject(this);
return Py_None;
Py_RETURN_NONE;
}
@ -1551,9 +1551,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
PyErr_Clear();
PyObject *pyother;
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother))
KX_GameObject *other;
if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
{
KX_GameObject *other = static_cast<KX_GameObject*>(pyother);
return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition()));
}
@ -1574,11 +1574,12 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo,
if (!PyVecArgTo(args, toPoint))
{
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother))
KX_GameObject *other;
if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
{
KX_GameObject *other = static_cast<KX_GameObject*>(pyother);
toPoint = other->NodeGetWorldPosition();
}else
} else
{
PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type");
return NULL;
@ -1648,12 +1649,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
{
KX_GameObject *other;
PyErr_Clear();
if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) {
if (ConvertPythonToGameObject(pyarg, &other, false))
{
toPoint = other->NodeGetWorldPosition();
} else
{
PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject");
return NULL;
}
other = static_cast<KX_GameObject*>(pyarg);
toPoint = other->NodeGetWorldPosition();
}
MT_Point3 fromPoint = NodeGetWorldPosition();
if (dist != 0.0f)
@ -1712,12 +1716,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
if (!PyVecTo(pyto, toPoint))
{
PyErr_Clear();
if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) {
if (ConvertPythonToGameObject(pyto, &other, false))
{
toPoint = other->NodeGetWorldPosition();
} else
{
PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject");
return NULL;
}
other = static_cast<KX_GameObject*>(pyto);
toPoint = other->NodeGetWorldPosition();
}
if (!pyfrom || pyfrom == Py_None)
{
@ -1726,12 +1733,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
else if (!PyVecTo(pyfrom, fromPoint))
{
PyErr_Clear();
if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) {
if (ConvertPythonToGameObject(pyfrom, &other, false))
{
fromPoint = other->NodeGetWorldPosition();
} else
{
PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject");
return NULL;
}
other = static_cast<KX_GameObject*>(pyfrom);
fromPoint = other->NodeGetWorldPosition();
}
if (dist != 0.0f) {
@ -1798,3 +1808,49 @@ void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter)
}
}
bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok)
{
if (value==NULL) {
PyErr_SetString(PyExc_TypeError, "Error in ConvertPythonToGameObject, python pointer NULL, should never happen");
*object = NULL;
return false;
}
if (value==Py_None) {
*object = NULL;
if (py_none_ok) {
return true;
} else {
PyErr_SetString(PyExc_TypeError, "Expected KX_GameObject or a string for a name of a KX_GameObject, None is invalid");
return false;
}
return (py_none_ok ? true : false);
}
if (PyString_Check(value)) {
*object = (KX_GameObject *)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( PyString_AsString(value) ));
if (*object) {
return true;
} else {
PyErr_SetString(PyExc_ValueError, "Requested name did not match any KX_GameObject");
return false;
}
}
if (PyObject_TypeCheck(value, &KX_GameObject::Type)) {
*object = static_cast<KX_GameObject*>(value);
return true;
}
*object = NULL;
if (py_none_ok) {
PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject, a string or None");
} else {
PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject or a string");
}
return false;
}

@ -48,6 +48,7 @@
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
#include "KX_IPhysicsController.h" /* for suspend/resume */
#include "DNA_object_types.h"
#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
#define KX_OB_DYNAMIC 1
@ -775,5 +776,8 @@ private :
};
/* utility conversion function */
bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok);
#endif //__KX_GAMEOBJECT

@ -480,7 +480,6 @@ PyObject* KX_IpoActuator::PySet(PyObject* self,
int startFrame, stopFrame;
if(!PyArg_ParseTuple(args, "siii", &mode, &startFrame,
&stopFrame, &forceToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
modenum = string2mode(mode);
@ -516,7 +515,6 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self,
/* args: property */
char *propertyName;
if(!PyArg_ParseTuple(args, "s", &propertyName)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -535,7 +533,6 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self,
PyObject* kwds) {
float startArg;
if(!PyArg_ParseTuple(args, "f", &startArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -561,7 +558,6 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self,
PyObject* kwds) {
float endArg;
if(!PyArg_ParseTuple(args, "f", &endArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -588,7 +584,6 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self,
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -617,7 +612,6 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self,
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -646,7 +640,6 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self,
int typeArg;
if (!PyArg_ParseTuple(args, "i", &typeArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
@ -678,7 +671,6 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self,
int boolArg;
if (!PyArg_ParseTuple(args, "i", &boolArg)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}

@ -238,5 +238,5 @@ KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
"Reinstance the physics mesh.")
{
//this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ?
return Py_None;//Py_Success(KX_ReInstanceShapeFromMesh(m_meshobj));
Py_RETURN_NONE;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE;
}

@ -360,7 +360,6 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self,
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_force.setValue(vecArg);
@ -390,7 +389,6 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self,
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_torque.setValue(vecArg);
@ -420,7 +418,6 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self,
int bToggle = 0;
if(!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_dloc.setValue(vecArg);
@ -450,7 +447,6 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self,
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_drot.setValue(vecArg);
@ -479,7 +475,6 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self,
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_linear_velocity.setValue(vecArg);
@ -508,7 +503,6 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self,
int bToggle = 0;
if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1],
&vecArg[2], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_angular_velocity.setValue(vecArg);
@ -523,7 +517,6 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* self,
PyObject* kwds) {
int damping = 0;
if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_damping = damping;
@ -553,7 +546,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self,
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_drot[0] = vecArg[0];
@ -581,7 +573,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self,
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_drot[1] = vecArg[0];
@ -609,7 +600,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self,
float vecArg[2];
int bToggle = 0;
if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_drot[2] = vecArg[0];
@ -636,7 +626,6 @@ PyObject* KX_ObjectActuator::PySetPID(PyObject* self,
{
float vecArg[3];
if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) {
PyErr_SetString(PyExc_TypeError, "Invalid arguments");
return NULL;
}
m_torque.setValue(vecArg);

@ -164,7 +164,7 @@ PyParentObject KX_ParentActuator::Parents[] = {
};
PyMethodDef KX_ParentActuator::Methods[] = {
{"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_VARARGS, SetObject_doc},
{"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, SetObject_doc},
{"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
{NULL,NULL} //Sentinel
};
@ -176,44 +176,44 @@ PyObject* KX_ParentActuator::_getattr(const STR_String& attr) {
/* 1. setObject */
char KX_ParentActuator::SetObject_doc[] =
"setObject(object)\n"
"\tSet the object to set as parent.\n"
"\tCan be an object name or an object\n";
PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) {
PyObject* gameobj;
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
{
if (m_ob != NULL)
m_ob->UnregisterActuator(this);
m_ob = (SCA_IObject*)gameobj;
if (m_ob)
m_ob->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
"\t- object: KX_GameObject, string or None\n"
"\tSet the object to set as parent.\n";
PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* value) {
KX_GameObject *gameobj;
char* objectname;
if (PyArg_ParseTuple(args, "s", &objectname))
{
SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));
if(object)
{
if (m_ob != NULL)
m_ob->UnregisterActuator(this);
m_ob = object;
m_ob->RegisterActuator(this);
Py_Return;
}
}
if (!ConvertPythonToGameObject(value, &gameobj, true))
return NULL; // ConvertPythonToGameObject sets the error
return NULL;
if (m_ob != NULL)
m_ob->UnregisterActuator(this);
m_ob = (SCA_IObject*)gameobj;
if (m_ob)
m_ob->RegisterActuator(this);
Py_RETURN_NONE;
}
/* 2. getObject */
char KX_ParentActuator::GetObject_doc[] =
"getObject()\n"
/* get obj ---------------------------------------------------------- */
char KX_ParentActuator::GetObject_doc[] =
"getObject(name_only = 1)\n"
"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the object that is set to.\n";
PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds) {
return PyString_FromString(m_ob->GetName());
}
PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args)
{
int ret_name_only = 1;
if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
return NULL;
if (!m_ob)
Py_RETURN_NONE;
if (ret_name_only)
return PyString_FromString(m_ob->GetName());
else
return m_ob->AddRef();
}
/* eof */

@ -79,9 +79,9 @@ class KX_ParentActuator : public SCA_IActuator
virtual PyObject* _getattr(const STR_String& attr);
/* 1. setObject */
KX_PYMETHOD_DOC(KX_ParentActuator,SetObject);
KX_PYMETHOD_DOC_O(KX_ParentActuator,SetObject);
/* 2. getObject */
KX_PYMETHOD_DOC(KX_ParentActuator,GetObject);
KX_PYMETHOD_DOC_VARARGS(KX_ParentActuator,GetObject);
}; /* end of class KX_ParentActuator : public SCA_PropertyActuator */

@ -61,7 +61,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -78,7 +78,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self,
@ -94,7 +94,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
@ -109,7 +109,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}

@ -91,7 +91,7 @@ static PyObject* gPySetGravity(PyObject* self,
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetDebugMode(PyObject* self,
@ -112,7 +112,7 @@ static PyObject* gPySetDebugMode(PyObject* self,
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -132,7 +132,7 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -151,7 +151,7 @@ static PyObject* gPySetNumIterations(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -171,7 +171,7 @@ static PyObject* gPySetDeactivationTime(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -190,7 +190,7 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -209,7 +209,7 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetContactBreakingTreshold(PyObject* self,
@ -227,7 +227,7 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -246,7 +246,7 @@ static PyObject* gPySetCcdMode(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetSorConstant(PyObject* self,
@ -264,7 +264,7 @@ static PyObject* gPySetSorConstant(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetSolverTau(PyObject* self,
@ -282,7 +282,7 @@ static PyObject* gPySetSolverTau(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -301,7 +301,7 @@ static PyObject* gPySetSolverDamping(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetLinearAirDamping(PyObject* self,
@ -319,7 +319,7 @@ static PyObject* gPySetLinearAirDamping(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -338,7 +338,7 @@ static PyObject* gPySetUseEpa(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
static PyObject* gPySetSolverType(PyObject* self,
PyObject* args,
@ -355,7 +355,7 @@ static PyObject* gPySetSolverType(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -388,7 +388,7 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self,
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -448,7 +448,7 @@ static PyObject* gPyCreateConstraint(PyObject* self,
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}
@ -502,7 +502,7 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
return NULL;
}
Py_INCREF(Py_None); return Py_None;
Py_RETURN_NONE;
}

@ -355,8 +355,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
if(!count)
pprint("No extenstions are used in this build");
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

@ -180,7 +180,7 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
NULL
};
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
{"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_VARARGS, SetObject_doc},
{"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, SetObject_doc},
{"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_VARARGS, SetTime_doc},
{"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
{"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_VARARGS, GetTime_doc},
@ -200,41 +200,25 @@ PyObject* KX_SCA_AddObjectActuator::_getattr(const STR_String& attr)
/* 1. setObject */
char KX_SCA_AddObjectActuator::SetObject_doc[] =
"setObject(name)\n"
"\t- name: string\n"
"setObject(object)\n"
"\t- object: KX_GameObject, string or None\n"
"\tSets the object that will be added. There has to be an object\n"
"\tof this name. If not, this function does nothing.\n";
PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self,
PyObject* args,
PyObject* kwds)
{
PyObject* gameobj;
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
{
if (m_OriginalObject != NULL)
m_OriginalObject->UnregisterActuator(this);
m_OriginalObject = (SCA_IObject*)gameobj;
if (m_OriginalObject)
m_OriginalObject->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, PyObject* value)
{
KX_GameObject *gameobj;
char* objectname;
if (PyArg_ParseTuple(args, "s", &objectname))
{
if (m_OriginalObject != NULL)
m_OriginalObject->UnregisterActuator(this);
m_OriginalObject = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));;
if (m_OriginalObject)
m_OriginalObject->RegisterActuator(this);
Py_Return;
}
if (!ConvertPythonToGameObject(value, &gameobj, true))
return NULL; // ConvertPythonToGameObject sets the error
return NULL;
if (m_OriginalObject != NULL)
m_OriginalObject->UnregisterActuator(this);
m_OriginalObject = (SCA_IObject*)gameobj;
if (m_OriginalObject)
m_OriginalObject->RegisterActuator(this);
Py_RETURN_NONE;
}
@ -280,19 +264,22 @@ PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self,
/* 4. getObject */
char KX_SCA_AddObjectActuator::GetObject_doc[] =
"getObject()\n"
"getObject(name_only = 1)\n"
"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the name of the object that will be added.\n";
PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self,
PyObject* args,
PyObject* kwds)
PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self, PyObject* args)
{
int ret_name_only = 1;
if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
return NULL;
if (!m_OriginalObject)
Py_Return;
return PyString_FromString(m_OriginalObject->GetName());
Py_RETURN_NONE;
if (ret_name_only)
return PyString_FromString(m_OriginalObject->GetName());
else
return m_OriginalObject->AddRef();
}

@ -113,13 +113,13 @@ public:
void InstantAddObject();
/* 1. setObject */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetObject);
KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetObject);
/* 2. setTime */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetTime);
/* 3. getTime */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetTime);
/* 4. getObject */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetObject);
KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,GetObject);
/* 5. getLinearVelocity */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLinearVelocity);
/* 6. setLinearVelocity */

@ -454,7 +454,7 @@ PyParentObject KX_TrackToActuator::Parents[] = {
PyMethodDef KX_TrackToActuator::Methods[] = {
{"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_VARARGS, SetObject_doc},
{"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, SetObject_doc},
{"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
{"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, SetTime_doc},
{"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, GetTime_doc},
@ -475,47 +475,45 @@ PyObject* KX_TrackToActuator::_getattr(const STR_String& attr)
/* 1. setObject */
char KX_TrackToActuator::SetObject_doc[] =
"setObject(object)\n"
"\t- object: string\n"
"\t- object: KX_GameObject, string or None\n"
"\tSet the object to track with the parent of this actuator.\n";
PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) {
PyObject* gameobj;
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
{
if (m_object != NULL)
m_object->UnregisterActuator(this);
m_object = (SCA_IObject*)gameobj;
if (m_object)
m_object->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* value)
{
KX_GameObject *gameobj;
char* objectname;
if (PyArg_ParseTuple(args, "s", &objectname))
{
if (m_object != NULL)
m_object->UnregisterActuator(this);
m_object= static_cast<SCA_IObject*>(SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)));
if (m_object)
m_object->RegisterActuator(this);
Py_Return;
}
if (!ConvertPythonToGameObject(value, &gameobj, true))
return NULL; // ConvertPythonToGameObject sets the error
return NULL;
if (m_object != NULL)
m_object->UnregisterActuator(this);
m_object = (SCA_IObject*)gameobj;
if (m_object)
m_object->RegisterActuator(this);
Py_RETURN_NONE;
}
/* 2. getObject */
char KX_TrackToActuator::GetObject_doc[] =
"getObject()\n"
"\tReturns the object to track with the parent of this actuator.\n";
PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds)
"getObject(name_only = 1)\n"
"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the object to track with the parent of this actuator\n";
PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args)
{
int ret_name_only = 1;
if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
return NULL;
if (!m_object)
Py_Return;
return PyString_FromString(m_object->GetName());
Py_RETURN_NONE;
if (ret_name_only)
return PyString_FromString(m_object->GetName());
else
return m_object->AddRef();
}

@ -75,9 +75,9 @@ class KX_TrackToActuator : public SCA_IActuator
virtual PyObject* _getattr(const STR_String& attr);
/* 1. setObject */
KX_PYMETHOD_DOC(KX_TrackToActuator,SetObject);
KX_PYMETHOD_DOC_O(KX_TrackToActuator,SetObject);
/* 2. getObject */
KX_PYMETHOD_DOC(KX_TrackToActuator,GetObject);
KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,GetObject);
/* 3. setTime */
KX_PYMETHOD_DOC(KX_TrackToActuator,SetTime);
/* 4. getTime */

@ -71,8 +71,7 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self,
} else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -157,8 +156,7 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self,
@ -175,8 +173,7 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self,
@ -193,8 +190,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self,
@ -210,8 +206,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self,
} else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self,
@ -227,8 +222,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self,
} else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self,
@ -245,8 +239,7 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -264,8 +257,7 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}
@ -285,8 +277,7 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* self,
else {
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}

@ -8,11 +8,13 @@ class KX_CameraActuator(SCA_IActuator):
@author: snail
"""
def getObject():
def getObject(name_only = 1):
"""
Returns the name of the object this actuator tracks.
rtype: string
@type name_only: bool
@param name_only: optional argument, when 0 return a KX_GameObject
@rtype: string, KX_GameObject or None if no object is set
"""
def setObject(target):
@ -20,7 +22,7 @@ class KX_CameraActuator(SCA_IActuator):
Sets the object this actuator tracks.
@param target: the object to track.
@type target: string or L{KX_GameObject}
@type target: L{KX_GameObject}, string or None
"""
def getMin():

@ -12,11 +12,12 @@ class KX_ParentActuator(SCA_IActuator):
Object can be either a L{KX_GameObject} or the name of the object.
@type object: L{KX_GameObject} or string
@type object: L{KX_GameObject}, string or None
"""
def getObject():
def getObject(name_only = 1):
"""
Returns the name of the object to change to.
@rtype: string
@type name_only: bool
@param name_only: optional argument, when 0 return a KX_GameObject
@rtype: string, KX_GameObject or None if no object is set
"""

@ -13,7 +13,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)}
"""
def setObject(obj):
def setObject(object):
"""
Sets the game object to add.
@ -21,17 +21,18 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
If the object does not exist, this function is ignored.
obj can either be a L{KX_GameObject} or the name of an object.
object can either be a L{KX_GameObject} or the name of an object or None.
@type obj: L{KX_GameObject} or string
@type object: L{KX_GameObject}, string or None
"""
def getObject():
def getObject(name_only = 0):
"""
Returns the name of the game object to be added.
Returns None if no game object has been assigned to be added.
@rtype: string
@type name_only: bool
@param name_only: optional argument, when 0 return a KX_GameObject
@rtype: string, KX_GameObject or None if no object is set
"""
def setTime(time):
"""

@ -18,16 +18,16 @@ class KX_TrackToActuator(SCA_IActuator):
"""
Sets the object to track.
@type object: L{KX_GameObject} or string
@type object: L{KX_GameObject}, string or None
@param object: Either a reference to a game object or the name of the object to track.
"""
def getObject():
"""
Returns the name of the object to track.
Returns None if no object has been set to track.
@rtype: string
@type name_only: bool
@param name_only: optional argument, when 0 return a KX_GameObject
@rtype: string, KX_GameObject or None if no object is set
"""
def setTime(time):
"""

@ -332,6 +332,8 @@ def read_opts(cfg, args):
('BF_X264_CONFIG', 'configuration flags for x264', ''),
('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''),
('BF_CONFIG', 'SCons python config file used to set default options', 'user_config.py'),
) # end of opts.AddOptions()