Collisions (ohysics) for Missiles, Bullets, Explosions etc

void Normalize()
    float lenSquared = LengthSquared();
    if (!Urho3D::Equals(lenSquared, 1.0f) && lenSquared > 0.0f)
        float invLen = 1.0f / sqrtf(lenSquared);
        x_ *= invLen;
        y_ *= invLen;
        z_ *= invLen;
Vector3 Normalized() const
    float lenSquared = LengthSquared();
    if (!Urho3D::Equals(lenSquared, 1.0f) && lenSquared > 0.0f)
        float invLen = 1.0f / sqrtf(lenSquared);
        return *this * invLen;
        return *this;

these are from engine source :rofl:


:bowing_man: lets pause here, gotta have my dinner


cool man, we’ll pick this up later, I’ll like you to try to explain what normalizing is and how it works given you can see the code. It’s basic stuff for me, and I’m pretty laid back and happy to share my brain, lots of people have contributed to my learning experience, I want to pay it forward.


I really have to say, what a pile of shit, that sourcecode is, before I even begin to explain how it really works - I hate API that hide math behind constructs like that - no mention of a dot product

float lenSquared = LengthSquared();

That hideous looking thing, is really, float lenSquared = dot (this vector, and also this vector);
One thing we do learn on the way, is that the dot product of a vector with itself, is its squared length, which we can only learn, by learning how the math works.


Wrapping reused code in a function is common practice in object oriented programming.
Indeed this does not conserve mathematical elegance.


I use oop as I see fit, I am starting to mix pure c with urho, because I am lazy, and because I am lazy like a fox
off topic police will be here any moment


game development is not my passion, its my calling, I trained for this with robots spitting hot metal at me, getting the decimal point in the wrong place in one line of code caused the 30 foot long monster to try to tear itself apart, it was not acceptable to make mistakes


Yet oh so tempting. :stuck_out_tongue:


ok so sometimes, I would stall the motor, and warm up my lunch on it


robots have a sense of humour, and put up with a lot of shit, except putting the decimal point in the wrong place, this is the cardinal sin - I coded up to seven axes, which is just like a bone hierarchy in a game


its really hard man, to code for many axes, when theres hammers smashing everywhere around you - and not make any mistakes, no errors, no floating point issues, no dot in the wrong spot


I was pondering earlier today how a proper AI might only be able to laugh uncontrollably (mainly at us) after it took in enough information.


I wish I could show you my work on gpu nnai for games, it scared the shit out of me


we’re wayyy off topic, take it to pm


:cactus: :oncoming_police_car:


lets back to this very basic question, should we? :joy:


Elaborating on my earlier post:

So you could multiply the mass of the bullet by it’s speed and apply that force to the target hit. That would be somewhat realistic. But you may want to increase the force and throw realism out the window, like they do in Hollywood, making a single bullet throw a person through the air.


ok so we have a ray, it has a direction, and theoretically infinite length, but for the purposes of working out the force, we have direction, mass, and force, where force is, in terms of guns, related to the exit velocity - we can compute the force that left the gun, apply drag and friction and any other slowdowns, and at the end of its travel, when it hits the target, we can make some assumptions, based on what we think we know about physics - its a game, we get to play with the input values, and make them plausible in our game - wait thats wrong, we need to make the OUTCOME plausible, and how we did it, what math cheats we took, are not relevant to the user


the magic in the magic show, is not in the hand or hat of the magician, its in his assistants underwear, its mostly slight of hand, doing the actual math is too slow, so we find ways to approximate it and get it done, getting shit done is the word of mouth way the game industry works, if you can get shit done, you get a job, and if you cant, you get the sack, its not a perfect world - but you can learn real magic from people around you, and apply it


:thinking: but the mass times speed wont equal force at all