Commit Graph

1617 Commits

Author SHA1 Message Date
Jorge Bernal
e7d051043d BGE: New hysteresis offset to improve LOD level transitions
This change introduces a new hysteresis parameter that it will be added
or subtracted to/from the LOD distance to avoid popping when a LOD
object moves close to the LOD transition continuously.

Then, we have the following:

- a new LOD Hysteresis setting per scene (default 10%) which is located
in Scene context --> Level of Detail panel. This scene parameter also
will active/deactive the scene hysteresis.
- and a new LOD Hysteresis setting per object (default 10%) which is
located in Object context --> Levels of Detail panel. The LOD hysteresis
setting per object (if active) will overwrite the hysteresis setting per
scene value.

For the new blends: the hysteresis setting per scene would be active by
default and the per object would be inactive by default.
For the old blends: both hysteresis settings (per scene and per object)
would be inactive by default. A quick way to take advantage of this
feature for old blends would be to activate the hysteresis parameter in
the scene context -> Level of Detail panel

Reviewers: campbellbarton, kupoman, moguri

Reviewed By: kupoman, moguri

Subscribers: nonamejuju, lordodin

Differential Revision: https://developer.blender.org/D957
2015-03-22 18:19:49 +01:00
Thomas Szepe
0b4a71b072 BGE: Add physics constraints replication
This patch will add a physics constraints replication for group instances
(dupli group).
It also fix crashing when when a group instance is made from a linked
group instance and both are on the active layer.

Initial patch T31443 from moerdn (Martin Sell).

Reviewers: lordloki, sergof, moguri, sybren

Reviewed By: moguri, sybren

Differential Revision: https://developer.blender.org/D658
2015-03-22 17:56:26 +01:00
Jorge Bernal
2744ce77de Revert part of D1074 related to acceleration taked into account.
It has been reverted because it was affecting obstacle avoidance
(T44041).

This fix should be backported to 2.74
2015-03-21 17:54:49 +01:00
Gaia Clary
9ed5a1073e fix D1130 renamed the enum OBJ_FONT to OBJ_TEXT to avoid naming conflicts in Windows 2015-03-16 18:46:40 +01:00
Antony Riakiotakis
77bc623bc4 Get rid og gluBuild2DMipmaps on game engine. 2015-03-16 16:18:37 +01:00
Pierluigi Grassi
225027ce5d BGE - new read-only attribute in KX_GameObject python api (LOD level)
Added a new "current_lod_level" property to the python api of
KX_GameObject. The property returns the current lod level of the game
object. The purpose of the property is activate logic routines only when
an object is at a certain lod-distance from the camera, avoiding to
separately recomputing the same distance in the logic script. Usage in
python script might look like:

owner = bge.logic.getCurrentController().owner
lod_level = owner.currentLodLevel
if lod_level == 0: ...do something
else: ... object might be too distant

Reviewers: dfelinto, kupoman, moguri

Reviewed By: kupoman, moguri

Subscribers: lordloki

Projects: #game_engine

Differential Revision: https://developer.blender.org/D978
2015-03-15 17:26:49 +01:00
Jorge Bernal
dd3ade250d BGE: Fix for T43994 Steering actuator bug with Navmesh
Now the facing option is taken into account as before

This is a regression and to be ported to the final release branch.
2015-03-15 11:38:04 +01:00
Porteries Tristan
176ecd9c9c BGE : Fix for T43724 and T41599 addObject() with KX_FontObject and
overlay scene

GetGameObjectType is overwritten in KX_FontObject to differentiate a
font object into AddNodeReplicaObject function. Now, in this function,
we add fonts in the appropriate list.

Reviewers: campbellbarton, moguri, dfelinto, lordloki

Reviewed By: lordloki

Subscribers: lordloki

Projects: #game_logic, #game_engine

Differential Revision: https://developer.blender.org/D1130
2015-03-15 10:50:59 +01:00
Jorge Bernal
73ad76970e BGE: Fix for T43980 MouseLook (actuator) triggers MouseMovement (sensor)
on other objects permanently

only trigger mouse event when it is necessary, this way we avoid
conflicts with other mouse sensors.
2015-03-13 00:50:25 +01:00
Campbell Barton
29e5de3728 Fix BGE: calling ReleaseInstance on NULL joystick 2015-03-09 16:36:35 +11:00
Antony Riakiotakis
15957a9e4d Get rid of gluScaleImage in our game engine as well. 2015-02-27 14:47:39 +01:00
Thomas Szepe
eaabe9d6c6 BGE: Fix for CreateConstraint API
This patch fix two bugs related to CreateConstraint().
1. Disable linked collision only working with 6DoF constraints.
2. If all pivot axis rotations setted to zero the linked object disappears.

{F101374}

Reviewers: moguri, sybren, brita_, lordloki

Reviewed By: lordloki

Subscribers: p9ablo

Differential Revision: https://developer.blender.org/D704
2015-02-26 20:08:22 +01:00
Sybren A. Stüvel
6d9c99422b Fix T43748: MouseLook actuator raises an Assert error
An assertion seems to be inverted by mistake, as MT_assert(!m_mouse); is followed
by using m_mouse->XXXX.
2015-02-21 14:39:04 +01:00
Ines Almeida
4c0adb95dc gamengine: removing useless comment 2015-02-21 12:16:21 +00:00
Ines Almeida
9bfdcc4d32 gameengine: removing addInitFromFrame hack 2015-02-21 12:16:20 +00:00
HG1
8db9b07cb3 Fix T33762 - texture fonts were not using the material color (gameengine) 2015-02-21 12:16:20 +00:00
Ines Almeida
c391a67830 gameengine: KX_Scene comment cleanup 2015-02-21 12:16:19 +00:00
Ines Almeida
cfec320f1e BGE cleanup: removing unused async logic bricks
This code was never run and is an outdated copy from the code above.
If someday this is needed again, it is better to start clean.
2015-02-21 12:16:19 +00:00
Jorge Bernal
5d0696052a BGE: Fix T41502 Path following jumping
New Lock Z velocity parameter was added. This parameter avoid the micro-jumping.
By default it is actived except when you load an old file that it is deactived to keep former behaviour.

Additionally it was solved another issue related with the acceleration: That is the acceleration value was not taked into account and we had always the maximum linear velocity from the beginning of movement. Now the acceleration is taken into account until we reach the maximum velocity.
When you load an old file, the acceleration value is set to the maximum range (1000.f). This way we simulate a maximum velocity constant from the beginning of movement (former behaviour).

{F142195}

Reviewers: moguri, dfelinto, campbellbarton

Reviewed By: campbellbarton

Subscribers: sergey

Differential Revision: https://developer.blender.org/D1074
2015-02-18 23:24:02 +01:00
Jorge Bernal
9bd2a7c0a8 BGE: Fix T41570: Blender crash when physics createConstraint
Move physicsid type to unsigned long long to avoid crashes on Windows 8.1 64bits.
Other systems also modified to put them inline with this solution.

Reviewers: dfelinto, brita_, moguri, juicyfruit, campbellbarton

Reviewed By: juicyfruit, campbellbarton

Subscribers: juicyfruit

Differential Revision: https://developer.blender.org/D1122
2015-02-18 19:52:54 +01:00
Campbell Barton
d4934f8f6d cleanup: style/indentation 2015-02-11 18:39:28 +11: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
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
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
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
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
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
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
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
46e2d5ee41 Cleanup: typo 2014-11-21 14:16:35 +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
Campbell Barton
6bde5381bb Cleanup: indentation 2014-10-02 10:33:15 +02:00
Mitchell Stokes
ed4075cb34 Fix T41259: Objects parented to non-armature objects cannot play shape actions in the BGE 2014-09-23 07:52:44 -07:00
Ines Almeida
a4c5570aba gameengine: fix T41272 - KX_Light.color returns wrong values 2014-08-23 20:24:19 +02:00
Benoit Bolsee
fb49c5aa56 BGE: fix crash and return boolean on scene.replace()
Scene replacement with invalid scene name was crashing blender,
now it's a no-op.
KS_Scene.replace() to return a boolean to indicate if the scene
is valid and is scheduled for replacement. This allows more
robust game management.
2014-08-23 12:31:32 +02:00