About Store Forum Documentation Contact



Post Reply 
PhysX
Author Message
Masterxilo Offline
Member

Post: #1
PhysX
Is there any way to improve fps when using physx in Esenthel Engine?

I've been able to simulate 2000 boxes, even with graphically "intensive" visualization with PhysX at about 40 FPS:
http://www.youtube.com/watch?v=ojhmkkVoWaI

However this runs at about 6 FPS for me (after the boxes all fell down):
Code:
#include "stdafx.h"

Actor ground;
Memb<Actor> boxes;

void InitPre()
{
    App.name("Physics");
    App.flag=APP_MS_EXCLUSIVE|APP_NO_FX|APP_RESIZABLE;
    Paks.add("../data/engine.pak");
    D.sync(true);
}

Bool Init()
{
    Cam.dist=4;

    // create physics
    Physics.create();

    // create actors
    REPD(x,10)
    {
        REPD(y,20)
        {
            REPD(z,10)
            {
                Actor& a = boxes.New();
                a.create(Box (0.6,1.0,0.6    ,Vec(x,y,z)));
            }
        }
    }

    ground.create(Box (150,2,150,Vec(0  ,-2, 0)), 0); // create ground actor from Box and density=0 (which means it's a static actor - will not move)

    return true;
}

void Shut()
{
}

Bool Update()
{
    if(Kb.bp(KB_ESC))return false;

    CamHandle(0.1,100,CAMH_ZOOM|CAMH_ROT);

    static Bool simulatedOnce= false;
    if(simulatedOnce)Physics.get();// end frame simulation

    Physics.sim(); // start frame simulation
    simulatedOnce = true;

    return true;
}

void Draw()
{
    D      .clear();
    Physics.draw (); // draw physical actors
    D.text(-D.w()+0.2,D.h()-0.1,Str16(L"FPS: ")+Tm.fps());
}
Notice I already make best use of multi threading by letting it simulate from one call to update up to the next.

---
Btw., if you look at my code, is this how you would do something like this? (I'm pretty new o this engine, so I could use some advice.)
Especially the creation of the boxes (Do I need to store them? Should I use another memory structure?) and the text drawing (Would I position stuff on the screen like this? Is what I do to create the text string (Str16(L"FPS: ")+Tm.fps()) good practice? How do I make text left aligned? Where are the default text draw settings?)
Hmm, OK, If I call
Physics.sim() with 1/60.0f, I also get 40 FPS. Looks like the physx engine was made for that update rate.

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
(This post was last modified: 12-13-2009 11:07 PM by Masterxilo.)
12-13-2009 10:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: PhysX
Quote:Is there any way to improve fps when using physx in Esenthel Engine?
you can test PhysicsClass& create (CONTROLLER_SLOPE_SLIDING_MODE css=CSS_NONE,Bool hardware=true)
hardware=false

and Physics.precision and Physics.timestep


Quote:Btw., if you look at my code, is this how you would do something like this?
yes

Quote:Do I need to store them?

Quote:Should I use another memory structure?)
memb is ok

Quote: Is what I do to create the text string (Str16(L"FPS: ")+Tm.fps()) good practice?
S+"Fps: "+Tm.fps() is better

Quote:How do I make text left aligned? Where are the default text draw settings?)
TextDS Text_ds; // <- default
TextDS tds; tds.align.set(1,0); D.text(tds,...
12-13-2009 11:12 PM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #3
RE: PhysX
ty

As you see in my post above, I did manage to get 40 FPS.
However, that is still without graphical visualization.
I managed to get 40 FPS WITH 2000 oildrums with specular lighting and shadows being drawn, I'll have to try that.

Quote:TextDS tds; tds.align.set(1,0); D.text(tds,...
Is there now way I can set the default TextDS used when I call
D.text without specifying any myself?
EDIT: found it: Text_ds.
OK for that (I'll see how it performs with meshes...).

Now, how do I increase the camera range (the lines disappear at about 100m)?

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
(This post was last modified: 12-13-2009 11:28 PM by Masterxilo.)
12-13-2009 11:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Mikesanimation Offline
Member

Post: #4
RE: PhysX
In InitPre() you can change ViewportFull.range to be something bigger. For example, ViewportFull.range=500;
12-14-2009 05:30 PM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #5
RE: PhysX
ty

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
12-14-2009 11:19 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #6
RE: PhysX
---
Is there any way to visualize the actor's states (awake/sleeping)?
Can the physx VRD (that comes with the sdk) be used?

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
12-16-2009 10:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #7
RE: PhysX
Actor::sleep
vrd is currently not available
12-16-2009 10:58 PM
Find all posts by this user Quote this message in a reply
Post Reply