Merge from trunk 16031:16122

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

View File

@@ -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()

View File

@@ -1 +1 @@
2.46 2.47

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -13,7 +13,7 @@ from Blender import Mesh, Scene, Window, sys, Image, Draw
import BPyMesh import BPyMesh
__author__ = "Bruce Merry" __author__ = "Bruce Merry"
__version__ = "0.92" __version__ = "0.93"
__bpydoc__ = """\ __bpydoc__ = """\
This script exports Stanford PLY files from Blender. It supports normals, This script exports Stanford PLY files from Blender. It supports normals,
colours, and texture coordinates per face or per vertex. 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. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Vector rounding se we can use as keys # 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 # Updated on Jan 1, 2007 by Gabe Ghearing
# - fixed normals so they are correctly smooth/flat # - fixed normals so they are correctly smooth/flat
@@ -162,7 +164,7 @@ def file_callback(filename):
file.write('ply\n') file.write('ply\n')
file.write('format ascii 1.0\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)) file.write('element vertex %d\n' % len(verts))
@@ -210,7 +212,6 @@ def file_callback(filename):
if faceUV: uvcoord= rvec2d(uv[j]) if faceUV: uvcoord= rvec2d(uv[j])
elif vertexUV: uvcoord= rvec2d(v.uvco) elif vertexUV: uvcoord= rvec2d(v.uvco)
if vertexColors: color= col[j].r, col[j].g, col[j].b if vertexColors: color= col[j].r, col[j].g, col[j].b
co = v.co
file.write('%d ' % vdict[v.index][normal, uvcoord, color]) file.write('%d ' % vdict[v.index][normal, uvcoord, color])

View File

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

View File

@@ -48,9 +48,6 @@
/* Math stuff for ray casting on mesh faces and for nearest surface */ /* 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) static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2)
{ {
float dist; float dist;
@@ -79,170 +76,324 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
return FLT_MAX; return FLT_MAX;
} }
/*
* This calculates the distance from point to the plane
* Distance is negative if point is on the back side of plane
*/
static float point_plane_distance(const float *point, const float *plane_point, const float *plane_normal)
{
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);
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(closest)
VECCOPY2D(closest, v0);
return sdist[0];
}
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;
//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(nearest_vertex == NULL || nearest_vertex == v0)
nearest_vertex = v0;
else
{
//choose nearest
return choose_nearest(nearest_vertex, v0, point, closest);
}
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)
{
if(nearest_vertex == NULL || nearest_vertex == v1)
nearest_vertex = v1;
else
{
return choose_nearest(nearest_vertex, v1, point, closest);
}
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)
{
VECSUB2D(v_point, nearest_vertex, point);
VECCOPY2D(closest, nearest_vertex);
return v_point[0]*v_point[0] + v_point[1]*v_point[1];
}
else
{
VECCOPY(closest, point); //point is already inside
return 0.0f;
}
}
/* /*
* Returns the square of the minimum distance between the point and a triangle surface * Function adapted from David Eberly's distance tools (LGPL)
* If nearest is not NULL the nearest surface point is written on it * http://www.geometrictools.com/LibFoundation/Distance/Distance.html
*/ */
static float nearest_point_in_tri_surface(const float *point, const float *v0, const float *v1, const float *v2, float *nearest) 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 )
{ {
//Lets solve the 2D problem (closest point-tri) float diff[3];
float normal_dist, plane_sdist, plane_offset; float e0[3];
float du[3], dv[3], dw[3]; //orthogonal axis (du=(v0->v1), dw=plane normal) 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;
float p_2d[2], tri_2d[3][2], nearest_2d[2]; VECSUB(diff, v0, p);
VECSUB(e0, v1, v0);
VECSUB(e1, v2, v0);
CalcNormFloat((float*)v0, (float*)v1, (float*)v2, dw); 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;
//point-plane distance and calculate axis if ( S + T <= Det )
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; if ( S < 0.0f )
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; 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
{
float tmp0, tmp1, numer, denom;
if ( S < 0.0f ) // Region 2
{
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
{
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;
}
}
}
else if ( T < 0.0f ) // Region 6
{
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
{
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;
}
}
}
} }
return plane_sdist + normal_dist*normal_dist; // Account for numerical round-off error
if ( sqrDist < FLT_EPSILON )
sqrDist = 0.0f;
{
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 );
}
*v = lv;
*e = le;
return sqrDist;
} }
@@ -267,23 +418,16 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co,
do do
{ {
float nearest_tmp[3], dist; float nearest_tmp[3], col_normal[3], dist;
float vec[3][3]; int vertex, edge;
// only insert valid triangles / quads with area > 0 dist = nearest_point_in_tri_surface(t0, t1, t2, co, &vertex, &edge, col_normal, nearest_tmp);
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(co,t0, t1, t2, nearest_tmp);
if(dist < nearest->dist) if(dist < nearest->dist)
{ {
nearest->index = index; nearest->index = index;
nearest->dist = dist; nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp); VECCOPY(nearest->co, nearest_tmp);
CalcNormFloat((float*)t0, (float*)t1, (float*)t2, nearest->no); //TODO.. (interpolate normals from the vertexs coordinates? VECCOPY(nearest->no, col_normal);
}
} }
t1 = t2; t1 = t2;

View File

@@ -69,6 +69,8 @@ variables on the UI for now
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_arithb.h" #include "BLI_arithb.h"
#include "BLI_ghash.h" #include "BLI_ghash.h"
#include "BLI_threads.h"
#include "BKE_curve.h" #include "BKE_curve.h"
#include "BKE_effect.h" #include "BKE_effect.h"
#include "BKE_global.h" #include "BKE_global.h"
@@ -118,6 +120,20 @@ typedef struct SBScratch {
float aabbmin[3],aabbmax[3]; float aabbmin[3],aabbmax[3];
}SBScratch; }SBScratch;
typedef struct SB_thread_context{
Object *ob;
float forcetime;
float timenow;
int ifirst;
int ilast;
ListBase *do_effector;
int do_deflector;
float fieldfactor;
float windfactor;
int nr;
int tot;
}SB_thread_context;
#define NLF_BUILD 1 #define NLF_BUILD 1
#define NLF_SOLVE 2 #define NLF_SOLVE 2
@@ -1514,17 +1530,15 @@ int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],float *damp
void scan_for_ext_spring_forces(Object *ob,float timenow) void _scan_for_ext_spring_forces(Object *ob,float timenow,int ifirst,int ilast, struct ListBase *do_effector)
{ {
SoftBody *sb = ob->soft; SoftBody *sb = ob->soft;
ListBase *do_effector;
int a; int a;
float damp; float damp;
float feedback[3]; float feedback[3];
do_effector= pdInitEffectors(ob,NULL);
if (sb && sb->totspring){ if (sb && sb->totspring){
for(a=0; a<sb->totspring; a++) { for(a=ifirst; a<ilast; a++) {
BodySpring *bs = &sb->bspring[a]; BodySpring *bs = &sb->bspring[a];
bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f; bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f;
feedback[0]=feedback[1]=feedback[2]=0.0f; feedback[0]=feedback[1]=feedback[2]=0.0f;
@@ -1584,9 +1598,88 @@ void scan_for_ext_spring_forces(Object *ob,float timenow)
} }
} }
} }
}
void scan_for_ext_spring_forces(Object *ob,float timenow)
{
SoftBody *sb = ob->soft;
ListBase *do_effector= NULL;
do_effector= pdInitEffectors(ob,NULL);
if (sb){
_scan_for_ext_spring_forces(ob,timenow,0,sb->totspring,do_effector);
}
if(do_effector) if(do_effector)
pdEndEffectors(do_effector); pdEndEffectors(do_effector);
} }
void *exec_scan_for_ext_spring_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
_scan_for_ext_spring_forces(pctx->ob,pctx->timenow,pctx->ifirst,pctx->ilast,pctx->do_effector);
return 0;
}
void sb_sfesf_threads_run(struct Object *ob, float timenow,int totsprings,int *ptr_to_break_func())
{
ListBase *do_effector = NULL;
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread,left,dec;
int lowsprings =10; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
do_effector= pdInitEffectors(ob,NULL);
/* figure the number of threads while preventing pretty pointless threading overhead */
if(totsprings < lowsprings) {totthread=1;}
else{
if(G.scene->r.mode & R_FIXED_THREADS)
totthread= G.scene->r.threads;
else
totthread= BLI_system_thread_count();
}
/*left to do--> what if we got zillions of CPUs running but 'totsprings' tasks to spread*/
sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBSpringsThread");
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
left = totsprings;
dec = totsprings/totthread +1;
for(i=0; i<totthread; i++) {
sb_threads[i].ob = ob;
sb_threads[i].forcetime = 0.0; // not used here
sb_threads[i].timenow = timenow;
sb_threads[i].ilast = left;
left = left - dec;
if (left >0){
sb_threads[i].ifirst = left;
}
else
sb_threads[i].ifirst = 0;
sb_threads[i].do_effector = do_effector;
sb_threads[i].do_deflector = 0;// not used here
sb_threads[i].fieldfactor = 0.0f;// not used here
sb_threads[i].windfactor = 0.0f;// not used here
sb_threads[i].nr= i;
sb_threads[i].tot= totthread;
}
if(totthread > 1) {
BLI_init_threads(&threads, exec_scan_for_ext_spring_forces, totthread);
for(i=0; i<totthread; i++)
BLI_insert_thread(&threads, &sb_threads[i]);
BLI_end_threads(&threads);
}
else
exec_scan_for_ext_spring_forces(&sb_threads[0]);
/* clean up */
MEM_freeN(sb_threads);
if(do_effector)
pdEndEffectors(do_effector);
}
/* --- the spring external section*/ /* --- the spring external section*/
int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,float*cb,float*cc) int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,float*cb,float*cc)
@@ -2023,9 +2116,325 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo
} }
static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int nl_flags) /* since this is definitely the most CPU consuming task here .. try to spread it */
/* core function _softbody_calc_forces_slice_in_a_thread */
/* result is int to be able to flag user break */
int _softbody_calc_forces_slice_in_a_thread(Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *ptr_to_break_func(),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
{
float iks;
int bb,do_selfcollision,do_springcollision,do_aero;
int number_of_points_here = ilast - ifirst;
SoftBody *sb= ob->soft; /* is supposed to be there */
BodyPoint *bp;
/* intitialize */
if (sb) {
/* check conditions for various options */
/* +++ could be done on object level to squeeze out the last bits of it */
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
/* --- could be done on object level to squeeze out the last bits of it */
}
else {
printf("Error expected a SB here \n");
return (999);
}
/* debugerin */
if (sb->totpoint < ifirst) {
printf("Aye 998");
return (998);
}
/* debugerin */
bp = &sb->bpoint[ifirst];
for(bb=number_of_points_here; bb>0; bb--, bp++) {
/* clear forces accumulator */
bp->force[0]= bp->force[1]= bp->force[2]= 0.0;
/* naive ball self collision */
/* needs to be done if goal snaps or not */
if(do_selfcollision){
int attached;
BodyPoint *obp;
BodySpring *bs;
int c,b;
float velcenter[3],dvel[3],def[3];
float distance;
float compare;
float bstune = sb->ballstiff;
for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) {
compare = (obp->colball + bp->colball);
VecSubf(def, bp->pos, obp->pos);
/* rather check the AABBoxes before ever calulating the real distance */
/* mathematically it is completly nuts, but performace is pretty much (3) times faster */
if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue;
distance = Normalize(def);
if (distance < compare ){
/* exclude body points attached with a spring */
attached = 0;
for(b=obp->nofsprings;b>0;b--){
bs = sb->bspring + obp->springs[b-1];
if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)){
attached=1;
continue;}
}
if (!attached){
float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ;
VecMidf(velcenter, bp->vec, obp->vec);
VecSubf(dvel,velcenter,bp->vec);
VecMulf(dvel,sb->nodemass);
Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def);
Vec3PlusStVec(bp->force,sb->balldamp,dvel);
/* exploit force(a,b) == -force(b,a) part2/2 */
VecSubf(dvel,velcenter,obp->vec);
VecMulf(dvel,sb->nodemass);
Vec3PlusStVec(obp->force,sb->balldamp,dvel);
Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def);
}
}
}
}
/* naive ball self collision done */
if(bp->goal < SOFTGOALSNAP){ /* ommit this bp when it snaps */
float auxvect[3];
float velgoal[3];
/* do goal stuff */
if(ob->softflag & OB_SB_GOAL) {
/* true elastic goal */
float ks,kd;
VecSubf(auxvect,bp->pos,bp->origT);
ks = 1.0f/(1.0f- bp->goal*sb->goalspring)-1.0f ;
bp->force[0]+= -ks*(auxvect[0]);
bp->force[1]+= -ks*(auxvect[1]);
bp->force[2]+= -ks*(auxvect[2]);
/* calulate damping forces generated by goals*/
VecSubf(velgoal,bp->origS, bp->origE);
kd = sb->goalfrict * sb_fric_force_scale(ob) ;
VecAddf(auxvect,velgoal,bp->vec);
if (forcetime > 0.0 ) { /* make sure friction does not become rocket motor on time reversal */
bp->force[0]-= kd * (auxvect[0]);
bp->force[1]-= kd * (auxvect[1]);
bp->force[2]-= kd * (auxvect[2]);
}
else {
bp->force[0]-= kd * (velgoal[0] - bp->vec[0]);
bp->force[1]-= kd * (velgoal[1] - bp->vec[1]);
bp->force[2]-= kd * (velgoal[2] - bp->vec[2]);
}
}
/* done goal stuff */
/* gravitation */
if (sb){
float gravity = sb->grav * sb_grav_force_scale(ob);
bp->force[2]-= gravity*sb->nodemass; /* individual mass of node here */
}
/* particle field & vortex */
if(do_effector) {
float kd;
float force[3]= {0.0f, 0.0f, 0.0f};
float speed[3]= {0.0f, 0.0f, 0.0f};
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
pdDoEffectors(do_effector, bp->pos, force, speed, (float)G.scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
/* apply forcefield*/
VecMulf(force,fieldfactor* eval_sb_fric_force_scale);
VECADD(bp->force, bp->force, force);
/* BP friction in moving media */
kd= sb->mediafrict* eval_sb_fric_force_scale;
bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale);
bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale);
bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale);
/* now we'll have nice centrifugal effect for vortex */
}
else {
/* BP friction in media (not) moving*/
float kd = sb->mediafrict* sb_fric_force_scale(ob);
/* assume it to be proportional to actual velocity */
bp->force[0]-= bp->vec[0]*kd;
bp->force[1]-= bp->vec[1]*kd;
bp->force[2]-= bp->vec[2]*kd;
/* friction in media done */
}
/* +++cached collision targets */
bp->choke = 0.0f;
bp->choke2 = 0.0f;
bp->flag &= ~SBF_DOFUZZY;
if(do_deflector) {
float cfforce[3],defforce[3] ={0.0f,0.0f,0.0f}, vel[3] = {0.0f,0.0f,0.0f}, facenormal[3], cf = 1.0f,intrusion;
float kd = 1.0f;
if (sb_deflect_face(ob,bp->pos,facenormal,defforce,&cf,timenow,vel,&intrusion)){
VECSUB(cfforce,bp->vec,vel);
Vec3PlusStVec(bp->force,-cf*50.0f,cfforce);
Vec3PlusStVec(bp->force,kd,defforce);
}
}
/* ---cached collision targets */
/* +++springs */
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
if(ob->softflag & OB_SB_EDGES) {
if (sb->bspring){ /* spring list exists at all ? */
int b;
BodySpring *bs;
for(b=bp->nofsprings;b>0;b--){
bs = sb->bspring + bp->springs[b-1];
if (do_springcollision || do_aero){
VecAddf(bp->force,bp->force,bs->ext_force);
if (bs->flag & BSF_INTERSECT)
bp->choke = bs->cf;
}
// sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags)
sb_spring_force(ob,ilast-bb,bs,iks,forcetime,0);
}/* loop springs */
}/* existing spring list */
}/*any edges*/
/* ---springs */
}/*omit on snap */
}/*loop all bp's*/
return 0; /*done fine*/
}
void *exec_softbody_calc_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
_softbody_calc_forces_slice_in_a_thread(pctx->ob,pctx->forcetime,pctx->timenow,pctx->ifirst,pctx->ilast,NULL,pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor);
return 0;
}
void sb_cf_threads_run(struct Object *ob, float forcetime, float timenow,int totpoint,int *ptr_to_break_func(),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
{
ListBase threads;
SB_thread_context *sb_threads;
int i, totthread,left,dec;
int lowpoints =10; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
/* figure the number of threads while preventing pretty pointless threading overhead */
if(totpoint < lowpoints) {totthread=1;}
else{
if(G.scene->r.mode & R_FIXED_THREADS)
totthread= G.scene->r.threads;
else
totthread= BLI_system_thread_count();
}
/*left to do--> what if we got zillions of CPUs running but 'totpoint' tasks to spread*/
sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBThread");
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
left = totpoint;
dec = totpoint/totthread +1;
for(i=0; i<totthread; i++) {
sb_threads[i].ob = ob;
sb_threads[i].forcetime = forcetime;
sb_threads[i].timenow = timenow;
sb_threads[i].ilast = left;
left = left - dec;
if (left >0){
sb_threads[i].ifirst = left;
}
else
sb_threads[i].ifirst = 0;
sb_threads[i].do_effector = do_effector;
sb_threads[i].do_deflector = do_deflector;
sb_threads[i].fieldfactor = fieldfactor;
sb_threads[i].windfactor = windfactor;
sb_threads[i].nr= i;
sb_threads[i].tot= totthread;
}
if(totthread > 1) {
BLI_init_threads(&threads, exec_softbody_calc_forces, totthread);
for(i=0; i<totthread; i++)
BLI_insert_thread(&threads, &sb_threads[i]);
BLI_end_threads(&threads);
}
else
exec_softbody_calc_forces(&sb_threads[0]);
/* clean up */
MEM_freeN(sb_threads);
}
static void softbody_calc_forcesEx(Object *ob, float forcetime, float timenow, int nl_flags)
{ {
/* rule we never alter free variables :bp->vec bp->pos in here ! /* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM)
*/
SoftBody *sb= ob->soft; /* is supposed to be there */
BodyPoint *bproot;
ListBase *do_effector;
float iks, gravity;
float fieldfactor = 1000.0f, windfactor = 250.0f;
int do_deflector,do_selfcollision,do_springcollision,do_aero;
gravity = sb->grav * sb_grav_force_scale(ob);
/* check conditions for various options */
do_deflector= query_external_colliders(ob);
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
bproot= sb->bpoint; /* need this for proper spring addressing */
if (do_springcollision || do_aero)
sb_sfesf_threads_run(ob,timenow,sb->totspring,NULL);
/* after spring scan because it uses Effoctors too */
do_effector= pdInitEffectors(ob,NULL);
if (do_deflector) {
float defforce[3];
do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow);
}
sb_cf_threads_run(ob,forcetime,timenow,sb->totpoint,NULL,do_effector,do_deflector,fieldfactor,windfactor);
/* finally add forces caused by face collision */
if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow);
/* finish matrix and solve */
if(do_effector) pdEndEffectors(do_effector);
}
static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int nl_flags)
{
/* redirection to the new threaded Version */
if (G.rt !=16){
softbody_calc_forcesEx(ob, forcetime, timenow, nl_flags);
return;
}
else{
/* so the following will die */
/* |||||||||||||||||||||||||| */
/* VVVVVVVVVVVVVVVVVVVVVVVVVV */
/* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM) * this will ruin adaptive stepsize AKA heun! (BM)
*/ */
SoftBody *sb= ob->soft; /* is supposed to be there */ SoftBody *sb= ob->soft; /* is supposed to be there */
@@ -2039,14 +2448,14 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
int a, b, do_deflector,do_selfcollision,do_springcollision,do_aero; int a, b, do_deflector,do_selfcollision,do_springcollision,do_aero;
/* jacobian /* jacobian
NLboolean success; NLboolean success;
if(nl_flags){ if(nl_flags){
nlBegin(NL_SYSTEM); nlBegin(NL_SYSTEM);
nlBegin(NL_MATRIX); nlBegin(NL_MATRIX);
} }
*/ */
gravity = sb->grav * sb_grav_force_scale(ob); gravity = sb->grav * sb_grav_force_scale(ob);
@@ -2256,9 +2665,9 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
//int ia =3*(sb->totpoint-a); //int ia =3*(sb->totpoint-a);
/* da/dv = */ /* da/dv = */
// nlMatrixAdd(ia,ia,forcetime*kd); // nlMatrixAdd(ia,ia,forcetime*kd);
// nlMatrixAdd(ia+1,ia+1,forcetime*kd); // nlMatrixAdd(ia+1,ia+1,forcetime*kd);
// nlMatrixAdd(ia+2,ia+2,forcetime*kd); // nlMatrixAdd(ia+2,ia+2,forcetime*kd);
} }
} }
@@ -2315,7 +2724,8 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
} }
// sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) // sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags)
sb_spring_force(ob,sb->totpoint-a,bs,iks,forcetime,nl_flags); // rather remove nl_falgs from code .. will make things a lot cleaner
sb_spring_force(ob,sb->totpoint-a,bs,iks,forcetime,0);
}/* loop springs */ }/* loop springs */
}/* existing spring list */ }/* existing spring list */
}/*any edges*/ }/*any edges*/
@@ -2341,7 +2751,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
nlEnd(NL_MATRIX); nlEnd(NL_MATRIX);
nlEnd(NL_SYSTEM); nlEnd(NL_SYSTEM);
if ((G.rt >0) && (nl_flags & NLF_BUILD)) if ((G.rt == 32) && (nl_flags & NLF_BUILD))
{ {
printf("####MEE#####\n"); printf("####MEE#####\n");
nlPrintMatrix(); nlPrintMatrix();
@@ -2354,7 +2764,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
float f; float f;
int index =0; int index =0;
/* for debug purpose .. anyhow cropping B vector looks like working */ /* for debug purpose .. anyhow cropping B vector looks like working */
if (G.rt >0) if (G.rt ==32)
for(a=2*sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { for(a=2*sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
f=nlGetVariable(0,index); f=nlGetVariable(0,index);
printf("(%f ",f);index++; printf("(%f ",f);index++;
@@ -2398,7 +2808,9 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
/* cleanup */ /* cleanup */
#endif #endif
if(do_effector) pdEndEffectors(do_effector); if(do_effector) pdEndEffectors(do_effector);
}
} }
static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *err, int mid_flags) static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *err, int mid_flags)
{ {
/* time evolution */ /* time evolution */
@@ -2458,7 +2870,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
/* x(t + dt) = x(t) + v(t~) * dt */ /* x(t + dt) = x(t) + v(t~) * dt */
VecMulf(dx,forcetime); VecMulf(dx,forcetime);
/* the freezer */ /* the freezer coming sooner or later */
/* /*
if ((Inpf(dx,dx)<freezeloc )&&(Inpf(bp->force,bp->force)<freezeforce )){ if ((Inpf(dx,dx)<freezeloc )&&(Inpf(bp->force,bp->force)<freezeforce )){
bp->frozen /=2; bp->frozen /=2;
@@ -3529,6 +3941,7 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
* we don't want to lock up the system if physics fail * we don't want to lock up the system if physics fail
*/ */
int loops =0 ; int loops =0 ;
SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */ SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */
if (sb->minloops > 0) forcetimemax = 1.0f / sb->minloops; if (sb->minloops > 0) forcetimemax = 1.0f / sb->minloops;
@@ -3546,13 +3959,13 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
sb->scratch->flag &= ~SBF_DOFUZZY; sb->scratch->flag &= ~SBF_DOFUZZY;
/* do predictive euler step */ /* do predictive euler step */
softbody_calc_forces(ob, forcetime,timedone/dtime,0); softbody_calc_forces(ob, forcetime,timedone/dtime,0);
softbody_apply_forces(ob, forcetime, 1, NULL,mid_flags);
softbody_apply_forces(ob, forcetime, 1, NULL,mid_flags);
/* crop new slope values to do averaged slope step */ /* crop new slope values to do averaged slope step */
softbody_calc_forces(ob, forcetime,timedone/dtime,0); softbody_calc_forces(ob, forcetime,timedone/dtime,0);
softbody_apply_forces(ob, forcetime, 2, &err,mid_flags);
softbody_apply_forces(ob, forcetime, 2, &err,mid_flags);
softbody_apply_goalsnap(ob); softbody_apply_goalsnap(ob);
if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */ if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */
@@ -3603,7 +4016,7 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
// if(G.f & G_DEBUG){ // if(G.f & G_DEBUG){
if(sb->solverflags & SBSO_MONITOR ){ if(sb->solverflags & SBSO_MONITOR ){
if (loops > HEUNWARNLIMIT) /* monitor high loop counts */ if (loops > HEUNWARNLIMIT) /* monitor high loop counts */
printf("\r needed %d steps/frame ",loops); printf("\r needed %d steps/frame",loops);
} }
} }
@@ -3627,7 +4040,7 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
if(sb->solverflags & SBSO_MONITOR ){ if(sb->solverflags & SBSO_MONITOR ){
sct=PIL_check_seconds_timer(); sct=PIL_check_seconds_timer();
if (sct-sst > 0.5f) printf(" solver time %f %s \r",sct-sst,ob->id.name); if (sct-sst > 0.5f) printf(" solver time %f sec %s \n",sct-sst,ob->id.name);
} }
} }

View File

@@ -114,6 +114,7 @@ void setflag_armature(short mode);
void unique_editbone_name (struct ListBase *ebones, char *name); void unique_editbone_name (struct ListBase *ebones, char *name);
void auto_align_armature(short mode); void auto_align_armature(short mode);
void switch_direction_armature(void);
void create_vgroups_from_armature(struct Object *ob, struct Object *par); 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); 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_selected_armature_bones(void);
void hide_unselected_armature_bones(void); void hide_unselected_armature_bones(void);
void show_all_armature_bones(void); void show_all_armature_bones(void);
void set_locks_armature_bones(short lock);
#define BONESEL_ROOT 0x10000000 #define BONESEL_ROOT 0x10000000
#define BONESEL_TIP 0x20000000 #define BONESEL_TIP 0x20000000
@@ -144,6 +144,10 @@ void set_locks_armature_bones(short lock);
#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */ #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() */ /* used in bone_select_hierachy() */
#define BONE_SELECT_PARENT 0 #define BONE_SELECT_PARENT 0
#define BONE_SELECT_CHILD 1 #define BONE_SELECT_CHILD 1

View File

@@ -105,6 +105,10 @@
#define EXPP_TEX_LACUNARITY_MAX 6.0f #define EXPP_TEX_LACUNARITY_MAX 6.0f
#define EXPP_TEX_OCTS_MIN 0.0f #define EXPP_TEX_OCTS_MIN 0.0f
#define EXPP_TEX_OCTS_MAX 8.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_MIN 0.0f
#define EXPP_TEX_ISCALE_MAX 10.0f #define EXPP_TEX_ISCALE_MAX 10.0f
#define EXPP_TEX_EXP_MIN 0.010f #define EXPP_TEX_EXP_MIN 0.010f
@@ -430,6 +434,8 @@ GETFUNC( getNoiseDepth );
GETFUNC( getNoiseSize ); GETFUNC( getNoiseSize );
GETFUNC( getNoiseType ); GETFUNC( getNoiseType );
GETFUNC( getOcts ); GETFUNC( getOcts );
GETFUNC( getOffset );
GETFUNC( getGain );
GETFUNC( getRepeat ); GETFUNC( getRepeat );
GETFUNC( getRGBCol ); GETFUNC( getRGBCol );
GETFUNC( getSType ); GETFUNC( getSType );
@@ -478,6 +484,8 @@ SETFUNC( setNoiseDepth );
SETFUNC( setNoiseSize ); SETFUNC( setNoiseSize );
SETFUNC( setNoiseType ); SETFUNC( setNoiseType );
SETFUNC( setOcts ); SETFUNC( setOcts );
SETFUNC( setOffset );
SETFUNC( setGain );
SETFUNC( setRepeat ); SETFUNC( setRepeat );
SETFUNC( setRGBCol ); SETFUNC( setRGBCol );
SETFUNC( setSType ); SETFUNC( setSType );
@@ -646,6 +654,14 @@ static PyGetSetDef BPy_Texture_getseters[] = {
(getter)Texture_getLacunarity, (setter)Texture_setLacunarity, (getter)Texture_getLacunarity, (setter)Texture_setLacunarity,
"Gap between succesive frequencies (for Musgrave textures)", "Gap between succesive frequencies (for Musgrave textures)",
NULL}, 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", {"noiseBasis",
(getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis, (getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis,
"Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted noise)", "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 ); 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 ) static int Texture_setOcts( BPy_Texture * self, PyObject * value )
{ {
return EXPP_setFloatClamped ( value, &self->texture->mg_octaves, 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 ); 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 ) static PyObject *Texture_getRepeat( BPy_Texture *self )
{ {
return Py_BuildValue( "(i,i)", self->texture->xrepeat, return Py_BuildValue( "(i,i)", self->texture->xrepeat,

View File

@@ -170,17 +170,6 @@ def SetRenderWinPos(locationList):
the location of the Render window on the screen. 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: class RenderData:
""" """
The RenderData object The RenderData object

View File

@@ -344,6 +344,12 @@ class Texture:
@ivar octs: Number of frequencies (for Musgrave textures). @ivar octs: Number of frequencies (for Musgrave textures).
Value is clamped to the range [0.0,8.0]. Value is clamped to the range [0.0,8.0].
@type octs: float @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). @ivar repeat: Repetition multiplier (for image textures).
@type repeat: tuple of 2 ints @type repeat: tuple of 2 ints
@ivar rgbCol: RGB color tuple. @ivar rgbCol: RGB color tuple.

View File

@@ -263,6 +263,11 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shade_input_set_shade_texco(shi); shade_input_set_shade_texco(shi);
if(is->mode==RE_RAY_SHADOW_TRA) if(is->mode==RE_RAY_SHADOW_TRA)
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); shade_color(shi, shr);
else { else {
if(shi->mat->nodetree && shi->mat->use_nodes) { if(shi->mat->nodetree && shi->mat->use_nodes) {

View File

@@ -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"); 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, 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+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 ) if ( ob->gameflag & OB_DYNAMIC )

View File

@@ -854,6 +854,7 @@ static void separate_armature_bones (Object *ob, short sel)
BLI_freelistN(&edbo); BLI_freelistN(&edbo);
} }
/* separate selected bones into their armature */
void separate_armature (void) void separate_armature (void)
{ {
Object *oldob, *newob; Object *oldob, *newob;
@@ -1094,13 +1095,13 @@ void armature_select_hierarchy(short direction, short add_to_sel)
arm= (bArmature *)ob->data; arm= (bArmature *)ob->data;
for (curbone= G.edbo.first; curbone; curbone= curbone->next) { 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 (curbone->flag & (BONE_ACTIVE)) {
if (direction == BONE_SELECT_PARENT) { if (direction == BONE_SELECT_PARENT) {
if (curbone->parent == NULL) continue; if (curbone->parent == NULL) continue;
else pabone = curbone->parent; 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); pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
@@ -1109,11 +1110,12 @@ void armature_select_hierarchy(short direction, short add_to_sel)
break; break;
} }
} else { // BONE_SELECT_CHILD }
else { // BONE_SELECT_CHILD
chbone = editbone_get_child(curbone, 1); chbone = editbone_get_child(curbone, 1);
if (chbone == NULL) continue; 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); chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
if (!add_to_sel) { 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 */ /* get flag to set (sync these with the ones used in eBone_Flag */
if (mode == 2) 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) 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 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) { switch (flag) {
case 1: flag = BONE_DRAWWIRE; break; case 1: flag = BONE_DRAWWIRE; break;
case 2: flag = BONE_NO_DEFORM; break; case 2: flag = BONE_NO_DEFORM; break;
case 3: flag = BONE_MULT_VG_ENV; break; case 3: flag = BONE_MULT_VG_ENV; break;
case 4: flag = BONE_HINGE; break; case 4: flag = BONE_HINGE; break;
case 5: flag = BONE_NO_SCALE; break; case 5: flag = BONE_NO_SCALE; break;
case 6: flag = BONE_EDITMODE_LOCKED; break;
default: return; default: return;
} }
@@ -1725,12 +1728,12 @@ void auto_align_armature(short mode)
float *cursor= give_cursor(); float *cursor= give_cursor();
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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) if (arm->flag & ARM_MIRROR_EDIT)
flipbone = armature_bone_get_mirrored(ebone); flipbone = armature_bone_get_mirrored(ebone);
if ((ebone->flag & BONE_SELECTED) || if ((ebone->flag & BONE_SELECTED) ||
(flipbone && flipbone->flag & BONE_SELECTED)) (flipbone && (flipbone->flag & BONE_SELECTED)))
{ {
/* specific method used to calculate roll depends on mode */ /* specific method used to calculate roll depends on mode */
if (mode == 1) { if (mode == 1) {
@@ -1975,7 +1978,7 @@ void addvert_armature(void)
/* find the active or selected bone */ /* find the active or selected bone */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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)) if (ebone->flag & (BONE_ACTIVE|BONE_TIPSEL))
break; break;
} }
@@ -1983,7 +1986,7 @@ void addvert_armature(void)
if (ebone==NULL) { if (ebone==NULL) {
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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)) if (ebone->flag & (BONE_ACTIVE|BONE_ROOTSEL))
break; break;
} }
@@ -2066,11 +2069,12 @@ static EditBone *get_named_editbone(char *name)
{ {
EditBone *eBone; EditBone *eBone;
if (name) if (name) {
for (eBone=G.edbo.first; eBone; eBone=eBone->next) { for (eBone=G.edbo.first; eBone; eBone=eBone->next) {
if (!strcmp(name, eBone->name)) if (!strcmp(name, eBone->name))
return eBone; return eBone;
} }
}
return NULL; return NULL;
} }
@@ -2136,7 +2140,7 @@ void adduplicate_armature(void)
/* Select mirrored bones */ /* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) { if (arm->flag & ARM_MIRROR_EDIT) {
for (curBone=G.edbo.first; curBone; curBone=curBone->next) { for (curBone=G.edbo.first; curBone; curBone=curBone->next) {
if (arm->layer & curBone->layer) { if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) { if (curBone->flag & BONE_SELECTED) {
eBone = armature_bone_get_mirrored(curBone); eBone = armature_bone_get_mirrored(curBone);
if (eBone) if (eBone)
@@ -2148,13 +2152,13 @@ void adduplicate_armature(void)
/* Find the selected bones and duplicate them as needed */ /* Find the selected bones and duplicate them as needed */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { 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) { if (curBone->flag & BONE_SELECTED) {
eBone=MEM_callocN(sizeof(EditBone), "addup_editbone"); eBone=MEM_callocN(sizeof(EditBone), "addup_editbone");
eBone->flag |= BONE_SELECTED; eBone->flag |= BONE_SELECTED;
/* Copy data from old bone to new bone */ /* Copy data from old bone to new bone */
memcpy (eBone, curBone, sizeof(EditBone)); memcpy(eBone, curBone, sizeof(EditBone));
curBone->temp = eBone; curBone->temp = eBone;
eBone->temp = curBone; eBone->temp = curBone;
@@ -2204,7 +2208,7 @@ void adduplicate_armature(void)
/* Run though the list and fix the pointers */ /* Run though the list and fix the pointers */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { 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) { if (curBone->flag & BONE_SELECTED) {
eBone=(EditBone*) curBone->temp; eBone=(EditBone*) curBone->temp;
@@ -2236,7 +2240,7 @@ void adduplicate_armature(void)
/* Deselect the old bones and select the new ones */ /* Deselect the old bones and select the new ones */
for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { 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); 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 */ /* loop over all bones, and only consider if visible */
for (ebo= G.edbo.first; ebo; ebo= ebo->next) { 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)) if (!(ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL))
fill_add_joint(ebo, 0, &points); fill_add_joint(ebo, 0, &points);
if (ebo->flag & BONE_TIPSEL) if (ebo->flag & BONE_TIPSEL)
@@ -2608,7 +2612,7 @@ void merge_armature(void)
/* only consider bones that are visible and selected */ /* only consider bones that are visible and selected */
for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) { for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) {
/* check if visible + selected */ /* 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_CONNECTED) || (ebo->parent==NULL)) &&
(ebo->flag & (BONE_SELECTED|BONE_ACTIVE)) ) (ebo->flag & (BONE_SELECTED|BONE_ACTIVE)) )
{ {
@@ -2659,7 +2663,7 @@ void hide_selected_armature_bones(void)
EditBone *ebone; EditBone *ebone;
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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 (ebone->flag & (BONE_SELECTED)) {
ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL|BONE_ACTIVE); ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL|BONE_ACTIVE);
ebone->flag |= BONE_HIDDEN_A; ebone->flag |= BONE_HIDDEN_A;
@@ -2678,7 +2682,7 @@ void hide_unselected_armature_bones(void)
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
bArmature *arm= G.obedit->data; bArmature *arm= G.obedit->data;
if (arm->layer & ebone->layer) { if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL)); if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL));
else { else {
ebone->flag &= ~BONE_ACTIVE; ebone->flag &= ~BONE_ACTIVE;
@@ -2711,32 +2715,6 @@ void show_all_armature_bones(void)
BIF_undo_push("Reveal Bones"); 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! */ /* check for null, before calling! */
static void bone_connect_to_existing_parent(EditBone *bone) static void bone_connect_to_existing_parent(EditBone *bone)
{ {
@@ -2803,7 +2781,7 @@ void make_bone_parent(void)
/* find active bone to parent to */ /* find active bone to parent to */
for (actbone = G.edbo.first; actbone; actbone=actbone->next) { for (actbone = G.edbo.first; actbone; actbone=actbone->next) {
if (arm->layer & actbone->layer) { if (EBONE_VISIBLE(arm, actbone)) {
if (actbone->flag & BONE_ACTIVE) if (actbone->flag & BONE_ACTIVE)
break; break;
} }
@@ -2815,7 +2793,7 @@ void make_bone_parent(void)
/* find selected bones */ /* find selected bones */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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)) { if ((ebone->flag & BONE_SELECTED) && (ebone != actbone)) {
foundselbone++; foundselbone++;
if (ebone->parent != actbone) allchildbones= 1; if (ebone->parent != actbone) allchildbones= 1;
@@ -2851,7 +2829,7 @@ void make_bone_parent(void)
else { else {
/* loop through all editbones, parenting all selected bones to the active bone */ /* loop through all editbones, parenting all selected bones to the active bone */
for (selbone = G.edbo.first; selbone; selbone=selbone->next) { 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)) { if ((selbone->flag & BONE_SELECTED) && (selbone!=actbone)) {
/* parent selbone to actbone */ /* parent selbone to actbone */
bone_connect_to_new_parent(selbone, actbone, val); bone_connect_to_new_parent(selbone, actbone, val);
@@ -2909,7 +2887,7 @@ void clear_bone_parent(void)
if (val<1) return; if (val<1) return;
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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 (ebone->flag & BONE_SELECTED) {
if (arm->flag & ARM_MIRROR_EDIT) if (arm->flag & ARM_MIRROR_EDIT)
flipbone = armature_bone_get_mirrored(ebone); flipbone = armature_bone_get_mirrored(ebone);
@@ -2959,7 +2937,7 @@ void unique_editbone_name (ListBase *ebones, char *name)
} }
for (number = 1; number <=999; number++) { for (number = 1; number <=999; number++) {
sprintf (tempname, "%s.%03d", name, number); sprintf(tempname, "%s.%03d", name, number);
if (!editbone_name_exists(ebones, tempname)) { if (!editbone_name_exists(ebones, tempname)) {
BLI_strncpy(name, tempname, 32); BLI_strncpy(name, tempname, 32);
return; return;
@@ -2980,7 +2958,7 @@ void extrude_armature(int forked)
/* since we allow root extrude too, we have to make sure selection is OK */ /* since we allow root extrude too, we have to make sure selection is OK */
for (ebone = G.edbo.first; ebone; ebone=ebone->next) { 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->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
if (ebone->parent->flag & BONE_TIPSEL) if (ebone->parent->flag & BONE_TIPSEL)
@@ -2992,7 +2970,7 @@ void extrude_armature(int forked)
/* Duplicate the necessary bones */ /* Duplicate the necessary bones */
for (ebone = G.edbo.first; ((ebone) && (ebone!=first)); ebone=ebone->next) { 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 */ /* we extrude per definition the tip */
do_extrude= 0; do_extrude= 0;
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED)) if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED))
@@ -3006,7 +2984,7 @@ void extrude_armature(int forked)
if (do_extrude) { if (do_extrude) {
/* we re-use code for mirror editing... */ /* we re-use code for mirror editing... */
flipbone= NULL; flipbone= NULL;
if(arm->flag & ARM_MIRROR_EDIT) { if (arm->flag & ARM_MIRROR_EDIT) {
flipbone= armature_bone_get_mirrored(ebone); flipbone= armature_bone_get_mirrored(ebone);
if (flipbone) { if (flipbone) {
forked= 0; // we extrude 2 different bones forked= 0; // we extrude 2 different bones
@@ -3046,7 +3024,7 @@ void extrude_armature(int forked)
newbone->flag= BONE_TIPSEL; newbone->flag= BONE_TIPSEL;
if (newbone->parent && ebone->flag & BONE_CONNECTED) { if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED; newbone->flag |= BONE_CONNECTED;
} }
} }
@@ -3065,8 +3043,8 @@ void extrude_armature(int forked)
BLI_strncpy (newbone->name, ebone->name, 32); BLI_strncpy (newbone->name, ebone->name, 32);
if (flipbone && forked) { // only set if mirror edit if (flipbone && forked) { // only set if mirror edit
if(strlen(newbone->name)<30) { if (strlen(newbone->name)<30) {
if(a==0) strcat(newbone->name, "_L"); if (a==0) strcat(newbone->name, "_L");
else strcat(newbone->name, "_R"); else strcat(newbone->name, "_R");
} }
} }
@@ -3111,7 +3089,7 @@ void subdivide_armature(int numcuts)
if (numcuts < 1) return; if (numcuts < 1) return;
for (mbone = G.edbo.last; mbone; mbone= mbone->prev) { for (mbone = G.edbo.last; mbone; mbone= mbone->prev) {
if (arm->layer & mbone->layer) { if (EBONE_VISIBLE(arm, mbone)) {
if (mbone->flag & BONE_SELECTED) { if (mbone->flag & BONE_SELECTED) {
for (i=numcuts+1; i>1; i--) { for (i=numcuts+1; i>1; i--) {
/* compute cut ratio first */ /* compute cut ratio first */
@@ -3176,6 +3154,59 @@ void subdivide_armature(int numcuts)
else BIF_undo_push("Subdivide multi"); 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 ********************* */ /* ***************** Pose tools ********************* */
void clear_armature(Object *ob, char mode) void clear_armature(Object *ob, char mode)

View File

@@ -2760,7 +2760,7 @@ void special_editmenu(void)
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
} }
else if(G.obedit->type==OB_ARMATURE) { 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) if(nr==1)
subdivide_armature(1); subdivide_armature(1);
if(nr==2) { if(nr==2) {
@@ -2773,10 +2773,8 @@ void special_editmenu(void)
else if(ELEM3(nr, 4, 5, 6)) { else if(ELEM3(nr, 4, 5, 6)) {
armature_autoside_names(nr-4); armature_autoside_names(nr-4);
} }
else if(nr==7) else if(nr == 7)
set_locks_armature_bones(1); switch_direction_armature();
else if(nr==8)
set_locks_armature_bones(0);
} }
else if(G.obedit->type==OB_LATTICE) { else if(G.obedit->type==OB_LATTICE) {
static float weight= 1.0f; static float weight= 1.0f;

View File

@@ -5139,7 +5139,7 @@ static char *snapmode_pup(void)
static char string[512]; static char string[512];
char *str = string; 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", "|Vertex%x0");
str += sprintf(str, "%s", "|Edge%x1"); str += sprintf(str, "%s", "|Edge%x1");
str += sprintf(str, "%s", "|Face%x2"); str += sprintf(str, "%s", "|Face%x2");
@@ -5777,7 +5777,7 @@ void view3d_buttons(void)
xco+= XIC; 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"); 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; 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; xco+= 70;
} else { } 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)"); 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

View File

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

View File

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

View File

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

View File

@@ -540,9 +540,16 @@ void BL_ConvertActuators(char* maggiename,
// does the 'original' for replication exists, and // does the 'original' for replication exists, and
// is it in a non-active layer ? // is it in a non-active layer ?
SCA_IObject* originalval = NULL; SCA_IObject* originalval = NULL;
if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo)) 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); originalval = converter->FindGameObject(editobact->ob);
}
}
MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]), MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]),
KX_BLENDERTRUNC(editobact->linVelocity[1]), KX_BLENDERTRUNC(editobact->linVelocity[1]),
KX_BLENDERTRUNC(editobact->linVelocity[2])); KX_BLENDERTRUNC(editobact->linVelocity[2]));

View File

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

View File

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

View File

@@ -94,7 +94,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor
* PyObjectPlus Methods -- Every class, even the abstract one should have a Methods * PyObjectPlus Methods -- Every class, even the abstract one should have a Methods
------------------------------*/ ------------------------------*/
PyMethodDef PyObjectPlus::Methods[] = { PyMethodDef PyObjectPlus::Methods[] = {
{"isA", (PyCFunction) sPy_isA, Py_NEWARGS}, {"isA", (PyCFunction) sPy_isA, METH_VARARGS},
{NULL, NULL} /* Sentinel */ {NULL, NULL} /* Sentinel */
}; };
@@ -134,7 +134,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
------------------------------*/ ------------------------------*/
PyObject *PyObjectPlus::_repr(void) 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 PyObject *PyObjectPlus::Py_isA(PyObject *args) // Python wrapper for isA
{ {
char *mytypename; char *mytypename;
Py_Try(PyArg_ParseTuple(args, "s", &mytypename)); if (!PyArg_ParseTuple(args, "s", &mytypename))
return NULL;
if(isA(mytypename)) if(isA(mytypename))
{Py_INCREF(Py_True); return Py_True;} Py_RETURN_TRUE;
else else
{Py_INCREF(Py_False); return Py_False;}; Py_RETURN_FALSE;
} }
#endif //NO_EXP_PYTHON_EMBEDDING #endif //NO_EXP_PYTHON_EMBEDDING

View File

@@ -44,22 +44,7 @@
------------------------------*/ ------------------------------*/
// some basic python macros // some basic python macros
#define Py_NEWARGS 1
#define Py_Return { Py_INCREF(Py_None); return Py_None;} #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) { static inline void Py_Fatal(char *M) {
//cout << M << endl; //cout << M << endl;
@@ -136,6 +121,13 @@ static inline void Py_Fatal(char *M) {
}; \ }; \
static char method_name##_doc[]; \ 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) \ #define KX_PYMETHOD_DOC_O(class_name, method_name) \
PyObject* Py##method_name(PyObject* self, PyObject* value); \ PyObject* Py##method_name(PyObject* self, PyObject* value); \
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \

View File

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

View File

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

View File

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

View File

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

View File

@@ -273,36 +273,16 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* break it by hand, then DECREF (which in this case * break it by hand, then DECREF (which in this case
* should always ensure excdict is cleared). * 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 *excdict= PyDict_Copy(m_pythondictionary);
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
excdict, excdict, excdict);
excdict
);
PyDict_Clear(excdict);
Py_DECREF(excdict);
#else
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
m_pythondictionary,
m_pythondictionary
);
#endif
if (resultobj) if (resultobj)
{ {
Py_DECREF(resultobj); Py_DECREF(resultobj);
} else }
else
{ {
// something is wrong, tell the user what went wrong // something is wrong, tell the user what went wrong
printf("PYTHON SCRIPT ERROR:\n"); printf("PYTHON SCRIPT ERROR:\n");
@@ -310,6 +290,11 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
//PyRun_SimpleString(m_scriptText.Ptr()); //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; m_sCurrentController = NULL;
} }

View File

@@ -846,8 +846,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if(mShader==0) { if(mShader==0) {
PyErr_Format(PyExc_TypeError, "invalid shader object"); 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)" ) KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
@@ -900,7 +898,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
//else //else
// spit("Invalid texture sample index: " << index); // spit("Invalid texture sample index: " << index);
} }
Py_Return; Py_RETURN_NONE;
} }
return NULL; return NULL;
} }
@@ -919,8 +917,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; 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)") KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
float array[2]={ 0,0 }; 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) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
float array[3]={0,0,0}; 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) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
float array[4]={0,0,0,0}; 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)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
int value=0; 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)") KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
int array[2]={ 0,0 }; 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) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; 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) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";
int array[4]={0,0,0, 0}; 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) )") KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char*uniform = ""; char*uniform = "";
PyObject *listPtr =0; 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) )") KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )")
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char*uniform = ""; char*uniform = "";
PyObject *listPtr =0; 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)" ) "setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
float matr[16] = { 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)" ) "setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
float matr[9] = { float matr[9] = {
@@ -1347,8 +1333,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
int attr=0; int attr=0;
if(PyArg_ParseTuple(args, "i", &attr )) { 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)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" )
{ {
if(mError) { if(mError) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
char *uniform=""; char *uniform="";

View File

@@ -395,8 +395,8 @@ PyParentObject KX_CameraActuator::Parents[] = {
}; };
PyMethodDef KX_CameraActuator::Methods[] = { PyMethodDef KX_CameraActuator::Methods[] = {
{"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_VARARGS, SetObject_doc}, {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, SetObject_doc},
{"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_NOARGS, GetObject_doc}, {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
{"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc}, {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc},
{"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc}, {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc},
{"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc}, {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc},
@@ -413,50 +413,43 @@ PyObject* KX_CameraActuator::_getattr(const STR_String& attr) {
} }
/* get obj ---------------------------------------------------------- */ /* get obj ---------------------------------------------------------- */
char KX_CameraActuator::GetObject_doc[] = 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"; "\tReturns the object this sensor reacts to.\n";
PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args)
PyObject* args,
PyObject* kwds)
{ {
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()); return PyString_FromString(m_ob->GetName());
else
return m_ob->AddRef();
} }
/* set obj ---------------------------------------------------------- */ /* set obj ---------------------------------------------------------- */
char KX_CameraActuator::SetObject_doc[] = 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"; "\tSets the object this sensor reacts to.\n";
PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value)
PyObject* args,
PyObject* kwds)
{ {
KX_GameObject *gameobj;
PyObject* gameobj; if (!ConvertPythonToGameObject(value, &gameobj, true))
if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) return NULL; // ConvertPythonToGameObject sets the error
{
if (m_ob) if (m_ob != NULL)
m_ob->UnregisterActuator(this); m_ob->UnregisterActuator(this);
m_ob = (SCA_IObject*)gameobj; m_ob = (SCA_IObject*)gameobj;
if (m_ob) if (m_ob)
m_ob->RegisterActuator(this); m_ob->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
char* objectname; Py_RETURN_NONE;
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;
}
}
return NULL;
} }
/* get min ---------------------------------------------------------- */ /* get min ---------------------------------------------------------- */

View File

@@ -123,9 +123,9 @@ private :
virtual PyObject* _getattr(const STR_String& attr); virtual PyObject* _getattr(const STR_String& attr);
/* set object to look at */ /* set object to look at */
KX_PYMETHOD_DOC(KX_CameraActuator,SetObject); KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
/* get current object */ /* 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,SetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,GetMin); KX_PYMETHOD_DOC(KX_CameraActuator,GetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,SetMax); KX_PYMETHOD_DOC(KX_CameraActuator,SetMax);

View File

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

View File

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

View File

@@ -942,7 +942,7 @@ PyObject* KX_GameObject::PyEndObject(PyObject* self)
KX_Scene *scene = PHY_GetActiveScene(); KX_Scene *scene = PHY_GetActiveScene();
scene->DelayedRemoveObject(this); scene->DelayedRemoveObject(this);
return Py_None; Py_RETURN_NONE;
} }
@@ -1551,9 +1551,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
PyErr_Clear(); PyErr_Clear();
PyObject *pyother; 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())); return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition()));
} }
@@ -1574,11 +1574,12 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo,
if (!PyVecArgTo(args, toPoint)) if (!PyVecArgTo(args, toPoint))
{ {
PyErr_Clear(); 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(); toPoint = other->NodeGetWorldPosition();
}else } else
{ {
PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type"); PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type");
return NULL; return NULL;
@@ -1648,12 +1649,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
{ {
KX_GameObject *other; KX_GameObject *other;
PyErr_Clear(); 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"); PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject");
return NULL; return NULL;
} }
other = static_cast<KX_GameObject*>(pyarg);
toPoint = other->NodeGetWorldPosition();
} }
MT_Point3 fromPoint = NodeGetWorldPosition(); MT_Point3 fromPoint = NodeGetWorldPosition();
if (dist != 0.0f) if (dist != 0.0f)
@@ -1712,12 +1716,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
if (!PyVecTo(pyto, toPoint)) if (!PyVecTo(pyto, toPoint))
{ {
PyErr_Clear(); 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"); PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject");
return NULL; return NULL;
} }
other = static_cast<KX_GameObject*>(pyto);
toPoint = other->NodeGetWorldPosition();
} }
if (!pyfrom || pyfrom == Py_None) if (!pyfrom || pyfrom == Py_None)
{ {
@@ -1726,12 +1733,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
else if (!PyVecTo(pyfrom, fromPoint)) else if (!PyVecTo(pyfrom, fromPoint))
{ {
PyErr_Clear(); 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"); PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject");
return NULL; return NULL;
} }
other = static_cast<KX_GameObject*>(pyfrom);
fromPoint = other->NodeGetWorldPosition();
} }
if (dist != 0.0f) { 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;
}

View File

@@ -48,6 +48,7 @@
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */ #include "KX_KetsjiEngine.h" /* for m_anim_framerate */
#include "KX_IPhysicsController.h" /* for suspend/resume */ #include "KX_IPhysicsController.h" /* for suspend/resume */
#include "DNA_object_types.h" #include "DNA_object_types.h"
#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
#define KX_OB_DYNAMIC 1 #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 #endif //__KX_GAMEOBJECT

View File

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

View File

@@ -238,5 +238,5 @@ KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
"Reinstance the physics mesh.") "Reinstance the physics mesh.")
{ {
//this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ? //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;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,11 +8,13 @@ class KX_CameraActuator(SCA_IActuator):
@author: snail @author: snail
""" """
def getObject(): def getObject(name_only = 1):
""" """
Returns the name of the object this actuator tracks. 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): def setObject(target):
@@ -20,7 +22,7 @@ class KX_CameraActuator(SCA_IActuator):
Sets the object this actuator tracks. Sets the object this actuator tracks.
@param target: the object to track. @param target: the object to track.
@type target: string or L{KX_GameObject} @type target: L{KX_GameObject}, string or None
""" """
def getMin(): def getMin():

View File

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

View File

@@ -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)} 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. 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. 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 the name of the game object to be added.
Returns None if no game object has been assigned to be added. Returns None if no game object has been assigned to be added.
@type name_only: bool
@rtype: string @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): def setTime(time):
""" """

View File

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

View File

@@ -333,6 +333,8 @@ def read_opts(cfg, args):
('BF_X264_CONFIG', 'configuration flags for x264', ''), ('BF_X264_CONFIG', 'configuration flags for x264', ''),
('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''), ('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() ) # end of opts.AddOptions()
return localopts return localopts