HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Physics engine - nearing completion, need feedback.

03-15-2007, 02:43 AM#1
grim001
Well today I hit a milestone in the development of my engine; the core engine is done and now I simply need a huge list of user-end functions to add to it. I already have plenty of ideas, but I think that asking the community will result in more ideas. Besides I created this project with the idea in mind that it would be used by others. I think that a new age of WC3 mapping that includes heavy use of physics is possible now.

FAQ:
What does the engine do?
-- It allows you to create spheres that bounce off the ground and each other realistically. It also allows you to create particles with no collision.
-- It allows you to create and control these objects using an an extremely user friendly syntax.
-- It allows you to specify individual object parameters such as friction, acceleration, etc.
-- It allows you to execute functions based on events such as an object bouncing, colliding with another object, dying, or killing something.

Why would you want to create spheres?
-- Spheres can approximate anything. Turn your heroes into spheres and now they will get shoved back when running into other objects, run up hills more slowly and down them more quickly, fall off of cliffs, and making them perform realistic jumps is as simple as issuing 1 line of code. Turn your fireballs, bullets, and other missiles into tiny spheres for realistic projectile behavior. Make your explosions knock stuff back and create whirlwinds that pick stuff up and throw it. Create bowling, pool, basketball minigames.

Sounds great, but isn't that the same thing as previous engines?
-- No, this is the first engine to support collision between objects, rolling objecs, and many other features. It is also the first to take advantage of the new object-oriented JASS and all of its advantages (yes, preprocessor is required).

OK, but isn't it laggy with all those extra features?
-- No, in fact it is less laggy by a magnitude of 10 due to the extremely optimized way in which it is written. On my computer (decently fast) and optimized with Vexorian's map optimizer, the engine can handle the maximum number of collision objects (about 250) without lagging. Non-collision objects have no limit on their number and also have virtually zero performance cost, so you could go well above 500 with a combination of collision and non-collision objects. The point is that this engine is fast enough that virtually every moving object in your map can be included in it if you so wish.

What's the syntax look like?
I am deleting this because the syntax changed

Some current features (not all):
Fully configurable performance options
Multisampling so that tiny, fast moving objects collide correctly
Automatically detects map bounds, but also accepts user-defined bounds
Mass (affects collisions between objects)
Friction
Drag
Gravity
Speed limit for individual objects
Easy option to accelerate in a unit's facing direction
Execute functions upon bouncing, colliding, death, and killing
Use GetObject(unit) to get the object associated with a unit
Objects can be removed and are cleaned up completely
object.forEach method to execute a function easily for every object
Some basic impulse commands (specify x, y, z force or distance, angle, angle)
Some basic acceleration commands (specify x, y, z force or distance, angle, angle)
Pause and resume engine
Struct-based object profiles for easy creation of objects

Some planned features:
Scalable objects
A function to knock units back within range of a point (useful for that fireball)
Max number of bounces for an object
Suite of commands for handling projectiles
Z-axis tilting for projectiles (thanks to vex's model)
"Gravitators," objects that pull other objects toward them like gravity
Objects can kick up tile-based dust
Static (non moving, but collidable) and particle (moving, but non colliding) objects
Tornado sample function

User suggested features:
maybe switch to interfaces (Vexorian)
enters/leaves quad events (Jazradel/Vexorian)
command to make objects orbit around other objects (Fulla)


When I get any cool suggestions that I like, I will add them to that last section along with credit for the idea. So feel free to ask any questions about the engine or make suggestions for features.

Attached is a test version, optimized with Vex's map optimizer. I don't want to release a usable version until it's done, but there's no point asking for feedback unless you can try it out. Remember that you can select the balls and control them by clicking... you can control it, not just watch it.

NOTICE: Don't run this from the editor if you use Grimoire, it will lag very badly because of Grimoire's error checking. Run it from WC3 instead.

NEW UPDATE: Better integration method, dynamically changable time step, fixed acceleration issue (default gravity is -1000 now, not -30), improved performance.
Attached Files
File type: w3xObjectEngine.w3x (31.4 KB)
03-15-2007, 02:51 AM#2
Pyrogasm
Quote:
Originally Posted by grim001
(yes, preprocessor is required)
FUCK!
03-15-2007, 02:57 AM#3
grim001
Quote:
Originally Posted by Pyrogasm
FUCK!

Didn't you say you're buying a crappy laptop to compile with?
03-15-2007, 03:06 AM#4
Pyrogasm
I said that I should.

I currently possess 17 dollars and 35 cents, and I'm not kidding. I just bought a PS3, which was dumb.

My bank account has its lowest possible amount in it: $10.
03-15-2007, 03:41 AM#5
Vexorian
I really, really think you should have used an interface instead of ExecuteFunc, but whatever, might test the map when I get time.
03-15-2007, 03:45 AM#6
wantok
Sounds cool. I'm checking it out now.

Edit: setting the gravity very high (-10000) causes the balls to bounce very high and fast. I would think that they wouldn't bounce at all at that gravity.

Edit again: nevermind, you probably haven't implemented that yet.
03-15-2007, 03:59 AM#7
Vexorian
Collapse JASS:
function cT takes nothing returns nothing
local integer o=aa
call cO(o,.1)
endfunction
function cu takes nothing returns nothing
local integer o=aa
call cn(o,.2)
endfunction
function cU takes nothing returns nothing
local integer o=aa
call cO(o,.0)
endfunction

I am kind of sure this is interchanging an integer variable with a typed one in order to call a method. If you used a typecast you could save the declaration of a variable and thus optimize those functions a little, you could even prevent using a function call there.
03-15-2007, 04:58 AM#8
grim001
Quote:
Originally Posted by Vexorian
I really, really think you should have used an interface instead of ExecuteFunc, but whatever, might test the map when I get time.

I have considered doing so, I just wrote it as ExecuteFunc because that's what I'm familiar with. It's not too big a deal to switch it over, but I need to figure out interfaces first, maybe I'll take a close look at how your mobile engine does it

Quote:
Originally Posted by wantok
Sounds cool. I'm checking it out now.

Edit: setting the gravity very high (-10000) causes the balls to bounce very high and fast. I would think that they wouldn't bounce at all at that gravity.

This is true if the balls were anything less than 100% bouncy.
Since they are 100% bouncy it just means that they become supercharged by the gravity.
Update: Tested this more. Even if an object is not 100% bouncy, ultra-high gravity settings cause the object to oscillate really quickly. The cause of the problem is that everything is calculated in steps so an objects winds up in the air for 1 frame before it gets pulled back down and bounces again. The solution is to not use retarded gravity numbers.
03-15-2007, 05:01 AM#9
Vexorian
Tried the interfaces sample?
03-15-2007, 05:08 AM#10
grim001
I'll read it... and those functions you pointed out are not actually part of the engine, they are just used for the demo map. Actually that global is of type object anyway, so I just realized I can do this

Collapse JASS:
function Drag takes nothing returns nothing
    call OE_Current.setDrag(.1)
endfunction
function Friction takes nothing returns nothing
    call OE_Current.setFriction(.2)
endfunction
function NoDrag takes nothing returns nothing
    call OE_Current.setDrag(0.)
endfunction
function NoFriction takes nothing returns nothing
    call OE_Current.setFriction(0.)
endfunction
function StopBall takes nothing returns nothing
    call OE_Current.vel.scale(0.)
endfunction
That's what those functions look like when it's not obfuscated.

It's pretty convenient, you could stop them all by doing object.forEach("StopBall"), and that's what the text commands do.
03-15-2007, 05:25 AM#11
harshateja
Quote:
Originally Posted by grim001
It is also the first to take advantage of the new object-oriented JASS and all of its advantages.

Yes I've been gone a while but I didn't think that long. since when did Jass become oop?
03-15-2007, 05:33 AM#12
grim001
Quote:
Originally Posted by harshateja
Yes I've been gone a while but I didn't think that long. since when did Jass become oop?

it looks like since 10-13-2006, 11:02 PM

well, it's only partially, but it's still very useful

http://www.wc3campaigns.net/showthread.php?t=88142

but let's not forget the purpose of this post! i need feature ideas.

I made an update in the first post btw
03-15-2007, 09:15 AM#13
Jazradel
On the first run I get easily noticeable lag and I have a high end computer.

User Suggestion: Be able to define regions that have different levels of force. Like a gravity field or a sticky patch.
03-15-2007, 09:31 AM#14
grim001
First run? You mean when all of the objects run into each other at once? I dunno, I doubt your CPU could be considered "high end" if it lags on that since mine is not high end and I don't lag on that.

But it is a configurable thing. I turned on recursive collision which makes situations like that (multiple object collision) much more computationally expensive but also more realistic. You can limit the number of extra collisions calculated, or you can turn it off entirely, and then it would not lag at all.

As for your suggestion, I could add a new method that takes 4 points to define a rect as well as 2 strings for functions to execute when the object enters and leaves the rect. It would look like...

Collapse JASS:
call object.rectEvent(x,y,x2,y2,x3,y3,x4,y4, "enterfunction", "leavefunction")

function enterfunction takes nothing returns nothing
    call OE_EventObject.addFriction(0.5)
endfunction
function leavefunction takes nothing returns nothing
    call OE_EventObject.addFriction(-0.5)
endfunction

Sounds like a good idea to me. This would create a sticky patch. As for "different levels of gravity" you could accomplish that with .gravityscale by setting it to .5 for every object that enters the rect. That would effectively make gravity half as powerful for units in that rect.
03-15-2007, 10:19 AM#15
Earth-Fury
Question: why 4 points when a rect is a rectangle?

XXXXXXXX
XRRRRRRX
XRRRRRRX
XXXXXXXX

Define the top left and bottom right, and the other 2 are simply a matter of math to figure out...


And: Lags for me in the first few seconts. AMD Athlon 64 X2 4200+, 2.20 GHz. Not the best out there by far, but allot better then allot of prossesors being used to play warcraft 3.

Edited because: Missed 2 X's.

Edit 2: And I forgot to mention, you now officially rock in my book.