Cloth Physics.

Cloth physics is a fantastic visual representation of how physics can be used to enhance a scene in a game, it can be used to convey character emotion like in the PS3 game Journey by thatgamecompany or just make a character feel more alive like in Beyond : Two souls in the chapter “The Embassy” where Jodie wears a red dress.

Cloth physics is also notoriously difficult to get right.  From numerical stability to collision. In this post i will talk about my approach to solving cloth simulation. Making it “feel” good, stable and usable in different situations, character cloth and flags. Continue reading “Cloth Physics.”

Debug Drawing

I’ve been reading Jason Gregory’s book Game Engine Architecture a lot lately. In Chapter 9 “Tools for Debugging and Development” he talks about how Naughty Dog use their own debug drawing API to visualize the results of mathematical calculations. I decide that this was a very nice simple feature to implement in my own physics engine. Continue reading “Debug Drawing”

Posted in C++

Virtual destructor in C++

Virtual destructors are useful when you can delete an instance of a derived class through a pointer to base class.

Here is an example when you don’t use virtual destructors.

class Base
     Base() {cout << "Base Constructor called";}
     // Base destructor is not virtual.
     ~Base() {cout << "Base Destructor called";}

class Derived :public Base
       Derived() {cout << "Derived Constructor called";}
       ~Derived() {cout << "Derived Destructor called";}

void main()
    Base *pBase = new Derived();

    delete pBase;    // Here is the problem.

Continue reading “Virtual destructor in C++”

Posted in C++

C++ Operator Overloading

The type of operator overloading that has some potential performance implications is one that returns an object of the type it operated on, usually binary operators. For example, operator+() is one of those operators. Consider the following code:

Vector3 velocity = oldVelocity + frameIncrement;
Vector3 propulsion = ComputePropulsion();
Vector3 finalVelocity = velocity + propulsion;

Continue reading “C++ Operator Overloading”

Using IMGUI in my Physics Engine.

I just recently implemented ImGui into my physics engine. Working on my physics engine is really fun and challenging, i have a lot more to add and learn to make this a polished programming product. Implementing a Graphical User interface was brought on by looking at the behind the scenes footage of Last Of US by Naughty Dog Inc. They had really simple GUI but it was highly useful to both programmers and game designers. They were able to configure options while Continue reading “Using IMGUI in my Physics Engine.”