Groups for entity physics

Post Reply
User avatar
Blocky_Player
Member
Posts: 14
Joined: Thu Apr 20, 2023 09:18
GitHub: Blocky-Player
In-game: mr_block
Location: The present

Groups for entity physics

by Blocky_Player » Post

This is not a suggestion, but I want to know if it is possible and, if so, how to do it. If you're a Dev and this isn't already in the game, please add it :)

There are groups for nodes, items and tools. For reference, I am trying to make a mod that allows the player to easily edit the physics properties of vehicles and easily register their own vehicles with their own properties


First: Are there groups for entities at all? What properties does Minetest support for entity physics? Are there such things like weight, acceleration.

secondly: Is it possible to make groups that change the physics of nodes or entities? something like

Code: Select all

falling_node = 1
but with more properties (things like weight, buoyancy - , acceleration, etc.) that can be used for anything.

For example, if I make a groups called 'car_heavy' and I want to use a weight property in the group, I would have to pre-define the weight property? or would I define with the group? I would also have to set gravity, mass, force & acceleration and put those in a formula to calculate the weight somehow. Another thing I would have to do is when the player presses a key or something in a formspec, it applies the formula.

After I have finished with the weight property, I could use it for the group and therefore the car. Also can I use algebra to calculate more physics, like

Code: Select all

weight = w
, mass = w/g?

Thanks and sorry for the amount of questions :D
Blocky_Player | My prized Minetest packages Epic Combat| More Stones| Happy Land

User avatar
Blockhead
Member
Posts: 1623
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Groups for entity physics

by Blockhead » Post

In direct answer to your main question: No, entities do not have groups built into them as an engine feature - see the docs. You can put any fields you like into the definition of the entity though, with fields that are prefixed with an underscore as the docs say.

What you are proposing is effectively a specialised entity API and some particular implementation details. Minetest's developers have always insisted we don't need those kinds of things in C++. The most popular specialised entity APIs are mob API, like mobs_redo or Creatura. We already have some vehicle APIs, such as D00Med's Vehicles and Vehicle Mash (those mods provide vehicles and also APIs for registering more vehicles).

And in answer to the question of using entities groups: I think that it is better to provide templates/presets for a full set of fields in your API, and to have an API that mimics the ones that Minetest uses. So you would have your own registration function like physics_entities.register_physics_entity(name, def), which eventually calls minetest.register_entity.

Full customisability works better than shoehorning features into groups. This template + full field customisation approach is how most specialised-entity-APIs do it: Advtrains, Mobs Redo, Creatura and Vehicle Mash. Others tend to just have you use minetest.register_entity directly and provide some useful functions for your entity to use.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Blocky_Player
Member
Posts: 14
Joined: Thu Apr 20, 2023 09:18
GitHub: Blocky-Player
In-game: mr_block
Location: The present

Re: Groups for entity physics

by Blocky_Player » Post

ok, thanks. But the thing is I would also have to create my own physics API with equations and such. I would have to use engine (Irrlicht) code for that maybe. I don't think Minetest's LUA API is good enough when it comes to entities and physics.
Blocky_Player | My prized Minetest packages Epic Combat| More Stones| Happy Land

User avatar
Blockhead
Member
Posts: 1623
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Groups for entity physics

by Blockhead » Post

Blocky_Player wrote:
Sun Apr 30, 2023 01:12
ok, thanks. But the thing is I would also have to create my own physics API with equations and such. I would have to use engine (Irrlicht) code for that maybe. I don't think Minetest's LUA API is good enough when it comes to entities and physics.
We already have a vector library, though I suppose for physics it would also be good to have matrices and maybe simultaneous equation algorithms. You can implement those in Lua and it may not be too much slower than the overhead of calling into C++ though, unless the C++ can use SIMD instructions that Lua can't. You'd have to benchmark both implementations.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Blocky_Player
Member
Posts: 14
Joined: Thu Apr 20, 2023 09:18
GitHub: Blocky-Player
In-game: mr_block
Location: The present

Re: Groups for entity physics

by Blocky_Player » Post

alright, thanks for the help. I will definitely research this further and look at the code of different vehicles mods. :)
Blocky_Player | My prized Minetest packages Epic Combat| More Stones| Happy Land

Astrobe
Member
Posts: 571
Joined: Sun Apr 01, 2018 10:46

Re: Groups for entity physics

by Astrobe » Post

Blockhead wrote:
Sun Apr 30, 2023 02:30
Blocky_Player wrote:
Sun Apr 30, 2023 01:12
ok, thanks. But the thing is I would also have to create my own physics API with equations and such. I would have to use engine (Irrlicht) code for that maybe. I don't think Minetest's LUA API is good enough when it comes to entities and physics.
We already have a vector library, though I suppose for physics it would also be good to have matrices and maybe simultaneous equation algorithms. You can implement those in Lua and it may not be too much slower than the overhead of calling into C++ though, unless the C++ can use SIMD instructions that Lua can't. You'd have to benchmark both implementations.
You mentioned that the dev team is opposed to the idea, however sliding and bouncing do apply to mobs/entities. Granted, it's actually implemented in builtin, not in the engine, but that should really be considered the vestibule of the engine. It's not often that a mod "monkey-patches" it, I think.

IMHO usual forces (gravity, friction, archimedian push in liquids and wing lift if possible) are most likely implemented in all of the mob/vehicle APIs, so they are very good candidate for native support (I'm pretty confident there's no overhead issue, the engine can do the physics before calling mob_step() like it does with collision detection).

Physics are universal laws; even though some games might pretend some of these forces don't exist for gameplay reasons (and that can be supported with sentinel values for related properties or whatever fits). The engine already has the notions of position, speed and acceleration, it already does apply gravity and surface friction to player entities, so it already kind of knows that stuff. To put it harshly, physics is already half-baked in the engine. I can tell without even having heard them, that the reasons for not baking the other half are weak unless you suggest to remove the first part from the engine.

A native implementation could use SIMD (luaJIT has had a support feature request for vectors open till 2015, for context) or even GPU or even Nvidia's PhysX for instance (IOW, the API will allow to use the best available option on the players' rig, even if in a first step it's just STL vectors or whatever).
My game? It's Minefall.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Groups for entity physics

by Wuzzy » Post

The only groups for entities that exist are armor groups but those are special as they affect damage.

I agree it would be a good idea that entities had regular groups as well, it would greatly simplify coding.

But I'm against the idea of using entity groups to affect physics. This stuff is supposed to be coded directly in Lua, and I think that's not really what groups should be used for. I think, regular entity groups should be just be a helper for coders with no special features.

However, I still think the physics helper functions we have right now are very weak and need serious improvement. For example, it is not possible to create an entity that moves in a circle and not go off the track immediately for clients that suffer from lag. While you can obviously trivially code the circle path in Lua, you can't fix the lag in Lua. Movement prediction is way too limited for stuff like that.

This is why the trains of Advanced Trains go (visually) off the rails so often if you're playing online.

Let's be real: Entities still kinda suck. :-(

User avatar
Blocky_Player
Member
Posts: 14
Joined: Thu Apr 20, 2023 09:18
GitHub: Blocky-Player
In-game: mr_block
Location: The present

Re: Groups for entity physics

by Blocky_Player » Post

Wuzzy: But I'm against the idea of using entity groups to affect physics. This stuff is supposed to be coded directly in Lua
My intention is to create an API sorta thing that makes it easy to create things with different physics properties. Like Blender geometry nodes, if you've ever used those before (I've watched too many tutorials and still don't understand them entirely).

Just like nodes but with entities. The closest things we already have is

Code: Select all

falling_node = 1
I just want it to be more specific but easy to use; the ability to use pre-defined properties or define your own for a specific vehicle.

entities do suck, maybe it is possible to override the current system (I think I'm going off the rails, like Advtrains :D)
Blocky_Player | My prized Minetest packages Epic Combat| More Stones| Happy Land

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 10 guests