Jump to content

  • Log In with Google      Sign In   
  • Create Account

Zaoshi Kaba

Member Since 04 Nov 2012
Offline Last Active Yesterday, 10:47 AM

#5316353 A quick way to determine if 8 small integers are all equal to each other

Posted by on 23 October 2016 - 12:41 PM

Wrote in N++ without testing so I'm not sure if it works correctly.

bool IsCellHomogeneous( const MaterialID (&_voxels)[8] ) {
	size_t idx = 0;
	// skip all 0
	for(; idx < 8 && _voxels[idx] == 0; ++idx); // intentionally empty
	if(idx == 8)
		return true; // everything is air
	const MaterialID expectedVal = _voxels[idx];
	for(; idx < 8 && (_voxels[idx] == 0 || _voxels[idx] == expectedVal); ++idx); // intentionally empty
	if(idx == 8)
		return true; // everything is same or 0
	return false;

#5311306 Visual Studio's Lower- and Upper-Case Ignorance

Posted by on 18 September 2016 - 10:55 AM

Windows (and thus most Windows software) ignores case when it comes to file paths, so you cannot change ONLY case.

Just rename it to anything.h and then back to my_class.h

#5301254 When you realize how dumb a bug is...

Posted by on 18 July 2016 - 01:53 PM

Today, at work I wrote code equivalent to this and spent over an hour debugging why username was randomly becoming empty. FML

// LPCWSTR username
if(username) {
	AutoPtr<WCHAR> ptrUsername = wcsdup(username); // cannot modify const so we duplicate
	username = removeLeadingWhitespace(ptrUsername.get()); // modifies
	username = removeTrailingWhitespace(username); // modifies
// use username sometime later

#5298816 [D3D11]Any explanation for a temporary performance hit on binding a 4k by 4k...

Posted by on 02 July 2016 - 11:11 AM

4k x 4k texture is about 67 MB (depends on format), so it's not exactly small. My GPU has 2 GB dedicated and video player eats 1.5 GB. Most software does wonders at memory consumption. Especially Chrome.

You can use this tool but I'm not sure how accurate it is: https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

#5297664 What maximum amount of flood fill can a dijkstra handle?

Posted by on 23 June 2016 - 12:01 AM

Slightly off topic, but I want to ask.


Most games use the A* (A star) algorithm, which is Dijkstra's single pair shortest path algorithm plus a small heuristic value to speed up the search a bit, at the cost of potentially not being optimal.


In which cases it would not be optimal? I thought it always takes the most optimal path.

#5288642 Diagsession files?

Posted by on 25 April 2016 - 01:51 PM

Just .zip it.

#5288276 Is there an official list of all registered game titles out there?

Posted by on 23 April 2016 - 05:33 AM

if a trademark is not registered does it carry the same weight legally?


I'm not an expert or lawyer, but I believe in case of dispute the one who proves they used that title earlier will be assumed to have ownership. Therefore, automatically you cannot use any existing titles. Sometimes even similar ones.


I remember reading a story where guy released game similar to Candy Crush and it was similar in name, later on Candy Crush came out and they started legal war. Of course Candy Crush was on losing side, since they came up with the name later, so they found another game with similar name, which came out much earlier, bought copyright for like $100 and made poor guy take down his game, because now Candy Crush holds rights to earlier title.

#5287168 Pressing a key down generates both KEYDOWN and KEYUP event

Posted by on 16 April 2016 - 05:45 AM

Aren't you just missing break; at the end of SDL_KEYDOWN case? Same issue with SDL_KEYUP case.

#5281874 Why didn't somebody tell me?

Posted by on 18 March 2016 - 10:20 AM

I thought I'd share this extension:


#5281175 how could unlimited speed and ram simplify game code?

Posted by on 14 March 2016 - 04:27 AM

Is this true Waterlimon?

I had to write a small program in Prolog that finds all magic squares constrained by certain rule. So I just wrote down all the rules:

  1. rows 1..n add to N
  2. columns 1..n add to N
  3. diagonal adds to N
  4. all numbers in cells <= n*n

And Prolog just proceeded bruteforcing all answers.


In Prolog you just write rules / result you WANT to have and it tells how to achieve that result.

#5279209 "It's when you...", or: little things you've discovered about...

Posted by on 03 March 2016 - 02:22 AM

This thread is probably more suited for Coding Horrors section.


I've encountered people who don't know this so I'll mention:

  1. Hold ALT and drag vertically to edit multiple rows in same location. Allows easy aligning, copy/paste works as well.
  2. Use this extension to add extra functionality to ALT - hold ALT and click arbitrary locations to add carets there.

#5277783 Determine whenever box is visible in frustum

Posted by on 23 February 2016 - 02:38 PM

You should only reject a box if all vertices are "outside" the same frustum plane.

OP doesn't mention whether he's trying to implement frustum culling so I believe it's worth to mention that such approach isn't error free. Sometimes it gives false-positives, as in flags box as visible even though it is not.

#5274873 Have You Ever....?

Posted by on 08 February 2016 - 11:38 AM

was copy-pasted in 5 different locations in the code

I spent a week creating such situation. Now I get to fix it.

#5273692 Frustum Culling Question

Posted by on 01 February 2016 - 11:36 AM

See Quad-Trees, Oct-trees, BSPs, K-trees.


Quad-Trees, and Oct-trees work by recursion. You start off with very large volumes, and you work your way downwards, checking smaller volumes, till you finally get to the actual meshes to check. For small worlds... these tend to be more costly. For larger worlds these are efficient. 


Are hierarchical structures even necessary for frustum culling? My CPU can cull ~450,000,000 AABBs per second (on 1 thread). 1 ms would be 450,000 AABBs. I'm sure you'll run into a dozen other problems before bruteforce frustum culling becomes a bottleneck.

#5270239 why does visual studio do this?

Posted by on 09 January 2016 - 03:41 AM

That isn't the issue. It won't recompile that cpp for some reason. it's using the old code.

What makes you think that? Debugging is impossible in Release build, so anything it tells you is false.