vertexPolyList.cpp
Engine/source/collision/vertexPolyList.cpp
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platform.h" 25#include "collision/vertexPolyList.h" 26 27 28VertexPolyList::VertexPolyList() 29{ 30 VECTOR_SET_ASSOCIATION(mVertexList); 31 mVertexList.reserve(100); 32 33 mCurrObject = NULL; 34 mBaseMatrix = MatrixF::Identity; 35 mMatrix = MatrixF::Identity; 36 mTransformMatrix = MatrixF::Identity; 37 mScale.set(1.0f, 1.0f, 1.0f); 38 39 mPlaneTransformer.setIdentity(); 40 41 mInterestNormalRegistered = false; 42} 43 44void VertexPolyList::clear() 45{ 46 mVertexList.clear(); 47} 48 49const PlaneF& VertexPolyList::getIndexedPlane(const U32 index) 50{ 51 static const PlaneF dummy( 0, 0, 0, -1 ); 52 return dummy; 53} 54 55U32 VertexPolyList::addPoint( const Point3F &p ) 56{ 57 // Apply the transform 58 Point3F tp = p * mScale; 59 mMatrix.mulP( tp ); 60 61 Vector<Point3F>::iterator iter = mVertexList.begin(); 62 for ( ; iter != mVertexList.end(); iter++ ) 63 { 64 if ( iter->equal( tp ) ) 65 return iter - mVertexList.begin(); 66 } 67 68 mVertexList.push_back( tp ); 69 return mVertexList.size() - 1; 70} 71