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!


Tapped

Member Since 29 Jan 2011
Offline Last Active Feb 03 2014 01:40 PM

Posts I've Made

In Topic: Physic of ball for review

05 January 2014 - 08:27 AM

First of all your code is not cache friendly at all. You branch your code to much, for example why check if the force vector is empty?
Another thing, you have not made a common solution for physic update. The same update function should work for all types of shapes not only spheres.

 

The update function should only be a physic integration. As you may recall: a = F / m, v += a * t, s += v * t + 0.5 * a * t * t for linear physic, and angularAcc = torq * I-1, rotation += angularAcc * t, orientation += rotation * t for angular physic.

I see you are doing this, however you should separate your integration code from the contact resolving, so that you can have common solution for all bodies. So what you need to do is to clean up your code, and separate it, and have in mind that your solution should not be specific for each shape, but common. 

Also to paste code from visual studio, turn on "space for tabs" in the editor settings, and then convert your code file before you copy it.


In Topic: Separate matrices for every glDrawCalls

27 December 2013 - 04:07 PM

@Tapped:

For your getWorldCoord() functions, I think the case where parent is true should be different, if you want to support nested parenting.

m_position is basically the offset from either origin or parent (whichever is applicable), but your code won't work correctly if the parent also has a parent.

"Box on top of table" would work, but "Book on top of box on top of table" wouldn't.

 

I think parent->m_position should instead be parent->getWorldCoord().

A similar fix would be needed for your second example.

 

Thanks for pointing that out, i have edited the post.


In Topic: Separate matrices for every glDrawCalls

27 December 2013 - 10:00 AM

I can't really see your problem. You can create a function that returns the world client position, and use it when you want.
Also, i would have made a struct/class for points/vectors, so that you could easily handle coordinates. 

// Example of how a Vector3 struct may look like
struct Vector3
{
    int x, y, z;
    Vector3(int x, int y, int z) : x(x), y(y), z(z) {}

    void set(int x, int y, int z)
    {
        x = x;
        y = y;
        z = z;
    }

    Vector3 operator+(const Vector3 &a) const
    {
        return Vector3(x + a.x, y + a.y, z + a.z);
    }

    /* ... add some other neat functions ... */
};

// Example #1
Vector3 Object::getWorldCoord()
{
    Vector3 result;
    if(parent)
    {
        result = parent->getWorldCoord() + m_position; // position is a Vector3, and is a member of the Object class.
    }
    else
    {
        result = m_position;
    }
    return result;
}

// Example #2 that works out of the box for you
void Object::getWorldCoord(int &outX, int &outY, int &outZ) 
{
    if(parent)
    {
        int parentX, parentY, parentZ;
        parent->getWorldCoord(parentX, parentY, parentZ);
        outX = parentX + x; 
        outY = parentY + y; 
        outZ = parentZ + z;
    }
    else
    {
        outX = x;
        outY = y;
        outZ = z;
    } 
}


In Topic: How to create a physics engine

14 October 2013 - 02:37 AM


Not at all, Bullet's GPU solver is not yet in release.

Did i mention Bullets? Even if i am wrong with Havok, since it has limited GPU support, however are going to have full on next-gen consoles.
 

Hmm, poorly expressed by me. What i mean is that AAA physic engines are moving towards GPU acceleration, which is state of the art. With the next-gen consoles, we would see that CPU based physics engine are being slowly thrown away, in favor of GPU based. Why create a CPU based physic engine, when we are missing a good and open-source GPU based physic engine, that are platform independent. Not that he is going to create a open-source engine, but you see what i mean. The question is what's the goal. Do you want to create an useful engine and push the market, or are you going to create an engine just for education(where parallel programming is a good start though).


In Topic: How to create a physics engine

13 October 2013 - 04:12 AM

If you want to make a physic engine, that may be used in a real project, you should hardware accelerate your physic engine for the GPU, by OpenCL or just by OpenGL shaders( a lot harder though, and more hackish...). That's what makes PhysX and Havoks performance so good. 

As people have pointed out, the method and algorithm used in a physic engine is common across the engines. And as L. Spiro said, Real-Time Collision Detection and Game Physics Engine Development are very good books(I have both). So it is up to you, how you gonna implement the engine, however you should have a decent understanding of geometry and physic laws, that you may recall from high-school. Another thing, it takes time to create a physic engine, so it should only be made for learning purposes or as part of your CV.


PARTNERS