Commit Graph

1049 Commits

Author SHA1 Message Date
Campbell Barton
a5f4d7cb53 BGE PyAPI epydoc errors fixed 2009-04-24 07:45:17 +00:00
Benoit Bolsee
0feaedfa9a BGE bug #17950: crash when GE softbody is parented to a rigid body/soft body/dynamic object. 2009-04-23 21:19:42 +00:00
Benoit Bolsee
67b3e1a07b BGE bug #17863: Shaky game camera. 2009-04-23 20:30:01 +00:00
Brecht Van Lommel
70f1b45430 Fix for part of bug #18496: issue with light state switching
when using Dome.
2009-04-23 13:30:34 +00:00
Dalai Felinto
073abf7047 BGE Dome update:
* Enviroment Map implemented (replacing truncated mode 2).
 - Now it's possible to pre-bake animated (or static) EnvMaps to use with Cube Map textures.

* Enabling 2DFilter in Dome mode
 - no GL_DEPTH_BUFFER supported though.

* Tweaking GameSettings menu (centralizing buttons)
2009-04-23 02:27:11 +00:00
Dalai Felinto
7ac233be8a BGE Rasterizer methods to handle Screen Space - (getScreenPosition, getScreenVect, getScreenRay)
getScreenPosition(obj):
 - Gets the position of an object projected on screen space.

getScreenVect(x, y):
 - Gets the vector from the camera position in the screen coordinate direction.

getScreenRay(x, y, dist, property):
 - Look towards a screen coordinate (x,y) and find first object hit within dist that matches prop.
- The ray is a call to KX_GameObject->rayCastTo from the KX_Camera object.

Patch [#18589] test files can be found there. Patch reviewed by Campbell
2009-04-23 00:49:38 +00:00
Campbell Barton
e8f5c75005 patch from Mitchell Stokes, comments only - KX_PYATTRIBUTE_TODO for missing attributes 2009-04-23 00:47:45 +00:00
Campbell Barton
6a270ecb94 BGE Python API
CListValue fixes
- Disable changing CValueLists that the BGE uses internally (scene.objects.append(1) would crash when drawing)
- val=clist+list would modify clist in place, now return a new value.
- clist.append([....]), was working like extend.
- clist.append(val) didnt work for most CValue types like KX_GameObjects.

Other changes
- "isValid" was always returning True.
- Set all errors for invalid proxy access to PyExc_SystemError (was using a mix of error types)
- Added PyObjectPlus::InvalidateProxy() to manually invalidate, though if python ever gains access again, it will make a new valid proxy. This is so removing an object from a scene can invalidate the object even if its stored elsewhere in a CValueList for eg.
2009-04-23 00:32:33 +00:00
Benoit Bolsee
90508ed125 BGE bug #17670: Python controlled mist doesnt work in textured mode. 2009-04-22 22:12:36 +00:00
Campbell Barton
fd108f1019 [#18586] [bug] Ray sensor doesn't return a hit object
Supporting len(GameOb) to see how many properties it has backfired since it can then evaluate as false.
2009-04-22 20:43:41 +00:00
Benoit Bolsee
48f483d14f BGE: some more cleanup, implement proper GetReplica/ProcessReplica workflow for touch/near/radar sensor. Remove duplicated code. 2009-04-22 18:20:41 +00:00
Benoit Bolsee
f6d27e73ee BGE: some more cleanup, remove useless ReplicaSetName(), move code to ProcessReplica. 2009-04-22 16:58:04 +00:00
Benoit Bolsee
076d1910f5 BGE: some more cleanup in GetReplica/ProcessReplica of deformers: make them consistent with the other classes. 2009-04-22 16:26:22 +00:00
Campbell Barton
5553d2c014 BGE C++ API
PyObjectPlus::ProcessReplica() is now called when any of its subclasses are replicated.

This is important because PyObjectPlus::ProcessReplica() NULL's the 'm_proxy' python pointer I added recently.
Without this a replicated subclass of PyObjectPlus could have an invalid pointer (crashing the BGE).

This change also means CValue::AddDataToReplica() can be moved into CValue::ProcessReplica() since ProcessReplica is always called.
2009-04-22 14:42:00 +00:00
Campbell Barton
a8592d09d0 BGE C++ API
Some functions used
	ProcessReplica(replica);
others
	replica->ProcessReplica()

Use the second method everywhere so the PyObjectPlus's ProcessReplica() can be called from its subclasses.

Note that PyObjectPlus's ProcessReplica isnt used yet.
2009-04-22 12:16:41 +00:00
Campbell Barton
785b784e09 BGE Python API
improved how attribute errors are set so each classes py_getattro function dosnt need to set an error if the attribute doesn't exist.
Now py_base_getattro sets an error on a NULL return value when no errors are set to avoid setting errors at multiple levels.
2009-04-22 09:47:57 +00:00
Nathan Letwory
88c58d6b2d BGE
* the ternary form refused to compile properly with msvc, rewrite a bit.
2009-04-22 06:30:32 +00:00
Campbell Barton
0145a93f24 Patch from Mitchell Stokes for KX_Light to use attrdef's
Added type access to the SCA_PropertyActuator, added missing function in library docs.
2009-04-21 23:15:18 +00:00
Benoit Bolsee
221f589f51 BGE bug #18521 fixed: Dupligroups + Bullet Softbodies are broken. 2009-04-21 21:33:03 +00:00
Daniel Genrich
aff2a11110 Fix for missing include using CMake 2009-04-21 13:34:33 +00:00
Benoit Bolsee
d11a5bbef2 BGE: Support mesh modifiers in the game engine.
Realtime modifiers applied on mesh objects will be supported in 
the game engine with the following limitations:

- Only real time modifiers are supported (basically all of them!)
- Virtual modifiers resulting from parenting are not supported: 
  armature, curve, lattice. You can still use these modifiers 
  (armature is really not recommended) but in non parent mode. 
  The BGE has it's own parenting capability for armature.
- Modifiers are computed on the host (using blender modifier
  stack).
- Modifiers are statically evaluated: any possible time dependency
  in the modifiers is not supported (don't know enough about
  modifiers to be more specific).
- Modifiers are reevaluated if the underlying mesh is deformed
  due to shape action or armature action. Beware that this is 
  very CPU intensive; modifiers should really be used for static
  objects only.
- Physics is still based on the original mesh: if you have a 
  mirror modifier, the physic shape will be limited to one half
  of the resulting object. Therefore, the modifiers should 
  preferably be used on graphic objects.
- Scripts have no access to the modified mesh. 
- Modifiers that are based on objects interaction (boolean,..)
  will not be dependent on the objects position in the GE.
  What you see in the 3D view is what you get in the GE regardless
  on the object position, velocity, etc.

Besides that, the feature is compatible with all the BGE features
that affect meshes: armature action, shape action, relace mesh, 
VideoTexture, add object, dupligroup.

Known problems:
- This feature is a bit hacky: the BGE uses the derived mesh draw 
  functions to display the object. This drawing method is a
  bit slow and is not 100% compatible with the BGE. There may
  be some problems in multi-texture mode: the multi-texture
  coordinates are not sent to the GPU. 
  Texface and GLSL on the other hand should be fully supported.
- Culling is still based on the extend of the original mesh. 
  If you have a modifer that extends the size of the mesh, 
  the object may disappear while still in the view frustrum.
- Derived mesh is not shared between replicas.
  The derived mesh is allocated and computed for each object
  with modifiers, regardless if they are static replicas.
- Display list are not created on objects with modifiers.
  
I should be able to fix the above problems before release.
However, the feature is already useful for game development.
Once you are ready to release the game, you can apply the modifiers
to get back display list support and mesh sharing capability.

MSVC, scons, Cmake, makefile updated.

Enjoy
/benoit
2009-04-21 11:01:09 +00:00
Campbell Barton
3e7cbd5388 Blender Python API
- Removed the gen_utils.c dependency from Mathutils (since gen_utils wont go into 2.5 but mathutils will), repalced with python functions.
- removed Blender.Mathutils.Point, since it was not documented, the C api never used it, none of our scripts used it (and I never saw a script that used it).
2009-04-21 09:44:29 +00:00
Benoit Bolsee
106b5a435c BGE: show profile in millisecond in addition to percentage. 2009-04-21 09:20:47 +00:00
Campbell Barton
720f7a8b69 use PyList_SET_ITEM instead of PyList_SetItem,
PyList_SetItem does error checking and decref's existing values, PyList_SET_ITEM is a macro for direct assignment, only for use on new lists.
2009-04-20 23:27:53 +00:00
Campbell Barton
217bbb7800 BGE Python API
Separate getting a normal attribute and getting __dict__, was having to do too a check for __dict__ on each class (multiple times per getattro call from python) when its not used that often.
2009-04-20 23:17:52 +00:00
Benoit Bolsee
2d0d06f642 BGE VideoTexture: fix bug with VideoTexture.materialID() since recent commit. 2009-04-20 21:20:33 +00:00
Campbell Barton
dee32d0b3f BGE Python API
- initialize pythons sys.argv in the blenderplayer
- ignore all arguments after a single " - " in the blenderplayer (like in blender), so args can be passed to the game.
- add a utility function PyOrientationTo() - to take a Py euler, quat or 3x3 matrix and convert into a C++ MT_Matrix3x3.
- add utility function ConvertPythonToMesh to get a RAS_MeshObject from a KX_MeshProxy or a name.
- Added error prefix arguments to ConvertPythonToGameObject, ConvertPythonToMesh and PyOrientationTo so the error messages can include what function they came from.
- deprecated brick.getOwner() for the "owner" attribute.
2009-04-20 09:13:59 +00:00
Campbell Barton
9078ce5da2 Scons epydos changed options
- no source code since this is only useful if the epydocs contain code, ours are only docstrings.
- set inheritance to included so you dont have to search up the classes to find available functions.
- SConstruct, isolate the exception for importing epydoc.
- Added a print to the SConscript files otherwise it looks like nothings happening.
2009-04-19 22:02:48 +00:00
Nathan Letwory
fcdbbee208 SCons / epydoc support
* properly detect if epydoc is installed.
  patch by Brandano
2009-04-19 21:26:29 +00:00
Campbell Barton
f5fc4ebdd8 BGE Python API
- More verbose error messages.
- BL_Shader wasnt setting error messages on some errors
- FilterNormal depth attribute was checking for float which is bad because scripts often expect ints assigned to float attributes.
- Added a check to PyVecTo for a tuple rather then always using a generic python sequence. On my system this is over 2x faster with an optmized build.
2009-04-19 21:01:12 +00:00
Daniel Genrich
7144838606 Compile fixed for Win64.
Please check if that also compiles on win32.
2009-04-19 19:31:32 +00:00
Campbell Barton
6bc162e679 BGE Python API
removed redundant (PyObject *self) argument from python functions that are not exposed to python directly.
2009-04-19 17:29:07 +00:00
Benoit Bolsee
fe08da3b4c BGE: fix Pyfrom_id to work on w64. 2009-04-19 17:26:03 +00:00
Campbell Barton
7dbc9dc719 BGE Python API cleanup - no functionality changes
- comments to PyObjectPlus.h
- remove unused/commented junk.
- renamed PyDestructor to py_base_dealloc for consistency
- all the PyTypeObject's were still using the sizeof() their class, can use sizeof(PyObjectPlus_Proxy) now which is smaller too.
2009-04-19 14:57:52 +00:00
Campbell Barton
8d2cb5bea4 BGE Python API
This changes how the BGE classes and Python work together, which hasnt changed since blender went opensource.
The main difference is PyObjectPlus - the base class for most game engine classes, no longer inherit from PyObject, and cannot be cast to a PyObject.

This has the advantage that the BGE does not have to keep 2 reference counts valid for C++ and Python.

Previously C++ classes would never be freed while python held a reference, however this reference could be problematic eg: a GameObject that isnt in a scene anymore should not be used by python, doing so could even crash blender in some cases.

Instead PyObjectPlus has a member "PyObject *m_proxy" which is lazily initialized when python needs it. m_proxy reference counts are managed by python, though it should never be freed while the C++ class exists since it holds a reference to avoid making and freeing it all the time.
When the C++ class is free'd it sets the m_proxy reference to NULL, If python accesses this variable it will raise a RuntimeError, (check the isValid attribute to see if its valid without raising an error).
- This replaces the m_zombie bool and IsZombie() tests added recently.

In python return values that used to be..
 return value->AddRef();
Are now
 return value->GetProxy();
or...
 return value->NewProxy(true); // true means python owns this C++ value which will be deleted when the PyObject is freed
2009-04-19 12:46:39 +00:00
Campbell Barton
92cea7c1b1 KX_MeshProxy "numPolygons" and "numMaterials" attributes were using the "materials" attribute function, error made recently when converting attributes. 2009-04-19 06:48:27 +00:00
Campbell Barton
d2ec468cd3 Hidden faces were not rendering displayed in the game engine, only the invisible face flag should be used for this.
Hiding faces is a editing option like selection and should not change rendering, it wasn't even working right because meshes without UVs ignored it.
I thought this was needed for compatibility with old files but just noticed this messes up 2 of the files in demos-2.42.zip
2009-04-19 06:29:15 +00:00
Benoit Bolsee
53fd3847bc BGE: restore a feature that was lost in 2.48: sharing of display lists between duplicated objects. 2009-04-18 09:14:51 +00:00
Campbell Barton
df8cf26404 Added m_zombie to the base python class (PyObjectPlus), when this is set all the subclasses will raise an error on access to their members.
Other small changes...
- KX_Camera and KX_Light didnt have get/setitem access in their PyType definition.
- CList.from_id() error checking for a long was checking for -1 against an unsigned value (own fault)
- CValue::SpecialRelease was incrementing an int for no reason.
- renamed m_attrlist to m_attr_dict since its a PyDict type.
- removed custom getattro/setattro functions for KX_Scene and KX_GameObject, use py_base_getattro, py_base_setattro for all subclasses of PyObjectPlus.
- lowercase windows.h in VideoBase.cpp for cross compiling.
2009-04-17 20:06:06 +00:00
Daniel Genrich
90c6cf77f1 Fixing SND_Scene.h missing include problems with cmake + bullet 2009-04-17 13:42:40 +00:00
Ton Roosendaal
1dd980768d Missing <stdlib.h> for abs() made this file not compile for me. 2009-04-17 10:24:44 +00:00
Benoit Bolsee
2c491b5d2e BGE: slow parent was causing scaling distortion, now use correct quaternion interpolation. 2009-04-16 20:13:13 +00:00
Campbell Barton
32253dfaaf bpy_internal_import.c should build with py2.3 now, also gave bpy_internal_import functions better names. 2009-04-16 06:24:47 +00:00
Benoit Bolsee
bbdaa03d65 BGE bug #18168: Get local orientation of object using game engine python script system. Added localOrientation and worldOrientation. orientation attribute deprecated. Same for position and scaling. World attributes are read-only except for worldPosition. Add systematic check on NULL SGNode in all python functions. This is necessary to handle zombie objects (deleted by the game but kept alive by a reference in a list). 2009-04-15 21:17:08 +00:00
Campbell Barton
52a3d5c518 BGE Python API
Free python modules defined within the blendfile between loading scenes since they would end up accessing old GameLogic, Rasterizer modules as well as old game engine data in the module namespace which can cause problems.
2009-04-15 19:20:12 +00:00
Kent Mein
f46f93ea13 This is patch [#18408] Build issues with make on Cygwin hosted MinGW (2.48.1)
submitted by Wayne Dennis

adds an include, changes pythonlib and does a little cleaning of dlltool stuff.

Kent
2009-04-15 16:23:13 +00:00
Campbell Barton
514c78ba39 BGE MouseFocusSensor
- fix for multiple viewpors broke single viewport (both work now)
- python could get uninitialized values from m_prevTargetPoint and m_prevSourcePoint
- getting the RayDirection for python could crash blender trying to normalize a zero length vector.
- added python attributes
- removed unused canvas from the MouseFocusSensor class
2009-04-15 13:50:56 +00:00
Campbell Barton
e8f4d93221 Disable using KX_GameObjects in python that have been removed from the scene (zombie objects) by raising a RuntimeError when accessing methods, attributes or passing to a function.
Common cases of this are when python references an object from the AddObject actuator that has ended, or a scene has been loaded and the old objects freed.

This means some scripts will raise errors now in certain cases but better give the error early rather then failing silently with strange hard to track down behavior & crashes.

Added "isValid" attribute for checking objects are in a scene.

At the moment it uses the SceneGraph Node to check of the objects valid but it might be better to do this in a more generic way so scenes, meshes etc also have this check.
2009-04-15 10:57:28 +00:00
Campbell Barton
19c869ab64 BGE Py Api
importing modules wasnt returning the error from the blender text if it failed.
2009-04-15 08:08:42 +00:00
Campbell Barton
34a617e308 [#7789] 3DS Import , Mesh not correct since Blender 2.44
There is a problem importing 3ds files where I cant find a way to check if the transforms are applied to the vertex locations or not.
Since 2.44 I made the importer assume they were not since you can manually remove transformations, but not reverse.

Nevertheless most 3ds files have the matrix applied, better not give a bad import by default.
Did some research and other 3ds importers (lib3ds for eg), have the same problem and just assume the transformations applied.

3dsMax imports both correctly so there must be a way to tell but I could not link it to the 3ds version or other mesh options.
Added an option to workaround this problem in rare cases where its needed.

- KX_GameObject.cpp & KX_Scene.cpp, clear the dict before removing the reference in case there is a circular reference.
2009-04-15 07:00:11 +00:00