OPC_BaseModel.cpp
Go to the documentation of this file.
00001 
00002 /*
00003  *      OPCODE - Optimized Collision Detection
00004  *      Copyright (C) 2001 Pierre Terdiman
00005  *      Homepage: http://www.codercorner.com/Opcode.htm
00006  */
00008 
00010 
00016 
00017 
00019 
00027 
00028 
00030 // Precompiled Header
00031 #include "Stdafx.h"
00032 
00033 using namespace Opcode;
00034 
00036 
00039 
00040 OPCODECREATE::OPCODECREATE()
00041 {
00042         mIMesh                          = null;
00043         mSettings.mRules        = SPLIT_SPLATTER_POINTS | SPLIT_GEOM_CENTER;
00044         mSettings.mLimit        = 1;    // Mandatory for complete trees
00045         mNoLeaf                         = true;
00046         mQuantized                      = true;
00047 #ifdef __MESHMERIZER_H__
00048         mCollisionHull          = false;
00049 #endif // __MESHMERIZER_H__
00050         mKeepOriginal           = false;
00051         mCanRemap                       = false;
00052 }
00053 
00055 
00058 
00059 BaseModel::BaseModel() : mIMesh(null), mModelCode(0), mSource(null), mTree(null)
00060 {
00061 }
00062 
00064 
00067 
00068 BaseModel::~BaseModel()
00069 {
00070         ReleaseBase();
00071 }
00072 
00074 
00077 
00078 void BaseModel::ReleaseBase()
00079 {
00080         DELETESINGLE(mSource);
00081         DELETESINGLE(mTree);
00082 }
00083 
00085 
00091 
00092 bool BaseModel::CreateTree(bool no_leaf, bool quantized)
00093 {
00094         DELETESINGLE(mTree);
00095 
00096         // Setup model code
00097         if(no_leaf)             mModelCode |= OPC_NO_LEAF;
00098         else                    mModelCode &= ~OPC_NO_LEAF;
00099 
00100         if(quantized)   mModelCode |= OPC_QUANTIZED;
00101         else                    mModelCode &= ~OPC_QUANTIZED;
00102 
00103         // Create the correct class
00104         if(mModelCode & OPC_NO_LEAF)
00105         {
00106                 if(mModelCode & OPC_QUANTIZED)  mTree = new AABBQuantizedNoLeafTree;
00107                 else                                                    mTree = new AABBNoLeafTree;
00108         }
00109         else
00110         {
00111                 if(mModelCode & OPC_QUANTIZED)  mTree = new AABBQuantizedTree;
00112                 else                                                    mTree = new AABBCollisionTree;
00113         }
00114         CHECKALLOC(mTree);
00115 
00116         return true;
00117 }
00118 
00120 
00126 
00127 bool BaseModel::Refit()
00128 {
00129         // Refit the optimized tree
00130         return mTree->Refit(mIMesh);
00131 
00132 // Old code kept for reference : refit the source tree then rebuild !
00133 //      if(!mSource)    return false;
00134 //      // Ouch...
00135 //      mSource->Refit(&mTB);
00136 //      // Ouch...
00137 //      return mTree->Build(mSource);
00138 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:18