Commit Graph

349 Commits

Author SHA1 Message Date
Campbell Barton
9cf6e305a9 split bge includes for scons onto their own lines (for easier merging) 2013-05-29 21:56:55 +00:00
Sergej Reich
b0d6c93ab6 game engine: Use bullet's default contact processing theshold
Blender's old default of 1 was too small here.
Now we don't override the default.
If it's really needed to use a smaller value here, the property should
be first exposed in the ui, but don't think this is necessary.

Fixes [#35076] Dynamic objects have periodic glitch in velocity when on an incline
2013-04-25 19:50:54 +00:00
Campbell Barton
502ddd3128 code cleanup: warnings and style. 2013-04-12 00:50:40 +00:00
Campbell Barton
8c1cb10cfd code cleanup: unused vars, make other vars static. 2013-04-10 22:49:50 +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
Campbell Barton
92d7955d13 fix for struct definition building with msvc2008 and some style cleanup. 2013-03-24 01:19:55 +00:00
Sergej Reich
643b0be4cb bullet: Update to current svn, r2636
Apply patches in patches directory, remove patches that were applied
upstream.
If you made changes without adding a patch, please check.

Fixes [#32233] exporting bullet format results in corrupt files.
2013-03-07 17:53:16 +00:00
Dalai Felinto
0945c3b43b fixing typo in include (report and patch by Jochen Schmitt) 2013-02-22 17:45:04 +00:00
Sergej Reich
c586159438 game engine: Revert to using regular gimpact for mesh shapes
This reverts part of r53019.
While the compound shape trick works well in some cases, overall it's
much slower and even causes crashes under certain conditions.

We could make this and option and fix the crashes, but it's better to
implement convex decomposition anyway so just reverting for now.

Fixes [#34353] Ray cast on Triangle mesh bounded Rigid Body Object causes blender crash to desktop without error.
2013-02-22 14:47:11 +00:00
Mitchell Stokes
815e00917d BGE cleanup: Removing the PHY__Vector classes and replacing them with MT_Vectors. The PHY__Vectors didn't offer anything (not even any real abstraction) and they required annoying MT_Vector <-> PHY_Vector conversions all over the place. No functional changes. 2013-02-21 18:30:11 +00:00
Mitchell Stokes
8eabdad3aa BGE: Fix to make KX_CharacterWrapper.jumpCount work a bit smoother. Previously jumpCount was only getting reset to 0 if the character was on the ground while jump() was being called. This works alright internally for double jumping, but it made things awkward if a user wanted to check jumpCount before calling jump() (i.e., before jumpCount was updated). 2013-02-09 06:32:17 +00:00
Campbell Barton
9da4cab9fd style cleanup: comment format 2013-02-02 04:48:21 +00:00
Mitchell Stokes
9191b783bb BGE: Some various changes to make moving the character physics type easier:
* Undoing the previous applyMovement() changes for characters. This was causing bugs for the Motion Actuator.
  * Creating a Character Motion type for the Motion Actuator with specific controls for characters. This includes moving, rotating and jumping.
  * Adding a KX_CharacterWrapper.walkDirection to set the character's direction and speed.

Note, this also resolves the following bugs:
[#33585] "Setting dLoc of motion actuator [0,0,0] via python won't stop object" reported by Manuel Bellersen (urfoex)
[#33503] "Character physics type won´t accept more than one motion anymore" reported by Mr Larodos
2013-01-30 05:55:17 +00:00
Campbell Barton
69ddc5eb99 make bullet optional again 2013-01-23 07:26:39 +00:00
Campbell Barton
c2839bfe76 add option WITH_SYSTEM_BULLET to link against the bullet installation found on the system.
Note: this doesn't work yet for everything with latest stable bullet (2.81), need to look into why and likely apply some patches upstream.
However I managed to link blender by disabling some features, likely it can be made to work without too much trouble.
2013-01-03 00:23:52 +00:00
Mitchell Stokes
18f134304c BGE: Adding a jumpCount to KX_CharacterWrapper. This can be used to have different logic for a single jump versus a double jump. For example, a different animation for the second jump. 2012-12-29 10:22:19 +00:00
Mitchell Stokes
4e604642de BGE: Don't set the character controller's gravity when creating the controller. The default from Bullet works much better than what we were using. 2012-12-26 01:50:01 +00:00
Mitchell Stokes
13f49f3101 BGE: Adding a maxJumps to the character controller to adjust how many jumps a character can perform before having to touch the ground. By default this is set to 1, which means a character can only jump once before having to touch the ground again. Setting this to 2 allows for double jumping. 2012-12-26 01:25:53 +00:00
Bastien Montagne
ab2c273b12 Added GPL header to sconscripts!
Also changed shebang to '#!/usr/bin/env python', this is more portable across unixes...
2012-12-17 08:01:43 +00:00
Erwin Coumans
1b37f8dca8 Hi there, it has been a while, just curious if my SVN account still works :)
This commit is an attempt to improve collisions between moving Bullet rigid bodies using (concave) triangle mesh bounds.
Instead of using Gimpact, this we create a btCompoundShape with child shape tetrahedra derived from the surface triangles.
For each triangle, we add a fourth vertex using the centroid, shifting inwards using the triangle normal.
If the centroid hits an internal triangle, we stop. The default depth could be exposed as 'advanced' setting in the user interface.
This solution will be a slower than the original/gimpact solution, but a bit more reliable. 
In the future, it is better to add HACD, convex decomposition to Blender, for moving concave meshes.
See http://kmamou.blogspot.com and the Bullet SDK's Demos/ConvexDecompositionDemo.
2012-12-15 01:01:35 +00:00
Campbell Barton
e3d3ffe746 fix [#33303] face selection masking for painting does not work with mesh with n-gon
caused by own change to how origindex is used, now if mpoly's CD_ORIGINDEX array is missing its assumes that its the original mpoly array.
2012-11-26 10:15:32 +00:00
Mitchell Stokes
f840bd4a9f BGE: This patch adds a character wrapper (similar to the already implemented vehicle wrapper) to control character physics options. Currently supported options are:
* jump() -- causes the character to jump
  * onGround -- specifies whether or not the character is on the ground
  * gravity -- controls the "gravity" that the character physics uses for the character

More options could be added (such as jump speed, step height, make fall speed, max slope, etc).
2012-11-04 20:56:02 +00:00
Campbell Barton
76ba8f017e code cleanup: remove unused transform snapping code (only use the BVH accelerated version now).
and quiet narrowing conversion warning between signed/unsigned int.
2012-10-30 19:27:15 +00:00
Campbell Barton
00acdb6292 remove CD_POLYINDEX customdata layer:
reported as [#29376] BMESH_TODO: remove tessface CD_ORIGINDEX layer

for a single mesh there could be 3 origindex mappings stored, one on the polygons and 2 on the tessfaces.
(CD_POLYINDEX and CD_ORIGINDEX).

as Andrew suggests, now tessfaces (which are really a cache of polygons), using origindex to point to polygons on
the same derived mesh, and polygons only store the original index values.
2012-10-30 19:20:17 +00:00
Mitchell Stokes
3bf9bb3b13 BGE: Adding support for Bullet's collision masks. Each object now has a collision mask and a collision group. Object A and object B collide if object A's groups is in object B's mask and object B's group is in object A's mask. In other words, the group defines what the object is (collision wise) and the group defines what the object can collide with.
The majority of this patch was provided by Kupoman with some edits from me and heavy testing by z0r.
2012-10-30 15:44:16 +00:00
Campbell Barton
ddc2dbc2a4 style cleanup 2012-10-22 08:15:51 +00:00
Campbell Barton
bc8f602601 style cleanup 2012-10-20 18:46:57 +00:00
Campbell Barton
4d4664d98f code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
Campbell Barton
3a947cf537 code cleanup: remove redundant casts 2012-10-14 08:49:01 +00:00
Campbell Barton
97d4fb4161 code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
Mitchell Stokes
244ce92dbd BGE: Setting up the RAS_ICanvas interface as the primary way to alter the OpenGL
viewport. This helps to eliminate OpenGL calls in weird places like the physics
code and to reduce glGet calls, which are expensive.

There should be no functional changes (except maybe a very slight speed improvement).
2012-10-08 03:28:11 +00:00
Mitchell Stokes
9fcb7cd520 BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves. This reduces issues with tunneling (the character going through other objects). 2012-10-07 19:10:03 +00:00
Campbell Barton
2fb8292005 style cleanup 2012-09-16 04:58:18 +00:00
Mitchell Stokes
47c7266522 Accidentally did a commit when I wanted to revert... (ignore my last revision) 2012-08-08 01:29:20 +00:00
Mitchell Stokes
843b45cafa 2012-08-08 01:24:48 +00:00
Mitchell Stokes
958dc02774 Fix for [#32270] "Removing a Character object from the scene causes a crash." reported by me. The character's action wasn't being removed from the dynamics world when the character controller was. 2012-08-05 22:31:55 +00:00
Sergej Reich
ce90041239 game engine: Fix CcdPhysicsEnvironment functions that accessed m_solverInfo
The functions had no effect because m_solverInfo wasn't used anywhere.
Now we get the solver info from the dynamics world directly instead of using our own copy.
2012-08-01 17:59:32 +00:00
Mitchell Stokes
f5d643e950 BGE: Fixing a memory leaked caused by the character controller (CcdPhysicsController::m_characterController was not getting freed). 2012-07-29 00:34:18 +00:00
Mitchell Stokes
188da23192 Fix for [#32185] "Incorrect physics for LibLoaded dupligroups" reported by Daniel Stokes (Kupoman). I'm not sure if this is the "correct" fix, but it at least allows all physics objects to be evaluated at least once by the new environment. This allows the new environment to sync up physics shapes for static objects. 2012-07-26 09:35:52 +00:00
Mitchell Stokes
1f9adff26f Fix for a crash caused by ReplaceMesh changing an objects physics shape. CcdShapeConstructionInfo::UpdateMesh() would change the CcdShapeConstructionInfo's m_meshObject, but didn't change m_meshShapeMap, which means the CcdShapeConstructionInfo object's destructor would not find it's m_meshObject in the m_meshShapeMap. This leaves some nasty dangling pointers laying around which caused issues if the scene was re-run, or the scene was changed to one that also had the mesh.
Note: This fix could cause other issues with shared physics meshes. In general, we may want to re-evaluate how we handle updating potentially shared physics meshes.
2012-07-10 02:05:06 +00:00
Mitchell Stokes
9d73cbf2c4 As a response to issue [#28483] "Enable/Disable Rigid Body actuator do nothing" reported by Jean-Francois Gallant (pyroevil), I'm adding preliminary support to enable and disable rigid body physics on dynamic objects. This is can be done via the Edit Object Actuator or through KX_GameObject.enableRigidBody() and KX_GameObject.disableRigidBody(). Thanks to Sergej Reich for his help with the patch. 2012-07-09 04:57:21 +00:00
Mitchell Stokes
4ff0efd5a2 Fixing a memory leak when using Bullet's btGImpactMeshShape for triangle meshes (e.g., rigid bodies). The physic controller's free was only handling the case where regular triangle meshes were used. 2012-07-08 23:15:26 +00:00
Mitchell Stokes
9af3e3bb9b Fixing a memory leak introduced by the Character Physics type patch: a new btGhostPairCallback was being created, but never freed. 2012-07-08 20:05:40 +00:00
Mitchell Stokes
8ce864784c Fix for [#31701] "radar causes collision" reported by Markus Rietz (afeature).
The problem was that the physics shapes for the near and radar sensor were getting turned into characters because CcdConstructionInfo::m_bCharacter was defaulting to true. Now it defaults to false and is explicitly set to true for only Character physics types.
2012-07-08 05:00:16 +00:00
Campbell Barton
cc0784c1b9 optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
Campbell Barton
f5f25b81e8 style cleanup:
also fix for building ghost test and fix double free in one of the tests
2012-06-17 09:58:26 +00:00
Campbell Barton
cb0b3558af style cleanup 2012-06-05 22:12:17 +00:00
Benoit Bolsee
58bc424b3c BGE #30734: add support for physics linear and angular thresholds and deactivation time from python and GUI.
========================
The linear and angular thresholds set the speed limit (in m/s) and rotation limit (in rad/s)
under which a rigid body will go to sleep (stop moving) if it stays below the limits for a 
time equal or longer than the deactivation time (sleeping is disabled is deactivation time is 
set to 0).
These settings help reducing the processing spent on Physics during the game.

Previously they were only accessible from python but not working because of a bug. 
Now the python functions are working and the settings are available in the Physics panel
of the World settings when using the Blender Game render engine.

Python API:
  import PhysicsConstraints
  PhysicsConstraints.setDeactivationLinearTreshold(float)
  PhysicsConstraints.setDeactivationAngularTreshold(float)
2012-05-29 20:30:33 +00:00
Benoit Bolsee
dfc19a1ff7 BGE patch #28476: Character object physics type
===============================================
This patch adds a new "Character" BGE physics type which uses Bullet's btKinematicCharacter for simulation instead of full-blown dynamics. It is appropiate for (player-controlled) characters, for which the other physics types often result unexpected results (bouncing off walls, sliding etc.) and for which simple kinematics offers much more precision.

"Character" can be chosen like any other physics type in the "Physics" section of the properties window. Current settings for tweaking are "Step Height" (to make the object automatically climb small steps if it collides with them), "Fall Speed" (the maximum speed that the object can have when falling) and "Jump Speed", which is currently not used.

See http://projects.blender.org/tracker/?func=detail&atid=127&aid=28476&group_id=9
for sample blends and a discussion on the patch: how to use it and what influences the behavior of the character object.

Known problem: there is a crash if the "compound" option is set in the physics panel of the Character object.
2012-05-28 21:36:29 +00:00
Campbell Barton
b374d9b20f fix for CcdPhysicsController::RelativeRotate reading 2 values past the input.
note: this function isn't used but may as well fix.
2012-04-24 01:52:59 +00:00