Commit Graph

3083 Commits

Author SHA1 Message Date
Sybren A. Stüvel
2b01b71339 Fix T43565: BGE removed unneeded if/else in BL_KetsjiEmbedStart 2015-02-10 21:28:18 +01:00
Ines Almeida
4edc1bbe02 BGE - Vehicle Controller - add background and API checks for arguments of function calls
Fixes T41570 crash
For readability, attachDir was renamed to downDir and the Python API docs renamed accordingly
2015-02-09 20:58:15 +00:00
Ines Almeida
a088b9488d Recreating bge python modules instead of using existing
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
2015-02-09 20:56:38 +00:00
Sybren A. Stüvel
dd65a44c9a BGE physics: When colliding, report first contact point to Python
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
2015-02-08 15:52:13 +01:00
Campbell Barton
b12f3cbee7 cleanup: style 2015-02-07 04:50:21 +11:00
Ines Almeida
15cd222270 BGE: python API initialization cleanup
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
2015-02-03 15:32:55 +00:00
Ines Almeida
2699866720 BGE: python API cleanup - initialization for bge with submodules, closes D615 2015-02-03 15:32:55 +00:00
Ines Almeida
0e0af4f772 BGE: python API cleanup - adding proper initialization to GameTypes 2015-02-03 15:32:55 +00:00
Ines Almeida
e67bd30bdf BGE: python API cleanup - replace BLI_program_path with BKE_appdir_program_path 2015-02-03 15:32:55 +00:00
Ines Almeida
ba0978c1a9 BGE: python API cleanup - bge submodules definitions 2015-02-03 15:32:54 +00:00
Ines Almeida
a7b0330c13 BGE: python API cleanup - using PyDoc_STRVAR instead of static char*
Cherry-picking d503f8a onto 117edbb
Conflicts:
	source/gameengine/Ketsji/KX_PythonInit.cpp
2015-02-03 15:32:54 +00:00
Ines Almeida
95425bc97a BGE: python API initialization cleanup
-Removing unused parameters
-Updating some parts to match bpy_interface.c initialization

Cherry-picking 14fceb6 onto 117edbb
Conflicts:
	source/gameengine/Ketsji/KX_PythonInit.cpp
2015-02-03 15:32:54 +00:00
Antony Riakiotakis
750506be97 Adjust GLSL drawing of window coordinates from camera view (use camera
bounds instead of window bounds). Fixes remaining part of T43346
2015-02-02 14:26:05 +01:00
Campbell Barton
3cf7a8008e Fix crash on joystick access (if SDL's not found)
D985 by @pgi
2015-01-29 17:17:29 +11:00
Sybren A. Stüvel
dd673337f1 BGE: draw contact points + normals in yellow
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
2015-01-28 22:09:58 +01:00
Sybren A. Stüvel
e5a852c3f3 BGE: draw contact points as sphere + line indicating the surface normal.
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
2015-01-28 22:09:58 +01:00
Campbell Barton
59e2f919ac missed last commit 2015-01-27 03:41:05 +11:00
Campbell Barton
b94efe0e8b BGE: remove Py3.1 workaround 2015-01-27 03:29:45 +11:00
Bastien Montagne
31219415d6 Fix BGE compilation after recent renames in BKE_image (tsst...). 2015-01-24 14:57:57 +01:00
Dalai Felinto
8ed439b89e bge.render.getStereoEye() and bge.types.LEFT_EYE/RIGHT_EYE
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")
"""
2015-01-22 03:00:24 -02:00
Sybren A. Stüvel
7165db53f2 Cleanup of BGE code CcdPhysicsEnvironment::CallbackTriggers()
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
2015-01-21 18:43:05 +01:00
Campbell Barton
6b655ca62c Cleanup: style 2015-01-21 11:57:11 +11:00
Sybren A. Stüvel
ed8dc78691 BGE physics: get/set linear and angular damping
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
2015-01-15 18:37:22 +01:00
Bastien Montagne
1187b98d48 Fix T43174: "Record animation" does not update fcurve handles
`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.
2015-01-09 15:29:47 +01:00
Mitchell Stokes
8ebb552a95 Fix T40257: Frustum culling not working properly
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.
2015-01-07 20:41:07 -08:00
Mitchell Stokes
4fac29ca0e Revert "Fix T40257: Frustum culling not working properly"
This reverts commit 315609ec0c1e28eb12bde3e8bbd2a5b03672b1a9.

This fix still causes more issues than it solves.
2015-01-07 20:38:05 -08:00
Campbell Barton
29d2c71117 Fix for bool flag use 2015-01-07 12:08:55 +11:00
Jorge Bernal
ee58d44945 BGE: Fix for bugs T42520 and T42097 (mouse look actuator related).
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
2015-01-05 22:07:35 -08:00
Campbell Barton
1ef33968fd Recent fix for SDL2 broke joysticks for SDL1.2 2015-01-05 20:23:30 +11:00
Campbell Barton
b240b8e231 Freestyle: reserve array sizes before filling
also use PyList_GET_ITEM when list size is known.
2015-01-04 21:23:26 +11:00
Campbell Barton
de6b546e15 Fix 8 memory leaks from bad PyList_Append use 2015-01-04 20:35:16 +11:00
Campbell Barton
8106a6b75d mathutils: refactor instantiation
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.
2015-01-04 17:43:57 +11:00
Campbell Barton
bf169d6ca6 Fix T43066: Joystick broken in GE since 2.73rc
Caused by move to SDL2, fix thanks to jensverwiebe.
2015-01-02 17:14:33 +11:00
Sergey Sharybin
784517dfb9 Joystick: Suppress add/remove device events
Previously they'll be printed to the console as a totally unknown events
together claim this shouldn't have happened which is just misleading.
2014-12-31 14:56:42 +05:00
Jens Verwiebe
c1f54bcdcc OSX: revive GHOST_HACK_getFirstFile cause it breaks things on older OSX versions.
Dunno exactly why this was done earlier, but propose not to remove code not understood.
2014-12-25 15:12:56 +01:00
Mitchell Stokes
1999b5a814 Fix ping-pong actions when using the Action Actuator. 2014-12-11 00:05:11 -08:00
Benoit Bolsee
cf7bdb42ac BGE VideoTexture: refresh() on ImageFFmpeg should have no effect.
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.
2014-12-04 23:55:53 +01:00
Antony Riakiotakis
76bfce231a Make sure materials are updated before passing to renderer in game
engine - report by Dalai on irc.
2014-12-03 18:12:31 +01:00
HG1
47ebf96de4 BGE: Fix Rigid body constraint deletion
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
2014-12-02 19:26:06 -08:00
Mitchell Stokes
5996ad2fd4 Fixes for T41168
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
2014-12-02 19:12:03 -08:00
Campbell Barton
43fa4baa6c Refactor: BLI_path_util (part 2)
Use BKE_appdir/tempdir naming prefix for functions extracted from BLI_path_util
2014-11-23 18:55:52 +01:00
Campbell Barton
6308c16675 Refactor: BLI_path_util (split out app directory access)
This module is intended for path manipulation functions
but had utility functions added to access various directories.
2014-11-23 18:42:18 +01:00
Campbell Barton
57c9d69e6b Cleanup: warnings 2014-11-23 15:13:58 +01:00
Campbell Barton
46e2d5ee41 Cleanup: typo 2014-11-21 14:16:35 +01:00
Sergey Sharybin
80d1d624d3 Support dynamic loading of SDL libraries
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
2014-11-17 17:43:18 +05:00
Campbell Barton
c31f74de6b Cleanup: use BLI_listbase_count_ex to avoid redundant looping 2014-11-16 14:23:37 +01:00
Campbell Barton
7d040d2a08 Cleanup: use BLI_listbase_*** prefix for count,sort,sort_r 2014-11-16 13:57:58 +01:00
Martijn Berger
96ca64629d Windows (MSVC2013) move to SDL2 2014-11-13 16:23:27 +01:00
Benoit Bolsee
04814476c0 Fix another crash with Navigation mesh.
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.
2014-10-11 12:17:31 +02:00
Jason Wilkins
8d084e8c8f Ghost Context Refactor
https://developer.blender.org/D643
Separates graphics context creation from window code in Ghost so that they can vary separately.
2014-10-07 15:47:32 -05:00