Commit Graph

1290 Commits

Author SHA1 Message Date
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
7271f86be5 removed un-needed hack, something weired was going on when debugging that made the pointers to these functions change after initialization. 2009-06-28 02:47:49 +00:00
Campbell Barton
388e59a768 BGE Fix for no redrawing.
Was caused by un-initialized engine ticrate, do_versions was working on 2.4x but isnt in 2.5 so just add a zero check when getting from the world.
2009-06-28 02:37:07 +00:00
Campbell Barton
aa933d2c9f BGE Redraw problem:
at the moment only files from blender 2.4x will display in 2.5x, compared area and window structs in both cases and dont see any differences.

This doesnt fix the problem but corrects a few things related to window drawing with the BGE,
also adds a hack because I noticed the window and area pointers in the KX_BlenderCanvas were offset after initialized, maybe need to use <static cast> ?
2009-06-27 23:54:20 +00:00
Campbell Barton
4b914c7f75 Made Mathutils use radians rather then degrees. defining USE_MATHUTILS_DEG for testing existing scripts.
Added conversion for BGE Quaternion WXYZ (Blender/C) -> XYZW (Moto C++).
BGE Python API now uses WXYZ following mathutils (break script warning).
2009-06-25 20:47:41 +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
Ton Roosendaal
af3f862480 2.5
Removing editors/include export from Make, it's not needed luckily :)
2009-06-23 17:06:46 +00:00
Ton Roosendaal
61e7734aaf 2.5
Game engine Makefile update.

Note to coders: including BLO_ for only intptr typedef is ehh... not
so nice. But it should not have been added there in first place.
(BLO_ = .blend file read/write). Nice for a future cleanup. :)

Also goes for ED_ includes btw, = bad level call for GE! If you need
it to get things work now, fine, but it will make player impossible.
2009-06-23 16:57:46 +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
6a35c7fc98 more corrections from cleanup :/ 2009-06-21 17:03:17 +00:00
Campbell Barton
8ead648fd1 Spring Cleaning
* removed radiosity render code, DNA and RNA (left in radio render pass options), we'll get GI to replace this probably, better allow baking to vertex colors for people who used this.
* removed deprecated solid physics library, sumo integrations and qhull, a dependency
* removed ODE, was no longer being build or supported
* remove BEOS and AMIGA defines and references in Makefiles.
2009-06-21 16:18:38 +00:00
Brecht Van Lommel
aa0aac706e 2.5
* Optimized RNA property lookups and path resolving, still can be
  much better, but now the 1000 IPO example on bf-taskforce25
  runs at reasonable speed.
* Also an optimization in the depsgraph when dealing with many
  objects, this was actually also a bottleneck here.
2009-06-19 23:05:21 +00:00
Campbell Barton
c3b8db4833 BGE: allow action blending by bringing back blend_poses() as game_blend_poses, the new animation system doesnt use it but doesnt have a replacement function so it can be kept for the BGE only. 2009-06-19 16:27:01 +00:00
Daniel Genrich
b6182781b0 Fix for compiler error since BLO_sys_types.h was not in the path 2009-06-18 21:25:21 +00:00
Martin Poirier
2269280910 don't include stdint.h directly, it's broken on non C99 compliant compilers (you know which one I'm talking about). 2009-06-18 20:23:46 +00:00
Brecht Van Lommel
89d2559e6d 2.5
* Update cmake and makefiles to link python generic.
* Fix game engine building for cmake and makefiles.
* Fix compile error with py 3.x, due to 2.x compat fix.
2009-06-18 19:25:58 +00:00
Campbell Barton
025b6dcbc3 fix for building with py2.3 2009-06-18 17:34:39 +00:00
Campbell Barton
7e57823c47 build generic modules in their own lib, compiling without the game engine would fail because bpy_internal_import.c wasnt being included.
(scons only)
2009-06-18 04:36:45 +00:00
Campbell Barton
489db9994d Some generic modules from blender 2.4x building with py3k and mostly working.
* Mathutils, Geometry, BGL, Mostly working, some //XXX comments for things to fix with py3

python import override (bpy_internal_import.c) so you can import python internal scripts from the BGE and running blender normally.
2009-06-17 20:33:34 +00:00
Campbell Barton
54ed699743 ActionActuator in the game engine working again to display deformed meshes with the new animation system.
Note that the animation conversion from existing 2.4x blend files doesnt yet set the Action pointer in the actuator so the only way to test is to use the python api to set the new converted action active on the actuator because there is no user interface.
2009-06-16 20:38:18 +00:00
Campbell Barton
ecb39291e9 small merge needed for testing new animsys in 2.5 BGE, mixing own changes with merge can be a hassle.
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20928:20937
2009-06-16 19:51:58 +00:00
Campbell Barton
2faf20c4b3 BGE Action Actuator setChannel() function was broken in a number of ways.
* extract_pose_from_pose only checked one of the list items for NULL when looping over them yet its possible they are different sizes.
* game_free_pose needed to be used rather then MEM_freeN, channels would never be freed leaking memory.
* setChannel() would make a new pose that wasnt aligned with the existing pose, the lists are assumed aligned so when extracting the channels its unlikely this was ever useful.
* Added getChannel() - returns pose loc/size/quat
* Added option args for setChannel(channel, matrix) or setChannel(channel, loc, size, quat)
2009-06-16 18:25:48 +00:00
Campbell Barton
a1cf7988c1 svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20855:20928
Sequencer changes from source/blender/src coming next
2009-06-16 14:21:58 +00:00
Campbell Barton
0a66e24bd7 KX_PythonSeq (used for a number of BGE sequence types)
* cont.actuators.get("key", default) # dict like get function
* if "key" in cont.sensors: ...

Updated docs
Added missing include to Particle.c
2009-06-16 08:52:04 +00:00
Campbell Barton
2ecbe1c81c BGE Py API
* Removed modules Expression and CValue, neither were ever available.
* Added GameLogic.EvalExpression(exp) from the Expression module, evaluates an expression like the expression controller (not sure if this is really that useful since python is far more advanced).
* resetting the original blend file path didint work (own fault == -> =)
* Py3.x PyModule_Create didnt allow importing since it didn't add to sys.modules,
  Looks like they want us to use init-tab array, but this doesn't suit us since
  it needs to be setup before python is initialized.
* Documented GameLogic.globalDict
2009-06-16 07:16:51 +00:00
Brecht Van Lommel
401b58cb45 2.5: Image Editor
* Started porting over to python, menus nearly done, header WIP.
* Game Properties panel is in python too
* Deprecated "Tiles" as a per face flag here, now it's always on
  the image, used to be both, working in a very confusing way.
  Unlikely someone actually had a purpose for this being per face.
* Remove GPC_PolygonMaterial.cpp/h, it's not actually used anymore,
  so I don't want to bother updating it.
* Fix crash in image painting (own mistake in porting over bugfix
  from 2.4x).
2009-06-16 01:22:56 +00:00
Campbell Barton
6efd2e6439 saving globalDict didnt work with python3.x 2009-06-15 20:22:50 +00:00
Campbell Barton
7453f4388e missing var in last commit 2009-06-15 11:47:16 +00:00
Campbell Barton
2773464561 Game Engine working with the new animation system for Ipos (IpoActuator)
FCurves are used for animation evaluation so FCurve modifiers work :).

Tested with object location and object color animation.
Armature and Shape Keys next.
2009-06-15 10:11:08 +00:00
Campbell Barton
e3fda550ba changing the scale of a sleeping object wasnt working with bullet.
Example is a cube that lands on a plane, sleeps after some time, a script changes the scale.
It would still use the scale when the object first went to sleep.

reported on blenderartist.
http://blenderartists.org/forum/showthread.php?t=158617
2009-06-14 06:03:12 +00:00
Campbell Barton
646d4041e2 BGE events, not sure every event works as it should but keyboard looking and mouse focus seems to work ok.
Tested some basic logic brick blend files that use key input which run properly.
2009-06-13 20:58:43 +00:00
Campbell Barton
611e2f484c GameEngine WIP,
* pressing P starts the BGE in the 3D view
* redraw window clipping isnt right
* BGE python api works in py3k (without __import__ override or Mathutils, BGL, Geometry)
* no events yet (so there is no way to exit)
2009-06-13 17:25:54 +00:00
Campbell Barton
fa01eef27e svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20849:20855
to get the BGE building with py3k and no sdl
2009-06-13 14:07:38 +00:00
Campbell Barton
b40eb540d3 G.sipo was being passed in the BGE when it wasnt needed, just access G.sipo directly.
KX_PythonSeq.cpp - disable the cmpfunc with py3, need to have richcmp.
2009-06-13 13:02:01 +00:00
Campbell Barton
c7debe1455 allow building without SDL 2009-06-13 11:28:29 +00:00
Campbell Barton
eed13b43b1 merged from trunk 20741:20848
* Missing changes to release/windows/installer
* Sequencer fixes in source/blender/src/seqaudio.c dont apply to 2.5
* brechts fix for #18855 r20763 wasnt merged, does this apply to 2.5?
2009-06-13 11:09:13 +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
Erwin Coumans
db8b4cee56 Bugfix for [#18911] Applied torque breaks rigid bodies in game engine 2009-06-11 13:42:41 +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
5a8b389ebe was printing all warnings twice 2009-06-10 19:33:59 +00:00
Dalai Felinto
323863015d fix for bug #18898: GE perspective 3D View not working properly (missing LENS)
note: I'm not changing GamePlayer files. There is no such a thing as 3D view camera in gameplayer (override_camera).
2009-06-09 22:56:43 +00:00
Brecht Van Lommel
e29c9bc4da Fix for bug #18900: game engine lights in non-glsl mode did move
anymore, missing matrix update. Also move some code to KX_LightObject
to avoid duplication with player.
2009-06-09 13:51:32 +00:00
Brecht Van Lommel
c8b4cf9206 2.50:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19820:HEAD

Notes:
* Game and sequencer RNA, and sequencer header are now out of date
  a bit after changes in trunk.
* I didn't know how to port these bugfixes, most likely they are
  not needed anymore.
  * Fix "duplicate strip" always increase the user count for ipo.
  * IPO pinning on sequencer strips was lost during Undo.
2009-06-08 20:08:19 +00:00
Erwin Coumans
a03c30ea77 Bugfix to avoid crashing BGE on Mobile Intel GMA 950/945 Express GPU (2009 latest driver 6.14.10.4926 Windows XP)
Command-line option to disable vertexarrays in BGE:
-g novertexarrays
2009-06-07 06:04:44 +00:00
Benoit Bolsee
80571c0408 BGE VideoTexture: fix VideoFFmpeg range attribute + error message. 2009-06-06 21:54:12 +00:00
Erwin Coumans
884a6a6573 #18872 bugfix for torque on dynamic objects
#18893, fix to getParam for generic 6dof constraints
2009-06-06 00:12:49 +00:00
Campbell Barton
04ccb0caf8 bpy.config.sequenceMemCacheLimit is the only way to set the memcache in background mode and it didnt work.
removed some unused vars from KX_Scene
2009-06-05 19:22:23 +00:00
Dalai Felinto
52b7c157a0 getScreenPosition, Ray and Vect fixes:
- fix for [#18867] getScreenRay error
 ... the Vector wasn't been added to KX_Camera origin. Therefore the Ray was always casted to the wrong coordinate when camera wasn't in [0,0,0] (where is obviously was in my tests :)

- making the input parameter compatible with Blender/BGE window coordinate system (Top-Bottom).
 ... that will break scripts done in 2.49. Since this feature was added only in 2.49 that fix is OK. (and the fix is ridiculous.

Note:
the input parameter is normalized. That means it runs from 0.0 to 1.0. Some users found it confusing, but it allows to make a game compatible with multiple desktop resolutions.a
2009-06-05 00:51:36 +00:00
Benoit Bolsee
8154de7045 BGE [#18884] light in skinned object only work properly after running the action once. 2009-06-04 21:24:41 +00:00