[GameEngine] Commit all Kester's changes made to the gameengine to restore 2.25 like physics.

[SCons] Build with Solid as default when enabling the gameengine in the build process
[SCons] Build solid and qhull from the extern directory and link statically against them

That was about it.

There are a few things that needs double checking:

* Makefiles
* Projectfiles
* All the other systems than Linux and Windows on which the build (with scons) has been successfully tested.
This commit is contained in:
Nathan Letwory 2004-03-22 22:02:18 +00:00
parent 5b90aafbd6
commit 00291b5cf4
133 changed files with 9550 additions and 1534 deletions

@ -68,7 +68,7 @@ if sys.platform == 'linux2' or sys.platform == 'linux-i386':
# SOLID library information
solid_lib = [] # TODO
solid_libpath = [] # TODO
solid_include = ['#extern/solid/include']
solid_include = ['#extern/solid']
qhull_lib = [] # TODO
qhull_libpath = [] # TODO
qhull_include = ['#extern/qhull/include']
@ -156,7 +156,7 @@ elif sys.platform == 'darwin':
# SOLID library information
solid_lib = [] # TODO
solid_libpath = [] # TODO
solid_include = ['#extern/solid/include']
solid_include = ['#extern/solid']
qhull_lib = [] # TODO
qhull_libpath = [] # TODO
qhull_include = ['#extern/qhull/include']
@ -247,8 +247,8 @@ elif sys.platform == 'win32':
use_openal = 'true'
use_fmod = 'false'
use_quicktime = 'true'
use_sumo = 'false'
use_ode = 'true'
use_sumo = 'true'
use_ode = 'false'
use_buildinfo = 'false'
build_blender_dynamic = 'true'
build_blender_static = 'false'
@ -313,7 +313,7 @@ elif sys.platform == 'win32':
# SOLID library information
solid_lib = ['extern/solid']
solid_libpath = ['#../lib/windows/solid/lib']
solid_include = ['#../lib/windows/solid/include']
solid_include = ['#extern/solid']
qhull_lib = ['qhull']
qhull_libpath = ['#../lib/windows/qhull/lib']
qhull_include = ['#extern/qhull/include']
@ -391,7 +391,7 @@ elif string.find (sys.platform, 'sunos') != -1:
# SOLID library information
solid_lib = [] # TODO
solid_libpath = [] # TODO
solid_include = ['#extern/solid/include']
solid_include = ['#extern/solid']
qhull_lib = [] # TODO
qhull_libpath = [] # TODO
qhull_include = ['#extern/qhull/include']
@ -558,7 +558,7 @@ elif sys.platform=='openbsd3':
# SOLID library information
solid_lib = [] # TODO
solid_libpath = [] # TODO
solid_include = ['#extern/solid/include']
solid_include = ['#extern/solid']
qhull_lib = [] # TODO
qhull_libpath = [] # TODO
qhull_include = ['#extern/qhull/include']
@ -617,10 +617,10 @@ else:
config.write ("BUILD_DIR = %r\n"%(root_build_dir))
config.write ("USE_INTERNATIONAL = %r\n"%(use_international))
config.write ("BUILD_GAMEENGINE = %r\n"%(use_gameengine))
if use_sumo == 'true':
config.write ("USE_PHYSICS = 'solid'\n")
else:
if use_ode == 'true':
config.write ("USE_PHYSICS = 'ode'\n")
else:
config.write ("USE_PHYSICS = 'solid'\n")
config.write ("USE_OPENAL = %r\n"%(use_openal))
config.write ("USE_FMOD = %r\n"%(use_fmod))
config.write ("USE_QUICKTIME = %r\n"%(use_quicktime))
@ -903,9 +903,7 @@ if user_options_dict['BUILD_GAMEENGINE'] == 1:
'NG_network',
'NG_loopbacknetwork'])
if user_options_dict['USE_PHYSICS'] == 'solid':
link_env.Append (LIBS=['PHY_Sumo'])
link_env.Append (LIBS=['extern_qhull',
'extern_solid'])
link_env.Append (LIBS=['PHY_Sumo', 'PHY_Physics', 'blender_MT', 'extern_solid', 'extern_qhull'])
else:
link_env.Append (LIBS=['PHY_Ode',
'PHY_Physics'])

@ -1,10 +1,17 @@
import sys
qhull_env = Environment()
# Import the C flags set in the SConstruct file
Import ('cflags')
Import ('defines')
Import ('user_options_dict')
qhull_env.Append (CCFLAGS = cflags)
if sys.platform=='linux2' or sys.platform=='linux-i386':
qhull_env.Append (CCFLAGS = ['-O2', '-ansi'])
elif sys.platform=='sunos':
qhull_env.Append (CCFLAGS = ['Xc', '-v', '-fast'])
else:
qhull_env.Append (CCFLAGS = cflags)
qhull_env.Append (CPPDEFINES = defines)
source_files = ['src/geom.c',

@ -13,6 +13,9 @@ cxxflags = []
if sys.platform=='win32':
defines += ['WIN32','NDEBUG', '_WINDOWS', '_LIB']
cflags += ['/MT', '/W3', '/GX', '/O2']
elif sys.platform=='linux2' or sys.platform=='linux-i386':
defines += ['NDEBUG']
cflags += ['-O2']
else:
print "################################################"
print

276
extern/solid/SOLID/SOLID.h vendored Normal file

@ -0,0 +1,276 @@
/*
* SOLID - Software Library for Interference Detection
*
* Copyright (C) 2001-2003 Dtecta. All rights reserved.
*
* This library may be distributed under the terms of the Q Public License
* (QPL) as defined by Trolltech AS of Norway and appearing in the file
* LICENSE.QPL included in the packaging of this file.
*
* This library may be distributed and/or modified under the terms of the
* GNU General Public License (GPL) version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Commercial use or any other use of this library not covered by either
* the QPL or the GPL requires an additional license from Dtecta.
* Please contact info@dtecta.com for enquiries about the terms of commercial
* use of this library.
*/
#ifndef SOLID_H
#define SOLID_H
#include "SOLID_types.h"
#ifdef __cplusplus
extern "C" {
#endif
DT_DECLARE_HANDLE(DT_ObjectHandle);
DT_DECLARE_HANDLE(DT_SceneHandle);
DT_DECLARE_HANDLE(DT_ShapeHandle);
DT_DECLARE_HANDLE(DT_VertexBaseHandle);
DT_DECLARE_HANDLE(DT_RespTableHandle);
DT_DECLARE_HANDLE(DT_ArchiveHandle);
typedef unsigned int DT_ResponseClass;
typedef enum DT_ResponseType {
DT_NO_RESPONSE, /* No response (obsolete) */
DT_SIMPLE_RESPONSE, /* No collision data */
DT_WITNESSED_RESPONSE, /* A point common to both objects
is returned as collision data
*/
DT_DEPTH_RESPONSE /* The penetration depth is returned
as collision data. The penetration depth
is the shortest vector over which one
object needs to be translated in order
to bring the objects in touching contact.
*/
} DT_ResponseType;
/* For witnessed response, the following structure represents a common point. The world
coordinates of 'point1' and 'point2' coincide. 'normal' is the zero vector.
For depth response, the following structure represents the penetration depth.
'point1' en 'point2' are the witness points of the penetration depth in world coordinates.
The penetration depth vector in world coordinates is represented by 'normal'.
*/
typedef struct DT_CollData {
DT_Vector3 point1; /* Point in object1 in world coordinates */
DT_Vector3 point2; /* Point in object2 in world coordinates */
DT_Vector3 normal; /* point2 - point1 */
} DT_CollData;
/* A response callback is called by SOLID for each pair of collding objects. 'client-data'
is a pointer to an arbitrary structure in the client application. The client objects are
pointers to structures in the client application associated with the coliding objects.
'coll_data' is the collision data computed by SOLID.
*/
typedef DT_Bool (*DT_ResponseCallback)(void *client_data,
void *client_object1,
void *client_object2,
const DT_CollData *coll_data);
/* Shape definition */
extern DECLSPEC DT_ShapeHandle DT_NewBox(DT_Scalar x, DT_Scalar y, DT_Scalar z);
extern DECLSPEC DT_ShapeHandle DT_NewCone(DT_Scalar radius, DT_Scalar height);
extern DECLSPEC DT_ShapeHandle DT_NewCylinder(DT_Scalar radius, DT_Scalar height);
extern DECLSPEC DT_ShapeHandle DT_NewSphere(DT_Scalar radius);
extern DECLSPEC DT_ShapeHandle DT_NewPoint(const DT_Vector3 point);
extern DECLSPEC DT_ShapeHandle DT_NewLineSegment(const DT_Vector3 source, const DT_Vector3 target);
extern DECLSPEC DT_ShapeHandle DT_NewMinkowski(DT_ShapeHandle shape1, DT_ShapeHandle shape2);
extern DECLSPEC DT_ShapeHandle DT_NewHull(DT_ShapeHandle shape1, DT_ShapeHandle shape2);
extern DECLSPEC DT_VertexBaseHandle DT_NewVertexBase(const void *pointer, DT_Size stride);
extern DECLSPEC void DT_DeleteVertexBase(DT_VertexBaseHandle vertexBase);
extern DECLSPEC void DT_ChangeVertexBase(DT_VertexBaseHandle vertexBase, const void *pointer);
extern DECLSPEC DT_ShapeHandle DT_NewComplexShape(DT_VertexBaseHandle vertexBase);
extern DECLSPEC void DT_EndComplexShape();
extern DECLSPEC DT_ShapeHandle DT_NewPolytope(DT_VertexBaseHandle vertexBase);
extern DECLSPEC void DT_EndPolytope();
extern DECLSPEC void DT_Begin();
extern DECLSPEC void DT_End();
extern DECLSPEC void DT_Vertex(const DT_Vector3 vertex);
extern DECLSPEC void DT_VertexIndex(DT_Index index);
extern DECLSPEC void DT_VertexIndices(DT_Count count, const DT_Index *indices);
extern DECLSPEC void DT_VertexRange(DT_Index first, DT_Count count);
extern DECLSPEC void DT_DeleteShape(DT_ShapeHandle shape);
/* Object */
extern DECLSPEC DT_ObjectHandle DT_CreateObject(
void *client_object, /* pointer to object in client memory */
DT_ShapeHandle shape /* the shape or geometry of the object */
);
extern DECLSPEC void DT_DestroyObject(DT_ObjectHandle object);
extern DECLSPEC void DT_SetPosition(DT_ObjectHandle object, const DT_Vector3 position);
extern DECLSPEC void DT_SetOrientation(DT_ObjectHandle object, const DT_Quaternion orientation);
extern DECLSPEC void DT_SetScaling(DT_ObjectHandle object, const DT_Vector3 scaling);
/* The margin is an offset from the actual shape. The actual geometry of an
object is the set of points whose distance to the transformed shape is at
most the margin. During the lifetime of an object the margin can be
modified.
*/
extern DECLSPEC void DT_SetMargin(DT_ObjectHandle object, DT_Scalar margin);
/* These commands assume a column-major 4x4 OpenGL matrix representation */
extern DECLSPEC void DT_SetMatrixf(DT_ObjectHandle object, const float *m);
extern DECLSPEC void DT_GetMatrixf(DT_ObjectHandle object, float *m);
extern DECLSPEC void DT_SetMatrixd(DT_ObjectHandle object, const double *m);
extern DECLSPEC void DT_GetMatrixd(DT_ObjectHandle object, double *m);
extern DECLSPEC void DT_GetBBox(DT_ObjectHandle object, DT_Vector3 min, DT_Vector3 max);
/* This next command returns the distance between the objects. De returned
closest points are given in world coordinates.
*/
extern DECLSPEC DT_Scalar DT_GetClosestPair(DT_ObjectHandle object1, DT_ObjectHandle object2,
DT_Vector3 point1, DT_Vector3 point2);
extern DECLSPEC DT_Bool DT_GetCommonPoint(DT_ObjectHandle object1, DT_ObjectHandle object2,
DT_Vector3 point);
extern DECLSPEC DT_Bool DT_GetPenDepth(DT_ObjectHandle object1, DT_ObjectHandle object2,
DT_Vector3 point1, DT_Vector3 point2);
/* Scene */
extern DECLSPEC DT_SceneHandle DT_CreateScene();
extern DECLSPEC void DT_DestroyScene(DT_SceneHandle scene);
extern DECLSPEC void DT_AddObject(DT_SceneHandle scene, DT_ObjectHandle object);
extern DECLSPEC void DT_RemoveObject(DT_SceneHandle scene, DT_ObjectHandle object);
/* Note that objects can be assigned to multiple scenes! */
/* Response */
/* Response tables are defined independent of the scenes in which they are used.
Multiple response tables can be used in one scene, and a response table
can be shared among scenes.
*/
extern DECLSPEC DT_RespTableHandle DT_CreateRespTable();
extern DECLSPEC void DT_DestroyRespTable(DT_RespTableHandle respTable);
/* Responses are defined on (pairs of) response classes. Each response table
maintains its set of response classes.
*/
extern DECLSPEC DT_ResponseClass DT_GenResponseClass(DT_RespTableHandle respTable);
/* To each object for which a response is defined in the response table a
response class needs to be assigned.
*/
extern DECLSPEC void DT_SetResponseClass(DT_RespTableHandle respTable,
DT_ObjectHandle object,
DT_ResponseClass responseClass);
extern DECLSPEC void DT_ClearResponseClass(DT_RespTableHandle respTable,
DT_ObjectHandle object);
extern DECLSPEC void DT_CallResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object1,
DT_ObjectHandle object2,
const DT_CollData *coll_data);
/* For each pair of objects multiple responses can be defined. A response is a callback
together with its response type and client data. */
/* Responses can be defined for all pairs of response classes... */
extern DECLSPEC void DT_AddDefaultResponse(DT_RespTableHandle respTable,
DT_ResponseCallback response,
DT_ResponseType type, void *client_data);
extern DECLSPEC void DT_RemoveDefaultResponse(DT_RespTableHandle respTable,
DT_ResponseCallback response);
/* ...per response class... */
extern DECLSPEC void DT_AddClassResponse(DT_RespTableHandle respTable,
DT_ResponseClass responseClass,
DT_ResponseCallback response,
DT_ResponseType type, void *client_data);
extern DECLSPEC void DT_RemoveClassResponse(DT_RespTableHandle respTable,
DT_ResponseClass responseClass,
DT_ResponseCallback response);
/* ... and per pair of response classes...*/
extern DECLSPEC void DT_AddPairResponse(DT_RespTableHandle respTable,
DT_ResponseClass responseClass1,
DT_ResponseClass responseClass2,
DT_ResponseCallback response,
DT_ResponseType type, void *client_data);
extern DECLSPEC void DT_RemovePairResponse(DT_RespTableHandle respTable,
DT_ResponseClass responseClass1,
DT_ResponseClass responseClass2,
DT_ResponseCallback response);
/* The next command calls the response callbacks for all intersecting pairs of objects in a scene.
'DT_Test' returns the number of pairs of objects for which callbacks have been called.
*/
extern DECLSPEC DT_Count DT_Test(DT_SceneHandle scene, DT_RespTableHandle respTable);
/* Set the maximum relative error in the closest points and penetration depth
computation. The default for `max_error' is 1.0e-3. Larger errors result
in better performance. Non-positive error tolerances are ignored.
*/
extern DECLSPEC void DT_SetAccuracy(DT_Scalar max_error);
/* Set the maximum tolerance on relative errors due to rounding. The default for `tol_error'
is the machine epsilon. Very large tolerances result in false collisions. Setting tol_error too small
results in missed collisions. Non-positive error tolerances are ignored.
*/
extern DECLSPEC void DT_SetTolerance(DT_Scalar tol_error);
/* This function returns the client pointer to the first object in a scene hit by the ray
(actually a line segment) defined by the points 'from' en 'to'. The spot is the hit point
on the object in local coordinates. 'normal' is the normal to the surface of the object in
world coordinates. The ignore_client pointer is used to make one of the objects transparent.
NB: Currently ray tests are implemented for spheres, boxes, and meshes only!!
*/
extern DECLSPEC void *DT_RayCast(DT_SceneHandle scene, void *ignore_client,
const DT_Vector3 source, const DT_Vector3 target,
DT_Scalar max_param, DT_Scalar *param, DT_Vector3 normal);
/* Similar, only here a single object is tested and a boolean is returned */
extern DECLSPEC DT_Bool DT_ObjectRayCast(DT_ObjectHandle object,
const DT_Vector3 source, const DT_Vector3 target,
DT_Scalar max_param, DT_Scalar *param, DT_Vector3 normal);
#ifdef __cplusplus
}
#endif
#endif

75
extern/solid/SOLID/SOLID_broad.h vendored Normal file

@ -0,0 +1,75 @@
/*
* SOLID - Software Library for Interference Detection
*
* Copyright (C) 2001-2003 Dtecta. All rights reserved.
*
* This library may be distributed under the terms of the Q Public License
* (QPL) as defined by Trolltech AS of Norway and appearing in the file
* LICENSE.QPL included in the packaging of this file.
*
* This library may be distributed and/or modified under the terms of the
* GNU General Public License (GPL) version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Commercial use or any other use of this library not covered by either
* the QPL or the GPL requires an additional license from Dtecta.
* Please contact info@dtecta.com for enquiries about the terms of commercial
* use of this library.
*/
#ifndef SOLID_BROAD_H
#define SOLID_BROAD_H
#include "SOLID_types.h"
#ifdef __cplusplus
extern "C" {
#endif
DT_DECLARE_HANDLE(BP_SceneHandle);
DT_DECLARE_HANDLE(BP_ProxyHandle);
typedef void (*BP_Callback)(void *client_data,
void *object1,
void *object2);
typedef bool (*BP_RayCastCallback)(void *client_data,
void *object,
const DT_Vector3 source,
const DT_Vector3 target,
DT_Scalar *lambda);
extern DECLSPEC BP_SceneHandle BP_CreateScene(void *client_data,
BP_Callback beginOverlap,
BP_Callback endOverlap);
extern DECLSPEC void BP_DestroyScene(BP_SceneHandle scene);
extern DECLSPEC BP_ProxyHandle BP_CreateProxy(BP_SceneHandle scene,
void *object,
const DT_Vector3 min,
const DT_Vector3 max);
extern DECLSPEC void BP_DestroyProxy(BP_SceneHandle scene,
BP_ProxyHandle proxy);
extern DECLSPEC void BP_SetBBox(BP_ProxyHandle proxy,
const DT_Vector3 min,
const DT_Vector3 max);
extern DECLSPEC void *BP_RayCast(BP_SceneHandle scene,
BP_RayCastCallback objectRayCast,
void *client_data,
const DT_Vector3 source,
const DT_Vector3 target,
DT_Scalar *lambda);
#ifdef __cplusplus
}
#endif
#endif

53
extern/solid/SOLID/SOLID_types.h vendored Normal file

@ -0,0 +1,53 @@
/*
* SOLID - Software Library for Interference Detection
*
* Copyright (C) 2001-2003 Dtecta. All rights reserved.
*
* This library may be distributed under the terms of the Q Public License
* (QPL) as defined by Trolltech AS of Norway and appearing in the file
* LICENSE.QPL included in the packaging of this file.
*
* This library may be distributed and/or modified under the terms of the
* GNU General Public License (GPL) version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Commercial use or any other use of this library not covered by either
* the QPL or the GPL requires an additional license from Dtecta.
* Please contact info@dtecta.com for enquiries about the terms of commercial
* use of this library.
*/
#ifndef SOLID_TYPES_H
#define SOLID_TYPES_H
#ifndef DECLSPEC
# ifdef WIN32
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC
# endif
#endif
#define DT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
typedef unsigned short DT_Index;
typedef unsigned short DT_Count;
typedef unsigned int DT_Size;
typedef float DT_Scalar;
typedef int DT_Bool;
#define DT_FALSE 0
#define DT_TRUE 1
#define DT_CONTINUE 0
#define DT_DONE 1
typedef DT_Scalar DT_Vector3[3];
typedef DT_Scalar DT_Quaternion[4];
#endif

@ -217,7 +217,7 @@ Mesh *add_mesh()
me->size[0]= me->size[1]= me->size[2]= 1.0;
me->smoothresh= 30;
me->texflag= ME_AUTOSPACE;
me->texflag= AUTOSPACE;
me->flag= ME_TWOSIDED;
me->subdiv= 1;
me->subdivr = 1;
@ -398,7 +398,7 @@ void tex_space_mesh(Mesh *me)
boundbox_mesh(me, loc, size);
if(me->texflag & ME_AUTOSPACE) {
if(me->texflag & AUTOSPACE) {
if(me->key) {
kb= me->key->refkey;
if (kb) {

@ -258,8 +258,72 @@ typedef enum {
#define BIFNICONIDS (BIFICONID_LAST-BIFICONID_FIRST + 1)
} BIFIconID;
typedef enum {
#define BIFCOLORSHADE_FIRST (COLORSHADE_DARK)
COLORSHADE_DARK,
COLORSHADE_GREY,
COLORSHADE_MEDIUM,
COLORSHADE_HILITE,
COLORSHADE_LIGHT,
COLORSHADE_WHITE,
#define BIFCOLORSHADE_LAST (COLORSHADE_WHITE)
#define BIFNCOLORSHADES (BIFCOLORSHADE_LAST-BIFCOLORSHADE_FIRST + 1)
} BIFColorShade;
/* ---------- theme ----------- */
typedef enum {
#define BIFCOLORID_FIRST (BUTGREY)
BUTGREY = 0,
BUTGREEN,
BUTBLUE,
BUTSALMON,
MIDGREY,
BUTPURPLE,
BUTYELLOW,
REDALERT,
BUTRUST,
BUTWHITE,
BUTDBLUE,
BUTPINK,
BUTDPINK,
BUTMACTIVE,
BUTIPO,
BUTAUDIO,
BUTCAMERA,
BUTRANDOM,
BUTEDITOBJECT,
BUTPROPERTY,
BUTSCENE,
BUTMOTION,
BUTMESSAGE,
BUTACTION,
BUTCD,
BUTGAME,
BUTVISIBILITY,
BUTYUCK,
BUTSEASICK,
BUTCHOKE,
BUTIMPERIAL,
BUTTEXTCOLOR,
BUTTEXTPRESSED,
BUTSBACKGROUND,
VIEWPORTBACKCOLOR,
VIEWPORTGRIDCOLOR,
VIEWPORTACTIVECOLOR,
VIEWPORTSELECTEDCOLOR,
VIEWPORTUNSELCOLOR,
EDITVERTSEL,
EDITVERTUNSEL,
EDITEDGESEL,
EDITEDGEUNSEL,
#define BIFCOLORID_LAST (EDITEDGEUNSEL)
#define BIFNCOLORIDS (BIFCOLORID_LAST-BIFCOLORID_FIRST + 1)
} BIFColorID;
enum {
TH_AUTO, /* for buttons, to signal automatic color assignment */
@ -355,6 +419,8 @@ void BIF_InitTheme(void);
void BIF_SetTheme(struct ScrArea *sa);
void BIF_resources_init (void);
void BIF_resources_free (void);
void BIF_colors_init (void);
void BIF_load_ui_colors (void);
// icon API
@ -368,4 +434,6 @@ char *BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid);
char *BIF_ThemeColorsPup(int spacetype);
void BIF_def_color (BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b);
#endif /* BIF_ICONS_H */

@ -74,6 +74,9 @@ extern void do_mballbuts(unsigned short event);
extern void do_latticebuts(unsigned short event);
extern void do_fpaintbuts(unsigned short event);
/* dont like it here , rather make a BIF_Buttons_Editing.h or so BM*/
extern int Buttons_Editing_GetFaceShadows();
/* shading */
extern void material_panels(void);
extern void do_matbuts(unsigned short event);
@ -97,6 +100,9 @@ extern void do_scriptbuts(unsigned short event);
/* ipowindow */
extern void do_ipobuts(unsigned short event); // drawipo.c (bad! ton)
/* uvautocalculation */
void do_uvautocalculationbuts(unsigned short event);
void get_uvautocalculationsettings(float *radius,float *cubesize, int *mapdir, int *mapalign);
/* butspace.c */
void test_meshpoin_but(char *name, struct ID **idpp);
void test_obpoin_but(char *name, struct ID **idpp);
@ -337,6 +343,14 @@ enum {
#define B_VERTEXSMOOTH 2080
#define B_MAKESTICKY 2082
#define B_MAKEVERTCOL 2083
#define B_CHROMADEPTH 2084
#define B_ISDEFLECTOR 2085
#define B_PDEFDAMPING 2086
#define B_GRAVITY 2087
#define B_GRAVSTRENGTH 2088
#define B_GRAVPOWER 2089
#define B_PDEFRDAMP 2090
#define B_PDEFPERM 2091
/* *********************** */
#define B_CURVEBUTS 2200
@ -416,6 +430,12 @@ enum {
#define B_SOUNDACT_BROWSE 2712
#define B_SETSECTOR 2713
#define B_SETPROP 2714
#define B_SETACTOR 2715
#define B_SETMAINACTOR 2716
#define B_SETDYNA 2717
/* *********************** */
#define B_FPAINTBUTS 2900
@ -508,8 +528,37 @@ enum {
B_CONSTRAINT_ADD_LOCLIKE,
B_CONSTRAINT_ADD_ACTION,
B_CONSTRAINT_ADD_LOCKTRACK,
B_CONSTRAINT_ADD_FOLLOWPATH
B_CONSTRAINT_ADD_FOLLOWPATH,
B_CONSTRAINT_ADD_DISTANCELIMIT
};
/*+++ BM */
/* *********************** */
#define B_UVAUTOCALCBUTS 3400
enum {
B_UVAUTO_REDRAW = 3301,
B_UVAUTO_SPHERE,
B_UVAUTO_CYLINDER,
B_UVAUTO_CYLRADIUS,
B_UVAUTO_WINDOW,
B_UVAUTO_CUBE,
B_UVAUTO_CUBESIZE,
B_UVAUTO_STD1,
B_UVAUTO_STD2,
B_UVAUTO_STD4,
B_UVAUTO_STD8,
B_UVAUTO_BOUNDS1,
B_UVAUTO_BOUNDS2,
B_UVAUTO_BOUNDS4,
B_UVAUTO_BOUNDS8,
B_UVAUTO_TOP,
B_UVAUTO_FACE,
B_UVAUTO_OBJECT,
B_UVAUTO_ALIGNX,
B_UVAUTO_ALIGNY
};
/* *********************** */
/*--- BM */
/* *********************** */

@ -217,6 +217,7 @@
#define REDRAWBUTSSCRIPT 0x401A
#define REDRAWBUTSLOGIC 0x401B
#define REDRAWBUTSSHADING 0x401C
#define REDRAWBUTSGAME 0x401D
#define REDRAWINFO 0x4021
#define RENDERPREVIEW 0x4022
@ -234,6 +235,7 @@
#define REDRAWTEXT 0x402E
#define REDRAWSOUND 0x402F
#define REDRAWACTION 0x4030
#define REDRAWBUTSCONSTRAINT 0x4034
#define REDRAWNLA 0x4031
#define REDRAWSCRIPT 0x4032

@ -79,8 +79,8 @@ typedef struct bKinematicConstraint{
typedef struct bTrackToConstraint{
Object *tar;
int reserved1; /* Track Axis */
int reserved2; /* Up Axis */
int reserved1; /* I'll be using reserved1 and reserved2 as Track and Up flags, not sure if that's what they were intented for anyway. Not sure either if it would create backward incompatibility if I were to rename them. - theeth*/
int reserved2;
char subtarget[32];
} bTrackToConstraint;
@ -126,6 +126,17 @@ typedef struct bFollowPathConstraint{
int upflag;
} bFollowPathConstraint;
/* Distance Limiting constraints */
typedef struct bDistanceLimitConstraint{
Object *tar;
char subtarget[32];
float pad1;
float pad2;
float distance;
float offset[3];
} bDistanceLimitConstraint;
/* Zero-target constraints */
typedef struct bRotationConstraint{
float xmin, xmax;
@ -133,6 +144,8 @@ typedef struct bRotationConstraint{
float zmin, zmax;
} bRotationConstraint;
/* bConstraint.type */
#define CONSTRAINT_TYPE_NULL 0
#define CONSTRAINT_TYPE_CHILDOF 1 /* Unimplemented */
@ -148,6 +161,7 @@ typedef struct bRotationConstraint{
#define CONSTRAINT_TYPE_PYTHON 11 /* Unimplemented */
#define CONSTRAINT_TYPE_ACTION 12
#define CONSTRAINT_TYPE_LOCKTRACK 13 /* New Tracking constraint that locks an axis in place - theeth */
#define CONSTRAINT_TYPE_DISTANCELIMIT 14
/* bConstraint.flag */
#define CONSTRAINT_EXPAND 0x00000001
@ -167,6 +181,39 @@ typedef struct bRotationConstraint{
#define LOCLIKE_X 0x00000001
#define LOCLIKE_Y 0x00000002
#define LOCLIKE_Z 0x00000004
#define LOCSPACE 0x00000008
/* Tracking flags */
#define LOCK_X 0x00000000
#define LOCK_Y 0x00000001
#define LOCK_Z 0x00000002
#define UP_X 0x00000000
#define UP_Y 0x00000001
#define UP_Z 0x00000002
#define TRACK_X 0x00000000
#define TRACK_Y 0x00000001
#define TRACK_Z 0x00000002
#define TRACK_nX 0x00000003
#define TRACK_nY 0x00000004
#define TRACK_nZ 0x00000005
/* Tracking flags */
#define LOCK_X 0x00000000
#define LOCK_Y 0x00000001
#define LOCK_Z 0x00000002
#define UP_X 0x00000000
#define UP_Y 0x00000001
#define UP_Z 0x00000002
#define TRACK_X 0x00000000
#define TRACK_Y 0x00000001
#define TRACK_Z 0x00000002
#define TRACK_nX 0x00000003
#define TRACK_nY 0x00000004
#define TRACK_nZ 0x00000005
/* Tracking flags */
#define LOCK_X 0x00000000

@ -100,7 +100,7 @@ typedef struct Mesh {
/* **************** MESH ********************* */
/* texflag */
#define ME_AUTOSPACE 1
#define AUTOSPACE 1
/* me->flag */
#define ME_ISDONE 1

@ -64,6 +64,18 @@ typedef struct BoundBox {
float vec[8][3];
} BoundBox;
/* OcInfo and LBuf structs are for the Enji gameengine */
typedef struct OcInfo {
float dvec[3];
float size[3];
} OcInfo;
typedef struct LBuf {
short tot, max;
int pad;
struct Object **ob;
} LBuf;
typedef struct Object {
ID id;
@ -153,6 +165,7 @@ typedef struct Object {
* bit 8: Friction is anisotropic
* bit 9: Object is a ghost
* bit 10: Do rigid body dynamics.
* bit 11: Use bounding object for physics
*/
int gameflag;
/**
@ -165,6 +178,13 @@ typedef struct Object {
ListBase constraints;
ListBase nlastrips;
struct Life *life;
LBuf lbuf;
LBuf port;
float toonedge, pad2;
} Object;
/* this work object is defined in object.c */
@ -250,6 +270,11 @@ extern Object workob;
#define OB_SOLID 3
#define OB_SHADED 4
#define OB_TEXTURE 5
#define OB_TOON_MONO 6
#define OB_TOON_COLOR 7
#define OB_TOON_TRANSP 8
#define OB_TOON_FLAT 9
#define OB_TOON_SMOOTH 10
/* dtx: flags */
#define OB_AXIS 2
@ -291,6 +316,7 @@ extern Object workob;
#define OB_ANISOTROPIC_FRICTION 256
#define OB_GHOST 512
#define OB_RIGID_BODY 1024
#define OB_BOUNDS 2048
#define OB_COLLISION_RESPONSE 4096
#define OB_SECTOR 8192

@ -63,6 +63,8 @@
#include "DNA_sound_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
#include "DNA_mesh_types.h"
#include "DNA_world_types.h"
#include "BKE_library.h"
#include "BKE_global.h"
@ -87,7 +89,6 @@
#include "nla.h" /* For __NLA : Important, do not remove */
#include "butspace.h" // own module
/* internals */
/****/
@ -346,7 +347,31 @@ void do_logic_buts(unsigned short event)
if(ob==0) return;
switch(event) {
case B_SETSECTOR:
/* check for inconsistant types */
ob->gameflag &= ~(OB_PROP|OB_MAINACTOR|OB_DYNAMIC|OB_ACTOR);
ob->dtx |= OB_BOUNDBOX;
allqueue(REDRAWBUTSGAME, 0);
allqueue(REDRAWVIEW3D, 0);
break;
case B_SETPROP:
/* check for inconsistant types */
ob->gameflag &= ~(OB_SECTOR|OB_MAINACTOR|OB_DYNAMIC|OB_ACTOR);
allqueue(REDRAWBUTSGAME, 0);
allqueue(REDRAWVIEW3D, 0);
break;
case B_SETACTOR:
case B_SETDYNA:
case B_SETMAINACTOR:
ob->gameflag &= ~(OB_SECTOR|OB_PROP);
allqueue(REDRAWBUTSGAME, 0);
allqueue(REDRAWVIEW3D, 0);
break;
case B_ADD_PROP:
prop= new_property(PROP_FLOAT);
make_unique_prop_names(prop->name);
@ -2246,12 +2271,128 @@ static uiBlock *actuator_menu(void *arg_unused)
return block;
}
void buttons_enji(uiBlock *block, Object *ob)
{
uiDefBut(block, TOG|INT|BIT|13, B_SETSECTOR, "Sector",
10,205,65,19, &ob->gameflag, 0, 0, 0, 0,
"All game elements should be in the Sector boundbox");
uiDefBut(block, TOG|INT|BIT|14, B_SETPROP, "Prop",
75,205,65,19, &ob->gameflag, 0, 0, 0, 0,
"An Object fixed within a sector");
uiBlockSetCol(block, BUTPURPLE);
uiDefBut(block, TOG|INT|BIT|2, B_SETACTOR, "Actor",
140,205,65,19, &ob->gameflag, 0, 0, 0, 0,
"Objects that are evaluated by the engine ");
if(ob->gameflag & OB_ACTOR) {
uiDefBut(block, TOG|INT|BIT|0, B_SETDYNA, "Dynamic",
205,205,75,19, &ob->gameflag, 0, 0, 0, 0,
"Motion defined by laws of physics");
uiDefBut(block, TOG|INT|BIT|15, B_SETMAINACTOR, "MainActor",
280,205,70,19, &ob->gameflag, 0, 0, 0, 0, "");
if(ob->gameflag & OB_DYNAMIC) {
uiDefBut(block, TOG|INT|BIT|6, B_DIFF, "Do Fh",
10,185,50,19, &ob->gameflag, 0, 0, 0, 0,
"Use Fh settings in Materials");
uiDefBut(block, TOG|INT|BIT|7, B_DIFF, "Rot Fh",
60,185,50,19, &ob->gameflag, 0, 0, 0, 0,
"Use face normal to rotate Object");
uiBlockSetCol(block, BUTGREY);
uiDefBut(block, NUM|FLO, B_DIFF, "Mass:",
110, 185, 120, 19, &ob->mass, 0.01, 100.0, 10, 0,
"The mass of the Object");
uiDefBut(block, NUM|FLO, REDRAWVIEW3D, "Size:",
230, 185, 120, 19, &ob->inertia, 0.01, 10.0, 10, 0,
"Bounding sphere size");
uiDefBut(block, NUM|FLO, B_DIFF, "Damp:",
10, 165, 100, 19, &ob->damping, 0.0, 1.0, 10, 0,
"General movement damping");
uiDefBut(block, NUM|FLO, B_DIFF, "RotDamp:",
110, 165, 120, 19, &ob->rdamping, 0.0, 1.0, 10, 0,
"General rotation damping");
}
}
}
void buttons_ketsji(uiBlock *block, Object *ob)
{
uiDefButI(block, TOG|BIT|2, B_REDR, "Actor",
10,205,75,19, &ob->gameflag, 0, 0, 0, 0,
"Objects that are evaluated by the engine ");
if(ob->gameflag & OB_ACTOR) {
uiDefButI(block, TOG|BIT|9, B_REDR, "Ghost", 85,205,65,19,
&ob->gameflag, 0, 0, 0, 0,
"Objects that don't restitute collisions (like a ghost)");
uiDefButI(block, TOG|BIT|0, B_REDR, "Dynamic", 150,205,65,19,
&ob->gameflag, 0, 0, 0, 0,
"Motion defined by laws of physics");
if(ob->gameflag & OB_DYNAMIC) {
uiDefButI(block, TOG|BIT|10, B_REDR, "Rigid Body", 215,205,135,19,
&ob->gameflag, 0, 0, 0, 0,
"Enable rolling physics");
uiDefButI(block, TOG|BIT|6, B_DIFF, "Do Fh", 10,185,50,19,
&ob->gameflag, 0, 0, 0, 0,
"Use Fh settings in Materials");
uiDefButI(block, TOG|BIT|7, B_DIFF, "Rot Fh", 60,185,50,19,
&ob->gameflag, 0, 0, 0, 0,
"Use face normal to rotate Object");
uiDefButF(block, NUM, B_DIFF, "Mass:", 110, 185, 80, 19,
&ob->mass, 0.01, 100.0, 10, 0,
"The mass of the Object");
uiDefButF(block, NUM, REDRAWVIEW3D, "Size:", 190, 185, 80, 19,
&ob->inertia, 0.01, 10.0, 10, 0,
"Bounding sphere size");
uiDefButF(block, NUM, B_DIFF, "Form:", 270, 185, 80, 19,
&ob->formfactor, 0.01, 100.0, 10, 0,
"Form factor");
uiDefButF(block, NUM, B_DIFF, "Damp:", 10, 165, 100, 19,
&ob->damping, 0.0, 1.0, 10, 0,
"General movement damping");
uiDefButF(block, NUM, B_DIFF, "RotDamp:", 110, 165, 120, 19,
&ob->rdamping, 0.0, 1.0, 10, 0,
"General rotation damping");
uiDefButI(block, TOG|BIT|8, B_REDR, "Anisotropic",
230, 165, 120, 19,
&ob->gameflag, 0.0, 1.0, 10, 0,
"Enable anisotropic friction");
}
if (ob->gameflag & OB_ANISOTROPIC_FRICTION) {
uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 145, 114, 19,
&ob->anisotropicFriction[0], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the x-direction.");
uiDefButF(block, NUM, B_DIFF, "y friction:", 124, 145, 113, 19,
&ob->anisotropicFriction[1], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the y-direction.");
uiDefButF(block, NUM, B_DIFF, "z friction:", 237, 145, 113, 19,
&ob->anisotropicFriction[2], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the z-direction.");
}
}
if (!(ob->gameflag & OB_GHOST)) {
uiDefButI(block, TOG|BIT|11, B_REDR, "Bounds", 10, 125, 75, 19,
&ob->gameflag, 0, 0,0, 0,
"Specify a bounds object for physics");
if (ob->gameflag & OB_BOUNDS) {
uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
85, 125, 100, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
}
}
}
/* never used, see CVS 1.134 for the code */
/* static FreeCamera *new_freecamera(void) */
/* never used, see CVS 1.120 for the code */
/* static uiBlock *freecamera_menu(void) */
void logic_buts(void)
{
ID **idar;
@ -2262,11 +2403,15 @@ void logic_buts(void)
bActuator *act;
uiBlock *block;
uiBut *but;
World *wrld;
int a;
short xco, yco, count, width, ycoo;
char *pupstr, name[32];
int butreturn = 0;
wrld= G.scene->world;
if(wrld==0) return;
ob= OBACT;
if(ob==0) return;
@ -2277,47 +2422,13 @@ void logic_buts(void)
uiBlockSetCol(block, TH_BUT_SETTING2);
uiDefButI(block, TOG|BIT|2, B_REDR, "Actor",
25,205,60,19, &ob->gameflag, 0, 0, 0, 0,
"Objects that are evaluated by the engine ");
if(ob->gameflag & OB_ACTOR) {
uiDefButI(block, TOG|BIT|9, B_REDR, "Ghost", 85,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Objects that don't restitute collisions (like a ghost)");
uiDefButI(block, TOG|BIT|0, B_REDR, "Dynamic", 150,205,65,19, &ob->gameflag, 0, 0, 0, 0, "Motion defined by laws of physics");
if(ob->gameflag & OB_DYNAMIC) {
uiDefButI(block, TOG|BIT|10, B_REDR, "Rigid Body", 215,205,135,19, &ob->gameflag, 0, 0, 0, 0, "");
uiDefButI(block, TOG|BIT|6, B_DIFF, "Do Fh", 10,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use Fh settings in Materials");
uiDefButI(block, TOG|BIT|7, B_DIFF, "Rot Fh", 60,185,50,19, &ob->gameflag, 0, 0, 0, 0, "Use face normal to rotate Object");
uiDefButF(block, NUM, B_DIFF, "Mass:", 110, 185, 80, 19, &ob->mass, 0.01, 100.0, 10, 0, "The mass of the Object");
uiDefButF(block, NUM, REDRAWVIEW3D, "Size:", 190, 185, 80, 19, &ob->inertia, 0.01, 10.0, 10, 0, "Bounding sphere size");
uiDefButF(block, NUM, B_DIFF, "Form:", 270, 185, 80, 19, &ob->formfactor, 0.01, 100.0, 10, 0, "Form factor");
uiDefButF(block, NUM, B_DIFF, "Damp:", 10, 165, 100, 19, &ob->damping, 0.0, 1.0, 10, 0, "General movement damping");
uiDefButF(block, NUM, B_DIFF, "RotDamp:", 110, 165, 120, 19, &ob->rdamping, 0.0, 1.0, 10, 0, "General rotation damping");
uiDefButI(block, TOG|BIT|8, B_REDR, "Anisotropic", 230, 165, 120, 19,
&ob->gameflag, 0.0, 1.0, 10, 0,
"Enable anisotropic friction");
}
}
if (ob->gameflag & OB_ANISOTROPIC_FRICTION) {
uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 145, 114, 19,
&ob->anisotropicFriction[0], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the x-direction.");
uiDefButF(block, NUM, B_DIFF, "y friction:", 124, 145, 113, 19,
&ob->anisotropicFriction[1], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the y-direction.");
uiDefButF(block, NUM, B_DIFF, "z friction:", 237, 145, 113, 19,
&ob->anisotropicFriction[2], 0.0, 1.0, 10, 0,
"Relative friction coefficient in the z-direction.");
}
if (wrld->physicsEngine == 1)
buttons_enji(block, ob);
if ( (wrld->physicsEngine == 4) || (wrld->physicsEngine == 2) )
buttons_ketsji(block, ob);
uiBlockSetCol(block, TH_AUTO);
uiDefBut(block, BUT, B_ADD_PROP, "ADD property", 10, 110, 340, 24,
uiDefBut(block, BUT, B_ADD_PROP, "ADD property", 10, 90, 340, 24,
NULL, 0.0, 100.0, 100, 0,
"");
@ -2327,10 +2438,10 @@ void logic_buts(void)
prop= ob->prop.first;
while(prop) {
but= uiDefBut(block, BUT, 1, "Del", 10, (short)(90-20*a), 40, 19, NULL, 0.0, 0.0, 1, (float)a, "");
but= uiDefBut(block, BUT, 1, "Del", 10, (short)(70-20*a), 40, 19, NULL, 0.0, 0.0, 1, (float)a, "");
uiButSetFunc(but, del_property, prop, NULL);
uiDefButS(block, MENU, B_CHANGE_PROP, pupstr, 50, (short)(90-20*a), 60, 19, &prop->type, 0, 0, 0, 0, "");
but= uiDefBut(block, TEX, 1, "Name:", 110, (short)(90-20*a), 105, 19, prop->name, 0, 31, 0, 0, "");
uiDefButS(block, MENU, B_CHANGE_PROP, pupstr, 50, (short)(70-20*a), 60, 19, &prop->type, 0, 0, 0, 0, "");
but= uiDefBut(block, TEX, 1, "Name:", 110, (short)(70-20*a), 105, 19, prop->name, 0, 31, 0, 0, "");
uiButSetFunc(but, make_unique_prop_names_cb, prop->name, (void*) 1);
if (strcmp(prop->name, "Text") == 0) {
@ -2340,19 +2451,19 @@ void logic_buts(void)
}
if(prop->type==PROP_BOOL) {
uiDefButI(block, TOG|BIT|0, B_REDR, "True", 215, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, "");
uiDefButI(block, TOGN|BIT|0, B_REDR, "False", 270, (short)(90-20*a), 55, 19, &prop->data, 0, 0, 0, 0, "");
uiDefButI(block, TOG|BIT|0, B_REDR, "True", 215, (short)(70-20*a), 55, 19, &prop->data, 0, 0, 0, 0, "");
uiDefButI(block, TOGN|BIT|0, B_REDR, "False", 270, (short)(70-20*a), 55, 19, &prop->data, 0, 0, 0, 0, "");
}
else if(prop->type==PROP_INT)
uiDefButI(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, &prop->data, -10000, 10000, 0, 0, "");
uiDefButI(block, NUM, butreturn, "", 215, (short)(70-20*a), 110, 19, &prop->data, -10000, 10000, 0, 0, "");
else if(prop->type==PROP_FLOAT)
uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 100, 0, "");
uiDefButF(block, NUM, butreturn, "", 215, (short)(70-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 100, 0, "");
else if(prop->type==PROP_STRING)
uiDefBut(block, TEX, butreturn, "", 215, (short)(90-20*a), 110, 19, prop->poin, 0, 127, 0, 0, "");
uiDefBut(block, TEX, butreturn, "", 215, (short)(70-20*a), 110, 19, prop->poin, 0, 127, 0, 0, "");
else if(prop->type==PROP_TIME)
uiDefButF(block, NUM, butreturn, "", 215, (short)(90-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 0, 0, "");
uiDefButF(block, NUM, butreturn, "", 215, (short)(70-20*a), 110, 19, (float*) &prop->data, -10000, 10000, 0, 0, "");
uiDefButS(block, TOG|BIT|0, 0, "D", 325, (short)(90-20*a), 20, 19, &prop->flag, 0, 0, 0, 0, "Print Debug info");
uiDefButS(block, TOG|BIT|0, 0, "D", 325, (short)(70-20*a), 20, 19, &prop->flag, 0, 0, 0, 0, "Print Debug info");
a++;
prop= prop->next;

@ -1066,10 +1066,10 @@ static void render_panel_render(void)
uiDefButI(block, TOG|BIT|7,0,"x", 665,50,20,23,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
uiDefButI(block, TOG|BIT|17,0,"Gauss", 564,30,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Gaussian sampling filter for antialiasing");
uiDefButF(block, NUM,B_DIFF,"", 624,30,60,20,&G.scene->r.gauss,0.5, 1.5, 100, 2, "Sets the Gaussian filter size)");
uiDefButF(block, NUM,B_DIFF,"", 624,30,60,20,&G.scene->r.gauss,0.5, 1.5, 100, 2, "Sets the Gaussian filter size");
uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border", 564,10,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
uiDefButI(block, TOG|BIT|2,B_REDR, "Gamma", 624,10,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
uiDefButI(block, TOG|BIT|2,0, "Gamma", 624,10,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
}

@ -3229,7 +3229,7 @@ void ob_to_tex_transob(Object *ob, TransOb *tob)
if(id==0);
else if( GS(id->name)==ID_ME) {
me= ob->data;
me->texflag &= ~ME_AUTOSPACE;
me->texflag &= ~AUTOSPACE;
tob->loc= me->loc;
tob->rot= me->rot;
tob->size= me->size;

@ -991,7 +991,7 @@ void sound_init_audio(void)
hSystem = SYS_GetSystem();
noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0);
if (1)/*(noaudio) intrr: disable game engine audio (openal) */
if (noaudio)/*(noaudio) intrr: disable game engine audio (openal) */
SND_SetDeviceType(snd_e_dummydevice);
ghAudioDeviceInterface = SND_GetAudioDevice();

@ -53,12 +53,8 @@
#include "KX_PyConstraintBinding.h"
#include "RAS_OpenGLRasterizer.h"
#include "RAS_CheckVertexArrays.h"
#ifdef WIN32
#include "RAS_VAOpenGLRasterizer.h"
#endif
#include "RAS_GLExtensionManager.h"
#include "NG_LoopBackNetworkDeviceInterface.h"
#include "SND_DeviceManager.h"
@ -102,6 +98,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
strcpy (pathname, maggie->name);
STR_String exitstring = "";
BlendFileData *bfd= NULL;
RAS_GLExtensionManager *extman = new RAS_GLExtensionManager(SYS_GetCommandLineInt(SYS_GetSystem(), "show_extensions", 1));
extman->LinkExtensions();
do
{
@ -121,17 +120,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
RAS_IRasterizer* rasterizer = NULL;
// let's see if we want to use vertexarrays or not
#ifdef WIN32
int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1);
bool useVertexArrays = (usevta > 0);
if (useVertexArrays && RAS_SystemSupportsVertexArrays())
if (useVertexArrays && extman->QueryVersion(1, 1))
rasterizer = new RAS_VAOpenGLRasterizer(canvas);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
#else
rasterizer = new RAS_OpenGLRasterizer(canvas);
#endif
// create the inputdevices
KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
@ -374,5 +369,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
}
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
if (extman)
{
delete extman;
extman = NULL;
}
if (bfd) BLO_blendfiledata_free(bfd);
}

@ -88,8 +88,7 @@ void KX_BlenderPolyMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cach
rasty->EnableTextures(false);
}
//TF_TWOSIDE == 512, todo, make this a ketsji enum
if(m_drawingmode & 512)
if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE)
{
rasty->SetCullFace(false);
}
@ -97,6 +96,13 @@ void KX_BlenderPolyMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cach
{
rasty->SetCullFace(true);
}
if (m_drawingmode & RAS_IRasterizer::KX_LINES) {
rasty->SetLines(true);
}
else {
rasty->SetLines(false);
}
}
rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);

@ -62,6 +62,11 @@
#include "STR_String.h"
#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting)
#include "SM_Scene.h"
#include "SumoPhysicsEnvironment.h"
#include "KX_SumoPhysicsController.h"
#include "KX_Scene.h"
KX_BlenderRenderTools::KX_BlenderRenderTools()
{
}
@ -174,29 +179,32 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
{
// shadow must be cast to the ground, physics system needed here!
// KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
MT_Vector3 direction = MT_Vector3(0,0,-1);
direction.normalize();
direction *= 100000;
// MT_Point3 topoint = frompoint + direction;
MT_Point3 topoint = frompoint + direction;
MT_Point3 resultpoint;
MT_Vector3 resultnormal;
//todo:
//use physics abstraction
KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
SumoPhysicsEnvironment *spe = dynamic_cast<SumoPhysicsEnvironment *>( kxscene->GetPhysicsEnvironment());
SM_Scene *scene = spe->GetSumoScene();
KX_SumoPhysicsController *spc = dynamic_cast<KX_SumoPhysicsController *>( gameobj->GetPhysicsController());
KX_GameObject *parent = gameobj->GetParent();
if (!spc && parent)
spc = dynamic_cast<KX_SumoPhysicsController *>(parent->GetPhysicsController());
if (parent)
parent->Release();
SM_Object *thisObj = spc?spc->GetSumoObject():NULL;
//SM_Scene* scene = (SM_Scene*) m_auxilaryClientInfo;
//SM_Object* hitObj = scene->rayTest(gameobj->GetSumoObject(),frompoint,topoint,
// resultpoint, resultnormal);
if (0) //hitObj)
if (scene->rayTest(thisObj, frompoint, topoint, resultpoint, resultnormal))
{
MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
MT_Vector3 dir = -(left.cross(resultnormal)).normalized();
@ -204,19 +212,17 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
// for the up vector, we take the 'resultnormal' returned by the physics
double maat[16]={
left[0], left[1],left[2], 0,
dir[0], dir[1],dir[2],0,
resultnormal[0],resultnormal[1],resultnormal[2],0,
0,0,0,1};
left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0,
resultnormal[0],resultnormal[1],resultnormal[2], 0,
0, 0, 0, 1};
glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
//glMultMatrixd(oglmatrix);
glMultMatrixd(maat);
// glMultMatrixd(oglmatrix);
} else
{
glMultMatrixd(oglmatrix);
}
} else
{

@ -39,7 +39,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_SUMO)/include
CPPFLAGS += -I$(NAN_SUMO)/include -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_BMFONT)/include
@ -65,6 +65,9 @@ CPPFLAGS += -I../SceneGraph
CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../Network
CPPFLAGS += -I../Network/LoopBackNetwork
CPPFLAGS += -I../Physics/common
CPPFLAGS += -I../Physics/Sumo
ifeq ($(OS),windows)
CPPFLAGS += -I../../blender
endif

@ -1,3 +1,4 @@
import sys
Import ('user_options_dict')
Import ('library_env')
@ -33,7 +34,8 @@ kx_blenderhook_env.Append (CPPPATH=['.',
'#source/gameengine/Expressions',
'#source/gameengine/Network',
'#source/gameengine/SceneGraph',
'#source/gameengine/Physics/Sumo/include',
'#source/gameengine/Physics/common',
'#source/gameengine/Physics/Sumo',
'#source/gameengine/Physics/Sumo/Fuzzics/include',
'#source/gameengine/Network/LoopBackNetwork',
'#intern/SoundSystem',
@ -44,4 +46,7 @@ kx_blenderhook_env.Append (CPPPATH=['.',
kx_blenderhook_env.Append (CPPPATH = user_options_dict['PYTHON_INCLUDE'])
kx_blenderhook_env.Append (CPPPATH = user_options_dict['SOLID_INCLUDE'])
if sys.platform=='win32':
kx_blenderhook_env.Append (CXXFLAGS = ['/GR'])
kx_blenderhook_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/KX_blenderhook', source=source_files)

@ -72,8 +72,8 @@ BL_ActionActuator::~BL_ActionActuator()
}
void BL_ActionActuator::ProcessReplica(){
bPose *oldpose = m_pose;
bPose *oldbpose = m_blendpose;
// bPose *oldpose = m_pose;
// bPose *oldbpose = m_blendpose;
m_pose = NULL;
m_blendpose = NULL;
@ -99,7 +99,6 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
{
bool bNegativeEvent = false;
bool bPositiveEvent = false;
int numevents = m_events.size();
bool keepgoing = true;
bool wrap = false;
bool apply=true;
@ -114,7 +113,6 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
i--;
if ((*i)->GetNumber() == 0.0f)
{
int ka=0;
bNegativeEvent = true;
}
else

@ -51,22 +51,23 @@ public:
float stride,
PyTypeObject* T=&Type)
: SCA_IActuator(gameobj,T),
m_blendframe(0),
m_lastpos(0, 0, 0),
m_flag(0),
m_starttime (starttime),
m_endtime(endtime) ,
m_localtime(starttime),
m_lastUpdate(-1),
m_propname(propname),
m_action(action),
m_playtype(playtype),
m_flag(0),
m_blendin(blendin),
m_blendframe(0),
m_pose(NULL),
m_userpose(NULL),
m_blendpose(NULL),
m_priority(priority),
m_stridelength(stride),
m_lastpos(0, 0, 0)
m_pose(NULL),
m_blendpose(NULL),
m_userpose(NULL),
m_propname(propname),
m_action(action)
{
};
virtual ~BL_ActionActuator();

@ -50,9 +50,10 @@ public:
struct bArmature *arm,
struct bPose *pose) :
KX_GameObject(sgReplicationInfo,callbacks),
m_armature(arm),
m_pose(pose),
m_mrdPose(NULL),
m_armature(arm),
m_lastframe(0.),
m_activeAct(NULL),
m_activePriority(999)
{}

@ -62,7 +62,6 @@
#include "KX_ConvertControllers.h"
#include "KX_ConvertSensors.h"
#include "KX_GameObject.h"
#include "SCA_LogicManager.h"
#include "SCA_EventManager.h"
#include "SCA_TimeEventManager.h"
@ -71,6 +70,7 @@
#include "KX_EmptyObject.h"
#include "MT_Point3.h"
#include "MT_Transform.h"
#include "MT_MinMax.h"
#include "SCA_IInputDevice.h"
#include "RAS_TexMatrix.h"
#include "RAS_ICanvas.h"
@ -175,9 +175,9 @@ static unsigned int KX_Mcol2uint_new(MCol col)
unsigned int temp=0;
unsigned char *cp= (unsigned char *)&temp;
cp[3]=255;
cp[2]= col.r;
cp[0]= col.r;
cp[1]= col.g;
cp[0]= col.b;
cp[2]= col.b;
return temp;
}
@ -580,7 +580,7 @@ void my_tex_space_mesh(Mesh *me)
my_boundbox_mesh(me, loc, size);
if(me->texflag & ME_AUTOSPACE) {
if(me->texflag & AUTOSPACE) {
if(me->key) {
kb= me->key->refkey;
if (kb) {
@ -650,9 +650,9 @@ void my_get_local_bounds(Object *ob, float *centre, float *size)
size[1]= 0.5*fabs(bb->vec[0][1] - bb->vec[2][1]);
size[2]= 0.5*fabs(bb->vec[0][2] - bb->vec[1][2]);
centre[0]= (bb->vec[0][0] + bb->vec[4][0])/2.0;
centre[1]= (bb->vec[0][1] + bb->vec[2][1])/2.0;
centre[2]= (bb->vec[0][2] + bb->vec[1][2])/2.0;
centre[0]= 0.5*(bb->vec[0][0] + bb->vec[4][0]);
centre[1]= 0.5*(bb->vec[0][1] + bb->vec[2][1]);
centre[2]= 0.5*(bb->vec[0][2] + bb->vec[1][2]);
}
}
@ -699,13 +699,42 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
objprop.m_dynamic_parent=NULL;
objprop.m_isdeformable = ((blenderobject->gameflag2 & 2)) != 0;
objprop.m_implicitsphere = false;
objprop.m_implicitbox = false;
objprop.m_boundclass = objprop.m_dyna?KX_BOUNDSPHERE:KX_BOUNDMESH;
if (blenderobject->dtx & OB_BOUNDBOX)
KX_BoxBounds bb;
my_get_local_bounds(blenderobject,objprop.m_boundobject.box.m_center,bb.m_extends);
if (blenderobject->gameflag & OB_BOUNDS)
{
objprop.m_implicitsphere = (blenderobject->boundtype == OB_BOUND_SPHERE);
objprop.m_implicitbox = (blenderobject->boundtype == OB_BOUND_BOX);
switch (blenderobject->boundtype)
{
case OB_BOUND_BOX:
objprop.m_boundclass = KX_BOUNDBOX;
//mmm, has to be divided by 2 to be proper extends
objprop.m_boundobject.box.m_extends[0]=2.f*bb.m_extends[0];
objprop.m_boundobject.box.m_extends[1]=2.f*bb.m_extends[1];
objprop.m_boundobject.box.m_extends[2]=2.f*bb.m_extends[2];
break;
case OB_BOUND_SPHERE:
{
objprop.m_boundclass = KX_BOUNDSPHERE;
objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], MT_max(bb.m_extends[1], bb.m_extends[2]));
break;
}
case OB_BOUND_CYLINDER:
{
objprop.m_boundclass = KX_BOUNDCYLINDER;
objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2];
break;
}
case OB_BOUND_CONE:
{
objprop.m_boundclass = KX_BOUNDCONE;
objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2];
break;
}
}
}
// get Root Parent of blenderobject
@ -724,13 +753,6 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0;
objprop.m_concave = (blenderobject->boundtype & 4) != 0;
my_get_local_bounds(blenderobject,objprop.m_boundingbox.m_center,objprop.m_boundingbox.m_extends);
//mmm, has to be divided by 2 to be proper extends
objprop.m_boundingbox.m_extends[0]*=2.f;
objprop.m_boundingbox.m_extends[1]*=2.f;
objprop.m_boundingbox.m_extends[2]*=2.f;
switch (physics_engine)
{
case UseSumo:

@ -62,5 +62,4 @@ CValue* BL_DeformableGameObject::GetReplica()
ProcessReplica(replica);
return replica;
}

@ -54,7 +54,7 @@
bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *mat)
{
int i, j, index;
size_t i, j, index;
vecVertexArray array;
vecIndexArrays mvarray;
vecIndexArrays diarray;

@ -49,11 +49,12 @@ public:
void RecalcNormals();
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map){};
BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj):
m_transverts(NULL),
m_tvtot(0),
m_transnors(NULL),
m_pMeshObject(meshobj),
m_bmesh((struct Mesh*)(obj->data)){};
m_bmesh((struct Mesh*)(obj->data)),
m_transnors(NULL),
m_transverts(NULL),
m_tvtot(0)
{};
virtual ~BL_MeshDeformer();
virtual void SetSimulatedTime(double time){};
virtual bool Apply(class RAS_IPolyMaterial *mat);

@ -65,7 +65,7 @@ BL_SkinDeformer::~BL_SkinDeformer()
bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
{
int i, j, index;
size_t i, j, index;
vecVertexArray array;
#ifdef __NLA_OLDDEFORM
vecMVertArray mvarray;

@ -66,8 +66,8 @@ public:
class BL_SkinMeshObject *mesh)
:BL_MeshDeformer(bmeshobj, mesh),
m_armobj(NULL),
m_defbase(&bmeshobj->defbase),
m_lastUpdate(-1)
m_lastUpdate(-1),
m_defbase(&bmeshobj->defbase)
{
/* Build all precalculatable matrices for bones */

@ -66,7 +66,7 @@ int BL_SkinMeshObject::FindOrAddDeform(int vtxarray, int mv, struct MDeformVert
int numvert = ao->m_MvertArrayCache1[vtxarray]->size();
/* Check to see if this has already been pushed */
for (int i=0; i<ao->m_MvertArrayCache1[vtxarray]->size(); i++){
for (size_t i=0; i<ao->m_MvertArrayCache1[vtxarray]->size(); i++){
if (mv == (*ao->m_MvertArrayCache1[vtxarray])[i])
return i;
}
@ -84,7 +84,7 @@ int BL_SkinMeshObject::FindVertexArray(int numverts,RAS_IPolyMaterial* polymat)
BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(polymat);
for (int i=0;i<ao->m_VertexArrayCache1.size();i++)
for (size_t i=0;i<ao->m_VertexArrayCache1.size();i++)
{
if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES)
{

@ -114,7 +114,7 @@ public:
int FindVertexArray(int numverts,RAS_IPolyMaterial* polymat);
BL_SkinMeshObject(int lightlayer) : RAS_MeshObject (lightlayer)
{};
{ m_class = 1;};
virtual ~BL_SkinMeshObject(){
};

@ -34,7 +34,6 @@
#endif
#ifdef WIN32
#pragma warning (disable:4786) // suppress stl-MSVC debug info warning
#endif
@ -171,120 +170,92 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
class RAS_IRenderTools* rendertools,
class RAS_ICanvas* canvas)
{
//find out which physics engine
Scene *blenderscene = GetSceneForName2(m_maggie, scenename);
//find out which physics engine
Scene *blenderscene = GetSceneForName2(m_maggie, scenename);
e_PhysicsEngine physics_engine = UseSumo;
e_PhysicsEngine physics_engine = UseSumo;
if (blenderscene)
/* FIXME: Force physics engine = sumo.
This isn't really a problem - no other physics engines are available.
if (blenderscene)
{
int i=0;
int i=0;
if (blenderscene->world)
if (blenderscene->world)
{
switch (blenderscene->world->physicsEngine)
switch (blenderscene->world->physicsEngine)
{
case 1:
{
physics_engine = UseNone;
break;
};
case 2:
{
physics_engine = UseSumo;
break;
}
case 3:
{
physics_engine = UseODE;
break;
}
case 4:
{
physics_engine = UseDynamo;
break;
}
default:
{
physics_engine = UseODE;
}
{
physics_engine = UseODE;
break;
}
case 3:
{
physics_engine = UseDynamo;
break;
}
case 2:
{
physics_engine = UseSumo;
break;
};
case 0:
{
physics_engine = UseNone;
}
}
}
}
switch (physics_engine)
*/
switch (physics_engine)
{
case UseSumo:
{
#ifdef USE_SUMO_SOLID
PHY_IPhysicsEnvironment* physEnv =
new SumoPhysicsEnvironment();
#else
physics_engine = UseNone;
PHY_IPhysicsEnvironment* physEnv =
new DummyPhysicsEnvironment();
case UseSumo:
destinationscene ->SetPhysicsEnvironment(new SumoPhysicsEnvironment());
break;
#endif
destinationscene ->SetPhysicsEnvironment(physEnv);
break;
}
case UseODE:
{
#ifdef USE_ODE
PHY_IPhysicsEnvironment* physEnv =
new ODEPhysicsEnvironment();
#else
PHY_IPhysicsEnvironment* physEnv =
new DummyPhysicsEnvironment();
case UseODE:
destinationscene ->SetPhysicsEnvironment(new ODEPhysicsEnvironment());
break;
#endif //USE_ODE
destinationscene ->SetPhysicsEnvironment(physEnv);
break;
}
case UseDynamo:
{
}
{
}
case UseNone:
{
};
{
}
default:
{
physics_engine = UseNone;
PHY_IPhysicsEnvironment* physEnv =
new DummyPhysicsEnvironment();
destinationscene ->SetPhysicsEnvironment(physEnv);
}
physics_engine = UseNone;
destinationscene ->SetPhysicsEnvironment(new DummyPhysicsEnvironment());
break;
}
BL_ConvertBlenderObjects(m_maggie,
scenename,
destinationscene,
m_ketsjiEngine,
physics_engine,
dictobj,
keyinputdev,
rendertools,
canvas,
this,
m_alwaysUseExpandFraming
);
BL_ConvertBlenderObjects(m_maggie,
scenename,
destinationscene,
m_ketsjiEngine,
physics_engine,
dictobj,
keyinputdev,
rendertools,
canvas,
this,
m_alwaysUseExpandFraming
);
m_map_blender_to_gameactuator.clear();
m_map_blender_to_gamecontroller.clear();
m_map_blender_to_gameactuator.clear();
m_map_blender_to_gamecontroller.clear();
m_map_blender_to_gameobject.clear();
m_map_mesh_to_gamemesh.clear();
m_map_gameobject_to_blender.clear();
m_map_blender_to_gameobject.clear();
m_map_mesh_to_gamemesh.clear();
m_map_gameobject_to_blender.clear();
}

@ -618,7 +618,7 @@ void BL_ConvertActuators(char* maggiename,
case ACT_CONSTRAINT:
{
float min = 0.0, max = 0.0;
int locrot;
KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
bConstraintActuator *conact
= (bConstraintActuator*) bact->data;
/* convert settings... degrees in the ui become radians */

@ -297,15 +297,13 @@ void BL_ConvertSensors(struct Object* blenderobject,
(blendertouchsensor->name ? blendertouchsensor->name: ""));
//if (gameobj->GetSumoObject())
//{
// gamesensor = 0;
//new KX_TouchSensor(eventmgr,
//gameobj,
//gameobj->GetSumoObject(),
//bFindMaterial,
//touchPropOrMatName);
//}
if (gameobj->GetPhysicsController())
{
gamesensor = new KX_TouchSensor(eventmgr,
gameobj,
bFindMaterial,
touchPropOrMatName);
}
}
@ -324,15 +322,13 @@ void BL_ConvertSensors(struct Object* blenderobject,
touchpropertyname = (char*) (blendertouchsensor->ma->id.name+2);
}
bool bFindMaterial = true;
//if (gameobj->GetSumoObject())
//{
// gamesensor = 0;
//new KX_TouchSensor(eventmgr,
// gameobj,
// gameobj->GetSumoObject(),
// bFindMaterial,
// touchpropertyname);
//}
if (gameobj->GetPhysicsController())
{
gamesensor = new KX_TouchSensor(eventmgr,
gameobj,
bFindMaterial,
touchpropertyname);
}
}
break;
}
@ -380,7 +376,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
//sumoObj->setMargin(blendernearsensor->dist);
//sumoObj->setPosition(gameobj->NodeGetWorldPosition());
bool bFindMaterial = false;
gamesensor = 0;//new KX_NearSensor(eventmgr,gameobj,blendernearsensor->dist,blendernearsensor->resetdist,bFindMaterial,nearpropertyname,kxscene);
gamesensor = new KX_NearSensor(eventmgr,gameobj,blendernearsensor->dist,blendernearsensor->resetdist,bFindMaterial,nearpropertyname,kxscene);
}
break;
@ -514,7 +510,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
case SENS_RADAR:
{
/*
SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
if (eventmgr)
{
@ -540,14 +536,9 @@ void BL_ConvertSensors(struct Object* blenderobject,
//MT_Scalar coneradius = coneheight * (factor / 2);
MT_Scalar coneradius = coneheight * factor;
DT_ShapeHandle shape = DT_Cone(coneradius,coneheight);
// this sumoObject is not deleted by a gameobj, so delete it ourself
// later (memleaks)!
SM_Object* sumoObj = new SM_Object(shape,NULL,NULL,NULL);
sumoObj->setMargin(0.0);
sumoObj->setPosition(gameobj->NodeGetWorldPosition());
MT_Scalar smallmargin = 0.0;
MT_Scalar largemargin = 0.1;
@ -560,13 +551,12 @@ void BL_ConvertSensors(struct Object* blenderobject,
radaraxis,
smallmargin,
largemargin,
sumoObj,
bFindMaterial,
radarpropertyname,
kxscene);
}
*/
break;
}
case SENS_RAY:
@ -586,15 +576,13 @@ void BL_ConvertSensors(struct Object* blenderobject,
int axis = blenderraysensor->axisflag;
gamesensor = 0;
/*new KX_RaySensor(eventmgr,
gamesensor = new KX_RaySensor(eventmgr,
gameobj,
checkname,
bFindMaterial,
distance,
axis,
kxscene->GetSumoScene());
*/
kxscene);
}
break;

@ -42,7 +42,8 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I../../blender
# these two needed because of blenkernel
CPPFLAGS += -I../../blender/imbuf

@ -50,7 +50,7 @@ kx_converter_env.Append (CPPPATH = ['.',
'#source/gameengine/Physics/common',
'#source/gameengine/Physics/BlOde',
'#source/gameengine/Physics/Dummy',
'#source/gameengine/Physics/Sumo/include',
'#source/gameengine/Physics/Sumo',
'#source/gameengine/Physics/Sumo/Fuzzics/include',
'#source/gameengine/Network/LoopBackNetwork',
'#source/blender/misc',

@ -45,8 +45,8 @@
using namespace std;
SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
: m_logicmgr(logicmgr),
SCA_EventManager(ALWAYS_EVENTMGR)
: SCA_EventManager(ALWAYS_EVENTMGR),
m_logicmgr(logicmgr)
{
}

@ -156,6 +156,10 @@ PyMethodDef SCA_ISensor::Methods[] = {
METH_VARARGS, GetUseNegPulseMode_doc},
{"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
METH_VARARGS, SetUseNegPulseMode_doc},
{"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
METH_VARARGS, GetInvert_doc},
{"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
METH_VARARGS, SetInvert_doc},
{NULL,NULL} //Sentinel
};

@ -46,8 +46,8 @@
SCA_KeyboardManager::SCA_KeyboardManager(SCA_LogicManager* logicmgr,
SCA_IInputDevice* inputdev)
: SCA_EventManager(KEYBOARD_EVENTMGR),
m_logicmanager(logicmgr),
m_inputDevice(inputdev)
m_inputDevice(inputdev),
m_logicmanager(logicmgr)
{
}
@ -70,7 +70,7 @@ void SCA_KeyboardManager::NextFrame(double curtime,double deltatime)
{
//const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
// cerr << "SCA_KeyboardManager::NextFrame"<< endl;
for (int i=0;i<m_sensors.size();i++)
for (unsigned int i=0;i<m_sensors.size();i++)
{
SCA_KeyboardSensor* keysensor = (SCA_KeyboardSensor*)m_sensors[i];
keysensor->Activate(m_logicmanager,NULL);

@ -50,13 +50,6 @@ SCA_LogicManager::SCA_LogicManager()
SCA_LogicManager::~SCA_LogicManager()
{
for (vector<SCA_EventManager*>::iterator it = m_eventmanagers.begin();!(it==m_eventmanagers.end());it++)
{
delete (*it);
}
m_eventmanagers.clear();
m_sensorcontrollermapje.clear();
int numgameobj = m_mapStringToGameObjects.size();
for (int i = 0; i < numgameobj; i++)
{
@ -73,6 +66,12 @@ SCA_LogicManager::~SCA_LogicManager()
delete controllerarray;
}
*/
for (vector<SCA_EventManager*>::iterator it = m_eventmanagers.begin();!(it==m_eventmanagers.end());it++)
{
delete (*it);
}
m_eventmanagers.clear();
m_sensorcontrollermapje.clear();
}

@ -52,8 +52,8 @@
SCA_MouseManager::SCA_MouseManager(SCA_LogicManager* logicmgr,
SCA_IInputDevice* mousedev)
: SCA_EventManager(MOUSE_EVENTMGR),
m_logicmanager(logicmgr),
m_mousedevice (mousedev)
m_mousedevice (mousedev),
m_logicmanager(logicmgr)
{
m_xpos = 0;
m_ypos = 0;
@ -78,7 +78,7 @@ void SCA_MouseManager::NextFrame(double curtime,double deltatime)
{
if (m_mousedevice)
{
for (int i = 0; i < m_sensors.size(); i++)
for (unsigned int i = 0; i < m_sensors.size(); i++)
{
SCA_MouseSensor* mousesensor = (SCA_MouseSensor*) m_sensors[i];
// (0,0) is the Upper Left corner in our local window

@ -46,11 +46,11 @@
/* ------------------------------------------------------------------------- */
SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,CValue* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T )
: SCA_IActuator(gameobj,T),
m_propname(propname),
m_exprtxt(expr),
m_type(acttype),
m_sourceObj(sourceObj)
: SCA_IActuator(gameobj,T),
m_type(acttype),
m_propname(propname),
m_exprtxt(expr),
m_sourceObj(sourceObj)
{
}

@ -53,12 +53,12 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
KX_PROPSENSOR_TYPE checktype,
PyTypeObject* T )
: SCA_ISensor(gameobj,eventmgr,T),
m_checkpropname(propname),
m_checktype(checktype),
m_checkpropval(propval),
m_checkpropmaxval(propmaxval),
m_checktype(checktype),
m_range_expr(NULL),
m_lastresult(false)
m_checkpropname(propname),
m_lastresult(false),
m_range_expr(NULL)
{
m_recentresult=false;
//CParser pars;

@ -50,9 +50,9 @@ SCA_PythonController* SCA_PythonController::m_sCurrentController = NULL;
SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj,
PyTypeObject* T)
: SCA_IController(gameobj, T),
m_pythondictionary(NULL),
m_bytecode(NULL),
m_bModified(true)
m_bModified(true),
m_pythondictionary(NULL)
{
}
@ -285,10 +285,8 @@ PyObject* SCA_PythonController::PyGetActuators(PyObject* self,
PyObject* args,
PyObject* kwds)
{
int index;
PyObject* resultlist = PyList_New(m_linkedactuators.size());
for (index=0;index<m_linkedactuators.size();index++)
for (unsigned int index=0;index<m_linkedactuators.size();index++)
{
PyList_SetItem(resultlist,index,m_linkedactuators[index]->AddRef());
}
@ -310,8 +308,7 @@ SCA_PythonController::PyGetSensor(PyObject* self,
return NULL;
}
int index;
for (index=0;index<m_linkedsensors.size();index++)
for (unsigned int index=0;index<m_linkedsensors.size();index++)
{
SCA_ISensor* sensor = m_linkedsensors[index];
STR_String realname = sensor->GetName();
@ -341,8 +338,7 @@ SCA_PythonController::PyGetActuator(PyObject* self,
return NULL;
}
int index;
for (index=0;index<m_linkedactuators.size();index++)
for (unsigned int index=0;index<m_linkedactuators.size();index++)
{
SCA_IActuator* actua = m_linkedactuators[index];
STR_String realname = actua->GetName();
@ -363,10 +359,8 @@ SCA_PythonController::PyGetSensors(PyObject* self,
PyObject* args,
PyObject* kwds)
{
int index;
PyObject* resultlist = PyList_New(m_linkedsensors.size());
for (index=0;index<m_linkedsensors.size();index++)
for (unsigned int index=0;index<m_linkedsensors.size();index++)
{
PyList_SetItem(resultlist,index,m_linkedsensors[index]->AddRef());
}

@ -56,10 +56,10 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
const STR_String &propName,
PyTypeObject* T)
: SCA_IActuator(gameobj, T),
m_distribution(mode),
m_propname(propName),
m_parameter1(para1),
m_parameter2(para2)
m_parameter2(para2),
m_distribution(mode)
{
m_base = new SCA_RandomNumberGenerator(seed);
m_counter = 0;
@ -94,7 +94,7 @@ bool SCA_RandomActuator::Update(double curtime,double deltatime)
RemoveAllEvents();
CValue *tmpval;
CValue *tmpval = NULL;
if (bNegativeEvent)
return false; // do nothing on negative events
@ -241,7 +241,15 @@ bool SCA_RandomActuator::Update(double curtime,double deltatime)
}
break;
default:
; /* unknown distribution... */
{
/* unknown distribution... */
static bool randomWarning = false;
if (!randomWarning) {
randomWarning = true;
std::cout << "RandomActuator '" << GetName() << "' has an unknown distribution." << std::endl;
}
return false;
}
}
/* Round up: assign it */

@ -45,8 +45,8 @@ using namespace std;
#endif
SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
: m_logicmgr(logicmgr),
SCA_EventManager(RANDOM_EVENTMGR)
: SCA_EventManager(RANDOM_EVENTMGR),
m_logicmgr(logicmgr)
{
}

@ -245,13 +245,13 @@ float GPC_Engine::DetermineProgress(void)
void GPC_Engine::UpdateLoadingAnimation(void)
{
int delta;
//int delta;
float progress = DetermineProgress();
if(progress > m_previousProgress)
{
delta = progress - m_previousProgress;
// delta = progress - m_previousProgress;
m_previousProgress = progress;
if(m_previousProgress > 1.0)
m_previousProgress = 1.0; // limit to 1.0 (has to change !)

@ -324,14 +324,14 @@ int my_set_tpage(TFace *tface)
if (!fDoMipMap)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else
{
int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST;
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}

@ -94,6 +94,11 @@
#include "IMB_imbuf_types.h"
// End of Blender includes
#include "SM_Scene.h"
#include "SumoPhysicsEnvironment.h"
#include "KX_SumoPhysicsController.h"
#include "KX_Scene.h"
GPC_RenderTools::GPC_RenderTools()
{
@ -454,8 +459,8 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in
if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
{
// shadow must be cast to the ground, physics system needed here!
KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
MT_Vector3 direction = MT_Vector3(0,0,-1);
@ -466,16 +471,20 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in
MT_Point3 resultpoint;
MT_Vector3 resultnormal;
//todo: replace by physicsenvironment raycast
//SM_Scene* scene = (SM_Scene*) m_auxilaryClientInfo;
SM_Object* hitObj = 0;
//scene->rayTest(gameobj->GetSumoObject(),frompoint,topoint,
// resultpoint, resultnormal);
//todo:
//use physics abstraction
KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
SumoPhysicsEnvironment *spe = dynamic_cast<SumoPhysicsEnvironment *>( kxscene->GetPhysicsEnvironment());
SM_Scene *scene = spe->GetSumoScene();
KX_SumoPhysicsController *spc = dynamic_cast<KX_SumoPhysicsController *>( gameobj->GetPhysicsController());
KX_GameObject *parent = gameobj->GetParent();
if (!spc && parent)
spc = dynamic_cast<KX_SumoPhysicsController *>(parent->GetPhysicsController());
if (parent)
parent->Release();
SM_Object *thisObj = spc?spc->GetSumoObject():NULL;
if (hitObj)
if (scene->rayTest(thisObj, frompoint, topoint, resultpoint, resultnormal))
{
MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
MT_Vector3 dir = -(left.cross(resultnormal)).normalized();
@ -483,19 +492,17 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in
// for the up vector, we take the 'resultnormal' returned by the physics
double maat[16]={
left[0], left[1],left[2], 0,
dir[0], dir[1],dir[2],0,
resultnormal[0],resultnormal[1],resultnormal[2],0,
0,0,0,1};
left[0], left[1], left[2], 0,
dir[0], dir[1], dir[2], 0,
resultnormal[0],resultnormal[1],resultnormal[2], 0,
0, 0, 0, 1};
glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
//glMultMatrixd(oglmatrix);
glMultMatrixd(maat);
// glMultMatrixd(oglmatrix);
} else
{
glMultMatrixd(oglmatrix);
}
} else
{

@ -52,6 +52,7 @@ CPPFLAGS += -I$(NAN_FUZZICS)/include
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SUMO)/include
CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I$(NAN_BMFONT)/include
@ -67,6 +68,8 @@ CPPFLAGS += -I../../../gameengine/Network/LoopBackNetwork
CPPFLAGS += -I../../../gameengine/Rasterizer
CPPFLAGS += -I../../../gameengine/SceneGraph
CPPFLAGS += -I../../../gameengine/Rasterizer/RAS_OpenGLRasterizer
CPPFLAGS += -I../../../gameengine/Physics/Sumo
CPPFLAGS += -I../../../gameengine/Physics/common
###############################

@ -153,6 +153,7 @@ bool GPG_Application::startWindow(STR_String& title,
* so that the client rectangle has the size requested.
*/
m_mainWindow->setClientSize(windowWidth, windowHeight);
m_mainWindow->setCursorVisibility(false);
success = initEngine(m_mainWindow, stereoMode);
if (success) {
@ -179,6 +180,7 @@ bool GPG_Application::startFullScreen(
setting.frequency = frequency;
fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual);
m_mainWindow->setCursorVisibility(false);
success = initEngine(m_mainWindow, stereoMode);
if (success) {

@ -81,6 +81,7 @@ extern "C"
#include "RAS_IRasterizer.h"
#include "BKE_main.h"
#include "BKE_utildefines.h"
#ifdef WIN32
#ifdef NDEBUG
@ -92,6 +93,8 @@ extern "C"
const int kMinWindowWidth = 100;
const int kMinWindowHeight = 100;
char bprogname[FILE_MAXDIR+FILE_MAXFILE];
void usage(char* program)
{
char * consoleoption;
@ -101,18 +104,19 @@ void usage(char* program)
consoleoption = "";
#endif
printf("usage: %s [-p l t w h] [-f fw fh fb ff] %s[-g gamengineoptions] "
printf("usage: %s -w [-p l t w h] %s[-g gamengineoptions] "
"-s stereomode filename.blend\n", program, consoleoption);
printf(" -w: display in a window\n");
printf(" -p: specify window position\n");
printf(" l = window left coordinate\n");
printf(" t = window top coordinate\n");
printf(" w = window width\n");
printf(" h = window height\n");
printf(" -f: start game in full screen mode\n");
/* printf(" -f: start game in full screen mode\n");
printf(" fw = full screen mode pixel width\n");
printf(" fh = full screen mode pixel height\n");
printf(" fb = full screen mode bits per pixel\n");
printf(" ff = full screen mode frequency\n");
printf(" ff = full screen mode frequency\n"); */
printf(" -s: start player in stereo\n");
printf(" stereomode = hwpageflip or syncdoubling depending on the type of stereo you want\n");
#ifdef _WIN32
@ -204,8 +208,8 @@ int main(int argc, char** argv)
int i;
bool error = false;
SYS_SystemHandle syshandle = SYS_GetSystem();
bool fullScreen = false;
bool fullScreenParFound = false;
bool fullScreen = true;
bool fullScreenParFound = true;
bool windowParFound = false;
bool closeConsole = true;
int stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
@ -215,8 +219,8 @@ int main(int argc, char** argv)
int windowTop = 100;
int windowWidth = 640;
int windowHeight = 480;
int fullScreenWidth = 640;
int fullScreenHeight= 480;
GHOST_TUns32 fullScreenWidth = 0;
GHOST_TUns32 fullScreenHeight= 0;
int fullScreenBpp = 16;
int fullScreenFrequency = 60;
@ -225,6 +229,7 @@ int main(int argc, char** argv)
signal (SIGFPE, SIG_IGN);
#endif /* __alpha__ */
#endif /* __linux__ */
BLI_where_am_i(bprogname, argv[0]);
#ifdef __APPLE__
// Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
@ -315,24 +320,12 @@ int main(int argc, char** argv)
}
break;
case 'f':
case 'w':
// Parse window position and size options
{
fullScreen = true;
i++;
if ((i + 4) < argc)
{
fullScreenWidth = atoi(argv[i++]);
fullScreenHeight = atoi(argv[i++]);
fullScreenBpp = atoi(argv[i++]);
fullScreenFrequency = atoi(argv[i]);
fullScreen = false;
fullScreenParFound = true;
}
else
{
error = true;
printf("error: too few options for fullscreen argument.\n");
}
i++;
}
break;
case 'c':
@ -403,6 +396,7 @@ int main(int argc, char** argv)
GHOST_ISystem* system = GHOST_ISystem::getSystem();
assertd(system);
system->getMainDisplayDimensions(fullScreenWidth, fullScreenHeight);
// process first batch of events. If the user
// drops a file on top off the blenderplayer icon, we
// recieve an event with the filename
@ -570,7 +564,7 @@ int main(int argc, char** argv)
bool run = true;
while (run)
{
system->processEvents(true);
system->processEvents(false);
system->dispatchEvents();
if (exitcode = app.getExitRequested())
{

@ -64,7 +64,7 @@ MT_Transform KX_Camera::GetWorldToCamera() const
trans.setBasis(NodeGetWorldOrientation());
trans.setOrigin(NodeGetWorldPosition());
camtrans.invert(trans);
return camtrans;
@ -95,8 +95,8 @@ const MT_Point3 KX_Camera::GetCameraLocation()
//return m_trans1.getOrigin();
//return MT_Point3(0,0,0); <-----
/* .... I want it in world coords */
MT_Transform trans;
trans.setBasis(NodeGetWorldOrientation());
//MT_Transform trans;
//trans.setBasis(NodeGetWorldOrientation());
return NodeGetWorldPosition();
}

@ -183,8 +183,6 @@ bool KX_CameraActuator::Update(double curtime,double deltatime)
MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition();
MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation();
float fp1[3], fp2[3], rc[3];
float inp, fac; //, factor = 0.0; /* some factor... */
float mindistsq, maxdistsq, distsq;

@ -55,11 +55,12 @@ private:
double m_ipotime;
public:
KX_CameraIpoSGController() : m_ipotime(0.0),
m_modify_lens(false),
m_modify_clipstart(false),
m_modify_clipend(false),
m_modified(true)
KX_CameraIpoSGController() :
m_modify_lens(false),
m_modify_clipstart(false),
m_modify_clipend(false),
m_modified(true),
m_ipotime(0.0)
{}
~KX_CameraIpoSGController();

@ -35,12 +35,21 @@
/**
* Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
*/
struct KX_ClientObjectInfo
{
int m_type;
enum {
STATIC,
ACTOR,
RESERVED1,
RADAR,
NEAR
} m_type;
void* m_clientobject;
void* m_auxilary_info;
public:
KX_ClientObjectInfo(void *clientobject) :
m_clientobject(clientobject)
{}
};
#endif //__KX_CLIENTOBJECT_INFO_H

@ -40,8 +40,11 @@
KX_ConstraintWrapper::KX_ConstraintWrapper(
PHY_ConstraintType ctype,
int constraintId,
PHY_IPhysicsEnvironment* physenv,PyTypeObject *T)
: m_constraintType(ctype),m_constraintId(constraintId),m_physenv(physenv),PyObjectPlus(T)
PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
PyObjectPlus(T),
m_constraintId(constraintId),
m_constraintType(ctype),
m_physenv(physenv)
{
}
KX_ConstraintWrapper::~KX_ConstraintWrapper()

@ -32,22 +32,35 @@
#ifndef KX_CONVERTPHYSICSOBJECTS
#define KX_CONVERTPHYSICSOBJECTS
/* These are defined by the build system... */
//#define USE_SUMO_SOLID
//solid is not available yet
#define USE_ODE
//#define USE_ODE
class RAS_MeshObject;
class KX_Scene;
typedef enum {
KX_BOUNDBOX,
KX_BOUNDSPHERE,
KX_BOUNDCYLINDER,
KX_BOUNDCONE,
KX_BOUNDMESH
} KX_BoundBoxClass;
struct KX_Bounds
struct KX_BoxBounds
{
float m_center[3];
float m_extends[3];
};
/* Cone/Cylinder */
struct KX_CBounds
{
float m_radius;
float m_height;
};
struct KX_ObjectProperties
{
bool m_dyna;
@ -59,9 +72,11 @@ struct KX_ObjectProperties
bool m_isactor;
bool m_concave;
bool m_isdeformable;
bool m_implicitsphere ;
bool m_implicitbox;
KX_Bounds m_boundingbox;
KX_BoundBoxClass m_boundclass;
union {
KX_BoxBounds box;
KX_CBounds c;
} m_boundobject;
};
#ifdef USE_ODE

@ -29,7 +29,9 @@
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
@ -63,7 +65,6 @@
// USE_SUMO_SOLID is defined in headerfile KX_ConvertPhysicsObject.h
#ifdef USE_SUMO_SOLID
#include "SumoPhysicsEnvironment.h"
#include "KX_SumoPhysicsController.h"
@ -83,16 +84,15 @@ void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_S
DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj);
void KX_ConvertSumoObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
class KX_Scene* kxscene,
PHY_ShapeProps* kxshapeprops,
PHY_MaterialProps* kxmaterial,
struct KX_ObjectProperties* objprop)
void KX_ConvertSumoObject( KX_GameObject* gameobj,
RAS_MeshObject* meshobj,
KX_Scene* kxscene,
PHY_ShapeProps* kxshapeprops,
PHY_MaterialProps* kxmaterial,
struct KX_ObjectProperties* objprop)
{
SM_ShapeProps* smprop = new SM_ShapeProps;
smprop->m_ang_drag = kxshapeprops->m_ang_drag;
@ -105,6 +105,7 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
smprop->m_inertia = kxshapeprops->m_inertia;
smprop->m_lin_drag = kxshapeprops->m_lin_drag;
smprop->m_mass = kxshapeprops->m_mass;
smprop->m_radius = objprop->m_radius;
SM_MaterialProps* smmaterial = new SM_MaterialProps;
@ -116,55 +117,48 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
smmaterial->m_friction = kxmaterial->m_friction;
smmaterial->m_restitution = kxmaterial->m_restitution;
class SumoPhysicsEnvironment* sumoEnv =
SumoPhysicsEnvironment* sumoEnv =
(SumoPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
SM_Scene* sceneptr = sumoEnv->GetSumoScene();
SM_Object* sumoObj=NULL;
if (objprop->m_dyna)
{
DT_ShapeHandle shape = DT_Sphere(0.0);
if (objprop->m_ghost)
DT_ShapeHandle shape = NULL;
switch (objprop->m_boundclass)
{
sumoObj = new SM_Object(shape,NULL,smprop,NULL);
} else
{
sumoObj = new SM_Object(shape,smmaterial,smprop,NULL);
case KX_BOUNDBOX:
shape = DT_NewBox(objprop->m_boundobject.box.m_extends[0], objprop->m_boundobject.box.m_extends[1], objprop->m_boundobject.box.m_extends[2]);
break;
case KX_BOUNDCYLINDER:
shape = DT_NewCylinder(objprop->m_radius, objprop->m_boundobject.c.m_height);
break;
case KX_BOUNDCONE:
shape = DT_NewCone(objprop->m_radius, objprop->m_boundobject.c.m_height);
break;
/* Enabling this allows you to use dynamic mesh objects. It's disabled 'cause it's really slow. */
case KX_BOUNDMESH:
if (meshobj && meshobj->NumPolygons() > 0)
{
if ((shape = CreateShapeFromMesh(meshobj)))
break;
}
/* If CreateShapeFromMesh fails, fall through and use sphere */
default:
case KX_BOUNDSPHERE:
shape = DT_NewSphere(objprop->m_radius);
break;
}
double radius = objprop->m_radius;
sumoObj = new SM_Object(shape, !objprop->m_ghost?smmaterial:NULL,smprop,NULL);
MT_Scalar margin = radius;//0.5;
sumoObj->setMargin(margin);
sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false);
//if (bRigidBody)
//{
if (objprop->m_in_active_layer)
{
DT_AddObject(sumoEnv->GetSolidScene(),
sumoObj->getObjectHandle());
}
//}
if (objprop->m_angular_rigidbody)
{
sumoObj->setRigidBody(true);
} else
{
sumoObj->setRigidBody(false);
}
bool isDynamic = true;
bool isActor = true;
BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,NULL,isDynamic,isActor);
objprop->m_isactor = objprop->m_dyna = true;
BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,NULL,true, true);
}
else {
@ -172,20 +166,40 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
if (meshobj)
{
int numpolys = meshobj->NumPolygons();
{
DT_ShapeHandle complexshape=0;
if (objprop->m_implicitbox)
switch (objprop->m_boundclass)
{
complexshape = DT_Box(objprop->m_boundingbox.m_extends[0],objprop->m_boundingbox.m_extends[1],objprop->m_boundingbox.m_extends[2]);
} else
{
if (numpolys>0)
{
complexshape = CreateShapeFromMesh(meshobj);
}
case KX_BOUNDBOX:
complexshape = DT_NewBox(objprop->m_boundobject.box.m_extends[0], objprop->m_boundobject.box.m_extends[1], objprop->m_boundobject.box.m_extends[2]);
break;
case KX_BOUNDSPHERE:
complexshape = DT_NewSphere(objprop->m_boundobject.c.m_radius);
break;
case KX_BOUNDCYLINDER:
complexshape = DT_NewCylinder(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
break;
case KX_BOUNDCONE:
complexshape = DT_NewCone(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
break;
default:
case KX_BOUNDMESH:
if (numpolys>0)
{
complexshape = CreateShapeFromMesh(meshobj);
//std::cout << "Convert Physics Mesh: " << meshobj->GetName() << std::endl;
/* if (!complexshape)
{
// Something has to be done here - if the object has no polygons, it will not be able to have
// sensors attached to it.
DT_Vector3 pt = {0., 0., 0.};
complexshape = DT_NewSphere(1.0);
objprop->m_ghost = evilObject = true;
} */
}
break;
}
if (complexshape)
@ -209,21 +223,7 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
}
if (objprop->m_ghost)
{
sumoObj = new SM_Object(complexshape,NULL,NULL, dynamicParent);
} else
{
sumoObj = new SM_Object(complexshape,smmaterial,NULL, dynamicParent);
}
if (objprop->m_in_active_layer)
{
DT_AddObject(sumoEnv->GetSolidScene(),
sumoObj->getObjectHandle());
}
sumoObj = new SM_Object(complexshape,!objprop->m_ghost?smmaterial:NULL,NULL, dynamicParent);
const STR_String& matname=meshobj->GetMaterialName(0);
@ -232,7 +232,6 @@ void KX_ConvertSumoObject( class KX_GameObject* gameobj,
matname.ReadPtr(),
objprop->m_dyna,
objprop->m_isactor);
}
}
}
@ -264,35 +263,34 @@ void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_S
KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,solidscene,sumoObj,motionstate,isDynamic);
gameobj->SetPhysicsController(physicscontroller);
physicscontroller->setClientInfo(gameobj);
if (!gameobj->getClientInfo())
std::cout << "BL_RegisterSumoObject: WARNING: Object " << gameobj->GetName() << " has no client info" << std::endl;
sumoObj->setClientObject(gameobj->getClientInfo());
gameobj->GetSGNode()->AddSGController(physicscontroller);
//gameobj->GetClientInfo()->m_type = (isActor ? 1 : 0);
gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
//gameobj->GetClientInfo()->m_clientobject = gameobj;
// store materialname in auxinfo, needed for touchsensors
//gameobj->GetClientInfo()->m_auxilary_info = (matname? (void*)(matname+2) : NULL);
gameobj->getClientInfo()->m_auxilary_info = (matname? (void*)(matname+2) : NULL);
physicscontroller->SetObject(gameobj->GetSGNode());
//gameobj->SetDynamicsScaling(MT_Vector3(1.0, 1.0, 1.0));
};
DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
{
DT_ShapeHandle* shapeptr = map_gamemesh_to_sumoshape[GEN_HashedPtr(meshobj)];
DT_ShapeHandle *shapeptr = map_gamemesh_to_sumoshape[GEN_HashedPtr(meshobj)];
if (shapeptr)
{
return *shapeptr;
}
// todo: shared meshes
DT_ShapeHandle shape = DT_NewComplexShape();
int p=0;
int numpolys = meshobj->NumPolygons();
if (!numpolys)
{
@ -300,38 +298,80 @@ DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
}
int numvalidpolys = 0;
for (p=0;p<meshobj->m_triangle_indices.size();p++)
for (int p=0; p<numpolys; p++)
{
RAS_TriangleIndex& idx = meshobj->m_triangle_indices[p];
// only add polygons that have the collisionflag set
if (idx.m_collider)
{
DT_Begin();
for (int v=0;v<3;v++)
{
int num = meshobj->m_xyz_index_to_vertex_index_mapping[idx.m_index[v]].size();
if (num != 1)
{
int i=0;
}
RAS_MatArrayIndex& vertindex = meshobj->m_xyz_index_to_vertex_index_mapping[idx.m_index[v]][0];
numvalidpolys++;
RAS_Polygon* poly = meshobj->GetPolygon(p);
{
const MT_Point3& pt = meshobj->GetVertex(vertindex.m_array,
vertindex.m_index,
(RAS_IPolyMaterial*)vertindex.m_matid)->xyz();
DT_Vertex(pt[0],pt[1],pt[2]);
}
}
DT_End();
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{
numvalidpolys++;
break;
}
}
if (numvalidpolys < 1)
return NULL;
DT_ShapeHandle shape = DT_NewComplexShape(NULL);
numvalidpolys = 0;
for (int p2=0; p2<numpolys; p2++)
{
RAS_Polygon* poly = meshobj->GetPolygon(p2);
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{ /* We have to tesselate here because SOLID can only raycast triangles */
DT_Begin();
DT_Vector3 pt;
/* V1 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[0],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
/* V2 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[1],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
/* V3 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[2],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
numvalidpolys++;
DT_End();
if (poly->VertexCount() == 4)
{
DT_Begin();
/* V1 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[0],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
/* V3 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[2],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
/* V4 */
meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
poly->GetVertexIndexBase().m_indexarray[3],
poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
DT_Vertex(pt);
numvalidpolys++;
DT_End();
}
}
}
DT_EndComplexShape();
if (numvalidpolys > 0)
@ -340,7 +380,7 @@ DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
return shape;
}
// memleak... todo: delete shape
delete shape;
return NULL;
}

@ -113,6 +113,7 @@ bool KX_GameActuator::Update(double curtime, double deltatime)
{
STR_String exitstring = "restarting game";
m_ketsjiengine->RequestExit(KX_EXIT_REQUEST_RESTART_GAME);
m_ketsjiengine->SetNameNextGame(m_filename);
m_scene->AddDebugProperty((this)->GetParent(), exitstring);
}
break;
@ -146,7 +147,7 @@ bool KX_GameActuator::Update(double curtime, double deltatime)
PyTypeObject KX_GameActuator::Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
"KX_SceneActuator",
"KX_GameActuator",
sizeof(KX_GameActuator),
0,
PyDestructor,
@ -177,9 +178,39 @@ PyParentObject KX_GameActuator::Parents[] =
PyMethodDef KX_GameActuator::Methods[] =
{
{"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, GetFile_doc},
{"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, SetFile_doc},
{NULL,NULL} //Sentinel
};
/* getFile */
char KX_GameActuator::GetFile_doc[] =
"getFile()\n"
"get the name of the file to start.\n";
PyObject* KX_GameActuator::PyGetFile(PyObject* self, PyObject* args, PyObject* kwds)
{
return PyString_FromString(m_filename);
}
/* setFile */
char KX_GameActuator::SetFile_doc[] =
"setFile(name)\n"
"set the name of the file to start.\n";
PyObject* KX_GameActuator::PySetFile(PyObject* self, PyObject* args, PyObject* kwds)
{
char* new_file;
if (!PyArg_ParseTuple(args, "s", &new_file))
{
return NULL;
}
m_filename = STR_String(new_file);
Py_Return;
}
PyObject* KX_GameActuator::_getattr(char* attr)

@ -78,7 +78,8 @@ class KX_GameActuator : public SCA_IActuator
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(char *attr);
KX_PYMETHOD_DOC(KX_GameActuator,GetFile);
KX_PYMETHOD_DOC(KX_GameActuator,SetFile);
}; /* end of class KX_GameActuator */

@ -66,14 +66,15 @@ KX_GameObject::KX_GameObject(
PyTypeObject* T
) :
SCA_IObject(T),
m_bUseObjectColor(false),
m_bDyna(false),
m_bSuspendDynamics(false),
m_pPhysicsController1(NULL),
m_bVisible(true)
m_bUseObjectColor(false),
m_bVisible(true),
m_pPhysicsController1(NULL)
{
m_ignore_activity_culling = false;
m_pClient_info = new KX_ClientObjectInfo();
m_pClient_info = new KX_ClientObjectInfo(this);
m_pClient_info->m_type = KX_ClientObjectInfo::ACTOR;
m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks);
// define the relationship between this node and it's parent.
@ -198,7 +199,7 @@ CValue* KX_GameObject::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
ProcessReplica(replica);
return replica;
}
@ -222,14 +223,11 @@ void KX_GameObject::ApplyTorque(const MT_Vector3& torque,bool local)
void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
{
if (this->IsDynamic())
if (m_pPhysicsController1) // (IsDynamic())
{
m_pPhysicsController1->RelativeTranslate(dloc,local);
}
else
{
GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local);
}
GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local);
}
@ -237,12 +235,14 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
{
MT_Matrix3x3 rotmat(drot);
rotmat.transpose();
if (this->IsDynamic()) //m_pPhysicsController)
m_pPhysicsController1->RelativeRotate(rotmat.transposed(),local);
else
// in worldspace
GetSGNode()->RelativeRotate(rotmat.transposed(),local);
//if (m_pPhysicsController1) // (IsDynamic())
// m_pPhysicsController1->RelativeRotate(rotmat_,local);
// in worldspace
GetSGNode()->RelativeRotate(rotmat,local);
if (m_pPhysicsController1)
m_pPhysicsController1->setOrientation(NodeGetWorldOrientation().getRotation());
}
@ -273,7 +273,7 @@ void KX_GameObject::Bucketize()
{
double* fl = GetOpenGLMatrix();
for (int i=0;i<m_meshes.size();i++)
for (size_t i=0;i<m_meshes.size();i++)
m_meshes[i]->Bucketize(fl, this, m_bUseObjectColor, m_objectColor);
}
@ -283,7 +283,7 @@ void KX_GameObject::RemoveMeshes()
{
double* fl = GetOpenGLMatrix();
for (int i=0;i<m_meshes.size();i++)
for (size_t i=0;i<m_meshes.size();i++)
m_meshes[i]->RemoveFromBuckets(fl, this);
//note: meshes can be shared, and are deleted by KX_BlenderSceneConverter
@ -315,7 +315,7 @@ void KX_GameObject::UpdateTransform()
void KX_GameObject::SetDebugColor(unsigned int bgra)
{
for (int i=0;i<m_meshes.size();i++)
for (size_t i=0;i<m_meshes.size();i++)
m_meshes[i]->DebugColor(bgra);
}
@ -411,9 +411,9 @@ KX_GameObject::MarkVisible(
* determined on this level. Maybe change this to mesh level
* later on? */
for (int i=0;i<m_meshes.size();i++)
double* fl = GetOpenGLMatrix();
for (size_t i=0;i<m_meshes.size();i++)
{
double* fl = GetOpenGLMatrix();
m_meshes[i]->MarkVisible(fl,this,visible,m_bUseObjectColor,m_objectColor);
}
}
@ -425,9 +425,9 @@ KX_GameObject::MarkVisible(
void
)
{
for (int i=0;i<m_meshes.size();i++)
double* fl = GetOpenGLMatrix();
for (size_t i=0;i<m_meshes.size();i++)
{
double* fl = GetOpenGLMatrix();
m_meshes[i]->MarkVisible(fl,
this,
m_bVisible,
@ -439,8 +439,8 @@ KX_GameObject::MarkVisible(
void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
// if (m_pPhysicsController1)
// m_pPhysicsController1->AddLinearVelocity(lin_vel,local);
if (m_pPhysicsController1)
m_pPhysicsController1->SetLinearVelocity(lin_vel + m_pPhysicsController1->GetLinearVelocity(),local);
}
@ -972,7 +972,6 @@ PyObject* KX_GameObject::PyGetOrientation(PyObject* self,
int row,col;
const MT_Matrix3x3& orient = NodeGetWorldOrientation();
int index = 0;
for (row=0;row<3;row++)
{
PyObject* veclist = PyList_New(3);

@ -217,7 +217,7 @@ public:
* instance allocated on the heap. Ownership of the new
* object belongs with the caller.
*/
CValue*
virtual CValue*
GetReplica(
);
@ -225,7 +225,7 @@ public:
* Inherited from CValue -- Makes sure any internal
* data owned by this class is deep copied. Called internally
*/
void
virtual void
ProcessReplica(
KX_GameObject* replica
);
@ -340,6 +340,9 @@ public:
m_pSGNode = node;
}
/**
* Deprecated & broken
*/
bool
IsDynamic(
) const {
@ -549,6 +552,7 @@ public:
*/
void Resume(void);
KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
/**
* @section Python interface functions.
*/

@ -44,17 +44,18 @@
#include "KX_IPO_SGController.h"
#include "KX_ScalarInterpolator.h"
#include "KX_GameObject.h"
#include "KX_IPhysicsController.h"
// All objects should start on frame 1! Will we ever need an object to
// start on another frame, the 1.0 should change.
KX_IpoSGController::KX_IpoSGController()
: m_ipotime(1.0),
m_modify_position(false),
: m_modify_position(false),
m_modify_orientation(false),
m_modify_scaling(false),
m_modified(true),
m_ipo_as_force(false),
m_force_ipo_acts_local(false)
m_force_ipo_acts_local(false),
m_modified(true),
m_ipotime(1.0)
{
m_sumo_object = NULL;
m_game_object = NULL;
@ -121,6 +122,11 @@ bool KX_IpoSGController::Update(double currentTime)
m_sumo_object->calcXform();
}
*/
if (m_game_object && ob) {
m_game_object->GetPhysicsController()->ApplyForce(m_force_ipo_acts_local ?
ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
m_ipo_xform.GetPosition(), false);
}
} else {
ob->SetLocalPosition(m_ipo_xform.GetPosition());
@ -137,6 +143,11 @@ bool KX_IpoSGController::Update(double currentTime)
m_sumo_object->calcXform();
}
*/
if (m_game_object && ob) {
m_game_object->ApplyTorque(m_force_ipo_acts_local ?
ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() :
m_ipo_xform.GetEulerAngles(), false);
}
} else {
ob->SetLocalOrientation(MT_Matrix3x3(m_ipo_xform.GetEulerAngles()));

@ -38,8 +38,8 @@
KX_IPhysicsController::KX_IPhysicsController(bool dyna,void* userdata)
: m_bDyna(dyna),
m_userdata(userdata),
m_suspendDynamics(false)
m_suspendDynamics(false),
m_userdata(userdata)
{
};

@ -89,7 +89,6 @@ public:
};
KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
float starttime,
@ -100,16 +99,16 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
bool force_ipo_local,
PyTypeObject* T)
: SCA_IActuator(gameobj,T),
m_starttime (starttime),
m_endtime(endtime) ,
m_localtime(starttime),
m_recurse(recurse),
m_type((IpoActType)acttype) ,
m_direction(1),
m_bNegativeEvent(false),
m_starttime (starttime),
m_endtime(endtime),
m_recurse(recurse),
m_localtime(starttime),
m_direction(1),
m_propname(propname),
m_ipo_as_force(ipo_as_force),
m_force_ipo_local(force_ipo_local)
m_force_ipo_local(force_ipo_local),
m_type((IpoActType)acttype)
{
// intentionally empty
}

@ -102,9 +102,10 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
* Constructor of the Ketsji Engine
*/
KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
: m_bInitialized(false),
m_activecam(0),
m_rasterizer(NULL)
:
m_rasterizer(NULL),
m_bInitialized(false),
m_activecam(0)
{
m_kxsystem = system;
m_bFixedTime = false;
@ -587,6 +588,8 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene)
m_logger->StartLog(tc_sound, m_kxsystem->GetTimeInSeconds(), true);
KX_Camera* cam = scene->GetActiveCamera();
if (!cam)
return;
MT_Point3 listenerposition = cam->NodeGetWorldPosition();
MT_Vector3 listenervelocity = cam->GetLinearVelocity();
MT_Matrix3x3 listenerorientation = cam->NodeGetWorldOrientation();
@ -734,6 +737,9 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene)
{
float left, right, bottom, top, nearfrust, farfrust;
KX_Camera* cam = scene->GetActiveCamera();
if (!cam)
return;
m_rasterizer->DisplayFog();
@ -998,8 +1004,8 @@ void KX_KetsjiEngine::RemoveScene(const STR_String& scenename)
}
else
{
STR_String tmpname = scenename;
printf("warning: scene %s does not exist, not removed!\n",tmpname.Ptr());
// STR_String tmpname = scenename;
std::cout << "warning: scene " << scenename << " does not exist, not removed!" << std::endl;
}
}

@ -55,11 +55,12 @@ private:
double m_ipotime;
public:
KX_LightIpoSGController() : m_ipotime(0.0),
m_modify_energy(false),
m_modify_color(false),
m_modify_dist(false),
m_modified(true)
KX_LightIpoSGController() :
m_modify_energy(false),
m_modify_color(false),
m_modify_dist(false),
m_modified(true),
m_ipotime(0.0)
{}
virtual ~KX_LightIpoSGController();

@ -51,6 +51,11 @@
#include "KX_Camera.h"
#include "KX_MouseFocusSensor.h"
#include "KX_ClientObjectInfo.h"
#include "SM_Object.h"
#include "SM_Scene.h"
#include "SumoPhysicsEnvironment.h"
/* ------------------------------------------------------------------------- */
/* Native functions */
/* ------------------------------------------------------------------------- */
@ -233,23 +238,23 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
* ignore-object. We don't ignore anything... */
KX_GameObject* thisObj = (KX_GameObject*) GetParent();
SumoPhysicsEnvironment *spe = dynamic_cast<SumoPhysicsEnvironment* > (m_kxscene->GetPhysicsEnvironment());
SM_Scene *sumoScene = spe->GetSumoScene();
//SM_Object* hitSMObj = m_sumoScene->rayTest(NULL,
// frompoint3,
// topoint3,
// resultpoint,
// resultnormal);
KX_GameObject* hitKXObj = 0;
SM_Object* hitSMObj = sumoScene->rayTest(NULL,
frompoint3,
topoint3,
resultpoint,
resultnormal);
/* all this casting makes me nervous... */
//SM_ClientObjectInfo* client_info
// = ( hitSMObj ?
// (SM_ClientObjectInfo*) ((SM_Object*)hitSMObj)->getClientObject() :
// NULL);
//KX_GameObject* hitKXObj = ( client_info ?
// (KX_GameObject*)client_info->m_clientobject :
// NULL);
KX_ClientObjectInfo* client_info
= ( hitSMObj ?
(KX_ClientObjectInfo*) ((SM_Object*)hitSMObj)->getClientObject() :
NULL);
KX_GameObject* hitKXObj = ( client_info ?
(KX_GameObject*)client_info->m_clientobject :
NULL);
/* Is this me? In the ray test, there are a lot of extra checks

@ -38,11 +38,40 @@
#include "KX_TouchEventManager.h"
#include "KX_Scene.h" // needed to create a replica
#include "SM_Object.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
KX_GameObject* gameobj,
void *vshape,
double margin,
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
class KX_Scene* scene,
PyTypeObject* T)
:KX_TouchSensor(eventmgr,
gameobj,
bFindMaterial,
touchedpropname,
/* scene, */
T),
m_Margin(margin),
m_ResetMargin(resetmargin)
#ifdef PHYSICS_NOT_YET
{
m_client_info = new KX_ClientObjectInfo(gameobj);
m_client_info->m_type = KX_ClientObjectInfo::NEAR;
DT_ShapeHandle shape = (DT_ShapeHandle) vshape;
m_sumoObj = new SM_Object(shape,NULL,NULL,NULL);
m_sumoObj->setMargin(m_Margin);
m_sumoObj->setClientObject(m_client_info);
SynchronizeTransform();
}
KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
KX_GameObject* gameobj,
@ -56,20 +85,27 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
gameobj,
bFindMaterial,
touchedpropname,
scene,
/* scene, */
T),
m_Margin(margin),
m_ResetMargin(resetmargin),
m_sumoScene(sumoscene)
m_ResetMargin(resetmargin)
{
m_client_info.m_type = 4;
m_client_info.m_clientobject = gameobj;
m_client_info.m_auxilary_info = NULL;
sumoObj->setClientObject(&m_client_info);
m_client_info = new KX_ClientObjectInfo(gameobj);
m_client_info->m_type = KX_ClientObjectInfo::NEAR;
m_client_info->m_auxilary_info = NULL;
m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL);
m_sumoObj->setMargin(m_Margin);
m_sumoObj->setClientObject(m_client_info);
SynchronizeTransform();
}
void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
touchman->GetSumoScene()->addSensor(*m_sumoObj);
}
CValue* KX_NearSensor::GetReplica()
{
@ -82,6 +118,16 @@ CValue* KX_NearSensor::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject);
replica->m_client_info->m_type = KX_ClientObjectInfo::NEAR;
replica->m_client_info->m_auxilary_info = NULL;
replica->m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL);
replica->m_sumoObj->setMargin(m_Margin);
replica->m_sumoObj->setClientObject(replica->m_client_info);
replica->SynchronizeTransform();
return replica;
}
@ -89,42 +135,11 @@ CValue* KX_NearSensor::GetReplica()
void KX_NearSensor::ReParent(SCA_IObject* parent)
{
DT_ShapeHandle shape = DT_Sphere(0.0);
// this sumoObject is not deleted by a gameobj, so delete it ourself
// later (memleaks)!
SM_Object* sumoObj = new SM_Object(shape,NULL,NULL,NULL);
sumoObj->setMargin(m_Margin);
//sumoObj->setPosition(gameobj->NodeGetWorldPosition());
//sumoobj->setPosition(m_sumoObj->getPosition());
//sumoobj->setOrientation(m_sumoObj->getOrientation());
//newobj->setRigidBody(this->m_sumoObj->isRigidBody());
m_sumoObj = sumoObj;
m_solidHandle = m_sumoObj->getObjectHandle();
double radius = m_sumoObj->getMargin();
sumoObj->setMargin(m_sumoObj->getMargin());
m_client_info.m_type = 4;
m_client_info.m_clientobject = parent;
m_client_info.m_auxilary_info = NULL;
sumoObj->setClientObject(&m_client_info);
//m_sumoScene->add(*newobj);
if (m_sumoObj)
{
DT_SetObjectResponse(m_resptable,
m_sumoObj->getObjectHandle(),
collisionResponse,
DT_SIMPLE_RESPONSE,
this);
}
SCA_ISensor::ReParent(parent);
m_client_info->m_clientobject = static_cast<KX_GameObject*>(parent);
SynchronizeTransform();
}
@ -133,19 +148,20 @@ KX_NearSensor::~KX_NearSensor()
{
// for nearsensor, the sensor is the 'owner' of sumoobj
// for touchsensor, it's the parent
m_sumoScene->remove(*m_sumoObj);
static_cast<KX_TouchEventManager*>(m_eventmgr)->GetSumoScene()->remove(*m_sumoObj);
if (m_sumoObj)
delete m_sumoObj;
if (m_client_info)
delete m_client_info;
}
bool KX_NearSensor::Evaluate(CValue* event)
{
bool result = false;
KX_GameObject* parent = (KX_GameObject*)GetParent();
KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
if (m_bTriggered != m_bLastTriggered)
{
@ -172,28 +188,27 @@ bool KX_NearSensor::Evaluate(CValue* event)
void KX_NearSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData * coll_data)
DT_Bool KX_NearSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData * coll_data)
{
KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
KX_GameObject* parent = (KX_GameObject*)GetParent();
KX_TouchEventManager* toucheventmgr = static_cast<KX_TouchEventManager*>(m_eventmgr);
KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
// need the mapping from SM_Objects to gameobjects now
SM_ClientObjectInfo* client_info =(SM_ClientObjectInfo*) (obj1 == m_sumoObj?
KX_ClientObjectInfo* client_info =static_cast<KX_ClientObjectInfo*> (obj1 == m_sumoObj?
((SM_Object*)obj2)->getClientObject() :
((SM_Object*)obj1)->getClientObject());
KX_GameObject* gameobj = ( client_info ?
(KX_GameObject*)client_info->m_clientobject :
static_cast<KX_GameObject*>(client_info->m_clientobject) :
NULL);
if (gameobj && (gameobj != parent))
{
if (!m_colliders->SearchValue(gameobj))
m_colliders->Add(gameobj->AddRef());
// only take valid colliders
if (client_info->m_type == 1)
if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
{
if ((m_touchedpropname.Length() == 0) ||
(gameobj->GetProperty(m_touchedpropname)))
@ -202,10 +217,9 @@ void KX_NearSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData * co
m_hitObject = gameobj;
}
}
} else
{
}
return DT_CONTINUE;
}
@ -262,4 +276,3 @@ KX_NearSensor::_getattr(char* attr)
_getattr_up(KX_TouchSensor);
}
#endif //PHYSICS_NOT_YET

@ -36,8 +36,10 @@
#define KX_NEARSENSOR_H
#include "KX_TouchSensor.h"
#include "KX_ClientObjectInfo.h"
class KX_Scene;
class KX_ClientObjectInfo;
class KX_NearSensor : public KX_TouchSensor
{
@ -45,17 +47,36 @@ class KX_NearSensor : public KX_TouchSensor
double m_Margin;
double m_ResetMargin;
KX_Scene* m_scene;
KX_ClientObjectInfo* m_client_info;
protected:
KX_NearSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
void *shape,
double margin,
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
class KX_Scene* scene,
PyTypeObject* T=&Type);
public:
KX_NearSensor(class SCA_EventManager* eventmgr,class KX_GameObject* gameobj,double margin,double resetmargin,bool bFindMaterial,const STR_String& touchedpropname,class KM_Scene* scene,PyTypeObject* T=&Type);
KX_NearSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
double margin,
double resetmargin,
bool bFindMaterial,
const STR_String& touchedpropname,
class KX_Scene* scene,
PyTypeObject* T=&Type);
virtual ~KX_NearSensor();
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual void ReParent(SCA_IObject* parent);
//virtual void HandleCollision(void* obj1,void* obj2,
// const DT_CollData * coll_data);
virtual DT_Bool HandleCollision(void* obj1,void* obj2,
const DT_CollData * coll_data);
virtual void RegisterSumo(KX_TouchEventManager *touchman);
virtual PyObject* _getattr(char *attr);
};

@ -48,9 +48,9 @@ private:
double m_ipotime;
public:
KX_ObColorIpoSGController() : m_ipotime(0.0),
m_modified(true)
KX_ObColorIpoSGController() :
m_modified(true),
m_ipotime(0.0)
{}
virtual ~KX_ObColorIpoSGController();
virtual SG_Controller* GetReplica(class SG_Node* destnode);

@ -44,7 +44,6 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
KX_ObjectActuator::
KX_ObjectActuator(
SCA_IObject* gameobj,
@ -64,8 +63,8 @@ KX_ObjectActuator(
m_drot(drot),
m_linear_velocity(linV),
m_angular_velocity(angV),
m_active_combined_velocity (false),
m_bitLocalFlag (flag)
m_bitLocalFlag (flag),
m_active_combined_velocity (false)
{
}
@ -83,6 +82,11 @@ bool KX_ObjectActuator::Update(double curtime,double deltatime)
// it should reconcile the externally set velocity with it's
// own velocity.
if (m_active_combined_velocity) {
static bool update_resolve_warning = 0;
if (!update_resolve_warning) {
update_resolve_warning = 1;
std::cout << "FIXME: KX_ObjectActuator::Update ResolveCombinedVelocities undefined!" << std::endl;
}
//if (parent->GetSumoObject()) {
//parent->GetPhysicsController()->ResolveCombinedVelocities(
// m_linear_velocity,

@ -34,11 +34,12 @@
enum e_PhysicsEngine
{
UseNone=1,
UseSumo,
UseODE,
UseDynamo,
NoSelection
NoSelection = -1,
UseNone = 0,
UseEnji = 1,
UseSumo = 2,
UseDynamo = 3,
UseODE = 4
};
#endif //__KX_PHYSICSENGINEENUMS

@ -40,8 +40,10 @@
KX_PhysicsObjectWrapper::KX_PhysicsObjectWrapper(
PHY_IPhysicsController* ctrl,
PHY_IPhysicsEnvironment* physenv,PyTypeObject *T)
: m_ctrl(ctrl),m_physenv(physenv),PyObjectPlus(T)
PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
PyObjectPlus(T),
m_ctrl(ctrl),
m_physenv(physenv)
{
}

@ -39,11 +39,8 @@
/**
* RadarSensor constructor. Creates a near-sensor derived class, with a cone collision shape.
*/
#ifdef PHYSICS_NOT_YET
KX_RadarSensor::KX_RadarSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
KX_GameObject* gameobj,
double coneradius,
double coneheight,
int axis,
@ -57,20 +54,21 @@ KX_RadarSensor::KX_RadarSensor(class SCA_EventManager* eventmgr,
: KX_NearSensor(
eventmgr,
gameobj,
DT_NewCone(coneradius,coneheight),
margin,
resetmargin,
bFindMaterial,
touchedpropname,
kxscene,
T),
m_coneheight(coneheight),
m_coneradius(coneradius),
m_coneheight(coneheight),
m_axis(axis)
{
m_client_info.m_type = 3;
m_client_info.m_clientobject = gameobj;
m_client_info.m_auxilary_info = NULL;
sumoObj->setClientObject(&m_client_info);
m_client_info->m_type = KX_ClientObjectInfo::RADAR;
//m_client_info->m_clientobject = gameobj;
//m_client_info->m_auxilary_info = NULL;
//sumoObj->setClientObject(&m_client_info);
}
@ -221,4 +219,3 @@ PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self,
}
#endif //PHYSICS_NOT_YET

@ -62,18 +62,18 @@ class KX_RadarSensor : public KX_NearSensor
MT_Point3 m_cone_target;
public:
KX_RadarSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
KX_RadarSensor(SCA_EventManager* eventmgr,
KX_GameObject* gameobj,
double coneradius,
double coneheight,
int axis,
double margin,
double resetmargin,
class SM_Object* sumoObj,
bool bFindMaterial,
const STR_String& touchedpropname,
class SM_Scene* sumoscene,
PyTypeObject* T=&Type);
class KX_Scene* kxscene,
PyTypeObject* T = &Type);
KX_RadarSensor();
virtual ~KX_RadarSensor();
virtual void SynchronizeTransform();

@ -44,8 +44,8 @@ class KX_RayEventManager : public SCA_EventManager
class SCA_LogicManager* m_logicmgr;
public:
KX_RayEventManager(class SCA_LogicManager* logicmgr)
: m_logicmgr(logicmgr),
SCA_EventManager(RAY_EVENTMGR)
: SCA_EventManager(RAY_EVENTMGR),
m_logicmgr(logicmgr)
{}
virtual void NextFrame(double curtime,double deltatime);
virtual void RegisterSensor(SCA_ISensor* sensor);

@ -41,6 +41,9 @@
#include "KX_GameObject.h"
#include "KX_Scene.h"
#include "SumoPhysicsEnvironment.h"
#include "KX_SumoPhysicsController.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@ -57,10 +60,10 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
m_propertyname(propname),
m_bFindMaterial(bFindMaterial),
m_distance(distance),
m_axis(axis),
m_ketsjiScene(ketsjiScene),
m_rayHit(false),
m_scene(ketsjiScene),
m_bTriggered(false),
m_axis(axis),
m_rayHit(false),
m_hitObject(NULL)
@ -139,56 +142,78 @@ bool KX_RaySensor::Evaluate(CValue* event)
}
case 3: // -X
{
todir[0] = invmat[0][0] * -1;
todir[1] = invmat[0][1] * -1;
todir[2] = invmat[0][2] * -1;
todir[0] = -invmat[0][0];
todir[1] = -invmat[0][1];
todir[2] = -invmat[0][2];
break;
}
case 4: // -Y
{
todir[0] = invmat[1][0] * -1;
todir[1] = invmat[1][1] * -1;
todir[2] = invmat[1][2] * -1;
todir[0] = -invmat[1][0];
todir[1] = -invmat[1][1];
todir[2] = -invmat[1][2];
break;
}
case 5: // -Z
{
todir[0] = invmat[2][0] * -1;
todir[1] = invmat[2][1] * -1;
todir[2] = invmat[2][2] * -1;
todir[0] = -invmat[2][0];
todir[1] = -invmat[2][1];
todir[2] = -invmat[2][2];
break;
}
}
todir.normalize();
m_rayDirection = todir;
MT_Point3 topoint = frompoint + (m_distance) * todir;
MT_Point3 resultpoint;
MT_Vector3 resultnormal;
bool ready = false;
/*
do {
SumoPhysicsEnvironment *spe = dynamic_cast<SumoPhysicsEnvironment *>(m_scene->GetPhysicsEnvironment());
SM_Scene *scene = spe->GetSumoScene();
KX_SumoPhysicsController *spc = dynamic_cast<KX_SumoPhysicsController *>(obj->GetPhysicsController());
KX_GameObject *parent = obj->GetParent();
if (!spc && parent)
spc = dynamic_cast<KX_SumoPhysicsController *>(parent->GetPhysicsController());
if (parent)
parent->Release();
SM_Object *thisObj = spc?spc->GetSumoObject():NULL;
SM_Object* hitObj = m_sumoScene->rayTest(obj->GetSumoObject(),
frompoint,
topoint,
resultpoint,
resultnormal);
do {
SM_Object* hitObj = scene->rayTest(thisObj,
frompoint,
topoint,
resultpoint,
resultnormal);
if (hitObj)
{
KX_ClientObjectInfo* info = (SM_ClientObjectInfo*)hitObj->getClientObject();
SCA_IObject* hitgameobj = (SCA_IObject*)info->m_clientobject;
KX_ClientObjectInfo* info = (KX_ClientObjectInfo*)hitObj->getClientObject();
bool bFound = false;
if (hitgameobj == obj)
if (!info)
{
std::cout<< "WARNING: Ray sensor " << GetName() << " cannot sense SM_Object " << hitObj << " - no client info.\n" << std::endl;
ready = true;
break;
}
SCA_IObject *hitgameobj = (SCA_IObject*)info->m_clientobject;
if (hitgameobj == obj || info->m_type > KX_ClientObjectInfo::ACTOR)
{
// false hit
MT_Scalar marg = obj->GetSumoObject()->getMargin() ;
frompoint = resultpoint + marg * todir;
KX_SumoPhysicsController *hitspc = dynamic_cast<KX_SumoPhysicsController *> (static_cast<KX_GameObject*> (hitgameobj) ->GetPhysicsController());
if (hitspc)
{
MT_Scalar marg = hitspc->GetSumoObject()->getMargin();
if (hitspc->GetSumoObject()->getShapeProps())
marg += hitspc->GetSumoObject()->getShapeProps()->m_radius;
frompoint = resultpoint + marg * todir;
} else {
ready = true;
}
}
else
{
@ -208,10 +233,7 @@ bool KX_RaySensor::Evaluate(CValue* event)
}
else
{
if (hitgameobj->GetProperty(m_propertyname) != NULL)
{
bFound = true;
}
bFound = hitgameobj->GetProperty(m_propertyname) != NULL;
}
}
@ -231,7 +253,7 @@ bool KX_RaySensor::Evaluate(CValue* event)
}
}
while (!ready);
*/
/* now pass this result to some controller */

@ -44,7 +44,7 @@ class KX_RaySensor : public SCA_ISensor
STR_String m_propertyname;
bool m_bFindMaterial;
double m_distance;
class KX_Scene* m_ketsjiScene;
class KX_Scene* m_scene;
bool m_bTriggered;
int m_axis;
bool m_rayHit;

@ -135,8 +135,8 @@ KX_SCA_ReplaceMeshActuator::KX_SCA_ReplaceMeshActuator(SCA_IObject *gameobj,
PyTypeObject* T) :
SCA_IActuator(gameobj, T),
m_scene(scene),
m_mesh(mesh)
m_mesh(mesh),
m_scene(scene)
{
} /* End of constructor */

@ -73,6 +73,8 @@
#include "PHY_IPhysicsEnvironment.h"
#include "KX_IPhysicsController.h"
#include "SM_Scene.h"
#include "SumoPhysicsEnvironment.h"
void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene)
{
@ -95,23 +97,20 @@ SG_Callbacks KX_Scene::m_callbacks = SG_Callbacks(KX_SceneReplicationFunc,KX_Sce
// (defined in KX_PythonInit.cpp)
extern bool gUseVisibilityTemp;
KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
class SCA_IInputDevice* mousedevice,
class NG_NetworkDeviceInterface *ndi,
class SND_IAudioDevice* adi,
const STR_String& sceneName):
m_mousemgr(NULL),
m_keyboardmgr(NULL),
m_active_camera(NULL),
m_ueberExecutionPriority(0),
m_adi(adi),
m_mousemgr(NULL),
m_physicsEnvironment(0),
m_sceneName(sceneName),
m_adi(adi),
m_networkDeviceInterface(ndi),
m_physicsEnvironment(0)
m_active_camera(NULL),
m_ueberExecutionPriority(0)
{
@ -130,11 +129,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_keyboardmgr = new SCA_KeyboardManager(m_logicmgr,keyboarddevice);
m_mousemgr = new SCA_MouseManager(m_logicmgr,mousedevice);
// m_solidScene = DT_CreateScene();
// m_respTable = DT_CreateRespTable();
SCA_AlwaysEventManager* alwaysmgr = new SCA_AlwaysEventManager(m_logicmgr);
//KX_TouchEventManager* touchmgr = new KX_TouchEventManager(m_logicmgr, m_respTable, m_solidScene);
SCA_PropertyEventManager* propmgr = new SCA_PropertyEventManager(m_logicmgr);
SCA_RandomEventManager* rndmgr = new SCA_RandomEventManager(m_logicmgr);
KX_RayEventManager* raymgr = new KX_RayEventManager(m_logicmgr);
@ -145,14 +140,11 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_logicmgr->RegisterEventManager(propmgr);
m_logicmgr->RegisterEventManager(m_keyboardmgr);
m_logicmgr->RegisterEventManager(m_mousemgr);
//m_logicmgr->RegisterEventManager(touchmgr);
m_logicmgr->RegisterEventManager(m_timemgr);
m_logicmgr->RegisterEventManager(rndmgr);
m_logicmgr->RegisterEventManager(raymgr);
m_logicmgr->RegisterEventManager(netmgr);
//m_sumoScene = new SM_Scene();
//m_sumoScene->setSecondaryRespTable(m_respTable);
m_soundScene = new SND_Scene(adi);
assert (m_networkDeviceInterface != NULL);
m_networkScene = new NG_NetworkScene(m_networkDeviceInterface);
@ -169,6 +161,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
KX_Scene::~KX_Scene()
{
// int numobj = m_objectlist->GetCount();
//int numrootobjects = GetRootParentList()->GetCount();
@ -708,6 +701,11 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
newobj->Release();
if (m_euthanasyobjects->RemoveValue(newobj))
newobj->Release();
if (newobj == m_active_camera)
{
m_active_camera = NULL;
}
}
@ -979,3 +977,15 @@ void KX_Scene::SetGravity(const MT_Vector3& gravity)
{
GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]);
}
void KX_Scene::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv)
{
SumoPhysicsEnvironment *sme = dynamic_cast<SumoPhysicsEnvironment *>(physEnv);
m_physicsEnvironment = physEnv;
if (sme)
{
KX_TouchEventManager* touchmgr = new KX_TouchEventManager(m_logicmgr, sme->GetSumoScene());
m_logicmgr->RegisterEventManager(touchmgr);
return;
}
}

@ -466,10 +466,7 @@ public:
return m_physicsEnvironment;
}
void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv)
{
m_physicsEnvironment = physEnv;
}
void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv);
void SetGravity(const MT_Vector3& gravity);
};

@ -295,12 +295,9 @@ PyObject* KX_SceneActuator::PySetScene(PyObject* self,
return NULL;
}
if (m_KetsjiEngine->FindScene(scene_name))
{
/* Scene switch is done by name. */
m_nextSceneName = scene_name;
}
/* Scene switch is done by name. */
m_nextSceneName = scene_name;
Py_Return;
}

@ -1,4 +1,7 @@
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include "KX_SumoPhysicsController.h"
#include "SG_Spatial.h"
@ -107,7 +110,7 @@ SG_Controller* KX_SumoPhysicsController::GetReplica(SG_Node* destnode)
//parentcontroller is here be able to avoid collisions between parent/child
PHY_IPhysicsController* parentctrl = NULL;
if (destnode != destnode->GetRootSGParent())
{
KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
@ -123,7 +126,7 @@ SG_Controller* KX_SumoPhysicsController::GetReplica(SG_Node* destnode)
childit!= destnode->GetSGChildren().end();
++childit
) {
KX_GameObject* clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
if (clientgameobj)
{
parentctrl = (KX_SumoPhysicsController*)clientgameobj->GetPhysicsController();
@ -145,8 +148,7 @@ void KX_SumoPhysicsController::SetObject (SG_IObject* object)
// cheating here...
KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
gameobj->SetPhysicsController(this);
GetSumoObject()->setClientObject(gameobj->getClientInfo());
}

@ -1,3 +1,34 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef __KX_SUMOPHYSICSCONTROLLER_H
#define __KX_SUMOPHYSICSCONTROLLER_H
@ -27,8 +58,8 @@ public:
class SM_Object* sumoObj,
class PHY_IMotionState* motionstate
,bool dyna)
: SumoPhysicsController(sumoScene,solidscene,sumoObj,motionstate,dyna),
KX_IPhysicsController(dyna,NULL)
: KX_IPhysicsController(dyna,NULL) ,
SumoPhysicsController(sumoScene,solidscene,sumoObj,motionstate,dyna)
{
};
virtual ~KX_SumoPhysicsController();

@ -36,8 +36,10 @@
#include <config.h>
#endif
KX_TimeLogger::KX_TimeLogger(unsigned int maxNumMeasurements)
: m_maxNumMeasurements(maxNumMeasurements), m_logging(false), m_logStart(0)
KX_TimeLogger::KX_TimeLogger(unsigned int maxNumMeasurements) :
m_maxNumMeasurements(maxNumMeasurements),
m_logStart(0),
m_logging(false)
{
}
@ -108,7 +110,7 @@ double KX_TimeLogger::GetAverage(void) const
unsigned int numMeasurements = m_measurements.size();
if (numMeasurements > 1) {
for (int i = 1; i < numMeasurements; i++) {
for (unsigned int i = 1; i < numMeasurements; i++) {
avg += m_measurements[i];
}
avg /= (float)numMeasurements - 1;

@ -38,33 +38,60 @@
#include <config.h>
#endif
#ifdef PHYSICS_NOT_YET
#include "SM_Object.h"
KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr,
DT_RespTableHandle resphandle,
DT_SceneHandle scenehandle)
SM_Scene *scene)
: SCA_EventManager(TOUCH_EVENTMGR),
m_resphandle(resphandle),
m_scenehandle(scenehandle),
m_logicmgr(logicmgr) {}
m_logicmgr(logicmgr),
m_scene(scene)
{
//m_scene->addTouchCallback(STATIC_RESPONSE, KX_TouchEventManager::collisionResponse, this);
m_scene->addTouchCallback(OBJECT_RESPONSE, KX_TouchEventManager::collisionResponse, this);
m_scene->addTouchCallback(SENSOR_RESPONSE, KX_TouchEventManager::collisionResponse, this);
}
DT_Bool KX_TouchEventManager::HandleCollision(void* object1,void* object2,
const DT_CollData * coll_data)
{
SM_Object * obj1 = (SM_Object *) object1;
SM_Object * obj2 = (SM_Object *) object2;
for ( vector<SCA_ISensor*>::iterator it = m_sensors.begin(); !(it==m_sensors.end()); it++)
{
KX_GameObject* gameobj = ((KX_GameObject*)((KX_TouchSensor*)*it)->GetParent());
KX_ClientObjectInfo *client_info = (KX_ClientObjectInfo *) obj1->getClientObject();
// Enable these printfs to create excesive debug info
// printf("KX_TEM::HC: Sensor %s\tGO: %p o1: %s (%p)", (const char *) (*it)->GetName(), gameobj, (const char *) ((KX_GameObject *) client_info->m_clientobject)->GetName(), client_info->m_clientobject);
if (client_info && client_info->m_clientobject == gameobj)
((KX_TouchSensor*)*it)->HandleCollision(object1,object2,coll_data);
client_info = (KX_ClientObjectInfo *) obj2->getClientObject();
// printf(" o2: %s (%p)\n", (const char *) ((KX_GameObject *) client_info->m_clientobject)->GetName(), client_info->m_clientobject);
if (client_info && client_info->m_clientobject == gameobj)
((KX_TouchSensor*)*it)->HandleCollision(object1,object2,coll_data);
}
return DT_CONTINUE;
}
DT_Bool KX_TouchEventManager::collisionResponse(void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data)
{
KX_TouchEventManager *touchmgr = (KX_TouchEventManager *) client_data;
touchmgr->HandleCollision(object1, object2, coll_data);
return DT_CONTINUE;
}
void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
m_sensors.push_back(touchsensor);
touchsensor->RegisterSumo();//this,m_resphandle);
//KX_GameObject* gameobj = ((KX_GameObject*)sensor->GetParent());
// SM_Object* smobj = touchsensor->GetSumoObject();//gameobj->GetSumoObject();
// if (smobj)
// {
// smobj->calcXform();
// DT_AddObject(m_scenehandle,
// smobj->getObjectHandle());
// }
touchsensor->RegisterSumo(this);
}
@ -89,10 +116,7 @@ void KX_TouchEventManager::NextFrame(double curtime,double deltatime)
vector<SCA_ISensor*>::iterator it;
for (it = m_sensors.begin();!(it==m_sensors.end());it++)
((KX_TouchSensor*)*it)->SynchronizeTransform();
if (DT_Test(m_scenehandle,m_resphandle))
int i = 0;
static_cast<KX_TouchSensor*>(*it)->SynchronizeTransform();
for (it = m_sensors.begin();!(it==m_sensors.end());it++)
(*it)->Activate(m_logicmgr,NULL);
@ -107,14 +131,10 @@ void KX_TouchEventManager::RemoveSensor(class SCA_ISensor* sensor)
std::find(m_sensors.begin(), m_sensors.end(), sensor);
if (!(i == m_sensors.end()))
{
//std::swap(*i, m_sensors.back());
//m_sensors.pop_back();
//SM_Object* smobj = ((KX_TouchSensor*)*i)->GetSumoObject();
//DT_RemoveObject(m_scenehandle,
// smobj->getObjectHandle());
std::swap(*i, m_sensors.back());
m_sensors.pop_back();
}
// remove the sensor forever :)
SCA_EventManager::RemoveSensor(sensor);
}
#endif

@ -37,19 +37,30 @@
#include "KX_GameObject.h"
#include <vector>
using namespace std;
class KX_TouchEventManager : public SCA_EventManager
{
class SCA_LogicManager* m_logicmgr;
SM_Scene *m_scene;
static DT_Bool KX_TouchEventManager::collisionResponse(void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data);
virtual DT_Bool HandleCollision(void* obj1,void* obj2,
const DT_CollData * coll_data);
public:
KX_TouchEventManager(class SCA_LogicManager* logicmgr);
KX_TouchEventManager(class SCA_LogicManager* logicmgr,
SM_Scene *scene);
virtual void NextFrame(double curtime,double deltatime);
virtual void EndFrame();
virtual void RemoveSensor(class SCA_ISensor* sensor);
virtual void RegisterSensor(SCA_ISensor* sensor);
SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
SM_Scene *GetSumoScene() { return m_scene; }
};
#endif //__KX_TOUCHEVENTMANAGER

@ -37,14 +37,14 @@
#include "SCA_LogicManager.h"
#include "KX_GameObject.h"
#include "KX_TouchEventManager.h"
#include "SM_Object.h"
#include "KX_SumoPhysicsController.h"
#include <iostream>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef PHYSICS_NOT_YET
/* ------------------------------------------------------------------------- */
/* Native functions */
/* ------------------------------------------------------------------------- */
@ -84,78 +84,81 @@ bool KX_TouchSensor::Evaluate(CValue* event)
return result;
}
KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj,SM_Object* sumoObj,bool bFindMaterial,const STR_String& touchedpropname,PyTypeObject* T)
KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj,/*SM_Object* sumoObj,*/bool bFindMaterial,const STR_String& touchedpropname,PyTypeObject* T)
:SCA_ISensor(gameobj,eventmgr,T),
m_touchedpropname(touchedpropname),
m_bFindMaterial(bFindMaterial),
m_sumoObj(sumoObj),
m_eventmgr(eventmgr),
/*m_sumoObj(sumoObj),*/
m_bCollision(false),
m_bTriggered(false),
m_bLastTriggered(false)
{
m_eventmgr = eventmgr;
KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr;
// m_resptable = touchmgr->GetResponseTable();
m_resptable = touchmgr->GetResponseTable();
m_solidHandle = m_sumoObj->getObjectHandle();
// m_solidHandle = m_sumoObj->getObjectHandle();
m_hitObject = NULL;
m_colliders = new CListValue();
KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
client_info->m_clientobject = gameobj;
client_info->m_auxilary_info = NULL;
KX_SumoPhysicsController *sphy = dynamic_cast<KX_SumoPhysicsController *>(gameobj->GetPhysicsController());
if (sphy)
m_sumoObj = sphy->GetSumoObject();
}
KX_TouchSensor::~KX_TouchSensor()
{
DT_ClearObjectResponse(m_resptable,m_solidHandle);
//DT_ClearObjectResponse(m_resptable,m_solidHandle);
m_colliders->Release();
}
void KX_TouchSensor::ReParent(SCA_IObject* parent)
{
KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
KX_SumoPhysicsController *sphy = dynamic_cast<KX_SumoPhysicsController *>(((KX_GameObject*)parent)->GetPhysicsController());
if (sphy)
m_sumoObj = sphy->GetSumoObject();
m_sumoObj = ((KX_GameObject*)parent)->GetSumoObject();
m_solidHandle = m_sumoObj->getObjectHandle();
m_client_info.m_clientobject = NULL;//parent;
m_client_info.m_auxilary_info = NULL;
// m_solidHandle = m_sumoObj->getObjectHandle();
KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
client_info->m_clientobject = parent;
client_info->m_auxilary_info = NULL;
SCA_ISensor::ReParent(parent);
}
void KX_TouchSensor::RegisterSumo()
void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
if (m_sumoObj)
{
touchman->GetSumoScene()->requestCollisionCallback(*m_sumoObj);
// collision
// Deprecated
if (m_sumoObj)
{
// collision
DT_SetObjectResponse(
m_resptable,
m_solidHandle,
collisionResponse,
DT_SIMPLE_RESPONSE,
this);
}
}
}
void KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData * coll_data)
DT_Bool KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData * coll_data)
{
KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
KX_GameObject* parent = (KX_GameObject*)GetParent();
// need the mapping from SM_Objects to gameobjects now
SM_ClientObjectInfo* client_info =(SM_ClientObjectInfo*) (obj1 == m_sumoObj?
KX_ClientObjectInfo* client_info =(KX_ClientObjectInfo*) (obj1 == m_sumoObj?
((SM_Object*)obj2)->getClientObject() :
((SM_Object*)obj1)->getClientObject());
KX_GameObject* gameobj = ( client_info ?
(KX_GameObject*)client_info->m_clientobject :
NULL);
if (gameobj && (gameobj != parent))
{
if (!m_colliders->SearchValue(gameobj))
@ -185,12 +188,14 @@ void KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollData
{
m_bTriggered = true;
m_hitObject = gameobj;
//printf("KX_TouchSensor::HandleCollision\n");
}
}
return DT_CONTINUE;
}
/* ------------------------------------------------------------------------- */
/* Python functions */
/* ------------------------------------------------------------------------- */
@ -322,10 +327,11 @@ PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self,
* - this also doesn't work (obviously) for multi-materials...
*/
KX_GameObject* gameob = (KX_GameObject*) m_colliders->GetValue(i);
SM_Object* smob = (SM_Object*) gameob->GetSumoObject();
KX_SumoPhysicsController* spc = dynamic_cast<KX_SumoPhysicsController*>(gameob->GetPhysicsController());
SM_Object* smob = spc?spc->GetSumoObject():NULL;
if (smob) {
SM_ClientObjectInfo* cl_inf = (SM_ClientObjectInfo*) smob->getClientObject();
KX_ClientObjectInfo* cl_inf = (KX_ClientObjectInfo*) smob->getClientObject();
if (m_touchedpropname == ((char*)cl_inf->m_auxilary_info)) {
newList->Add(m_colliders->GetValue(i)->AddRef());
@ -392,6 +398,5 @@ PyObject* KX_TouchSensor::PySetTouchMaterial(PyObject* self, PyObject* args, PyO
Py_Return;
}
#endif //#ifdef PHYSICS_NOT_YET
/* eof */

@ -38,8 +38,13 @@
#include "SCA_ISensor.h"
#include "ListValue.h"
#include <SOLID/SOLID.h>
#include "SM_Scene.h"
#include "KX_ClientObjectInfo.h"
class KX_TouchEventManager;
class KX_TouchSensor : public SCA_ISensor
{
protected:
@ -52,10 +57,9 @@ protected:
bool m_bFindMaterial;
class SCA_EventManager* m_eventmgr;
//class SM_Object* m_sumoObj;
//DT_ObjectHandle m_solidHandle;
//SM_ClientObjectInfo m_client_info;
//DT_RespTableHandle m_resptable;
class SM_Object* m_sumoObj;
DT_ObjectHandle m_solidHandle;
DT_RespTableHandle m_resptable;
bool m_bCollision;
@ -67,7 +71,7 @@ protected:
public:
KX_TouchSensor(class SCA_EventManager* eventmgr,
class KX_GameObject* gameobj,
class SM_Object* sumoObj,
/*class SM_Object* sumoObj,*/
bool fFindMaterial,
const STR_String& touchedpropname,
PyTypeObject* T=&Type) ;
@ -88,25 +92,15 @@ public:
virtual bool Evaluate(CValue* event);
virtual void ReParent(SCA_IObject* parent);
/* static void collisionResponse(void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data) {
class KX_TouchSensor* sensor = (class KX_TouchSensor*) client_data;
sensor->HandleCollision(object1,object2,coll_data);
}
virtual void RegisterSumo(KX_TouchEventManager* touchman);
void RegisterSumo();
virtual void HandleCollision(void* obj1,void* obj2,
virtual DT_Bool HandleCollision(void* obj1,void* obj2,
const DT_CollData * coll_data);
// SM_Object* GetSumoObject() { return m_sumoObj; };
SM_Object* GetSumoObject() { return m_sumoObj; };
*/
virtual bool IsPositiveTrigger() {
bool result = m_bTriggered;
@ -115,7 +109,7 @@ public:
}
void EndFrame();
virtual void EndFrame();
// todo: put some info for collision maybe

@ -53,11 +53,12 @@ private:
double m_ipotime;
public:
KX_WorldIpoController() : m_ipotime(0.0),
m_modify_mist_color(false),
m_modify_mist_start(false),
m_modify_mist_dist(false),
m_modified(true)
KX_WorldIpoController() :
m_modify_mist_color(false),
m_modify_mist_start(false),
m_modify_mist_dist(false),
m_modified(true),
m_ipotime(0.0)
{}
virtual ~KX_WorldIpoController();

@ -42,7 +42,8 @@ CPPFLAGS += $(OGL_CPPFLAGS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I../Rasterizer -I../GameLogic -I../SceneGraph
CPPFLAGS += -I../BlenderRoutines -I../Expressions
CPPFLAGS += -I../../kernel/gen_system

@ -1,3 +1,5 @@
import sys
Import ('user_options_dict')
Import ('library_env')
@ -59,6 +61,7 @@ if user_options_dict['USE_PHYSICS'] == 'solid':
if user_options_dict['USE_PHYSICS'] == 'ode':
source_files += ['KX_OdePhysicsController.cpp']
ketsji_env.Append (CPPPATH = user_options_dict['SOLID_INCLUDE'])
ketsji_env.Append (CPPPATH = ['.',
'#source/kernel/gen_system',
@ -90,7 +93,7 @@ ketsji_env.Append (CPPPATH = ['.',
'#source/gameengine/Physics/common',
'#source/gameengine/Physics/BlOde',
'#source/gameengine/Physics/Dummy',
'#source/gameengine/Physics/Sumo/',
'#source/gameengine/Physics/Sumo',
'#source/gameengine/Physics/Sumo/include',
'#source/gameengine/Physics/Sumo/Fuzzics/include',
'#source/gameengine/Network/LoopBackNetwork',
@ -98,6 +101,8 @@ ketsji_env.Append (CPPPATH = ['.',
'#source/blender/blenloader'
])
if sys.platform == 'win32':
ketsji_env.Append (CXXFLAGS = ['/GR'])
ketsji_env.Append (CPPPATH = user_options_dict['PYTHON_INCLUDE'])
ketsji_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/KX_ketsji', source=source_files)

@ -0,0 +1,26 @@
#ifndef __SM_DEBUG_H__
#define __SM_DEBUG_H__
/* Comment this to disable all SUMO debugging printfs */
#define SM_DEBUG
#ifdef SM_DEBUG
#include <stdio.h>
/* Uncomment this to printf all ray casts */
//#define SM_DEBUG_RAYCAST
/* Uncomment this to printf collision callbacks */
//#define SM_DEBUG_BOING
/* Uncomment this to printf Xform matrix calculations */
//#define SM_DEBUG_XFORM
#endif /* SM_DEBUG */
#endif /* __SM_DEBUG_H__ */

@ -1,3 +1,34 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef SM_FHOBJECT_H
#define SM_FHOBJECT_H
@ -5,19 +36,15 @@
class SM_FhObject : public SM_Object {
public:
SM_FhObject() {}
SM_FhObject(const MT_Vector3& ray, SM_Object *client_object) :
SM_Object(DT_Ray(ray[0], ray[1], ray[2]), 0, 0, 0),
m_ray(ray),
m_ray_direction(ray.normalized()),
m_client_object(client_object) {}
virtual ~SM_FhObject();
SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object);
const MT_Vector3& getRay() const { return m_ray; }
MT_Point3 getSpot() const { return m_pos + m_ray; }
const MT_Vector3& getRayDirection() const { return m_ray_direction; }
SM_Object *getClientObject() const { return m_client_object; }
SM_Object *getParentObject() const { return m_parent_object; }
static void ray_hit(void *client_data,
static DT_Bool ray_hit(void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data);
@ -25,7 +52,7 @@ public:
private:
MT_Vector3 m_ray;
MT_Vector3 m_ray_direction;
SM_Object *m_client_object;
SM_Object *m_parent_object;
};
#endif

@ -1,9 +1,40 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef SM_OBJECT_H
#define SM_OBJECT_H
#include <vector>
#include "solid.h"
#include <SOLID/SOLID.h>
#include "SM_Callback.h"
#include "SM_MotionState.h"
@ -15,6 +46,7 @@ class SM_FhObject;
// Properties of dynamic objects
struct SM_ShapeProps {
MT_Scalar m_mass; // Total mass
MT_Scalar m_radius; // Bound sphere size
MT_Scalar m_inertia; // Inertia, should be a tensor some time
MT_Scalar m_lin_drag; // Linear drag (air, water) 0 = concrete, 1 = vacuum
MT_Scalar m_ang_drag; // Angular drag
@ -36,6 +68,7 @@ struct SM_MaterialProps {
};
class SM_Object : public SM_MotionState {
public:
SM_Object() ;
@ -45,7 +78,6 @@ public:
const SM_ShapeProps *shapeProps,
SM_Object *dynamicParent
);
virtual ~SM_Object();
bool isDynamic() const;
@ -89,7 +121,7 @@ public:
void setMargin(MT_Scalar margin) ;
MT_Scalar getMargin() const ;
const SM_MaterialProps *getMaterialProps() const ;
const SM_ShapeProps *getShapeProps() const ;
@ -164,7 +196,8 @@ public:
void applyAngularImpulse(const MT_Vector3& impulse);
MT_Point3 getWorldCoord(const MT_Point3& local) const;
MT_Point3 getLocalCoord(const MT_Point3& world) const;
MT_Vector3 getVelocity(const MT_Point3& local) const;
@ -180,9 +213,6 @@ public:
DT_ObjectHandle getObjectHandle() const ;
DT_ShapeHandle getShapeHandle() const ;
void setClientObject(void *clientobj) ;
void *getClientObject() ;
SM_Object *getDynamicParent() ;
void integrateForces(MT_Scalar timeStep);
@ -192,10 +222,9 @@ public:
bool isRigidBody() const ;
// This is the callback for handling collisions of dynamic objects
static
void
DT_Bool
boing(
void *client_data,
void *object1,
@ -203,6 +232,26 @@ public:
const DT_CollData *coll_data
);
static
DT_Bool
fix(
void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data
);
void *getClientObject() { return m_client_object; }
void setClientObject(void *client_object) { m_client_object = client_object; }
void relax();
void backup() {
m_pos = m_prev_state.getPosition();
m_orn = m_prev_state.getOrientation();
m_xform = m_prev_xform;
}
private:
// return the actual linear_velocity of this object this
@ -217,11 +266,20 @@ private:
MT_Vector3
actualAngVelocity(
) const ;
void dynamicCollision(MT_Point3 local2,
MT_Vector3 normal,
MT_Scalar dist,
MT_Vector3 rel_vel,
MT_Scalar restitution,
MT_Scalar friction_factor,
MT_Scalar invMass
);
typedef std::vector<SM_Callback *> T_CallbackList;
T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
SM_Object *m_dynamicParent; // Collisions between parent and children are ignored
// as the collision callback now has only information
@ -229,7 +287,7 @@ private:
// can identify it's clientdata after a collision
void *m_client_object;
DT_ShapeHandle m_shape; // Shape for collision detection
DT_ShapeHandle m_shape; // Shape for collision detection
// Material and shape properties are not owned by this class.
@ -237,7 +295,7 @@ private:
const SM_MaterialProps *m_materialPropsBackup; // Backup in case the object temporarily becomes a ghost.
const SM_ShapeProps *m_shapeProps;
const SM_ShapeProps *m_shapePropsBackup; // Backup in case the object's dynamics is temporarily suspended
DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
MT_Scalar m_margin; // Offset for the object's shape (also for collision detection)
MT_Vector3 m_scaling; // Non-uniform scaling of the object's shape
@ -258,6 +316,8 @@ private:
MT_Vector3 m_ang_mom; // Angular momentum (angualr velocity times inertia)
MT_Vector3 m_force; // Force on center of mass (afffects linear momentum)
MT_Vector3 m_torque; // Torque around center of mass (affects angualr momentum)
MT_Vector3 m_error; // Error in position:- amount object must be moved to prevent intersection with scene
// Here are the values of externally set linear and angular
// velocity. These are updated from the outside

@ -2,38 +2,70 @@
* $Id$
* Copyright (C) 2001 NaN Technologies B.V.
* The physics scene.
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef SM_SCENE_H
#define SM_SCENE_H
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include <vector>
#include <set>
#include <utility> //needed for pair
#include "solid.h"
#include <SOLID/SOLID.h>
#include "MT_Vector3.h"
#include "MT_Point3.h"
class SM_Object;
#include "SM_Object.h"
typedef enum
{
FH_RESPONSE,
SENSOR_RESPONSE, /* Touch Sensors */
CAMERA_RESPONSE, /* Visibility Culling */
OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
STATIC_RESPONSE, /* Static Geometry Response */
NUM_RESPONSE
};
class SM_Scene {
public:
SM_Scene() :
m_scene(DT_CreateScene()),
m_respTable(DT_CreateRespTable()),
m_secondaryRespTable(0),
m_forceField(0.0, 0.0, 0.0)
{}
SM_Scene();
~SM_Scene() {
DT_DeleteRespTable(m_respTable);
DT_DeleteScene(m_scene);
}
~SM_Scene();
DT_RespTableHandle getRespTableHandle() const {
return m_respTable;
}
@ -50,6 +82,9 @@ public:
m_forceField = forceField;
}
void addTouchCallback(int response_class, DT_ResponseCallback callback, void *user);
void addSensor(SM_Object& object);
void add(SM_Object& object);
void remove(SM_Object& object);
@ -61,9 +96,10 @@ public:
m_pairList.clear();
}
void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable) {
m_secondaryRespTable = secondaryRespTable;
}
void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable);
DT_RespTableHandle getSecondaryRespTable() { return m_secondaryRespTable; }
void requestCollisionCallback(SM_Object &object);
// Perform an integration step of duration 'timeStep'.
@ -96,7 +132,16 @@ private:
// Clear the user set velocities.
void clearObjectCombinedVelocities();
// This is the callback for handling collisions of dynamic objects
static
DT_Bool
boing(
void *client_data,
void *object1,
void *object2,
const DT_CollData *coll_data
);
/** internal type */
typedef std::vector<SM_Object *> T_ObjectList;
/** internal type */
@ -106,10 +151,19 @@ private:
DT_SceneHandle m_scene;
/** Following response table contains the callbacks for the dynmics */
DT_RespTableHandle m_respTable;
DT_ResponseClass m_ResponseClass[NUM_RESPONSE];
/**
* Following response table contains callbacks for the client (=
* game engine) */
DT_RespTableHandle m_secondaryRespTable; // Handle
DT_ResponseClass m_secondaryResponseClass[NUM_RESPONSE];
/**
* Following resposne table contains callbacks for fixing the simulation
* ie making sure colliding objects do not intersect.
*/
DT_RespTableHandle m_fixRespTable;
DT_ResponseClass m_fixResponseClass[NUM_RESPONSE];
/** The acceleration from the force field */
MT_Vector3 m_forceField;

Some files were not shown because too many files have changed in this diff Show More