All of the initXPythonBinding functions are changed to always creating the module instead of importing if previously existing.
I can instead only remove the module return when the import is ok, so that it always inits. But then, I don't see the point in importing.
I make sure that these functions are called only once per run, inside initBGE.
This was not the case with GameTypes. I moved initPyTypes inside of initGameTypesPythonBinding due to that.
I reorganized initGamePlayerPythonScripting and initGamePythonScripting so that they run things in the same order.
initGamePlayerPythonScripting imports mathutils and aud, the other only aud. Shouldn't it be the same for both?
Reviewers: campbellbarton
Subscribers: sybren
Projects: #game_engine, #game_python
Differential Revision: https://developer.blender.org/D1070
This patch adds two parameters to the functions in the
collisionCallbacks list. The callback function should thus be like
this:
```
def on_colliding(other, point, normal):
print("Colliding with %s at %s with normal %s" % (other, point, normal))
game_ob.collisionCallbacks.append(on_colliding)
```
The `point` parameter will contain the collision point in world
coordinates on the current object, and the `normal` contains the
surface normal at the collision point.
The callback functions are checked for the number of arguments
`co_argcount`. The new `point` and `normal` arguments are only passed
when `co_argcount > 1` or when `co_argcount` cannot be determined.
Reviewers: brita_, campbellbarton
Subscribers: sergey, sybren, agoose77
Projects: #game_physics
Differential Revision: https://developer.blender.org/D926
The goal of these changes is to Close T40132 and to get rid of the 'PyRun_SimpleString'
Hilighted changes are:
- consistent naming and initialization of BGE submodules
- initialization of the 'bge' module as a proper module
- using PyDoc_STRVAR instead of static char*
- generic cleanup (unused arguments, logica ordering, naming and whitespace)
Reviewers: campbellbarton
Maniphest Tasks: T40132
Differential Revision: https://developer.blender.org/D983
-Removing unused parameters
-Updating some parts to match bpy_interface.c initialization
Cherry-picking 14fceb6 onto 117edbb
Conflicts:
source/gameengine/Ketsji/KX_PythonInit.cpp
Red was used with different semantics in the physics visualisation,
switching to yellow to prevent confusion.
A screenshot can be found at http://www.pasteall.org/pic/80766 -- it's
the yellow balls + lines.
Reviewers: brita_, lordloki, campbellbarton
Reviewed By: lordloki, campbellbarton
Subscribers: lordloki
Projects: #game_physics
Differential Revision: https://developer.blender.org/D925
A screenshot can be found at http://www.pasteall.org/pic/80766 -- it's the yellow balls + lines.
Reviewers: brita_, lordloki, campbellbarton
Reviewed By: lordloki, campbellbarton
Subscribers: lordloki
Projects: #game_physics
Differential Revision: https://developer.blender.org/D925
This function allows the user to run specific code for each of the
rendered stereoscopic eyes in the Game Engine.
The initial use case is to set the camera projection matrix in
a scene.pre_draw callback function for each eye, to be used in VR
(Virtual Reality) installations.
Reviewed by Mitchell Stokes and Campbell Barton, thank you guys.
Sample Test Python Script:
"""
import bge
import bgl
import blf
def init():
"""init function - runs once"""
scene = bge.logic.getCurrentScene()
scene.post_draw.append(write)
def write():
"""write on screen - depending on the eye"""
width = bge.render.getWindowWidth()
height = bge.render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
eye = bge.render.getStereoEye()
if eye == bge.render.LEFT_EYE:
blf.position(0, (width * 0.2), (height * 0.3), 0)
blf.size(0, 40, 72)
blf.draw(0, "Left")
else: # bge.render.RIGHT_EYE:
blf.position(0, (width * 0.7), (height * 0.3), 0)
blf.size(0, 40, 72)
blf.draw(0, "Right")
"""
Refactored some code to be easier to read. Semantically the code is
identical.
- Some conditions were negated to be able to return/continue early,
rather than having the majority of the code inside an if-body.
- Conditions were simplified (!(a == b)) turned into (a != b);
repeated conditions calculated only once.
- Unnecessary variables and one unnecessary condition were
eliminated.
Reviewers: campbellbarton, lordloki
Reviewed By: lordloki
Projects: #game_physics
Differential Revision: https://developer.blender.org/D954
This patch adds the following R/W properties and method to `KX_GameObject`:
- `linearDamping` -- get/set linear damping
- `angluarDamping` -- get/set angular damping
- `setDamping(linear, angular)` -- set both simultaneously
These allow runtime changes to the same properties that are accessible at design time in Blender's UI via `game.damping` and `game.rotation_damping`. The names of the properties were chosen to mirror the internal names of the BGE physics engine, as these are (AFAIK) also the commonly used names in physics literature.
Reviewers: campbellbarton
Projects: #game_physics
Differential Revision: https://developer.blender.org/D936
`INSERT_FAST` implies you call `calchandles_fcurve()` at the end...
For now, since we do not store edited FCurves nor can we get them easily
(requires RNA...), just update handles of all fcurves, it's much more
performant than removing usage of `INSERT_FAST` anyway.
Instead of getting fancy this time, we'll just use Mahalin's simpler
fix. This may have slight performance impacts, but it is a lot simpler
than the previous fix and shouldn't cause as many bugs.
With this fix the mouse actuator movement works well as with even screen resolutions as odd screen resolutions.
Also it fixed the movement when the border of the blenderplayer window is out of the screen limits.
Reviewed By: moguri
Differential Revision: https://developer.blender.org/D946
remove 'type' argument, very few mathutils objects are wrapped,
add new function for creating wrapped objects.
also fixes unlikely memory leak if the data-array can't be allocated.
ImageFFmpeg objects will not refresh properly because the image
file is closed immediately after creation. Therefore refresh()
should have no effect on them.
This was causing problems with ImageMix using ImageFFmpeg as
sources: refreshing the ImageMix object is required to update
the mix but it has the side effect of refreshing the underlying
sources, hence the need to skip refresh on fixed images.
Fix for T41294.
Rigid body constraints are not deleted, if the corresponding game objects are deleted.
Reviewers: moguri
Differential Revision: https://developer.blender.org/D701
after the completion of the action in "Flipper", layer is removed and the actuator mistakenly receive zero when trying to get the current frame
Patch Author: avrprj
Reviewers: moguri
Projects: #game_logic
Differential Revision: https://developer.blender.org/D906
This is mainly to address old issue when one need to have SDL library installed
in order to use our official builds. Some hip distros already installs SDL,
but it's not quite the same across all the variety of the distros.
We also now switching to SDL-2.0, most of the distros have it in repositories
already, so it shouldn't be huge deal to install it if needed.
Reviewers: campbellbarton
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D878
Navigation mesh object need to access the current scene at
creation time. This can be at scene start or when an object
is instantiated from an inactive layer. The method of getting
the scene differs in these cases. This fix handles both.