Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Trienco

Member Since 22 Aug 2001
Offline Last Active Jan 29 2015 10:59 PM

Posts I've Made

In Topic: C++ how to declare something that isn't declared?!?

18 December 2014 - 11:14 PM

Not sure it would be making much sense in this example, but consider you might end up changing the raw pointer to a shared or unique ptr later on. Having the type defined in one location is much less painful than having it all over the place. Though you should probably not be using it all over the place before thinking about what the proper ownership should be.


In Topic: Proper C++ header file?

20 November 2014 - 10:52 PM

I've seen people screw it up at least three times in a single project, because new files were always copy/pasted from existing files (nobody wants to worry about copyright notices, doxygen syntax, etc.). Guess what got copied without updating: doxygen info (file name, file description), copyright header and... bingo... the include guards.

 

Then there's people not able to consistently follow a naming scheme for the guards or insisting on starting them with _ or __ (triggering plenty of complaints in code analysis tools).

 

Unless you need to support some very exotic or outdated compilers, #pragma once is easier, safer and allegedly faster in some implementations.


In Topic: Why only rotation in degrees?

16 November 2014 - 11:11 PM

Take a long look at the actual vectors that make up your rotation matrix. Eventually you should notice (depending on how your game defines its axes) that the rotation matrix is nothing else but the forward, right and up direction vectors. No point in additionally storing angles. If you need to apply the rotation, just use the matrix, if you need to move, just use the vectors from the matrix. That's basically the benefit for using a representation that is more wasteful than others (angles, quaternions, two vectors).

 

One major downside if you keep accumulating rotations in a matrix is that small errors will also accumulate and force you to re-orthonormalize the matrix every once in a while.


In Topic: weird header behavior in gcc and llvm

29 October 2014 - 11:21 PM

Header guards do exactly zero to help with circular includes. In fact, they are causing the problem in the first place (kind of, otherwise you'd get endless recursion and are still screwed). You use them to prevent getting multiple declarations of the same stuff for one source file. You have the opposite problem where your circular includes result in one header trying to use something from the other header before it was ever declared (no matter which order you include them).

 

A says "copy everything from B to here, because I need it declared before my stuff", then B says "copy everything from A to here, because I need it declared before my stuff". But A already declared the header guards and nothing is included. You end up with a file in the order B - A - source. B is trying to use stuff from A that is only declared further down and you get errors.

 

The two steps when you have circular includes is a) ask yourself if you screwed up the design when you introduced circular dependencies in the first place and if your answer is "no" then b) break them with forward declarations.

 

Okay, technically you should prefer forward declarations anyway (at least if you just need a single class or two... but then, if you find yourself needing declarations for dozens of functions from somewhere else in a header file, you probably got bigger problems).


In Topic: Error: unique_ptr constructed with null deleter pointer

26 October 2014 - 10:45 PM

Since the error is about the default constructor, I'd blame it on the map creating a default constructed object if you call the [] operator with a new key. Are you getting the same error for simpler containers like a vector or if you try using a shared_ptr? Maybe some detail about the operator [] implementation is screwing you over and tries to copy a default constructed unique_ptr?

 

emplace is definitely more likely to work than insert. Does the error move somewhere else if you comment out the code in add_resource? If not, the problem really seems to be limited to adding it the proper way. If it does, the problem is probably more fundamental than that.


PARTNERS