Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Quick 'n Dirty Verlet Fluids v0.1  (Read 9131 times)
0 Members and 1 Guest are viewing this topic.
Offline fermixx

Senior Newbie





« Reply #30 - Posted 2009-08-12 04:05:44 »

asus laptop
intel core2Duo (2 cores) t7250 @ 2ghz
2gb ram
windows vista home premium

fps:
average = 33
minimum = 28


the weird thing is that even with these fps, i dont see it smooth. it looks laggy even if its always +28fps
my gpu is not top notch (ati hd 2400). cant play crysis but i can play oblivion and gears of war at decent fps (+30)

CPU :  70~90 %   (thats a lot dude!!)


hope it helps

RTS game or a big rock-paper-sissors ?
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #31 - Posted 2009-08-12 11:44:37 »

asus laptop
intel core2Duo (2 cores) t7250 @ 2ghz
2gb ram
windows vista home premium

fps:
average = 33
minimum = 28


the weird thing is that even with these fps, i dont see it smooth. it looks laggy even if its always +28fps
my gpu is not top notch (ati hd 2400). cant play crysis but i can play oblivion and gears of war at decent fps (+30)

CPU :  70~90 %   (thats a lot dude!!)

Well, it's certainly a lot! There are 8K particles, so in theory, that's 64 million collisions per frame. Due to the spatial algorithm, that gets reduced to roughly 1% (still 640K collisions or collision checks). You won't see true fluid simulation in any modern game, because it's just too darn heavy to compute, even simulating a glass of water is harder to realistically calculate (not to mention render) than Crisis.

I'm probably going to find some more shortcuts, maybe I can speed it up like 2-5 times, but it won't get much better than that. At that time, I'm probably going to make the drops smaller anyway.

The gfx card is not used BTW, maybe by Java2D, but I'm mainly drawing rects and there isn't exactly much room for improvement there, and the GPU won't really accelerate that that much. It's like OpenGL immediate mode with 1 quad in every begin/end at best, as every quad has it's own color.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #32 - Posted 2009-08-12 13:14:22 »

Looking very good, I'm impressed you're getting that many particles going at once without too much slowdown.

Going to release code, too?

Maybe, the code is very simple actually, it's just not really nicely coded.

Yesterday I optimized a fair bit - without touching the algorithms, and it seems to be 20% faster. Will upload later.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #33 - Posted 2009-08-12 18:16:41 »

for those interested, this is the whacky 'kernel':

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
 public static final void collideLiquid(VerletSphere a, VerletSphere b, float viscosity)
   {
      final float rad = a.radius; // 'b' is just as big...
      final Vec3 aNow = a.p.now;
      final Vec3 bNow = b.p.now;

      final float dx = bNow.x - aNow.x;
      final float dy = bNow.y - aNow.y;
      final float dz = bNow.z - aNow.z;
      final float d2 = dx * dx + dy * dy + dz * dz;

      final float outer = (rad * 3.0f);
      if (d2 > outer * outer)
      {
         return;
      }

      float force = viscosity / d2; // decreases like gravity

      final float rad2_doub = rad * rad * 4.00f; // (rad*2)^2
      final float rad2_half = rad * rad * 0.25f; // (rad/2)^2

      if (d2 < rad2_doub) // d < rad*2
      {
         // prevent extreme collisions
         local: if (d2 > rad2_half) // d > rad/2
         {
            float diam = rad * 2.0f;
            if (d2 > (diam * diam))
               break local;

            float d = (float) Math.sqrt(d2);
            float f = (d - diam) / diam * 0.25f; // spring with half stiffness = 0.5*0.5

            aNow.x += dx * f;
            aNow.y += dy * f;
            aNow.z += dz * f;

            bNow.x -= dx * f;
            bNow.y -= dy * f;
            bNow.z -= dz * f;
         }

         // this is a collision, flip the viscosity force (makes no sense, but it works)
         force *= -0.5f;
      }
      else
      {
         // these drops are so far away, that viscosity shouldn't really have such a big influence...
         force *= 0.5f;
      }

      final Vec3 aOld = a.p.old;
      final Vec3 bOld = b.p.old;

      aOld.x -= dx * force;
      aOld.y -= dy * force;
      aOld.z -= dz * force;

      bOld.x += dx * force;
      bOld.y += dy * force;
      bOld.z += dz * force;
   }

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Hansdampf

Senior Devvie


Projects: 3


too offending?


« Reply #34 - Posted 2009-08-12 18:29:03 »

I implemented something similiar and sped it up by
1) precalculating the inverse radius
2) using a lookup table for sqrt (interesting values are always in radius range)
could help you too  Smiley

lots of sillystupid games: http://www.emaggame.com
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #35 - Posted 2009-08-12 18:44:01 »

well, those are probably going to gain me a few percent, if any at all. not really worth the effort at the moment, as it's not the bottleneck.

the spatial algorithms take 25%, the above code takes 45%, everything else takes the remainder.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #36 - Posted 2009-08-12 21:13:38 »

I actually didn't know you could use break and block labels like that in Java. Good to know.

See my work:
OTC Software
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #37 - Posted 2009-08-12 21:23:31 »

I actually didn't know you could use break and block labels like that in Java. Good to know.

This is the 2nd time I did that in over a decade. It stinks. Don't do it.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #38 - Posted 2009-08-12 22:24:23 »

what's the min. required screen resolution?
Tried to give it a spin on my netbook, but can't see much of the window area. (1024x600)

Of what I could see, it ran @ 8-10fps.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #39 - Posted 2009-08-12 22:40:27 »

1024x768, but it is really meant for 1280x1024.

At the moment I don't have the time to change much. I removed the raft for some obscure reason, so if I'd upload it now it would be kind of a boring demo, for everybody else Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #40 - Posted 2009-08-12 22:50:32 »

This is the 2nd time I did that in over a decade. It stinks. Don't do it.
Despite knowing its existence in other languages, I haven't ever used labels and gotos in anything other than Assembly, ever.

See my work:
OTC Software
Offline DzzD
« Reply #41 - Posted 2009-08-13 00:19:49 »

Quote
This is the 2nd time I did that in over a decade. It stinks. Don't do it.

Despite knowing its existence in other languages, I haven't ever used labels and gotos in anything other than Assembly, ever.

I use it sometime in java rarely but...  it can be very usefull in some special cases and can give cleaver code, I think that it is not so much unlogical to use it even in Java

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #42 - Posted 2009-08-13 00:28:19 »

I use it sometime in java rarely but...  it can be very usefull in some special cases and can give cleaver code, I think that it is not so much unlogical to use it even in Java

Sure, it has its uses, just like:


   static int guessWhat()
   {
      int a = 15;

      try
      {
         return --a - 100;
      }
      finally
      {
         return --a + 100;
      }
   }


Who needs multiple return values anyway?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline fermixx

Senior Newbie





« Reply #43 - Posted 2009-08-13 01:38:49 »

i used labels in my last game inside a for loop for  my collision checking like so:


uniFor: for (total units) {
     Unit u = getUnitAt(index)
     
     enemyFor: for (total enemies){
           Enemy e = getEnemyAt(index)
           
           if (u.collidesWith(e){
                 continue uniFor;  //otherwise i could use break enemyFor
           }
     }
     
}


this is because when an unit collides with an enemy and attacks it, its useless to keep looking for more collissions


Anyways its not something that useful, and you gotta keep an eye not make it really complicated, coz this is all about structured programming, so not goTo nor many breaks/continue

RTS game or a big rock-paper-sissors ?
Offline Meraxupypr

Senior Newbie





« Reply #44 - Posted 2009-08-15 06:41:27 »

winxp
core2duo E8200 2.66ghz
50 FPS
Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #45 - Posted 2009-08-15 08:16:26 »

I rarely do as fermixx posted, but I name the label "outerLoop".

On my i7 920 (4 cores, 8 threads) with a GTX 275 video card, if the raft is not colliding at all, about 85 to 90 fps. If the raft is deep in the water, about 75 fps. ~30% CPU utilization.

Interestingly, if you use the raft to block the outlet at the bottom, water molecules pop out of the top of the water like popcorn. Smiley

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 831
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #46 - Posted 2009-08-15 11:30:56 »

On my i7 920 (4 cores, 8 threads) with a GTX 275 video card, if the raft is not colliding at all, about 85 to 90 fps. If the raft is deep in the water, about 75 fps. ~30% CPU utilization.
The raft code is very inefficient, and the water<->raft code even more. It collides every drop in the boundingbox of the boundingsphere of the bounding box (it keeps getting bigger Smiley)

Interestingly, if you use the raft to block the outlet at the bottom, water molecules pop out of the top of the water like popcorn. Smiley
Yeah, I mentioned the stability problems when drops are under high pressure. I might have to move towards grids, and drop the particle approach, to really get rid of that. Nice thing is grids is that their are embarrassingly parallel. Downside is that your are limited to a fixed shape and can't have that much control over the actual collisions (there are none).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (62 views)
2014-11-13 12:34:49

digdugdiggy (41 views)
2014-11-12 21:11:50

digdugdiggy (36 views)
2014-11-12 21:10:15

digdugdiggy (30 views)
2014-11-12 21:09:33

kovacsa (53 views)
2014-11-07 19:57:14

TehJavaDev (56 views)
2014-11-03 22:04:50

BurntPizza (55 views)
2014-11-03 18:54:52

moogie (70 views)
2014-11-03 06:22:04

CopyableCougar4 (71 views)
2014-11-01 23:36:41

DarkCart (156 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!