Jump to content

  • Log In with Google      Sign In   
  • Create Account

Nick C.

Member Since 06 Nov 2012
Offline Last Active Mar 08 2015 06:11 PM

Posts I've Made

In Topic: debugging extremely slow after CreateSwapChain

05 October 2014 - 03:07 PM

I have solved my problem by updating my graphics driver. That was dumb of me, should've been my first thought.
This topic can be closed if needed.

In Topic: Character Move Forward after Camera Perspective

05 October 2014 - 02:25 PM

If I understand your question correctly, this may work.

1) Optionally: Update your character's rotation:


mRotation.y += mRotationSpeed * GAMETIMER->DeltaTime();

2) Optionally: Update your character's position

mPosition.x += sin(mRotation.y) * mMovementSpeed * GAMETIMER->DeltaTime();
mPosition.z += cos(mRotation.y) * mMovementSpeed * GAMETIMER->DeltaTime();

3) Set the position and angle of your camera, according to your character's position and rotation.

x = mPosition.x - sin(-mRotation.y) * mZoom
y = mPosition.y - sin(your camera's roll (rotation around x axis)) * mZoom
z = mPosition.z + cos(-mRotation.y)* mZoom

Rotation: That's up to you. Good luck ;)

Depending on your logic, you may adjust the sign, add/substract pi and change cos/sin.

Edit: Don't forget about possible overflow. Make sure your angles stay under 2 * pi.

In Topic: Returning pointer to array of function pointers not working

17 June 2014 - 09:46 AM

I have the feeling you're abusing pointers a bit :).
I've never in my life seen a pointer to pointer to pointer to pointer.

In Topic: optimizing my code (memory usage, postfix and prefix notation, "continue...

02 April 2013 - 09:45 AM

Okay, thanks everyone for the replies (and sorry for my late reply).
It seems that I should have included my entire function to prevent confusion here, as some people don't really know what I want to archieve here.

So: the object of this function was to split a string on a character. However, the function that Ravyne showed here (yes, I know there are even more possible solutions) doesn't really do what I want, as I have a few more requirements xd. That function was actually one of the first I came up with.
Let me explain you a few other things.
- If the string doesn't contain that character, the function stores the entire string in a vector (size 1)
-if the string is empty, the function stores an empty string ("") in a vector (also size 1)
-If the character occurs as first character an empty string will be stored as first element in the vector
-If there are multiple duplicates of that character following, it ignores all those.

An example:
vector<string> splittedString;
char splitChar = '.';
string stringToSplit = ".test...12..3.";

After the instruction
SplitLine(stringToSplit, splittedString, splitChar);
splittedString contains the strings
0.  (empty)
1. test
2. 12

3. 3
4.  (empty)

Not trying to argue, just saying how it is... Like wintertime said, those two loops don't exactly do the same thing, but they do if you actually see the entire function. As I said before, I've tested all the possibilities comprehensively. So, without further ado, my entire function. You can use all my possibilities, they all do the same thing.

inline void DaeToAniConverter::SplitLine(string line, vector<string>& splittedline, char splitchar)
	//vector with string segments should contain at least one string
	if (line == "")
        int ll = line.length();
	int prevIndex(0);
	int  j(0);
	while(j < ll)
		int tempJ = line.find_first_of(splitchar, j);
		j = tempJ >= 0 ? tempJ : ll;
		//skip multiple equal characters
		splittedline.push_back(line.substr(prevIndex, (j-prevIndex)));
		while (j < ll - 1 && line[++j] == splitchar)
		prevIndex = j;



As you can see here, the main loop is only executed as many times as there will be string segments (in my last example, 5 times), so not character per character. I actually do use line.find_first_of.

And about that performance issue, you are all right smile.png. It really doesn't make a big difference, and a good structure is sometimes more important than performance.
Thanks to everyone else for your constructive remarks.
Again (but now you know what I want to archieve here), if there is a better way to archieve this functionctionality, I would gladly hear about it.

I'm just a 19 year old student, programming in my free time. Everyone makes mistakes, right? smile.png


Edit: This may be important. This function is part of a program that reads a file, converts it to a custom format, and writes it to a new file. I'm talking about pretty big files, so this function is usually executed at least hundred times (usually a few hundred). Right now it only takes 2-5 seconds for the program to do its thing, so that's not too bad smile.png.

In Topic: Using bitmap resources (*.rc) in Visual Studio 2010

23 December 2012 - 07:28 AM

I think it would help the reader if you provided some specific code or compling errors ;) It's quite hard right now to see the problem.