Esempio n. 1
0
        /// Overriden PS_Collider
        bool _support(const PS_Vector3& point, PS_Vector3& position, PS_Vector3& normal) const
        {
            if (!mTester)
                return false;

            Vector3 pos, norm;
            if (!mTester->_support(Vector3(point.x, point.y, point.z), pos, norm))
                return false;

            position = PS_Vector3(pos.x, pos.y, pos.z);
            normal = PS_Vector3(norm.x, norm.y, norm.z);
            return true;
        }
//------------------------------------------------------------------------------
bool PS_SphereCollider::_support(const PS_Vector3& point, PS_Vector3& position, PS_Vector3& normal) const
{
    // Transform point to our local coordinate, note that rotation of sphere is meaningless
    PS_Vector3 v = point - mPosition;

    // Calculate the distane between the point and the sphere centre
    PS_Scalar squaredDistance = v.squaredLength();

    // Check out of bound
    if (mSquaredRadius <= squaredDistance)
        return false;

    // Reuse v to calculate normal to avoid allocate
    if (squaredDistance)
        v = v / PS_Math::Sqrt(squaredDistance);
    else
        v = PS_Vector3(0, 0, 1);

    normal = v;
    position = mPosition + v * mRadius;
    return true;
}
Esempio n. 3
0
 void setPosition(const Vector3& pos)
 {
     this->Impl::setPosition(PS_Vector3(pos.x, pos.y, pos.z));
 }
Esempio n. 4
0
 StdCollider* createBoxCollider(const Vector3& extents)
 {
     return _addCollider(new StdColliderImpl<PS_BoxCollider>(PS_Vector3(extents.x, extents.y, extents.z)));
 }