Commit Graph

209 Commits

Author SHA1 Message Date
Campbell Barton
0876fce009 rename and negate DISABLE_PYTHON --> WITH_PYTHON 2010-10-31 04:11:39 +00:00
Dalai Felinto
4814ffa07b BGE object.life - gives you the life countdown for temporary objects.
Whenever using AddObject actuator, this feature gives you control over morbid events (a.k.a. trigger events before the object ends).

Demo file here:  
http://blenderecia.orgfree.com/blender/tmp/cube_life.blend

Feature implemented as part of the BGE development workshop in BlenderPRO 2010 - Fortaleza, Brazil
2010-10-11 10:47:20 +00:00
Campbell Barton
f49fc58df6 enable building the game engine without bullet for scons & cmake 2010-10-10 07:01:56 +00:00
Campbell Barton
9b518710c6 update for MingW/CMake
- ignore MSVC warnings when FREE_WINDOWS is defined to quiet warnings.
- the CMake flags were not being set correctly making blender have weirdo colors (no -funsigned-char).
2010-09-15 16:13:32 +00:00
Campbell Barton
75410037fd - correct some spelling errors.
- remove FreeCamera struct (wasnt used)
- remove world color alpha values (not used anywhre).
2010-07-20 10:41:08 +00:00
Campbell Barton
374d3a6685 bugfix [#21748] KX_Object scaling property not "writing" vector access .:. e.g. obj.scaling[2] = 2.0
- made worldspace readonly
- mathutils 'set' callbacks can now set their own error
2010-06-14 01:41:43 +00:00
Campbell Barton
c2ffcb8497 no functional changes
- add PySequenceMethods members (all NULL)
- spaces -> tabs
- cmake syntax warning from recent ghost commit
2010-05-16 10:09:07 +00:00
Campbell Barton
b28c6d3c14 bugfix for own error [#22269] object vector operations (position) not working properly after rev. 28471
double checked other get_index callbacks for the same error.
2010-05-06 22:07:03 +00:00
Campbell Barton
124c55fcc3 remove redundant argument from mathutils callbacks 2010-04-27 19:21:36 +00:00
Campbell Barton
6bb55fd93e py/rna, euler objects order is now wrapped correctly...
eg:
 eul = bpy.context.object.rotation_euler
 eul.order = 'XZY' # will update the objects setting.
2010-04-26 21:04:42 +00:00
Campbell Barton
8f1500da00 remove config.h references, was added for automake build system rev around 124-126 but isnt used by any build systems now. 2010-04-18 10:28:37 +00:00
Dalai Felinto
ea0e0b3f15 BGE fix: Parenting the object to itself crashes BGE + stubs update
it may happen if you start doing exec, setParent, ... in Python
not a big deal, but to crash Blender is always bad
2010-03-31 22:49:59 +00:00
Benoit Bolsee
3ed81eeccf BGE: [#19836] Recursive Parenting in game crashes Blender. Added parenting loop detection. 2010-03-25 21:43:36 +00:00
Campbell Barton
081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Dalai Felinto
2541429ded BGE: linear velocity and angular velocity are attributes now
... what lead me to wonder if we should remove obj.setAngularVelocity, obj.setLinearVelocity, obj.getLinearVelocity and obj.getAngularVelocity.

* this was so Copy and Paste ... anyways tests are welcome (I never used those methods in python myself).
2010-02-12 03:40:28 +00:00
Campbell Barton
1943a73439 rename game object obcolor to color 2010-01-30 21:59:20 +00:00
Campbell Barton
68c8054191 patch [#20560] [patch] KX_GameObject.obcolor
by Mitchell Stokes (moguri)
* renamed attribute obcolor to color
2010-01-16 23:53:51 +00:00
Benoit Bolsee
042c2b2aa5 BGE: KX_GameObject.rayCast() to return 5-tuple in case of no hit when poly=2 option is used. 2010-01-06 08:44:10 +00:00
Benoit Bolsee
0b6873a776 BGE: Add option to return UV coordinates aofthe hit point to KX_GameObject::rayCast(). Details in PyDoc. 2009-12-04 11:27:40 +00:00
Brecht Van Lommel
37e4a311b0 Math Lib
* Convert all code to use new functions.
* Branch maintainers may want to skip this commit, and run this
  conversion script instead, if they use a lot of math functions
  in new code:
  http://www.pasteall.org/9052/python
2009-11-10 20:43:45 +00:00
Ton Roosendaal
0e5a6a21e8 Fixes to get Blender compile and run on PowerPC OSX 10.3, gcc 3.3
(yes antique, but having 5 year old OS's work is very cool)

In short:
- include <cmath> after <math.h> fails
- STL template issues (recursion, syntax)
2009-10-20 15:51:18 +00:00
Campbell Barton
98ee2a781d option to build the BGE without python, uses existing python check (cmake and scons)
when python is disabled videotextures are not built.
2009-09-29 21:42:40 +00:00
Campbell Barton
c8b7384c4b remove ray sensors own logic manager (now stored in parent class) + other minor changes. 2009-09-29 07:51:54 +00:00
Benoit Bolsee
1483fafd13 Merge of itasc branch. Project files, scons and cmake should be working. Makefile updated but not tested. Comes with Eigen2 2.0.6 C++ matrix library. 2009-09-24 21:22:24 +00:00
Campbell Barton
f12f238062 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22875:22935
Note, missing r22897, schlaile
source/blender/src/hddaudio.c
2009-09-01 18:49:33 +00:00
Benoit Bolsee
0795d8237d BGE bug #18963: obj.sendMessage() with 4 arguments crashes Blender. 2009-08-31 15:28:43 +00:00
Campbell Barton
75697c40a0 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22717:22875 2009-08-29 23:41:09 +00:00
Campbell Barton
28392eedbe was casting the PyObjectPlus type to a PyObject for new BGE vector and matrix types, need to get its proxy instead. 2009-08-27 16:34:13 +00:00
Campbell Barton
324b3fbe74 - BGE crash fix when casting a ray to the same location as the object from python.
- Incorrect Mathutils vector docstrings.
- last rayshade commit had an incomplete comment.
2009-08-27 06:55:54 +00:00
Campbell Barton
0a23895f95 remove all python api functions deprecated in 2.49 2009-08-25 22:51:18 +00:00
Campbell Barton
9521fa9456 remove gameOb.has_key(key) method from KX_GameObject and ListValue since python 3.x removes has_key from dictionaries.
Instead use __contains__, eg.
 if key in gameOb: ...
 
Mathutils returns from PyMath.cpp were incorrectly using wrapped Mathutils types. Wrapped types should only be used with a callback now.
2009-08-25 13:54:56 +00:00
Campbell Barton
c3041ae7cd - fix for BGE warnings
- when C++ uses guardedalloc SYS_DeleteSystem was called after MEM_printmemlist(), making it look like there was a leak.
2009-08-19 10:26:43 +00:00
Campbell Barton
7440fee85c remove python2.x support 2009-08-10 00:07:34 +00:00
Campbell Barton
9bb8540ba9 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22130:22205 2009-08-04 05:34:21 +00:00
Campbell Barton
856dba000b no need to store the physics env in each KX_GameObject 2009-08-04 05:14:10 +00:00
Campbell Barton
c371f49d9a svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r21908:22075 2009-07-31 00:42:10 +00:00
Campbell Barton
dd918da8de ReplaceMesh Actuator option to replace the physics mesh and display mesh + python api options.
When the mesh field is left blank and Physics option is enabled, it reinstances the physics mesh from the existing mesh.
like calling gameOb.reinstancePhysicsMesh() from python.
2009-07-26 01:32:37 +00:00
Campbell Barton
777a0d78e7 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r21899:21908 2009-07-25 23:16:45 +00:00
Campbell Barton
e9ca43521f BGE Physics
Add support back for reinstancePhysics mesh, a frequently requested feature in the BGE forums.
from what I can tell Sumo supported this but bullet never did.
Currently only accessible via python at the moment.

- rigid body, dynamic, static types work.
- instanced physics meshes are modified too.
- compound shapes are not supported.

Physics mesh can be re-instanced from...
* shape keys & armature deformations
* subsurf (any other modifiers too)
* RAS_TexVert's (can be modified from python)

Moved the reinstancePhysicsMesh functions from RAS_MeshObject into KX_GameObject since the physics data is stored here.

video and blend file demo.
http://www.graphicall.org/ftp/ideasman42/reinstance.ogv
http://www.graphicall.org/ftp/ideasman42/reinstance_demo.blend
2009-07-25 22:57:29 +00:00
Campbell Barton
9a7ea9664e BGE PyAPI support for subclassing any BGE game type from python, scripters define extra functions on gameObjects.
Adding a UI to set the type on startup can be added easily.

# ----
class myPlayer(GameTypes.KX_GameObject):
  def die(self):
    # ... do stuff ...
    self.endObject()

# make an instance
player = myPlayer(gameOb) # gameOb is made invalid now.
player.die()

# ----

One limitation (which could also be an advantage), is making the subclass instance will return that subclass everywhere, you cant have 2 different subclasses of the same BGE data at once.
2009-06-29 12:06:46 +00:00
Campbell Barton
c50bbe5ae7 BGE Py API using python3 c/api calls. include bpy_compat.h to support py2.x 2009-06-29 02:25:54 +00:00
Campbell Barton
6b9f3b5f5c BGE Python API
Remove the last of the odd C++/python wrapper code from http://www.python.org/doc/PyCPP.html (~1998)

* Use python subclasses rather then having fake subclassing through get/set attributes calling parent types.
* PyObject getset arrays are created while initializing the types, converted from our own attribute arrays. This way python deals with subclasses and we dont have to define getattro or setattro functions for each type.
* GameObjects and Scenes no longer have attribute access to properties. only dictionary style access - ob['prop']
* remove each class's get/set/dir functions.
* remove isA() methods, can use PyObject_TypeCheck() in C and issubclass() in python.
* remove Parents[] array for each C++ class, was only used for isA() and wasnt correct in quite a few cases.
* remove PyTypeObject that was being passed as the last argument to each class (the parent classes too).

TODO -
* Light and VertexProxy need to be converted to using attributes.
* memory for getset arrays is never freed, not that bad since its will only allocates once.
2009-06-28 11:22:26 +00:00
Campbell Barton
d428ba1de8 PyAPI RNA/BGE
* all mathutils types now have optional callbacks
* PyRNA returns mathutils quat and euler types automatically when they have the rotation subtype.
* PyRNA, reuse the BPy_StructRNA PyObject rather name making a new one for each function returned.
* use more arithb.c functions for Mathutils quaternion type (less inline cruft).
* BGE Mathutils integration mostly finished- KX_PyMath now converts to Mathutils types rather then lists.
* make all mathutils types share the same header so they can share a number of functions - dealloc, getWrapped, getOwner.
2009-06-25 10:11:37 +00:00
Campbell Barton
eb22a7b210 PyRNA API support for matrix types as Mathutils matrix (with callbacks) rather then a generic rna sequence of floats.
Any 3x3 or 4x4 rna matrix will automatically be returned as a Mathutils matrix.
This makes useful stuff like multiplying a vector location by an object matrix possible.
 ob = bpy.data.scenes[0].objects[0]
 print (ob.data.verts[0].co * ob.matrix)

Also added mathutils matrix types to the BGE GameObject.localOrientation, worldOrientation

* MT_Matrix3x3 added getValue3x3 and setValue3x3, assumed a 4x3 float array.
* KX_GameObject.cpp convenience functions NodeSetGlobalOrientation, NodeGetLocalOrientation, NodeGetLocalScaling, NodeGetLocalPosition.
* 2.5 python api now initializes modules BGL, Mathutils and Geometry
* modules py3 PyModuleDef's use PyModuleDef_HEAD_INIT, rather then {}, was making msvc fail to build.
* added macros for Vector_ReadCallback, Vector_WriteCallback etc. to check if the callback pointer is set before calling the function.
2009-06-23 13:34:45 +00:00
Campbell Barton
bce3f7e019 PyAPI Mathutils Vector callbacks, referencing other PyObjects rather then thin wrapping vectors which is crash prone.
in short, vectors can work as if they are thin wrapped but not crash blender if the original data is removed.

* RNA vector's return Mathutils vector types.
* BGE vectors for GameObject's localPosition, worldPosition, localPosition, localScale, worldScale, localInertia.
* Comment USE_MATHUTILS define to disable returning vectors.

Example...

* 2.49... *
 loc = gameOb.worldPosition
 loc[1] = 0
 gameOb.worldPosition = loc

* With vectors... *
 gameOb.worldPosition[1] = 0


* But this wont crash... *
 loc = gameOb.worldPosition
 gameOb.endObject()
 loc[1] = 0 # will raise an error that the objects removed.

This breaks games which assume return values are lists.

Will add this to eulers, matrix and quaternion types later.
2009-06-22 04:26:48 +00:00
Campbell Barton
1c2ce9535c use contains for ListValue and KX_GameObject types (has_key is deprecated by python)
eg.
 if 'prop' in gameOb: ...
 if 'GameOb' in sce.objects: ...
2009-06-12 12:56:12 +00:00
Campbell Barton
a543a1549e Sound actuator bug reported by zapman on blenderartist.
Negative events would play on an actuator if it hadn't played a sound yet.
2009-06-11 10:26:53 +00:00
Campbell Barton
8e882d0d61 Bug in KX_GameObject.get() and ListValue.get(), wasn't checking if the CValue derived objects could be converted to a PyObject.
so where foo is an int prop,
 gameOb.get("foo") == 0, would end up returning a CValue int proxy.

This is more a problem for KX_GameObject since ListValues with python access mostly don't contain ints, strings, floats.
This also wont break games from 2.48 since the .get() function wasn't available.
2009-05-31 17:44:38 +00:00
Benoit Bolsee
dd9c9efde7 BGE modifier: last minute commit to fix a nasty bug with modifers messing the alpha blend mode of the GE. Note the alpha sorting on modified mesh is not implemented so derived mesh should not have alpha faces (clip will work though). Incidently fixed a performance problem in GLSL where the derived mesh was possibly rendered multiple times. Modifier support is still a bit experimental and should not be used in production game. 2009-05-29 13:37:51 +00:00
Campbell Barton
33b974ee43 BGE Py API
- Deprecation warnings for using attribute access

- Added dictionary functions to KX_GameObject and ListValue
    ob.get(key, default=None)
    ob.has_key(key)
 ob.has_key is important since there was no way to do something like hasattr(ob, "attr") which can be replaced by ob.has_key("attr") - (both still work of course).
 ob.get is just useful in many cases where you want a property if it exists but can fallback to a default.

- CListValue::FindValue was adding a reference but the ~3 places it was used were releasing the reference. added a FindValue that accepts a const char* type to avoid converting python strings to STR_String.
2009-05-26 16:15:40 +00:00