-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bullet physics #1246
Bullet physics #1246
Conversation
i'm waiting for quick, general review of code then i'll continue work on it |
anyone has anything to say about this project? What should be added/changed to marge it? |
I've given your changes a very quick skim. API stuff:
However, for the code itself, here are some recommendations for basic improvements:
Generally:
|
IMHO, first fixing the other PR would be nice(the gtasa collision customization), because that also fixes setScale to resize the collision which is neat. |
Someone smart, we need idea how to sync this!!!! I have few solution for it:
Depends on distance from element to rigid body, frequency of synchronization should change with option to change behaviour. |
test 2
# Conflicts: # Server/mods/deathmatch/StdInc.h # Server/mods/deathmatch/logic/lua/LuaCommon.h # Shared/data/MTA San Andreas/MTA/locale/en_US/client.pot
# Conflicts: # Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h
Can you show real usage for this feature? |
don't have any more realistic examples yet, but i'm since few days working on feature branch to be able later to just create prs out of it. Example real examples that don't need to completly revamp gtasa collisions ere for example:
following examples are not that hard to implement, maybe i will try make some of them as a demo using feature branch i'm working on |
Today there was a discussion on dev discord, that i think is valuable for putting a few things into perspective, should CrosRoad95's large PR's like this and V8 engine turn out to not get merged. I can very well relate to devs that are hestitant, and dont want to, as they say, burn their fingers on it The discussion: https://imgur.com/a/seD0hqQ |
Adds bullet physics engine to mta.
Plan changed.
Initial pr ( this pr ) will contain:
physicsCreateBoxShape, physicsCreateRigidBody, physicsCreateStaticCollision, physicsGetDebugLines + destroyElement, setElementPosition, setElementRotation support for rigid body and static collision
tests v1.zip
More details at mta development discord
More info
= SHERED = physics-box-shape physicsCreateBoxShape( Dimensions size ) - creates box, cube shape. Minimum size of each dimension: 0.0001, maximum: 8196 physics-rigid-body physicsCreateRigidBody( physics-shape shape, RigidBodyOptions options ) - spawns a rigid body with given options, when spawned in air, it will immidently starts falling. Shape must be convex ( see below ). In future: eg.: some types of triangle mesh will not accepted, but compound-shape will even technically is not convex physics-static-collision physicsCreateStaticCollision( physics-shape, Vector3 position, Vector3 rotation ) - spawns static collision, it will not affected by gravity, always stay in one place (like a platform) table physicsGetDebugLines( Vector3 position, float radius ) - returns table {{fromX, fromY, fromZ, toX, toY, toZ, color}, ...} with collision wireframe at given position and radius. Send to client and loop to see current state of simulation. Color indicate current state of rigid body.
= CLIENT ONLY =
void physicsDrawDebug() - renders all debug lines, use in onClientRender
= Types =
RigidBodyOptions - table with accepted keys: {["mass"] = float, ["localInertia"] = Vector3, ["centerOfMass"] = Vector3, ["position"] = Vector3, ["rotation"] = Vector3}
Dimensions- can be x,y,z, or one number with all dimensions
= Hierarchy, type description:
physics-element - base of any physics element
physics-world-element : physics-element - element that has position and rotation
physics-shape : physics-element - base of all physics shape
physics-convex-shape : physics-shape - base of all convex shape
physics-box-shape : physics-convex-shape - box shape
physics-rigid-body : physics-world-element - shape affected by gravity ( eg: car, player, ball, some gta models )
physics-static-collision : physics-world-element - non moving collision ( eg: terrains, buildings, roads :D )
=== Extras:
physics-rigid-body and physics-static-collisions is always made of single physics-shape
treat physics-shape as a instance, can be used in multiple collisions and compound shape ( in future )
=== extended functionality of already existing functions:
set/getElementPosition, set/getElementRotation, destroyElement, now accept physics-world-element
getUserdataType - returns physics element type
set/getElementVelocity accept physics-rigid-body
=== important:
destroyElement side effect:
due to hierarchy style of physics elements, if you destroy shape, all references ( rigid-bodies and static-collisions ) get destroyed too, see example below
=== nice to know:
samples:
Additional test script that tests rotation confirms that setElementRotation working exact the same for objects and bullet physics static collisions ( rigid body using same logic ):