upeppe / physics.inc Goto Github PK
View Code? Open in Web Editor NEWphysics.inc - SA-MP library to simulate 2D and 3D physics (realistic movements, collisions, and more)
physics.inc - SA-MP library to simulate 2D and 3D physics (realistic movements, collisions, and more)
Hi uPeppe.
How can I use the include with CreateDynamicObject?
Due to the confusion with SA-MP forums deleting the topic (sigh.. yet another topic), I didnt realize my physics.inc file was ancient. Fortunately, I found the new forum topic on bugershot forums. I tried looking through the commits on this repository, but some of the old functions I use aren't even on here, even dating back to 0.1! I'm trying to update my physics.inc to the latest. I've had pretty good luck so far (GetHandle -> GetObject, SetHandle -> SetObject). I am on the last function change, but I can't seem to find a suitable replacement for it, without having to restructure the whole code that uses physics.
physics.old.inc (unknown version)
#define PHY_GetHandleObject(%1) (PHY_Object[%1][PHY_DynamicObject])
It seems this old include uses PHY_DynamicObject, to store the object id internally. Starting with the repository, this function was completely removed.
I've attached the unknown physics.old.inc include to help determine what version it is; and further pinpoint what changes need to be made to make it compatible with the latest version.
I've also attached snippets from functions throughout the script that contain this function, in order to better understand how the module utilizes this include.
Here are the lines in the code which contain the function: 28, 66, 107, 141, 164, 272, 290, 309, 337, 493, 522, 539
It wouldn't exactly be a problem.
But the collision with vehicles is still missing.
Collision of objects with vehicles to make many very cool mini-games.
Can you attach this to your project?
sorry for my bad english
Codes like this could be optimized significantly using VectorSize
Codes below seems to be very slow according to performance profiler results..
stock IsObjectInSphere(objectid,Float:x,Float:y,Float:z,Float:radius2) { new Float:x1,Float:y1,Float:z1,Float:tmpdis; GetObjectPos(objectid,x1,y1,z1); tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+ floatpower(floatabs(floatsub(y,y1)),2)+ floatpower(floatabs(floatsub(z,z1)),2)); // if(tmpdis < radius2) return 1; return 0; }
to
`IsObjectInSphere(objectid, Float:x, Float:y, Float:z, Float:radius2)
{
new Float:x1, Float:y1, Float:z1;
if (GetObjectPos(objectid, x1, y1, z1)) // object exists
{
return VectorSize(x1-x, y1-y, z1-z) <= radius2;
}
return 0;
}`
a more optimized version
Perhaps you could consider doing major optimizations on the scripts so it performs better
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.