vehicleBlocker.cpp
Engine/source/T3D/vehicles/vehicleBlocker.cpp
Public Functions
ConsoleDocClass(VehicleBlocker , "@brief Legacy class from Tribes, originally used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> blocking <a href="/coding/class/classvehicle/">Vehicle</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">objects.\n\n</a>" " @note This is no longer useful and should be deprecated <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">soon.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">internal\n</a>" )
Detailed Description
Public Functions
ConsoleDocClass(VehicleBlocker , "@brief Legacy class from Tribes, originally used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> blocking <a href="/coding/class/classvehicle/">Vehicle</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">objects.\n\n</a>" " @note This is no longer useful and should be deprecated <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">soon.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">internal\n</a>" )
IMPLEMENT_CO_NETOBJECT_V1(VehicleBlocker )
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 "T3D/vehicles/vehicleBlocker.h" 26 27#include "core/stream/bitStream.h" 28#include "scene/sceneRenderState.h" 29#include "scene/sceneManager.h" 30#include "math/mathIO.h" 31#include "console/consoleTypes.h" 32 33IMPLEMENT_CO_NETOBJECT_V1(VehicleBlocker); 34 35ConsoleDocClass( VehicleBlocker, 36 "@brief Legacy class from Tribes, originally used for blocking Vehicle objects.\n\n" 37 38 "@note This is no longer useful and should be deprecated soon.\n\n" 39 40 "@internal\n" 41); 42 43//-------------------------------------------------------------------------- 44//-------------------------------------------------------------------------- 45VehicleBlocker::VehicleBlocker() 46{ 47 mNetFlags.set(Ghostable | ScopeAlways); 48 49 mTypeMask = VehicleBlockerObjectType; 50 51 mConvexList = new Convex; 52} 53 54VehicleBlocker::~VehicleBlocker() 55{ 56 delete mConvexList; 57 mConvexList = NULL; 58} 59 60//-------------------------------------------------------------------------- 61void VehicleBlocker::initPersistFields() 62{ 63 addField("dimensions", TypePoint3F, Offset(mDimensions, VehicleBlocker)); 64 Parent::initPersistFields(); 65} 66 67//-------------------------------------------------------------------------- 68bool VehicleBlocker::onAdd() 69{ 70 if(!Parent::onAdd()) 71 return false; 72 73 mObjBox.minExtents.set(-mDimensions.x, -mDimensions.y, 0); 74 mObjBox.maxExtents.set( mDimensions.x, mDimensions.y, mDimensions.z); 75 if( !mObjBox.isValidBox() ) 76 { 77 Con::errorf("VehicleBlocker::onAdd - Fail - No valid object box"); 78 return false; 79 } 80 81 resetWorldBox(); 82 setRenderTransform(mObjToWorld); 83 84 addToScene(); 85 86 return true; 87} 88 89 90void VehicleBlocker::onRemove() 91{ 92 mConvexList->nukeList(); 93 removeFromScene(); 94 95 Parent::onRemove(); 96} 97 98 99U32 VehicleBlocker::packUpdate(NetConnection *con, U32 mask, BitStream *stream) 100{ 101 U32 retMask = Parent::packUpdate(con, mask, stream); 102 103 mathWrite(*stream, getTransform()); 104 mathWrite(*stream, getScale()); 105 mathWrite(*stream, mDimensions); 106 107 return retMask; 108} 109 110 111void VehicleBlocker::unpackUpdate(NetConnection *con, BitStream *stream) 112{ 113 Parent::unpackUpdate(con, stream); 114 115 MatrixF mat; 116 Point3F scale; 117 Box3F objBox; 118 mathRead(*stream, &mat); 119 mathRead(*stream, &scale); 120 mathRead(*stream, &mDimensions); 121 mObjBox.minExtents.set(-mDimensions.x, -mDimensions.y, 0); 122 mObjBox.maxExtents.set( mDimensions.x, mDimensions.y, mDimensions.z); 123 setScale(scale); 124 setTransform(mat); 125} 126 127 128void VehicleBlocker::buildConvex(const Box3F& box, Convex* convex) 129{ 130 // These should really come out of a pool 131 mConvexList->collectGarbage(); 132 133 if (box.isOverlapped(getWorldBox()) == false) 134 return; 135 136 // Just return a box convex for the entire shape... 137 Convex* cc = 0; 138 CollisionWorkingList& wl = convex->getWorkingList(); 139 for (CollisionWorkingList* itr = wl.wLink.mNext; itr != &wl; itr = itr->wLink.mNext) 140 { 141 if (itr->mConvex->getType() == BoxConvexType && 142 itr->mConvex->getObject() == this) { 143 cc = itr->mConvex; 144 break; 145 } 146 } 147 if (cc) 148 return; 149 150 // Create a new convex. 151 BoxConvex* cp = new BoxConvex; 152 mConvexList->registerObject(cp); 153 convex->addToWorkingList(cp); 154 cp->init(this); 155 156 mObjBox.getCenter(&cp->mCenter); 157 cp->mSize.x = mObjBox.len_x() / 2.0f; 158 cp->mSize.y = mObjBox.len_y() / 2.0f; 159 cp->mSize.z = mObjBox.len_z() / 2.0f; 160} 161 162