Commit Graph

455 Commits

Author SHA1 Message Date
Sergej Reich
6fe5b3be38 Fix T37673: Ray casting could fail with 0 collision margins
Use bullet's old method of doing ray casts to stay compatible with old
files. It's faster but a bit less accurate.
2014-01-28 08:31:56 +01:00
Campbell Barton
a5606fadbb Code Cleanup: remove object arg to CDDM_from_mesh mesh_create_derived 2013-12-26 08:27:08 +11:00
Mitchell Stokes
eba07b77da Fix T37566: KX_GameObject.resumeDynamics() was not properly restoring collision groups and masks. 2013-11-29 14:32:56 -08:00
Mitchell Stokes
c73f82b6f0 Fix T37040: Removing vehicles in BGE causes a crash
The vehicle constraint is now properly removed if bge.constraints.removeConstraint()
is used or the object is deleted. This also fixes a memory leak with the
vehicle wrapper.
2013-11-18 09:37:58 -08:00
Mitchell Stokes
537f28fc0e Fix T37325: applyRotation() wasn't working correctly on rigid bodies in the game engine.
During the physics cleanup/refactor, the rotation matrix in
CcdPhysicsController::RelativeRotate() became transposed.
2013-11-17 16:04:26 -08:00
Mitchell Stokes
5cd28bbe80 BGE: Fix for #37335 "Moving the camera with a key (after the recent BGE cleanup commits) now crashes the game" reported by Ace Dragon.
CcdPhysicsEnvironment->GetCharacterController(); was missing a NULL check.
2013-11-06 19:40:37 +00:00
Bastien Montagne
93de84f267 Fix for recent BGE commits, when building with c++ guardedalloc. 2013-11-04 22:22:54 +00:00
Mitchell Stokes
b792ad2b46 BGE Physics Cleanup: Fixing an error that GCC didn't catch. 2013-11-04 19:23:00 +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
Daniel Stokes
017d7b5447 BGE fix [#21488] Pumpkin in Gamekit Tutorial flips upside down
A reference was being grabbed when a copy was wanted.
2013-07-24 00:32:26 +00:00
Campbell Barton
fb92835819 bge: de-duplicate cleanup code for empty mesh error case 2013-07-23 10:59:29 +00:00
Daniel Stokes
23dccfadf0 Bge fix [#33016] Blender crashes when I start the game engine
Caused by a bit of a disconnect from the BGE mesh and BMesh.
2013-07-19 22:11: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
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
Mitchell Stokes
7ba339ad32 BGE: Adding back the virtual destructor to PHY_IPhysicsController, which was accidentally removed in r54807. 2013-02-24 18:48:57 +00:00
Mitchell Stokes
ed1d215cea BGE: Removing the source files for the PHY interfaces since they just contained virtual destructors. This means we had license and doc blocks for 3 lines of code, which seemed silly. This also means that ge_phys_common no longer needs to be built as a library. I tested this with CMake and SCons using GCC; hopefully this doesn't break other systems. 2013-02-24 07:09:39 +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
Jens Verwiebe
074565330d Fix scons compile 2013-02-21 19:23:41 +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
f6a110d6ea BGE: Committing patch [#32697] "New BGE gravity API" by HG1.
This patch adds a gravity attribute to KX_Scene.
2012-11-10 03:11:18 +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