00001 // Filename: physxHeightField.cxx 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 #include "physxHeightField.h" 00016 00017 TypeHandle PhysxHeightField::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: PhysxHeightField::link 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 void PhysxHeightField:: 00025 link(NxHeightField *hfPtr) { 00026 00027 PhysxManager::get_global_ptr()->_heightfields.add(this); 00028 _ptr = hfPtr; 00029 _error_type = ET_ok; 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: PhysxHeightField::unlink 00034 // Access: Public 00035 // Description: 00036 //////////////////////////////////////////////////////////////////// 00037 void PhysxHeightField:: 00038 unlink() { 00039 00040 _error_type = ET_released; 00041 PhysxManager::get_global_ptr()->_heightfields.remove(this); 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: PhysxHeightField::release 00046 // Access: Public 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 void PhysxHeightField:: 00050 release() { 00051 00052 nassertv(_error_type == ET_ok); 00053 00054 unlink(); 00055 NxGetPhysicsSDK()->releaseHeightField(*_ptr); 00056 _ptr = NULL; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: PhysxHeightField::get_height 00061 // Access: Published 00062 // Description: 00063 //////////////////////////////////////////////////////////////////// 00064 float PhysxHeightField:: 00065 get_height(float x, float y) const { 00066 00067 nassertr(_error_type == ET_ok, 0.0f); 00068 return _ptr->getHeight(x, y); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: PhysxHeightField::get_reference_count 00073 // Access: Published 00074 // Description: Returns the reference count for shared meshes. 00075 //////////////////////////////////////////////////////////////////// 00076 unsigned int PhysxHeightField:: 00077 get_reference_count() const { 00078 00079 nassertr(_error_type == ET_ok, 0); 00080 return _ptr->getReferenceCount(); 00081 } 00082