Panda3D
 All Classes Functions Variables Enumerations
physxHeightFieldDesc.I
00001 // Filename: physxHeightFieldDesc.I
00002 // Created by:  enn0x (15Oct09)
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 
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: PhysxHeightFieldDesc::Constructor
00019 //       Access: Published
00020 //  Description:
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE PhysxHeightFieldDesc::
00023 PhysxHeightFieldDesc() {
00024 
00025   _samples = NULL;
00026   _desc.setToDefault();
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: PhysxHeightFieldDesc::Destructor
00031 //       Access: Published
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE PhysxHeightFieldDesc::
00035 ~PhysxHeightFieldDesc() {
00036 
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: PhysxHeightFieldDesc::set_to_default
00041 //       Access: Published
00042 //  Description: (re)sets the structure to the default.
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE void PhysxHeightFieldDesc::
00045 set_to_default() {
00046 
00047   _desc.setToDefault();
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: PhysxHeightFieldDesc::is_valid
00052 //       Access: Published
00053 //  Description: Returns true if the descriptor is valid.
00054 ////////////////////////////////////////////////////////////////////
00055 INLINE bool PhysxHeightFieldDesc::
00056 is_valid() const {
00057 
00058   return _desc.isValid();
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: PhysxHeightFieldDesc::set_size
00063 //       Access: Private
00064 //  Description:
00065 ////////////////////////////////////////////////////////////////////
00066 INLINE void PhysxHeightFieldDesc::
00067 set_size(unsigned int num_rows, unsigned int num_columns) {
00068 
00069   if (_samples) {
00070     unset_size();
00071   }
00072 
00073   _desc.format = NX_HF_S16_TM;
00074   _desc.nbRows = (NxU32) num_rows;
00075   _desc.nbColumns = (NxU32) num_columns;
00076   _desc.sampleStride = sizeof(NxU32);
00077 
00078   _samples = new NxU32[_desc.nbColumns * _desc.nbRows];
00079   _desc.samples = _samples;
00080 
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: PhysxHeightFieldDesc::unset_size
00085 //       Access: Private
00086 //  Description: Releases the memory allocated for the height field
00087 //               samples.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void PhysxHeightFieldDesc::
00090 unset_size() {
00091 
00092   if (_samples) {
00093     _desc.nbRows = (NxU32) 0;
00094     _desc.nbColumns = (NxU32) 0;
00095     _desc.samples = NULL;
00096     delete[] _samples;
00097   }
00098 }
00099 
 All Classes Functions Variables Enumerations