2 Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
\r
5 Physics Effects is open software; you can redistribute it and/or
\r
6 modify it under the terms of the BSD License.
\r
8 Physics Effects is distributed in the hope that it will be useful,
\r
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
11 See the BSD License for more details.
\r
13 A copy of the BSD License is distributed with
\r
14 Physics Effects under the filename: physics_effects_license.txt
\r
17 #include "pfx_intersect_common.h"
\r
18 #include "pfx_intersect_ray_box.h"
\r
21 namespace PhysicsEffects {
\r
23 PfxBool pfxIntersectRayBox(const PfxRayInput &ray,PfxRayOutput &out,const PfxBox &box,const PfxTransform3 &transform)
\r
26 PfxTransform3 transformBox = orthoInverse(transform);
\r
27 PfxVector3 rayStartPosition = transformBox.getUpper3x3() * ray.m_startPosition + transformBox.getTranslation();
\r
28 PfxVector3 rayDirection = transformBox.getUpper3x3() * ray.m_direction;
\r
31 PfxFloat tmpVariable=0.0f;
\r
32 PfxVector3 tmpNormal(0.0f);
\r
33 if(pfxIntersectRayAABB(rayStartPosition,rayDirection,PfxVector3(0.0f),box.m_half,tmpVariable,tmpNormal)) {
\r
34 if(tmpVariable > 0.0f && tmpVariable < out.m_variable) {
\r
35 out.m_contactFlag = true;
\r
36 out.m_variable = tmpVariable;
\r
37 out.m_contactPoint = ray.m_startPosition + tmpVariable * ray.m_direction;
\r
38 out.m_contactNormal = transform.getUpper3x3() * tmpNormal;
\r
39 out.m_subData.m_type = PfxSubData::NONE;
\r
46 } //namespace PhysicsEffects
\r