Jump to content


Member Since 18 Sep 2008
Offline Last Active Jun 29 2016 04:32 AM

Posts I've Made

In Topic: Text file I/O - read line functions and buffering

06 July 2013 - 02:22 AM

This depends on what underlying systems you are using.  In general, this does not matter for disk io though since, as you say, even if you use unbuffered IO the disk IO still reads a disk block at a time and as such ends up with a small buffer preventing repeatedly hitting the disk.  Having said that though, the overhead of the function calls adds up quickly, especially when they talk to OS buffers due to a lot of additional checks that the OS has to perform which you can avoid if you buffer yourself.


I did do a test on this at one time.  Using a simple fread 1 character at a time versus simply reading the entire file and then parsing myself, the result was about a 1:5 ratio in favor of the manual parsing.  On the other hand, when I used C++ ifstream and the generic read line function, it turned out to be as fast as the full file version which suggests the C++ streams are pretty smart about behind the scenes buffering.


All said and done, I know that the calls to the underlying io functions are generally fairly slow so you want to avoid that.  Other solutions though, you just have to test them yourself.  It should also be noted that I ran this test several years ago on WinXP, it could easily be completely out of date by this time.  So, test test test.. smile.png


Thanks for the great answer!


I have doubts this concern is meaningful. While loading data from disk is necessary and might be performance-critical in some situations, I strongly suggest to keep away from it for all serious use only good reason being memory management.


It's more curiosity than concern, really. I don't think any way would actually impact performance noticeably in my case.

In Topic: How to implement better Collision detection

29 March 2013 - 01:25 PM

The post I made earlier literally walks through how to do ellipse collision detection step by step


I've had the post up on a tab for some hours and didn't refresh it so only saw 1 reply, my bad.

In Topic: Collision Sliding Problem

29 March 2013 - 03:15 AM

There are several different ways of doing all of this. From what I've read it seems to be common to move the objects, detect a collision then solve the intersection by moving it along a vector make the objects not intersect anymore and then apply some force/impulse to make it bounce (if that's what you want, otherwise just move them apart).




The first circle to the left might be where the intersection is detected and the red vector is the direction it has been moving. Then moving it along the normal of the surface (green vector) it would appear sliding along this plane. This might be sufficient for your application.


EDIT: Just realized the image is a bit misleading. The image implies the sphere that is intersecting the plane still is moving along the red vector but my point is that it has moved along its entire vector and should only be moved "up" along the plane's normal. But the red vector is the direction it has already moved (to get to its current position). Sorry, this is perhaps quite confusing. If you have any questions about this, please ask.

In Topic: How to implement better Collision detection

29 March 2013 - 03:03 AM

You could have an ellipse shaped bound on the ellipse shaped smiley monster. It's a bit complicated but this article explains a very simple way of converting this into a sphere box text which are quite simple and cheap. This way you could have a perfect bound for the ellipse smiley monster.


I'm not sure if this is true or not but it doesn't help with any ellipse - ellipse testing nor sphere - ellipse testing (except they're both have the same axes and orientation, I guess).

In Topic: How do I implement multiple material in deferred shading?

16 March 2013 - 02:10 AM

This was the second google result when searching for "deferred shading multiple materials" and could perhaps be of help. It has a link to another page from NVIDIA with more information. I just skimmed it through so I'm not sure it's exactly what you're looking for.