On Friday, 13 January 2017 at 16:56:43 UTC, WhatMeWorry wrote:
I'm converting some C++ and glm code to D and gl3n. And I'm stumped at the following line.


GLboolean CheckCollision(BallObject &one, GameObject &two) // AABB - Circle collision
{
    // Get center point circle first
    glm::vec2 center(one.Position + one.Radius);
    . . .
}

one.Position is a vec2 (x and y) whereas Radius is a GLfloat

// my D code statement

vec2 center2 = one.position + one.radius;   // D code with gl3n

returns Error: incompatible types for ((one.position) + (one.radius)): 'Vector!(float, 2)' and 'float'

I agree with the D code. A vec and scalar can't be added together. So why (or how) is the glm code working?


I looked at https://github.com/g-truc/glm project source, but I'm not even sure where to start?

Thanks

If you're doing game dev stuff I'd highly recommend using/taking a look at https://github.com/d-gamedev-team/ and in particular using https://github.com/d-gamedev-team/gfm/ as your math library.

It appears to support what you want https://github.com/d-gamedev-team/gfm/blob/master/math/gfm/math/vector.d#L53-59

Reply via email to