Popular Post CrosRoad95 Posted October 6, 2019 Popular Post Share Posted October 6, 2019 (edited) For long time i considered to do something with physics in mta. For now doing even simplest things such falling box, tree on flat area looks cartoonish. In my history of i saw few attempts of doing simple physics, mostly it was in closed area without bigger interactions with poor performance due you just can't calculate collision in other way than processLineOfSight, isLineOfSightClear or read directly .col file as Tederis did. I started with something to render things, thats how FBX https://github.com/multitheftauto/mtasa-blue/pull/1093 to bypass default rendering to handle future i'll introduce in future. That's how bullet physics project born, first idea how to use react physics, works simillar but is lighter and general smaller project but 0x416c69 suggested to use bullet. I'll use this topic also to prepare long list of features it contains for future copy paste to PR and wiki page The main assumption is to allow for create multiple world with completly independed simulations, get and set detailed information about current step of simulation, fully control how everything is simulated, quality of collision tests, speed and a lot more. i'm trying keep amount of functions low, because if that most stuff is packed into one function. Syntax and name of some function might change in future or along suggestions. Not all properties supports every physics element, some are only get, other set only, however most of them are set/get Current stage: I already implemented function such a: physics physicsCreateWorld() - responsible for creating new world for simulations, return element which will use later. physics-rigidbody physicsCreateRigidBody( shape-type, mixed arguments ) - creates rigid body which is use to simulation bahaviour of non-static shapes, collisions ( currently only few models in mta can do this in simple way ). physics-rigidbody physicsCreateRigidBodyFromModel( model ) - used to create rigid body directly from collision data taken from gta model. physics-static-collision physicsCreateStaticCollision( shape-type, mixed arguments ) - creates static collision which will not move at all ( it is still possible to move it by Lua script ) physics-shape physicsAddShape( shape-type, mixed arguments ) - if you create compound shape, this function let you add more shapes into static collision or rigid body bool physicsSetProperties( any physics element, physics-property, mixed arguments ) - main function to control physics, rigid bodies, static collisions, shapes. Works in simillar way as handling functions. mixed physicsGetProperties( any physics element, physics-property ) - same as above, but getting properties bool physicsDrawDebug( physics ) - use to visualization of world, must be used in render function bool physicsSetDebugMode( physics-debug-mode, enabled ) - use to turn off/on debugging features bool physicsBuildCollisionFromGTA( physics ) - used to create static collisions in specified world from original collisions, doesn't create whole world instantly, require to move player around world to load collision data. physics-constraint physicsCreateConstraint( physics, physics-rigid-body, physics-rigid-body, constraint-type, mixed arguments ) - use to connecting two or more rigid bodies into one entity bool physicsApplyForce( physics-rigid-body, vector from, vector to ) - pushing rigid body in particular point you choosed. bool physicsApplyCentralForce( physics-rigid-body, vector direction ) - apply force from central position of rigid, it's more like "accelereate", should be used more than once at the some period of time bool physicsApplyCentralImpulse( physics-rigid-body, vector direction ) - setting position from center of rigid bool physicsApplyDamping( physics-rigid-body, float force ) - i'm not sure, but it should slow down velocity and rotation of model by specified amount of units physicsApplyImpulse( physics-rigid-body, vector direction ) - i'm not sure how it works physicsApplyTorque( physics-rigid-body, vector rotation ) - same as physicsApplyCentralForce but for rotation physicsApplyTorqueImpulse( physics-rigid-body, vector rotation ) - setting rotation speed physics-properties: "mass", "position" ,"rotation", "sleepingthresholds", "restitution", "scale" "debugcolor", "filtermask", "filtergroup", "stiffness" `sleepingthresholds` means how slow rigid must move/rotate to sleep, it makes stops moving at all but still can be pushed by other rigids `restitution` bounciness, between 0-1 but accept any value above `stiffness` - for fixed constraint `filtermask` i still figuring out how it work, but should let you use 32 bit mask to set which rigid with which should collide Bullet documentation: https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf page 13 contains useful information when which shape should be used physics-constraints: "pointtopoint", "hidge", "fixed", "slider" Physics-shapes: "box", "sphere", "capsule", "cone", "cylinder", "heightfieldterrain", "compound", "trianglemesh", "convexhull" `compound` is used for constructing rigid made of various shapes Plans for future: "heightfieldterrain" shape type accept black-white texture for faster creation Support for cloths, soft bodies Media: Videos are availiable at my youtube channel https://www.youtube.com/channel/UC95MpsQ1JppDNpMvl_7c1rg screenshots and gifs of current progress: Spoiler Ray casting fixed constaraint fixed constraint scaled heightmap capsule shape cone shape cylinder shape heightfield terrain filled with spheres single sphere in heightfield terrain heightfield terrain scale and filled with spheres example usage of physicsCreateRigidBodyFromModel example usage of physicsCreateRigidBodyFromModel random spheres and boxes spreaded around world, green are sleeping one Documentation i use: https://pybullet.org/Bullet/BulletFull I'm waiting for your suggestions Topic not finishedd Edited December 21, 2020 by Tut Raycast example 13 3 Link to comment
XaskeL Posted October 6, 2019 Share Posted October 6, 2019 it's some kind of madness. I want it in mta Link to comment
Fist Posted October 10, 2019 Share Posted October 10, 2019 Is there really need physics for bullets? Render distance in MTA on its own is really terrible, as such having bullets that fall slowly wouldn't make much of sense as bullet wouldn't start falling before it would reach render distance. None the less, this looks really fun to play around with and make some cool stuff with so i could see some other use with this. Link to comment
JeViCo Posted October 19, 2019 Share Posted October 19, 2019 Awesome idea, however it sounds impossible for a single person. Since collisions are client-side, bullets, object and ped ragdolls will be asynced. It may cause additional problems in future so you have to deal with server as well. Anyway i guess it's time to go onto the next level for good old SA so good luck Link to comment
Einheit-101 Posted November 12, 2019 Share Posted November 12, 2019 Will your bullet physics increase the default GTA collision range of 300 meters? Its pretty annoying to have stuff falling through the ground when reaching the 300m distance mark. And it should be no problem for a powerful PC. Link to comment
CrosRoad95 Posted November 30, 2019 Author Share Posted November 30, 2019 for now project is frozen until first set of rendering functions will released 1 1 Link to comment
CrosRoad95 Posted February 9, 2020 Author Share Posted February 9, 2020 i started to document functions here https://wiki.multitheftauto.com/wiki/PhysicsCreateWorld and pull request here https://github.com/multitheftauto/mtasa-blue/pull/1246 i'm waiting for feedback about syntax 1 Link to comment
Shagwrath Posted April 28, 2020 Share Posted April 28, 2020 Oh man I really hope this gets added, I found these functions on accident on the wiki and I would love them to fix the issue i have modding the dynamic objects. Link to comment
Popular Post CrosRoad95 Posted December 20, 2020 Author Popular Post Share Posted December 20, 2020 I back to work on BP! I Successfully added support for multithreading, so simulation will work smooth until you get crazy. Also set of function get changed, old function has changed and new get added. Here's current progress: 5 1 Link to comment
Moderators IIYAMA Posted August 11, 2021 Moderators Share Posted August 11, 2021 Looks very cool CrosRoad. Will there also be a Serverside implementation? (Would be nice to have a {backwards compatible} module) And will it be possible to create separate environments on multiple threads? Link to comment
The_GTA Posted August 11, 2021 Share Posted August 11, 2021 That proof-of-concept Video that CrosRoad95 has created looks promising. Link to comment
Einheit-101 Posted August 11, 2021 Share Posted August 11, 2021 Really not trying to flame or whatever, but sadly i doubt that this will release ever. Also, nice to see you back, The_GTA! 1 Link to comment
The_GTA Posted August 11, 2021 Share Posted August 11, 2021 (edited) 39 minutes ago, Einheit-101 said: Really not trying to flame or whatever, but sadly i doubt that this will release ever. Also, nice to see you back, The_GTA! Com' on, man! You know I am a dreamer just like most of us here. Let our inspired people work on things they are passionate about. Since OP has created documentation and implementations already, he has a good chance to get beyond the development stage into testing stage. Maybe OP grows up in the process, becomes better and better at development. Edited August 11, 2021 by The_GTA Link to comment
Einheit-101 Posted August 11, 2021 Share Posted August 11, 2021 He already is pretty good at that, the problems are more likely his time and MTA team not implementing pull requests, especially not such big ones. It would be amazing to see it live. Link to comment
The_GTA Posted August 11, 2021 Share Posted August 11, 2021 (edited) 19 minutes ago, Einheit-101 said: He already is pretty good at that, the problems are more likely his time and MTA team not implementing pull requests, especially not such big ones. It would be amazing to see it live. I don't think we are fully aware of the risk associated with big features like this: Is the proposed API easy to learn for scripters? Has the Bullet API been properly used according to documentation, best practices? Is there any exploit inside the Bullet collision framework that could be escalated to crashes or worse? What about longterm support of this feature? Will OP be around to keep the code up-to-date? Are there any estimations about the cost/benefit tradeoffs? But maybe this is being too cruel to new feature proposals. Consider the amount of time that new content like this takes for development. Verification should take less time, if there was an elected board of experts for decisions like this. Possible Benefits: Bullet Collision is known across the internet so we could attract scripters that want more "bang for their buck" Encouragement for working on new features can be increased Edited August 11, 2021 by The_GTA 1 Link to comment
-ffs-PLASMA Posted August 11, 2021 Share Posted August 11, 2021 More interesting question would be: - Is it compatible with default SA world collision system? So I can use it with default SA map/objects without any further modifications. - If the first point is true, serversided logic will be hard to implement since server is not aware of the physical SA world. We talked about this problem in general and someone came up with a simple collision mesh of the default SA world being loaded by server to handle certain physics calculations, though kinda got lost somewhere. Link to comment
Moderators IIYAMA Posted August 11, 2021 Moderators Share Posted August 11, 2021 36 minutes ago, -ffs-PLASMA said: More interesting question would be: - Is it compatible with default SA world collision system? So I can use it with default SA map/objects without any further modifications. - If the first point is true, serversided logic will be hard to implement since server is not aware of the physical SA world. We talked about this problem in general and someone came up with a simple collision mesh of the default SA world being loaded by server to handle certain physics calculations, though kinda got lost somewhere. It doesn't appear to be making use of GTA objects. Atleast I base that on the previews. A Serverside implementation could be interesting, when you add the collisions yourself. Link to comment
The_GTA Posted August 11, 2021 Share Posted August 11, 2021 (edited) 54 minutes ago, -ffs-PLASMA said: More interesting question would be: - Is it compatible with default SA world collision system? So I can use it with default SA map/objects without any further modifications. - If the first point is true, serversided logic will be hard to implement since server is not aware of the physical SA world. We talked about this problem in general and someone came up with a simple collision mesh of the default SA world being loaded by server to handle certain physics calculations, though kinda got lost somewhere. - SA physics consist of cones, triangles, boxes and spheres. Bullet Physics supports all of those collision objects so yes. But you cannot just embed Bullet Physics into the game world without heavily patching the GTA SA game executable. Since there is engineRequestModel now I do not see the point why, you can just create a .col file for that instead. - Since GTA game physics depend on FPS, it is not recommended to perform GTA game physics calculations on the server. Loading the game world is possible if you copy the game files onto the server (every game client has the same collision files). I would find it cool if Bullet Physics enabled us to write small minigames that are not embedded into the GTA game world. Then you can perform custom time-based synchronization across all game clients through the server. Edited August 11, 2021 by The_GTA Link to comment
-ffs-PLASMA Posted August 11, 2021 Share Posted August 11, 2021 51 minutes ago, The_GTA said: Since GTA game physics depend on FPS, it is not recommended to perform GTA game physics calculations on the server. Loading the game world is possible if you copy the game files onto the server (every game client has the same collision files). I would find it cool if Bullet Physics enabled us to write small minigames that are not embedded into the GTA game world. Then you can perform custom time-based synchronization across all game clients through the server. That leads to the well known problem of syncing. How do you sync physics behaviour between clients it ultimatively depends on clients FPS? What I was refering to is make a simple collision mesh of the default SA map, load it completly or in chunks into server, but without built in GTA functions as you will quickly hit the limit. Once the server has such a navigation mesh, syncing of elements (vehicles/projectiles) could be offloaded to server for more accuracy rather than depending on clients sync. 1 Link to comment
Recommended Posts