Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Having huge VertexArray of units and map tiles want to implement culling  (Read 2053 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Hello ::).
I have VertexArray holding mapSize of 50x50 that type is sf::PrimitiveType::Quads the size is 10,000
At one moment i draw 26x20 how do i implement culling on VertexArray?
I will adjust the storage as required to achieve good performance.

Unit VertexArray is holding ~50 units that type is sf::PrimitiveType::Quads and their position is at start pretty predictable but it gets chaotic as time passes because they move randomly so i have no idea how to achieve culling on them.
And The sizes of units and map can scale its not set that is why i want culling to allow me to go big.
Suggestions on sfml culling pls.
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Having huge VertexArray of units and map tiles want to implement culling
« Reply #1 on: January 09, 2014, 02:35:55 pm »
Quote
I have VertexArray holding mapSize of 50x50 that type is sf::PrimitiveType::Quads the size is 10,000

Break your world into chunks, lets say 400x400 blocks. Each chunk/block will get one vertex array. Then you can simply draw only the chunks that are in a visible area of the current view.  ;)

Quote
Unit VertexArray is holding ~50 units that type is sf::PrimitiveType::Quads and their position is at start pretty predictable but it gets chaotic as time passes because they move randomly so i have no idea how to achieve culling on them.

For only 50 units? That is only 200 vertices. A single 3D model can easily have more than this. It is not worth implementing culling for such a small vertex array. Just keep drawing the entire array until performance becomes an issue. Even at 300 units which is 1200 vertices you will be fine without culling.
« Last Edit: January 09, 2014, 02:43:20 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: Having huge VertexArray of units and map tiles want to implement culling
« Reply #2 on: January 09, 2014, 02:49:39 pm »
Quote
I have VertexArray holding mapSize of 50x50 that type is sf::PrimitiveType::Quads the size is 10,000

Break your world into chunks, lets say 400x400 blocks. Each chunk/block will get one vertex array. Then you can simply draw only the chunks that are in a visible area of the current view.  ;)

Quote
Unit VertexArray is holding ~50 units that type is sf::PrimitiveType::Quads and their position is at start pretty predictable but it gets chaotic as time passes because they move randomly so i have no idea how to achieve culling on them.

For only 50 units? That is only 200 vertices. A single 3D model can easily have more than this. It is not worth implementing culling for such a small vertex array. Just keep drawing the entire array until performance becomes an issue.
ID separate units intro objects that hold those 400x400 as well so i keep collision and other interactions up to speed.
I counted of making main map 500x500size and the separation to 400x400 seams a great idea  ;D thx!
The most units i had on screen with auto movement logic was 20,000-25,000 depends on my pc so id max it to 10k because i want to implement more complex AI for them.

That being said i do not want to loop logic for all units but maybe 2-3 regions around my player.
so one region is 400x400. I do not how to efficiently manage units intro these regions, i am thinking of having a sf::Vector<Unit*> that is in this vector when unit leaves the region it gets removed from leaving region and gets added to entering region that is the best idea i have at top of my head right now.

I was thinking and looking for some hard solution when just separating like you suggested sound so easy and perfect...
Simple is best
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0