Commit Graph

447 Commits

Author SHA1 Message Date
Campbell Barton
f5e020a7a6 PyAPI: fix memory leaks in dictionary assignment
Thanks to Kévin Dietrich for spotting driver leak,
checked other uses of PyDict_SetItem and found more.
2016-07-14 17:30:52 +10:00
Campbell Barton
2465bd90d5 Cleanup: style, whitespace, doxy filepaths 2016-06-19 06:33:29 +10:00
Bastien Montagne
ce65fae8f3 Fix T48369: Missing suport for main '+' key.
Many keyboard layouts (italian, spanish, german...) have direct access to '+' key on main
keyboard area (not the numpad one), ans x11 has own define for this key, so use it instead
of generating an unkown key event.

Note that we most likely have much more missing 'specific' keycodes for non-US keyboard layout,
but think since we already had a 'minus' keyevent, supporting 'plus' one is totally consistent.
And we had a spare space in our defined values just for it even!

This keyevent is only supported/generated by x11 and cocoa Ghost backends for now,
neither SDL nor win32 seem to have matching key events...
2016-05-10 08:29:03 +02:00
Porteries Tristan
2050ecc307 BGE: Fix T48071: Global logic manager
Previously the logic manager was used as a global variable for SCA_ILogicBrick::m_sCurrentLogicManager,
this request to always update it before run any python script and allow call function like
ConvertPythonTo[GameObject/Mesh]. The bug showed in T48071 is that as exepted the global
m_sCurrentLogicManager is not updated with the proper scene logic manager.
Instead of trying to fix it by updating the logic manager everywhere and wait next bug report to add
a similar line. The following patch propose a different way:
- Every logic brick now contain its logic manager to SCA_ILogicBrick::m_logicManager, this value is
  set and get by SCA_ILogicBrick::[Set/Get]LogicManager, It's initialized from blender conversion and
  scene merging.
- Function ConvertPythonTo[GameObject/mesh] now take as first argument the logic manager to find name
  coresponding object or mesh. Only ConvertPythonToCamera doesn't do that because it uses the
  KX_Scene::FindCamera function.

Reviewers: moguri

Differential Revision: https://developer.blender.org/D1913
2016-04-10 23:57:43 +02:00
Sergey Sharybin
d3fa1bd4d5 Fix warnings reported by MSVC
Mainly it's related on a bad practice in SDL to force-define __SSE__
and __SSE2__ flags which generates quite some warnings and causes too
much noise.

There are some other warnings fixed. Should be no functional changes.

NeXyon, please check the changes in audaspace :)
2016-02-23 09:44:54 +01:00
Sergey Sharybin
5d99cde822 Remove SCons building system
While SCons building system was serving us really good for ages it's no longer
having much attention by the developers and started to become quite a difficult
task to maintain.

What's even worse -- there started to be quite serious divergence between SCons
and CMake which was only accumulating over the releases now. The fact that none
of the active developers are really using SCons and that our main studio is also
using CMake spotting bugs in the SCons builds became quite a difficult task and
we aren't always spotting them in time.

Meanwhile CMake became really mature building system which is available on every
platform we support and arguably it's also easier and more robust to use.

This commit includes:

- Removal of actual SCons building system
- Removal of SCons git submodule
- Removal of documentation which is stored in the sources and covers SCons
- Tweaks to the buildbot master to stop using SCons submodule
  (this change requires deploying to the server)
- Tweaks to the install dependencies script to skip installing or mentioning
  SCons building system
- Tweaks to various helper scripts to avoid mention of SCons folders/files
  as well

Reviewers: mont29, dingto, dfelinto, lukastoenne, lukasstockner97, brecht, Severin, merwin, aligorith, psy-fi, campbellbarton, juicyfruit

Reviewed By: campbellbarton, juicyfruit

Differential Revision: https://developer.blender.org/D1680
2016-01-04 14:20:48 +05:00
Porteries Tristan
95164a09a7 BGE: generic python callback list + replace KX_PythonSeq.
I made this patch to declared a python list without converting all elements in python object (too slow) or use a CListValue which required CValue items (too expensive in memory).  In the case of a big list of points like a collision contacts points list, to use a CListValue we must implement a new class based on CValue for 3D vector to create a python proxy even if mathutils do it perfectly, we must also convert all points (frequently ~100 points) when fill the CListValue even if the list is not used (in the case of the collision callback). The easy way is to use callback (it doesn't worth to do an inheritance) which convert the item in PyObject only during an acces.
5 callbacks are used :
- Check if the list is valid = allow acces (like PyObjectPlus.invalid)
- Get the list size
- Get an item in the list by index.
- Get an item name in the list by index (used for operator `list["name"]`)
- Set an item in the list at the index position.
All of these callback take as first argument the client instance.
Why do we use a void * for the client instance ? : In KX_PythonInitTypes.cpp we have to initialize each python inherited class, if we use a template (the only other way) we must add this class each time we use a new type with in KX_PythonInitTypes.cpp

To check if the list can be accessed from python by the user, we check if the python proxy,  which is the `m_base` member, is still a valid proxy like in PyObjectPlus. But we can use a callback for more control of user access (e.g a list of collision point invalidate a frame later, in this case no real python owner).

This python list is easily defined with :
```
CPythonCallBackList(
void *client, // The client instance
PyObject *base, // The python instance which owned this list, used to know if the list is valid (like in KX_PythonSeq)
bool (*checkValid)(void *), // A callback to check if this list is till valid (optional)
int (*getSize)(void *), // A callback to get size
PyObject *(*getItem)(void *, int), // A callback to get an item
const char *(*getItemName)(void *, int), // A callback to get an item name (optional) use for acces by string key
bool (*setItem)(void *, int, PyObject *) // A callback to set an item (optional)
)
```
To show its usecase i replaced the odd KX_PythonSeq, it modify KX_Gameobject.sensors/controllers/actuators, SCA_IController.sensors/actuators and BL_ArmatureObject.constraints/channels.

Example : {F245193}, See message in console, press R to erase the object and see invalid proxy error message.

Reviewers: brita_, #game_python, youle, campbellbarton, moguri, agoose77, sergey

Reviewed By: campbellbarton, moguri, agoose77, sergey

Subscribers: sergey

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1363
2015-10-26 20:27:08 +01:00
Campbell Barton
afe3b55483 Cleanup: warning & whitespace 2015-10-26 22:22:30 +11:00
Porteries Tristan
0d638172ec BGE: Fix T30179 action actuator not stoped when state changed.
The function SCA_IActuator::DecLink is now under virtual : in some case the actuator have to know when is useless.
2015-10-23 10:54:08 +02:00
Dalai Felinto
07a7d64c06 BGE: make error message more clear when trying to de/activate actuator from non-active controller 2015-09-15 00:01:32 -03:00
Jorge Bernal
6ffc988ae3 BGE Clean-up: New EXP prefix for the BGE Expression module
The expression module now uses an EXP prefix and it follows a
distribution similar to blender.

Additionally the hash function in EXP_HashedPtr.h was simplified and the
files EXP_C-Api.h &.EXP_C-Api.cpp were deleted because were unused.

Reviewers: campbellbarton, moguri, sybren, hg1

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1221
2015-07-12 16:58:12 +02:00
Jorge Bernal
71dcaa7744 BGE Cleanup: Identical code for both if/else branches 2015-05-30 18:15:11 +02:00
Jorge Bernal
8c98b1649d BGE: Fix for T42341 Sensor.frequency is badly named
"Frequency" parameter is renamed to "Skip" in the LogicBricks sensors as it represents skipped frames between pulses.

Naming something (frequency) the exact opposite of what it represents (period) was the worst choice.

Also, a new BGE python attribute 'skippedTicks' was introduced. 'frequency' attribute is maintained but deprecated.

Internally, freq variable is used yet at DNA_Sensor to maintain compability and to avoid do_versions.

Thanks to Sybren for the investigation.

{F162440}

Reviewers: campbellbarton, sybren, moguri, hg1

Reviewed By: sybren, hg1

Differential Revision: https://developer.blender.org/D1229
2015-04-16 06:39:33 +02:00
Gaia Clary
ef70d644d6 reverting unintentionally changed value of enum OBJ_TEXT 2015-03-16 18:58:58 +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
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
b4fccce1f6 BGE: Fix for regressions T43883 and T43456 (and T43876 likely). SDL joystick related
Only to create and destroy joystick devices for connected joysticks

Reviewers: campbellbarton, sybren, moguri

Reviewed By: sybren

Maniphest Tasks: T43883, T43876

Differential Revision: https://developer.blender.org/D1161
2015-03-07 21:27:30 +01:00
Campbell Barton
b12f3cbee7 cleanup: style 2015-02-07 04:50:21 +11: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
Campbell Barton
6b655ca62c Cleanup: style 2015-01-21 11:57:11 +11:00
Campbell Barton
1ef33968fd Recent fix for SDL2 broke joysticks for SDL1.2 2015-01-05 20:23:30 +11:00
Campbell Barton
de6b546e15 Fix 8 memory leaks from bad PyList_Append use 2015-01-04 20:35:16 +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
Campbell Barton
57c9d69e6b Cleanup: warnings 2014-11-23 15:13:58 +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
Martijn Berger
96ca64629d Windows (MSVC2013) move to SDL2 2014-11-13 16:23:27 +01:00
Campbell Barton
3f2cf6da6f Cleanup: remove _DEBUG define usage 2014-08-27 18:59:32 +10:00
HG1
12a0cccfbf BGE: Add level mode to property actuator
This patch adds to the existing property actuator a level mode, which is switching the property depending on the input level.

Reviewers: moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D652
2014-07-17 22:49:40 -07:00
HG1
984d6c8677 BGE debug API and actuator
This patch adds some new debug methods to the KX_GameObject for manually adding the debug list and bge.render for controlling the debug visualization.
It also adds a new debug actuator, which allows to control the same functions.

This patch is a updated version of T33701.

Thread on Blenderartists:
http://blenderartists.org/forum/showthread.php?264745-Debug-proerties-for-added-objects-patch&p=2256018&viewfull=1#post2256018

Reviewers: moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D635
2014-07-11 16:00:14 -07:00
Mitchell Stokes
04fdd35ba5 Slight cleanup for 4af848e. 2014-07-02 22:55:39 -07:00
Mitchell Stokes
4af848e557 Fix T40923: An error from a python controller on a LibFreed object causes a crash 2014-07-02 21:58:08 -07:00
Jorge Bernal
7d99a4ded9 BGE: New Mouse Actuator
Disclaimer: The author of this patch is Geoffrey Gollmer (gomer). I only updated the patch to the current git master status, reworked several parts to fit well with current coding style and applied several fixes.

This actuator allows users to show/hide the mouse cursor using logic bricks, as well as control object rotation with a mouse in the BGE.
The mouse rotation is flexible enough to allow any type of mouse look, as well as banking for flight controls.

{F94520}

{F91859}

Blend file for testing Mouse actuator (with default parameters and crosshair): {F94920}

Reviewers: moguri

Reviewed By: moguri

CC: gomer, lordodin

Differential Revision: https://developer.blender.org/D559
2014-06-25 15:47:37 -07:00
Jorge Bernal
8c16f4c7d0 BGE: New Property sensor evaluation types
This patch adds "Less Than" and "Greater Than" evaluation types to the property sensor.
The Wiki Docs modifications http://wiki.blender.org/index.php/User:Lordloki/Doc:2.6/Manual/Game_Engine/Logic/Sensors/Property
Also, I have attached a screenshot and a blend to check.

Reviewers: dfelinto, moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D476
2014-06-16 14:56:36 -07:00
Mitchell Stokes
27cbb28659 BGE cleanup: Removing the unused SCA_EventManager::Replace_PhysicsScene(). 2014-05-01 19:43:07 -07:00
Campbell Barton
3b71cab420 Fix T38110: GameEngine keyboard sensor ignores unicode characters 2014-01-23 14:58:04 +11:00
Campbell Barton
5fc2fe9fad Code Cleanup: move MOUSEX/Y to BGE, describe INBETWEEN_MOUSEMOVE 2014-01-12 01:59:17 +11:00
Mitchell Stokes
8aff45d8f6 Fix T36804: the property sensor when set to interval was causing a memory leak
The property sensor was using CValue::FindIdentifier(), which does an AddRef(). However,
the property sensor was not calling Release() when it was done with the value. This could
cause more leaks when used in conjunction with the copy property actuator since it would
really throw off ref counts.
2013-11-29 18:34:06 -08:00
Campbell Barton
91a24654dd Code Cleanup: whitespace / formatting 2013-11-24 15:23:38 +11:00
Campbell Barton
fc618bbcbf fix for possible leak in the expression controller find identifier. 2013-11-02 05:18:31 +00:00
Brecht Van Lommel
eaf354e222 Fix related to #36319: restore SDL_VIDEODRIVER=dummy environment variable, it
seems that somehow not having this is causing keyboard events to be caught by
SDL. This was removed because it broke addons that could use SDL, now set the
environment variable only temporary during SDL initialization.

This may have been causing issues with keyboard events getting missed in the
game engine, but I couldn't confirm the issue here.
2013-09-23 14:48:28 +00:00
Mitchell Stokes
07e655dfa6 Cleaning up some prints related to SDL. 2013-08-29 22:48:37 +00:00
Mitchell Stokes
f62fabca3d Allowing the BGE to build with SDL2. I'm not sure if this is the correct fix yet, but at least it builds. 2013-08-29 22:48:27 +00:00
Campbell Barton
47c23750e8 style cleanup: indent/whitespace 2013-08-19 01:48:44 +00:00
Daniel Stokes
ef4d599194 Changing the python error when accessing SCA_JoystickSensor.axisSingle in the wrong mode to an AttributeError instead of a TypeError as this more accurately reflects the problem. 2013-07-20 03:15:57 +00:00
Mitchell Stokes
eb21bdd249 Merging changes from trunk r58091-58323. 2013-07-17 01:40:26 +00:00
Campbell Barton
02ba328ca8 clang/cmake - quiet warnings for external libs and reference moto as a system include. 2013-07-15 08:26:16 +00:00
Mitchell Stokes
83e9f32382 BGE: Committing patch #32422 "Debug properties for added objects" by HG1.
This patch allows debug properties from objects added to the scene at runtime to be displayed under the Debug Properties in the overhead display.
2013-07-09 20:06:36 +00:00
Mitchell Stokes
4eded6dbdc BGE: Fix for [#35479] "OSKEY (Command Key on Mac) not working" reported by Mike Pan (mpan3).
The OSKEY was never added to the game engine, so it didn't recognize it.
2013-06-20 03:22:55 +00:00
Campbell Barton
9cf6e305a9 split bge includes for scons onto their own lines (for easier merging) 2013-05-29 21:56:55 +00:00