Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Apr 2011
Offline Last Active Today, 12:48 AM

Posts I've Made

In Topic: is there a better way top refer to assets in a game?

17 November 2014 - 08:40 PM

Yes using a string to refer assets is slower than integer. But it will not be "noticeably" slower. Unless you are referring it ten thousand times each frame, and that means your design is probably wrong.


Since you are doing this on a PC, time and space spent on this simply do not matter. I would say you should not waste too much time on this, it would probably give you a 0.01% performance gain with a super fast resource id;


A simple modification you can do is instead of a linear search through a array of strings, use something like map<string,asset> that can do it in log(n).

In Topic: How to create line segments from tile map outlines

03 November 2014 - 07:35 PM

Marching squares


In Topic: "Hard-C"

28 October 2014 - 07:39 PM

I think -Wall and -pedantic pretty much covers all the compile time undefined behaviors. But run time undefined behaviors will be very costly to check. For example, you'll need to check every signed addition for overflow.


Also in the real world, undefined behavior sometimes could/need to be exploited, because you are so close to the OS and hardware and there are so much feature that the standard can not and do not want to cover.

In Topic: A short discussion on PODs

22 October 2014 - 11:05 AM

POD in c++11 is two concepts: standard layout(which guarantees the order of elements), and trivial(no special actions are done while initializing, destructing and copying). Both combined guarantees same behavior with C, the plain old ways.


Identical access control is required for standard layout, since C++ require members with the same access control to be ordered in declaration order, but no requirement regarding different access control. The compiler is allowed to reorder different access control (maybe for optimization or hardware level read/write restrictions, I don't know why one would want to do that but it's their freedom), so having a class with multiple access control could break the layout, thus is non-standard layout.


Trivial-ness of a class is to ensure the compiler can use a no-brainer memcpy on your class and nothing will break. If you need a non-default constructor, that means you are doing something in it and memcpy-ing it could break it.


And ctor() = delete means no default constructor could be used. you need ctor() = default instead.


It's kind of late here so I didn't read all of your wall of text. I wonder why you want your class to be POD? You can still memcpy a non-POD if you know what you are doing, so having a constructor that only set the default values won't harm, and I bet the compiler can still optimize it while using default copy.

POD is only to guarantee to compiler nothing could possibly go wrong while doing certain operations. You can still ensure it yourself, even in a standard conformant way.

In Topic: Fusion Energy Source Advancement - News Today!

15 October 2014 - 10:14 AM

Reminded me of this: