-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple tile visibility checking in the ViewModule #5
Conversation
@@ -49,6 +52,6 @@ class ViewModule { | |||
float m_height; | |||
float m_aspect; | |||
|
|||
void init(float width, float height); | |||
void init(float _width, float _height); | |||
|
|||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline!!! :)
|
||
m_visibleTiles.clear(); | ||
|
||
float tileSize = 2 * PI * EARTH_RADIUS_M / pow(2, m_zoom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small thing.
Its always recommended to do multiplication over division. Sometime the performance gains are huge..
Some Floating point processing multiplication can be 5 to 8 times faster than floating point division.
float inversePowZoon = 1/pow(2, m_zoom);
float tileSize = 2_PI_EARTH_RADIUS_M*inversePowZoon;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tallytalwar really?? Do you have some docs to point to on that - curious to read more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup... hence use of bitwise operators is also recommended. (multiplication by 2 should be replaced with one right shift, and division by 2 should be replaced by one left shift)..
there are many more such optimizations ...
http://books.google.com/books?id=IRN0IEXJzKEC&pg=PA92&lpg=PA92&dq=floating+point+division+multiplication+optimization+c%2B%2B&source=bl&ots=P1mjHg8EAs&sig=sZD71hukKFcJ6RaBJz4Q5awC9gs&hl=en&sa=X&ei=hZUXVNvRENSn8QGvq4HoBw&ved=0CFEQ6AEwBw#v=onepage&q=floating%20point%20division%20multiplication%20optimization%20c%2B%2B&f=false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep but those references are over a decade old, so I wonder if they still
apply. Bit-shifting is an old x86 technique, I use it out of habit. I
wonder though if the compiler won't apply these optimizations automatically
anyway... worth reading up on just to know.
On Mon, Sep 15, 2014 at 9:45 PM, Varun notifications@github.com wrote:
In core/viewModule/viewModule.cpp:
@@ -60,3 +62,47 @@ glm::mat2 ViewModule::getBoundsRect() {
return glm::mat2(m_pos.x - hw, m_pos.y - hh, m_pos.x + hw, m_pos.y + hh);}
+
+const std::vectorglm::ivec3& ViewModule::getVisibleTiles() {
+
- if (!m_dirty) {
return m_visibleTiles;
- }
- m_visibleTiles.clear();
- float tileSize = 2 * PI * EARTH_RADIUS_M / pow(2, m_zoom);
yup... hence use of bitwise operators is also recommended. (multiplication
by 2 should be replaced with one right shift, and division by 2 should be
replaced by one left shift)..there are many more such optimizations ...
—
Reply to this email directly or view it on GitHub
https://github.com/tangram-map/tangram-es/pull/5/files#r17579753.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will do..
What I have been told by developers I have interacted with at DWA and other gaming studios that these still apply. But I will still confirm. If compiler optimization are there then it will save us a lot of pain. :D
Just to clarify the logic, m_dirty should be set to true, every time any of the set functions are called on the viewModule and not just on init? These set functions will be called by user triggered events (gestures, mouse move, etc). |
No description provided.