Panda3D

bulletBoxShape.cxx

00001 // Filename: bulletBoxShape.cxx
00002 // Created by:  enn0x (24Jan10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "bulletBoxShape.h"
00016 #include "bullet_utils.h"
00017 
00018 TypeHandle BulletBoxShape::_type_handle;
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: BulletBoxShape::Constructor
00022 //       Access: Published
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 BulletBoxShape::
00026 BulletBoxShape(const LVecBase3 &halfExtents) {
00027 
00028   btVector3 btHalfExtents = LVecBase3_to_btVector3(halfExtents);
00029 
00030   _shape = new btBoxShape(btHalfExtents);
00031   _shape->setUserPointer(this);
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: BulletBoxShape::ptr
00036 //       Access: Public
00037 //  Description:
00038 ////////////////////////////////////////////////////////////////////
00039 btCollisionShape *BulletBoxShape::
00040 ptr() const {
00041 
00042   return _shape;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: BulletBoxShape::get_half_extents_without_margin
00047 //       Access: Published
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 LVecBase3 BulletBoxShape::
00051 get_half_extents_without_margin() const {
00052 
00053   return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin());
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: BulletBoxShape::get_half_extents_with_margin
00058 //       Access: Published
00059 //  Description:
00060 ////////////////////////////////////////////////////////////////////
00061 LVecBase3 BulletBoxShape::
00062 get_half_extents_with_margin() const {
00063 
00064   return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin());
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: BulletBoxShape::make_from_solid
00069 //       Access: Public
00070 //  Description:
00071 ////////////////////////////////////////////////////////////////////
00072 BulletBoxShape *BulletBoxShape::
00073 make_from_solid(const CollisionBox *solid) {
00074 
00075   LPoint3 p0 = solid->get_min();
00076   LPoint3 p1 = solid->get_max();
00077 
00078   LVecBase3 extents(p1.get_x() - p0.get_x() / 2.0,
00079                      p1.get_y() - p0.get_y() / 2.0,
00080                      p1.get_z() - p0.get_z() / 2.0);
00081 
00082   return new BulletBoxShape(extents);
00083 }
00084 
 All Classes Functions Variables Enumerations