From 315c701f34296eabe828894599841581f4807559 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Wed, 30 Mar 2016 07:09:35 +0200 Subject: [PATCH] Move method in cpp file --- src/collision/shapes/HeightFieldShape.cpp | 25 +++++++++++++++++++++++ src/collision/shapes/HeightFieldShape.h | 25 ----------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/collision/shapes/HeightFieldShape.cpp b/src/collision/shapes/HeightFieldShape.cpp index 12df598c..c2bd652b 100644 --- a/src/collision/shapes/HeightFieldShape.cpp +++ b/src/collision/shapes/HeightFieldShape.cpp @@ -208,6 +208,31 @@ bool HeightFieldShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxySh return triangleCallback.getIsHit(); } +// Return the vertex (local-coordinates) of the height field at a given (x,y) position +Vector3 HeightFieldShape::getVertexAt(int x, int y) const { + + // Get the height value + const decimal height = getHeightAt(x, y); + + // Height values origin + const decimal heightOrigin = -(mMaxHeight - mMinHeight) * decimal(0.5) - mMinHeight; + + Vector3 vertex; + switch (mUpAxis) { + case 0: vertex = Vector3(heightOrigin + height, -mWidth * decimal(0.5) + x, -mLength * decimal(0.5) + y); + break; + case 1: vertex = Vector3(-mWidth * decimal(0.5) + x, heightOrigin + height, -mLength * decimal(0.5) + y); + break; + case 2: vertex = Vector3(-mWidth * decimal(0.5) + x, -mLength * decimal(0.5) + y, heightOrigin + height); + break; + default: assert(false); + } + + assert(mAABB.contains(vertex)); + + return vertex * mScaling; +} + // Raycast test between a ray and a triangle of the heightfield void TriangleOverlapCallback::testTriangle(const Vector3* trianglePoints) { diff --git a/src/collision/shapes/HeightFieldShape.h b/src/collision/shapes/HeightFieldShape.h index 82a4d667..77c906a3 100644 --- a/src/collision/shapes/HeightFieldShape.h +++ b/src/collision/shapes/HeightFieldShape.h @@ -219,31 +219,6 @@ inline void HeightFieldShape::setLocalScaling(const Vector3& scaling) { CollisionShape::setLocalScaling(scaling); } -// Return the vertex (local-coordinates) of the height field at a given (x,y) position -inline Vector3 HeightFieldShape::getVertexAt(int x, int y) const { - - // Get the height value - const decimal height = getHeightAt(x, y); - - // Height values origin - const decimal heightOrigin = -(mMaxHeight - mMinHeight) * decimal(0.5) - mMinHeight; - - Vector3 vertex; - switch (mUpAxis) { - case 0: vertex = Vector3(heightOrigin + height, -mWidth * decimal(0.5) + x, -mLength * decimal(0.5) + y); - break; - case 1: vertex = Vector3(-mWidth * decimal(0.5) + x, heightOrigin + height, -mLength * decimal(0.5) + y); - break; - case 2: vertex = Vector3(-mWidth * decimal(0.5) + x, -mLength * decimal(0.5) + y, heightOrigin + height); - break; - default: assert(false); - } - - assert(mAABB.contains(vertex)); - - return vertex * mScaling; -} - // Return the height of a given (x,y) point in the height field inline decimal HeightFieldShape::getHeightAt(int x, int y) const {