Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 Apr 2005
Offline Last Active Today, 01:09 AM

#5305201 Fast Square Root For Distance Calculations?

Posted by on 10 August 2016 - 06:37 PM

One way to speed these things up in Python is to use numpy:
import numpy as np

vectors = np.random.rand(1500, 3)
lengths = np.linalg.norm(vectors, axis=1)

Voila, no (Python) loops.

#5297933 Python Engine?

Posted by on 24 June 2016 - 08:50 PM

Panda3D is probably the most full-featured, there are also interesting looking hobbyist ones like Soya3D, but I wouldn't expect them to be anything close to Unity.

#5287901 Object reference not set to an instance of an object

Posted by on 20 April 2016 - 11:40 PM

Just curious: My C# is rusty, but isn't there anything like this?
private static IEnumerable<T> Generate(Func<T> f) {
    while (true) yield return f();

Used like so:
var Planets = Generate(() => new PlanetDetails()).Take(10).ToArray();

Feels a bit more straightforward than WozNZ's suggestions.

#5277236 vertex shader useless when using geometry shader?

Posted by on 21 February 2016 - 12:32 AM

It depends, but in general I would say the more computation you can offload to the vertex shader the better. For example, if you're just transforming vertices, depending on your primitive topology, the geometry shader may end up doing more operations. But as always in optimisation, benchmarking is key...

#5144098 [C++] Is there an easy way to mimic printf()'s behavior?

Posted by on 03 April 2014 - 08:15 AM

Nice one Aardvajk. But ouch, all those template arguments. My shot at a C++11 version:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>

namespace detail {

template<typename TOStream, typename... TArgs>
void print(TOStream& os, TArgs&&... args) {}

template<typename TOStream, typename TArg, typename... TArgs>
void print(TOStream& os, TArg&& arg, TArgs&&... args)
	print(os << std::forward<TArg>(arg), std::forward<TArgs>(args)...);


template<typename... TArgs>
std::string print(TArgs&&... args)
	std::ostringstream os;
	detail::print(os, std::forward<TArgs>(args)...);
	return os.str();

int main()
	std::cout << print("Hello", std::boolalpha, std::fixed, std::setprecision(2), ' ', 1, ' ', 2.0, ' ', true) << std::endl;
	return 0;

#5064288 Reflection on Uneven Planes

Posted by on 23 May 2013 - 04:18 PM

It is fairly hard to do these accurately. Basically, you would need ray-tracing. However, there are techniques that can provide a good visual approximation. In particular, you should have a look at environment mapping (or cube mapping).

#5058669 Little help with code, requiring knowledge.

Posted by on 02 May 2013 - 11:26 AM

However they work completely opposite from each other. As C# constructs the derived class first and then the base, in C++ however the base gets constructed before the derived class.

This is almost true, but there's one important detail to be aware of. Although objects do indeed start out as the most derived type, with the method table being for the most derived type, the constructors are still run in order from the base class to the most derived class. This is the most sensible order, since a constructor in a base class must be run before the constructor of any derived class in order for the object to be in a consistent state. Therefore, in C# one has to be extra careful when making virtual method calls in a constructor. If the type is not the most derived type in its inheritance hierarchy, the method will be called on a class whose constructor has not yet been run. (See Stack Overflow)

#5058415 GLSL lingo comparison/evolution chart

Posted by on 01 May 2013 - 02:53 PM

Nice find, this is going into my bookmarks!


The OpenGL wiki actually has some pretty great content. Google has led me there before...

#5055905 A C++ code to smooth (and fix cracks in) meshes generated by the standard, or...

Posted by on 22 April 2013 - 08:12 PM

Nice work! This could surely come in handy at some point.

#5012312 Does making a game like fruit ninja/angry brids require a large team

Posted by on 18 December 2012 - 09:27 PM

No, but it helps ... seriously, I would love to love Gimp and InkScape and I check up on them every few years to see if I can reasonably make the switch from Adobe products but it still seems like it would be hard.

In general, I agree with your point. However, you should also consider that switching from a complex piece of software to another is always frustrating. Of course, this is exacerbated if the new tool is missing some particular feature that you like. Yet, I find that the transition is the most difficult part.

I did the switch from Photoshop to Gimp a long time ago. It took quite some time for me to adjust. Now that I am used to it, Gimp allows me to do anything I need. Most of my image processing needs are fairly basic. But, if you are not a professional graphics artist and you are not already using Photoshop, you will probably be quite content with Gimp.

#4999348 How efficient is glm when it returns the result

Posted by on 09 November 2012 - 11:10 AM

I believe the relevant optimization technique here is Return value optimization.

#4991753 Good C++11 resources for advanced programmer

Posted by on 19 October 2012 - 05:40 AM

As mentioned by mrbastard and MikeBMcL, channel9 is pretty great.

Since you asked about C++11: This is the best explanation of rvalue references that I have heard so far:


#4979768 Abbreviations for programming related words-

Posted by on 13 September 2012 - 10:46 AM

Abbrev. 4 prgm rl8d wrdz-

There I fixed it.

#4938433 Why use scripting languages? And which one to use?

Posted by on 08 May 2012 - 11:26 AM

Let me just add that if you cannot think of a good reason to add scripting to your game, chances are you don't need it (yet). Don't add features just because you see them somewhere else. If you keep adding features that don't directly benefit your game, you will lose track and likely never finish.

#4927062 Starting in Python: best graphics module?

Posted by on 31 March 2012 - 06:47 PM

If you're saying that getting an image up on the screen with PyOgre is as easy as this:

from PySFML import sf

def main():
    window = sf.RenderWindow(sf.VideoMode(800, 600), "SFML Sprite")

    image = sf.Image()
    if not image.LoadFromFile("image.png"):

    sprite = sf.Sprite(image)

    while window.IsOpened():
        event = sf.Event()
        while window.GetEvent(event):
            if event.Type == sf.Event.Closed:


if __name__ == '__main__':

I'm going to have to take your word for it. Like I said, not much experience with Ogre3D on my side...