Jump to content

Navigation without physics?


f13rce
 Share

Recommended Posts

Hey everybody,

 

I'm still working on that game where you capture bases and spawn fighters. I've been struggling for a while with my laptop because too many units (fighters) cause an insane drop of FPS.

 

Fortunately I know this time that my code is no big mess like it was back when I made Ravage (oops). It seems that the physics I had to apply with the navigation was bringing it down a lot (~120 FPS to ~5 FPS with 32 units on the field (tested on my laptop (specs below))). So whenever a unit is being created, I use the following lines to move it towards a position:

 

model = Model::Box(1,1,1);
pivot = Pivot::Create();

pivot->SetPosition(0, 0, 0);
model->SetPosition(0, 0, 0);

model->SetParent(pivot);

pivot->SetMass(1);
pivot->SetPhysicsMode(Entity::CharacterPhysics);

pivot->GoToPoint(10, 0, 0, 3); //Doesn't get called every update. Only when initialized.

 

Unfortunately, GoToPoint() does not work anymore if you comment out the SetMass() and SetPhysicsMode(). Neither does it work to replace Entity::CharacterPhysics with Entity::RigidbodyPhysics (which makes sense though).

 

I've included the source of the testproject to check the FPS. Just make a new C++ project and replace the files with the ones in the attached .rar file. I used Fraps to display the FPS.

 

---

Even if I can't disable the physics, is there any way to improve the FPS nonetheless? I'm not calling GoToPoint() every update or something like that, so that doesn't seem the problem.

 

Laptop specs:

OS: Windows 8 64bit

CPU: Intel Core i7 Q720 @ 1.60GHz (8CPUs)

Memory: 6GB RAM

GPU: Ati Mobility Radeon HD 5400

 

Thanks in advance

 

Edit: I should also note that I don't need any physics. The landscape is flat and the units only need to be on one constant Y position. I only need the navigation.

TestprojectSource.rar

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

Thanks for the comment beo6.

 

It's running fine if I don't add any sort of physics, but then I can't make use of the GoToPoint() function as navigation. So I'm kinda stuck here.

I've already set the graphics on its lowest settings. Disabled everything that wasn't necessary. It's really the physics taking the FPS down while I don't need it aside from the navigation.

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

Sounds like a great solution! Although, do you still remember where you can find that post? I've done a quick search through the forums and documentation but I couldn't find anything related to that specifically. I'll keep searching though.

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

I see, thanks for the hint. I also saw from the post Rick linked you had a variable called "path" from the type NavPath. How did you assign the path the variable should be using?

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

Ah yeah, FindPath() does return a NavPath. Now all I have to do is to find out how NavMesh works.

 

Edit:

World* world = World::Create();
NavMesh* navMesh = world->navmesh;

NavPath* path = new NavPath();
path->navmesh = navMesh;
path = path->navmesh->FindPath(pivot->GetPosition(true), Vec3(10, 0, 10));

 

Seems to work. When I add this debug for loop:

 

for (int i = 0; i < path->points.size(); i++){
cout << i << ": " << path->points.at(i).x << ", " << path->points.at(i).y << ", " << path->points.at(i).z << endl;
}

 

I get the following result:

0: 0, 1.75, 0
1: 8.25, 1.75, 5.5
2: 10, 1, 10

 

Sooo it seems to work! All I have to do now is making the unit move from waypoint to waypoint. Thanks for the help! smile.png

 

Final edit: Results are in... and wow.

With my PC the FPS would drop to 1 FPS after 64 units spawned using physics and GoToPoint()..

With the new way of pathfinding I get 1 FPS after spawning 1135 units who don't use physics anymore.

That's about 94% increase in FPS in general. Thanks again!

  • Upvote 1

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

  • 2 weeks later...

Could it be possible to have that feature in Lua in the future ?

 

Such increase performance if you just use the path infos without physics should be available for Lua users.

 

Well any game not concentrated on physics would benefit such "LightWeight" navigation system, as Entities that would

follow navmesh would not have to care about physics and environment in lot of cases of games like pure RPG, MMo style, RTS, tactics turn based etc ...

  • Upvote 2

Stop toying and make games

Link to comment
Share on other sites

I agree.

 

But using pathfinding without any physics can suit lot of games styles. Just need to port this code to some Lua function :

NavPath* path = new NavPath();

path->navmesh = navMesh;

path = path->navmesh->FindPath(pivot->GetPosition(true), Vec3(10, 0, 10));

 

And this should be an option for people to be able to choose to use physics or not in Navmesh functions.

 

And the result without physics is unbeatable like tested by Evayr :

With my PC the FPS would drop to 1 FPS after 64 units spawned using physics and GoToPoint()..

With the new way of pathfinding I get 1 FPS after spawning 1135 units who don't use physics anymore.

Stop toying and make games

Link to comment
Share on other sites

Keep in mind, Evayr's use case for this approach was that the laptop which he is temporarily using to develop is too slow to run Leadwerks properly. It is an impressive improvement and certainly worth considering for some game types, but in general game engines use physics systems for good reasons.

Link to comment
Share on other sites

If you make some RPG, with characters distance management, world of warcraft (no physics, even characters passing throught others) or even more simple, believe me you don't care at all about physics.

And such big performance improvement is just lot more power saved, specially if your game already takes lot of CPU.

Stop toying and make games

Link to comment
Share on other sites

Navigation is for NPC not for player, in WOW the ennemies pursue you by running on ground they don't jump, they could use navigation without any physic caus no jump.

If your RPG don't have jump abilty : diablo and others style games, you don't care about physics, gaining 100 FPS in navigation from CPU would be great benefit in lot of cases.

 

One big thing is that you could TOTALLY get rid of the first person controller, so you could make a ball, or cylinder OF ANY SIZE (that would be the character collision obejct) that would just follow the navigation path. NO more strange FIXED character controller size, specially when your character figths and walk against some giants bosses.

Stop toying and make games

Link to comment
Share on other sites

The navigation path itself is calculated based on given parameters like height and radius. Different sized characters would require a separate navmesh, as some openings might be too small for one character's dimensions, but big enough for another one's.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...