Commit Graph

262 Commits

Author SHA1 Message Date
Jorge Bernal
ddf58004c4 BGE: LoD Hysteresis clean up
Move scene hysteresis value to KX_Scene where it should be (instead of
KX_GameObject)
2015-03-23 19:03:56 +01:00
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
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
Ines Almeida
c391a67830 gameengine: KX_Scene comment cleanup 2015-02-21 12:16:19 +00: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
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
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
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
315609ec0c Fix T40257: Frustum culling not working properly
This is mostly the same fix as before, but now code depending on culling
checks is executed after KX_Scene->CalculateVisibleMeshes(). As a
side-effect, LoD checks and animation culling now use the current
frame's culling information rather than the previous frame's.
2014-07-10 22:14:30 -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
Mitchell Stokes
84e8cabac6 Fix T40697: Skinned meshes with shapekeys crashing in the BGE 2014-06-19 18:20:56 -07:00
Mitchell Stokes
7317b4fcf1 Fix 40343: Using replace mesh (e.g., LODs) on a skinned mesh crashes.
Need to use parent->AddRef() in a few places.
2014-05-27 17:05:35 -07:00
Mitchell Stokes
04623e8b1f BGE: Accidentally committed some debug code in 8dafbe. 2014-05-27 14:32:32 -07:00
Mitchell Stokes
8dafbed4b5 BGE cleanup: Remove unused KX_TrackToActuator::m_tracktime member. 2014-05-27 14:12:53 -07:00
Mitchell Stokes
3abb2e0a3d BGE cleanup: Removing the unused KX_Scene::UpdateMeshTransformations() function. 2014-05-19 21:14:18 -07:00
Mitchell Stokes
43f3e79cee Fix T40111: replaceMesh() crashes BGE when used on a parented object
The replace mesh code was still calling release() on the parent object when it
no longer needed to (due to earlier commits).
2014-05-12 22:53:31 -07:00
Mitchell Stokes
087bbe624f BGE: Fixing shape key animations on meshes with no armature.
Their transverts were not being updated after code changes for
multi-threaded skinning.
2014-05-09 16:03:54 -07:00
Mitchell Stokes
362b25b382 Fix T39928: Blender crash/freeze when game engine is started with animation played directly on camera object with parents.
Updating object IPOs is not currently thread-safe since it also updates
children. This leads to problems when parents and children are both
animated. For now, updating object IPOs is done in its own loop to avoid
threading issues.
2014-05-04 15:39:15 -07:00
Mitchell Stokes
1a8b17661f Fix T35552: LibLoading objects with Collision sensors gives an error
The collision sensors were not being properly unregistered from the
physics system before they were merged into the current scene.
2014-05-02 00:08:00 -07:00
Mitchell Stokes
60c8c130fe BGE cleanup: KX_GameObject::GetParent() no longer increases the object's refcount.
I'm not sure why this function ever increased the object's refcount. Any
place in the code that calls KX_GameObject::GetParent() has to turn
around and call parent->Release(). Forgetting to call Release() was a
common cause of memory leaks (in fact, KX_SteeringActuator was probably
leaking). If the refcount needs to be increased, the calling code can
handle calling AddRef().
2014-04-30 18:53:32 -07:00
Antony Riakiotakis
6ab3a2f8a4 Change naming slightly, it conflicts with DrawText function define on
windows on MinGW
2014-04-30 11:57:12 +03:00
Mitchell Stokes
f5c3c624f8 BGE Cleanup: Moving reinstancing physics shapes from KX_ConvertPhysicsObject to PHY_IPhysicsController
This was the last item in KX_ConvertPhysicsObject. Therefore,
KX_ConvertPhysicsObject.h and KX_ConvertPhysicsObjects.cpp have been
removed.
2014-04-23 19:39:57 -07:00
Mitchell Stokes
3442a658fc BGE Cleanup: Reducing KX_Scene's dependence on Bullet.
Instead, it now relies more on our physics abstractions (e.g.,
PHY_IPhysicsEnvironment).
2014-04-23 14:08:49 -07:00
Mitchell Stokes
d050577176 Fix T39445: Async LibLoad Crash
There was some deadlock due to trying manage Python's GIL. Instead of
continuing to fight with it, anything needing to call into Python while
conversion during lib loading is just delayed until it can be done in
the main thread.
2014-04-16 01:15:40 -07:00
Mitchell Stokes
1ce726adb9 BGE: Allow skinned meshes with modifiers to do skinning updates in parallel. 2014-04-09 17:04:17 -07:00
Mitchell Stokes
19413644da BGE: Fixing a crash when animating objects with modifiers and armatures.
Our deformer system really needs some work. First, there was a crash
with shape keys because BL_ModifierDeformer derives from
BL_ShapeDeformer, which means we try to execute shape keys even if we do
not have them. Also, for some reason BL_ModifierDeformer::Update() does
not work if called from the threaded loop, so it is skipped for now. In
other words, skinned updates on meshes with modifiers are currently not
run in parallel.
2014-04-09 16:22:55 -07:00
Mitchell Stokes
fe05f97841 BGE: Multi-threading animation updates and skinning.
This required BL_ArmatureObject to have tighter control over armatures and poses.
Also, (Blender) armature objects are now copied instead of shared between
BL_ArmatureObjects to avoid race conditions. Also, due to the armature copy,
shape key drivers need a bit of extra fiddling to get the correct armature copy.

Initially OpenMP was used for threading, but then BLI_task was used due to being
less compiler dependent.

This commit also places time spent on skinning updates in the Animation
profiler category (was previously under the Rasterizer category).
2014-04-06 16:30:59 -07:00
Mitchell Stokes
df9d6737b9 BGE code cleanup: Removing OpenGL and bf_gpu code from KX_LightObject
The ultimate goal is to only allow the rasterizer to handle OpenGL and bf_gpu
calls. This commit creates a RAS_ILightObject interface and a RAS_OpenGLLight
implementation.
2014-03-27 22:32:06 -07:00
Campbell Barton
5621e63d36 Code cleanup: duplicate headers 2014-02-14 10:55:38 +11:00
Daniel Stokes
e9e08a1d12 Game Engine: Level of detail support and tools
Levels of detail can be added and modified in the object panel. The object
panel also contains new tools for generating levels of detail, setting up
levels of detail based on object names (useful for importing), and
clearing an object's level of detail settings. This is meant as a game
engine feature, though the level of details settings can be previewed in
the viewport.

Reviewed By: moguri, nexyon, brecht

Differential Revision: http://developer.blender.org/D109
2013-12-17 17:03:27 -08:00
HG1
406289497f Fix T37636: double added pyattr_get_lights 2013-11-27 08:42:41 +11:00
Mitchell Stokes
0f32bc49ec Fix T37171: Camera parented to a bone doesn't move with the bone, unless another object is parented too
Armatures used to check if any of their meshes were culled to see if they needed
to be updated. However, this meant armatures with no meshes would never update,
since non-mesh objects are always considered culled. Instead, if a non-culled
child was not found, we now check to see if the armature contained only
non-mesh objects. If this is the case, always update the armature. If this
becomes a problem, we can look into being able to cull non-mesh objects.
2013-11-18 14:52:07 -08:00
Campbell Barton
7874447e4a code cleanup: typo and warning when openmp's disabled. 2013-11-05 21:59:30 +00:00
Campbell Barton
9e2beaa1e2 bge builds again without bullet. 2013-11-05 06:19:19 +00:00
Mitchell Stokes
be114086f2 BGE: The recent physics cleanup was using KX_GameObject::GetParent() with out calling parent->Release(). Since GetParent() does an AddRef(), this was causing a leak, which resulted in Zombie Object errors. 2013-11-04 19:22:52 +00:00
Mitchell Stokes
b90de0331d BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code.
This is a squashed commit of the following:
    BGE Physics Cleanup: Fix crashes with LibLoading and replication. Also fixing some memory leaks.
    BGE Physics Cleanup: Removing KX_IPhysicsController and KX_BulletPhysicsController.
    BGE Physics Cleanup: Moving the replication code outside of KX_BlenderBulletController and switching KX_ConvertPhysicsObjects to create a CcdPhysicsController instead of a KX_BlenderBulletController.
    BGE Physics Cleanup: Getting rid of an unsued KX_BulletPhysicsController.h include in KX_Scene.cpp.
    BGE Physics Cleanup: Removing unused KX_IPhysicsController and KX_BulletPhysicsController includes.
    BGE Physics Cleanup: Removing m_pPhysicsController1 and GetPhysicsController1() from KX_GameObject.
    BGE Physics Cleanup: Remove SetRigidBody() from KX_IPhysicsController and remove GetName() from CcdPhysicsController.
    BGE Physics Cleanup: Moving Add/RemoveCompoundChild() from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: Removing GetLocalInertia() from KX_IPhysicsController.
    BGE Physics Cleanup: Making BlenderBulletCharacterController derive from PHY_ICharacter and removing CharacterWrapper from CcdPhysicsEnvironment.cpp. Also removing the character functions from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetOrientation(), SetOrientation(), SetPosition(), SetScaling(), and GetRadius() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing GetReactionForce() since all implementations returned (0, 0, 0). The Python interface for KX_GameObject still has reaction force code, but it still also returns (0, 0, 0). This can probably be removed as well, but removing it can break scripts, so I'll leave it for now.
    BGE Physics Cleanup: Removing Get/SetLinVelocityMin() and Get/SetLinVelocityMax() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing SetMargin(), RelativeTranslate(), and RelativeRotate() from KX_IPhysicsController.
    BGE Physics Cleanup: Using constant references for function arguments in PHY_IPhysicsController where appropriate.
    BGE Physics Cleanup: Removing ApplyImpulse() from KX_IPhysicsController.
    BGE Physics Cleanup: Removing ResolveCombinedVelocities() from KX_IPhysicsController.
    BGE Physics Cleanup: Accidently removed a return when cleaning up KX_GameObject::PyGetVelocity().
    BGE Physics Cleanup: Remove GetLinearVelocity(), GetAngularVelocity() and GetVelocity() from KX_IPhysicsController. The corresponding PHY_IPhysicsController functions now also take Moto types instead of scalars to match the KX_IPhysicsController interface.
    BGE Physics Cleanup: Moving SuspendDynamics, RestoreDynamics, SetMass, GetMass, and SetTransform from KX_IPhysicsController to PHY_IPhysicsController.
    BGE Physics Cleanup: PHY_IPhysicsEnvironment and derived classes now use the same naming scheme as PHY_IController.
    BGE Physics Cleanup: PHY_IMotionState and derived classes now use the same naming convention as PHY_IController.
    BGE Phsyics Cleanup: Making PHY_IController and its derived classes follow a consistent naming scheme for member functions. They now all start with capital letters (e.g., setWorldOrientation becomes SetWorldOrientation).
    BGE Physics Cleanup: Getting rid of KX_GameObject::SuspendDynamics() and KX_GameObject::RestoreDynamics(). Instead, use the functions from the physics controller.
    BGE: Some first steps in trying to cleanup the KX_IPhysicsController mess. KX_GameObject now has a GetPhysicsController() and a GetPhysicsController1(). The former returns a PHY_IPhysicsController* while the latter returns a KX_IPhysicsController. The goal is to get everything using GetPhysicsController() instead of GetPhysicsController1().
2013-11-04 19:22:47 +00:00
Mitchell Stokes
fb94a53978 BGE Rasterizer Cleanup: Cleaning up some includes. 2013-11-04 19:22:10 +00:00
Mitchell Stokes
cf9fe8f329 BGE Rasterizer Cleanup: Removing RAS_IRenderTools and moving the functionality to RAS_IRasterizer. RAS_OpenGLRasterizer is a bit of a mess now with references to Ketsji and other modules it shouldn't be accessing. 2013-11-04 19:21:07 +00:00
Campbell Barton
47c23750e8 style cleanup: indent/whitespace 2013-08-19 01:48:44 +00:00
Mitchell Stokes
82c845425f BGE: Adding partial support for LibLoaded lights with GLSL materials.
Any GLSL materials loaded after lights are LibLoaded will now use the lights in
heir shaders. This includes materials loaded from the same scene as the LibLoaded
lights. We could later add a new flag to LibLoad to recompile all existing shaders,
but this commit should offer a lot more flexibility as is.
2013-08-17 04:37:25 +00:00
Mitchell Stokes
19dee5e413 BGE: Adding animation culling. Armature objects will only have their poses updated if their children meshes have not already been culled. Regular object animations will always be updated since they are cheap. 2013-07-09 20:50:15 +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
1e64732d52 BGE: Fix for [#34781] "bge.texture.ImageRender does not show Font object" reported by Monster.
This fix is mostly based off of HG1's patch from the bug report, which had ImageRender::Render() call KX_KetsjiEngine::RenderFonts(). However, I have moved RenderFonts() from KX_KetsjiEngine to KX_Scene where all of the other font and rendering functions are. The real fix for this mess would be to not have ImageRender::Render() have so much duplicate code from KX_KetsjiEngine::Render(), but that's a code cleanup problem for another day.
2013-06-20 03:50:02 +00:00
Mitchell Stokes
bb7b04bd94 BGE: A little bit of cleanup:
* Removing KX_Scene::RemoveAnimatedObject() since KX_Scene::NewRemoveObject() is already handling this.
  * Don't create a new BL_ActionManager when replicating an object. Just set m_actionManager to NULL and let KX_GameObject::GetActionManager() allocate a new BL_ActionManager when one is needed.
  * Use KX_GameObject::GetScene() instead of KX_GetActiveScene() in KX_GameObject::GetActionManager() to make sure we're using the object's scene instead of one where Python might currently be running from. This could avoid potential issues with playing actions for objects in other scenes.
2013-05-14 22:52:10 +00:00
Campbell Barton
0874237358 code cleanup: bge warnings 2013-04-04 23:16:23 +00:00
Campbell Barton
64d161de87 style cleanup:
also rename mesh_getVertexCos() --> BKE_mesh_vertexCos_get() to match curve function.
2013-03-26 07:29:01 +00:00