mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Debug renderer: rendering triangles and improved performance, and smaller fixes.
This commit is contained in:
parent
2e503bd284
commit
d5c93ae026
@ -71,6 +71,7 @@
|
||||
physxJointLimitDesc.I physxJointLimitDesc.h \
|
||||
physxJointLimitSoftDesc.I physxJointLimitSoftDesc.h \
|
||||
physxKitchen.I physxKitchen.h \
|
||||
physxLinearInterpolationValues.I physxLinearInterpolationValues.h \
|
||||
physxManager.I physxManager.h \
|
||||
physxMask.I physxMask.h \
|
||||
physxMaterial.I physxMaterial.h \
|
||||
@ -120,6 +121,10 @@
|
||||
physxUtilLib.I physxUtilLib.h \
|
||||
physxWheelShape.I physxWheelShape.h \
|
||||
physxWheelShapeDesc.I physxWheelShapeDesc.h \
|
||||
#physxVehicleGears.I physxVehicleGears.h \
|
||||
#physxVehicleGearsDesc.I physxVehicleGearsDesc.h \
|
||||
#physxVehicleMotor.I physxVehicleMotor.h \
|
||||
#physxVehicleMotorDesc.I physxVehicleMotorDesc.h \
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_physx.cxx \
|
||||
@ -182,6 +187,7 @@
|
||||
physxJointLimitDesc.cxx \
|
||||
physxJointLimitSoftDesc.cxx \
|
||||
physxKitchen.cxx \
|
||||
physxLinearInterpolationValues.cxx \
|
||||
physxManager.cxx \
|
||||
physxMask.cxx \
|
||||
physxMaterial.cxx \
|
||||
@ -231,6 +237,10 @@
|
||||
physxUtilLib.cxx \
|
||||
physxWheelShape.cxx \
|
||||
physxWheelShapeDesc.cxx \
|
||||
#physxVehicleGears.cxx \
|
||||
#physxVehicleGearsDesc.cxx \
|
||||
#physxVehicleMotor.cxx \
|
||||
#physxVehicleMotorDesc.cxx \
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
config_physx.h \
|
||||
@ -293,6 +303,7 @@
|
||||
physxJointLimitDesc.I physxJointLimitDesc.h \
|
||||
physxJointLimitSoftDesc.I physxJointLimitSoftDesc.h \
|
||||
physxKitchen.I physxKitchen.h \
|
||||
physxLinearInterpolationValues.I physxLinearInterpolationValues.h \
|
||||
physxManager.I physxManager.h \
|
||||
physxMask.I physxMask.h \
|
||||
physxMaterial.I physxMaterial.h \
|
||||
@ -342,6 +353,10 @@
|
||||
physxUtilLib.I physxUtilLib.h \
|
||||
physxWheelShape.I physxWheelShape.h \
|
||||
physxWheelShapeDesc.I physxWheelShapeDesc.h \
|
||||
#physxVehicleGears.I physxVehicleGears.h \
|
||||
#physxVehicleGearsDesc.I physxVehicleGearsDesc.h \
|
||||
#physxVehicleMotor.I physxVehicleMotor.h \
|
||||
#physxVehicleMotorDesc.I physxVehicleMotorDesc.h \
|
||||
|
||||
#define IGATESCAN all
|
||||
|
||||
|
@ -54,6 +54,10 @@
|
||||
#include "physxSphericalJoint.h"
|
||||
#include "physxTriangleMesh.h"
|
||||
#include "physxTriangleMeshShape.h"
|
||||
//#include "physxVehicle.h"
|
||||
//#include "physxVehicleGears.h"
|
||||
//#include "physxVehicleMotor.h"
|
||||
//#include "physxWheel.h"
|
||||
#include "physxWheelShape.h"
|
||||
|
||||
ConfigureDef(config_physx);
|
||||
@ -140,6 +144,10 @@ init_libphysx() {
|
||||
PhysxSphericalJoint::init_type();
|
||||
PhysxTriangleMesh::init_type();
|
||||
PhysxTriangleMeshShape::init_type();
|
||||
//PhysxVehicle::init_type();
|
||||
//PhysxVehicleGears::init_type();
|
||||
//PhysxVehicleMotor::init_type();
|
||||
//PhysxWheel::init_type();
|
||||
PhysxWheelShape::init_type();
|
||||
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
|
@ -279,12 +279,12 @@ report_scene_changed() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxController::update
|
||||
// Function: PhysxController::update_controller
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxController::
|
||||
update(float dt) {
|
||||
update_controller(float dt) {
|
||||
|
||||
nassertv(_error_type == ET_ok);
|
||||
|
||||
|
@ -61,7 +61,7 @@ PUBLISHED:
|
||||
INLINE void ls(ostream &out, int indent_level=0) const;
|
||||
|
||||
public:
|
||||
void update(float dt);
|
||||
void update_controller(float dt);
|
||||
|
||||
static PhysxController *factory(NxControllerType shapeType);
|
||||
|
||||
|
@ -23,6 +23,26 @@ INLINE PhysxDebugGeomNode::
|
||||
PhysxDebugGeomNode() : GeomNode("debug") {
|
||||
|
||||
_scale = 1.0f;
|
||||
|
||||
_vdata = new GeomVertexData("", GeomVertexFormat::get_v3c4(), Geom::UH_stream);
|
||||
|
||||
// Lines
|
||||
_prim_lines = new GeomLines(Geom::UH_stream);
|
||||
_prim_lines->set_shade_model(Geom::SM_uniform);
|
||||
|
||||
_geom_lines = new Geom(_vdata);
|
||||
_geom_lines->add_primitive(_prim_lines);
|
||||
|
||||
this->add_geom(_geom_lines);
|
||||
|
||||
// Triangles
|
||||
_prim_triangles = new GeomTriangles(Geom::UH_stream);
|
||||
_prim_triangles->set_shade_model(Geom::SM_uniform);
|
||||
|
||||
_geom_triangles = new Geom(_vdata);
|
||||
_geom_triangles->add_primitive(_prim_triangles);
|
||||
|
||||
this->add_geom(_geom_triangles);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
#include "physxDebugGeomNode.h"
|
||||
|
||||
#include "geomVertexFormat.h"
|
||||
#include "geomVertexWriter.h"
|
||||
|
||||
TypeHandle PhysxDebugGeomNode::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -35,31 +38,72 @@ update(NxScene *scenePtr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const NxDebugLine *lines = renderable->getLines();
|
||||
NxU32 n = renderable->getNbLines();
|
||||
GeomVertexWriter vwriter = GeomVertexWriter(_vdata, InternalName::get_vertex());
|
||||
GeomVertexWriter cwriter = GeomVertexWriter(_vdata, InternalName::get_color());
|
||||
|
||||
_segs.reset();
|
||||
int v = 0;
|
||||
|
||||
for (NxU32 i=0; i<n; i++)
|
||||
_prim_lines->clear_vertices();
|
||||
_prim_triangles->clear_vertices();
|
||||
|
||||
// Lines
|
||||
{
|
||||
NxF32 b = NxF32((lines[i].color)&0xff) / 255.0f;
|
||||
NxF32 g = NxF32((lines[i].color>>8)&0xff) / 255.0f;
|
||||
NxF32 r = NxF32((lines[i].color>>16)&0xff) / 255.0f;
|
||||
NxU32 n = renderable->getNbLines();
|
||||
const NxDebugLine *lines = renderable->getLines();
|
||||
|
||||
NxVec3 p0 = lines[i].p0;
|
||||
NxVec3 p1 = lines[i].p1;
|
||||
for (NxU32 i=0; i<n; i++)
|
||||
{
|
||||
NxF32 b = NxF32((lines[i].color)&0xff) / 255.0f;
|
||||
NxF32 g = NxF32((lines[i].color>>8)&0xff) / 255.0f;
|
||||
NxF32 r = NxF32((lines[i].color>>16)&0xff) / 255.0f;
|
||||
|
||||
NxVec3 p0 = lines[i].p0;
|
||||
NxVec3 p1 = lines[i].p1;
|
||||
|
||||
cwriter.add_data4f(r, g, b, 1.0f);
|
||||
vwriter.add_data3f(p0.x, p0.y, p0.z);
|
||||
_prim_lines->add_vertex(v++);
|
||||
|
||||
cwriter.add_data4f(r, g, b, 1.0f);
|
||||
vwriter.add_data3f(p1.x, p1.y, p1.z);
|
||||
_prim_lines->add_vertex(v++);
|
||||
}
|
||||
|
||||
_segs.set_color(r, g, b);
|
||||
_segs.move_to(p0.x, p0.y, p0.z);
|
||||
_segs.draw_to(p1.x, p1.y, p1.z);
|
||||
}
|
||||
|
||||
GeomNode *node = _segs.create();
|
||||
remove_all_geoms();
|
||||
add_geoms_from(node);
|
||||
delete node;
|
||||
// Triangles
|
||||
{
|
||||
NxU32 n = renderable->getNbTriangles();
|
||||
const NxDebugTriangle *triangles = renderable->getTriangles();
|
||||
|
||||
physx_cat.spam() << "Updated PhysxDebugGeomNode geometry (" << n << " lines)\n";
|
||||
for (NxU32 i=0; i<n; i++)
|
||||
{
|
||||
NxF32 b = NxF32((triangles[i].color)&0xff) / 255.0f;
|
||||
NxF32 g = NxF32((triangles[i].color>>8)&0xff) / 255.0f;
|
||||
NxF32 r = NxF32((triangles[i].color>>16)&0xff) / 255.0f;
|
||||
|
||||
NxVec3 p0 = triangles[i].p0;
|
||||
NxVec3 p1 = triangles[i].p1;
|
||||
NxVec3 p2 = triangles[i].p2;
|
||||
|
||||
cwriter.add_data4f(r, g, b, 1.0f);
|
||||
vwriter.add_data3f(p0.x, p0.y, p0.z);
|
||||
_prim_triangles->add_vertex(v++);
|
||||
|
||||
cwriter.add_data4f(r, g, b, 1.0f);
|
||||
vwriter.add_data3f(p1.x, p1.y, p1.z);
|
||||
_prim_triangles->add_vertex(v++);
|
||||
|
||||
cwriter.add_data4f(r, g, b, 1.0f);
|
||||
vwriter.add_data3f(p2.x, p2.y, p2.z);
|
||||
_prim_triangles->add_vertex(v++);
|
||||
}
|
||||
}
|
||||
|
||||
_prim_lines->close_primitive();
|
||||
_prim_triangles->close_primitive();
|
||||
|
||||
physx_cat.spam() << "Updated PhysxDebugGeomNode geometry\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -19,7 +19,10 @@
|
||||
#include "pointerTo.h"
|
||||
#include "geomNode.h"
|
||||
#include "transformState.h"
|
||||
#include "lineSegs.h"
|
||||
#include "geom.h"
|
||||
#include "geomVertexData.h"
|
||||
#include "geomLines.h"
|
||||
#include "geomTriangles.h"
|
||||
|
||||
#include "physx_includes.h"
|
||||
|
||||
@ -78,9 +81,14 @@ public:
|
||||
void update(NxScene *scenePtr);
|
||||
|
||||
private:
|
||||
LineSegs _segs;
|
||||
float _scale;
|
||||
|
||||
PT(GeomVertexData) _vdata;
|
||||
PT(Geom) _geom_lines;
|
||||
PT(GeomLines) _prim_lines;
|
||||
PT(Geom) _geom_triangles;
|
||||
PT(GeomTriangles) _prim_triangles;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
@ -301,8 +301,14 @@
|
||||
|
||||
#endif // CPPPARSER
|
||||
|
||||
// PhysxWheelFlag
|
||||
#define NX_WF_STEERABLE_INPUT 1<<0
|
||||
#define NX_WF_STEERABLE_AUTO 1<<1
|
||||
#define NX_WF_AFFECTED_BY_HANDBRAKE 1<<2
|
||||
#define NX_WF_ACCELERATED 1<<3
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : BamEnums
|
||||
// Class : PhysxEnums
|
||||
// Description : This class exists just to provide scoping for the
|
||||
// enums shared by PhysX classes.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -603,6 +609,13 @@ PUBLISHED:
|
||||
Z_up = NX_Z
|
||||
};
|
||||
|
||||
enum PhysxWheelFlag {
|
||||
WF_steerable_input = NX_WF_STEERABLE_INPUT,
|
||||
WF_steerable_auto = NX_WF_STEERABLE_AUTO,
|
||||
WF_affected_by_handbrake = NX_WF_AFFECTED_BY_HANDBRAKE,
|
||||
WF_accelerated = NX_WF_ACCELERATED
|
||||
};
|
||||
|
||||
enum PhysxWheelShapeFlag {
|
||||
WSF_wheel_axis_contact_normal = NX_WF_WHEEL_AXIS_CONTACT_NORMAL,
|
||||
WSF_input_lat_slipvelocity = NX_WF_INPUT_LAT_SLIPVELOCITY,
|
||||
|
35
panda/src/physx/physxLinearInterpolationValues.I
Normal file
35
panda/src/physx/physxLinearInterpolationValues.I
Normal file
@ -0,0 +1,35 @@
|
||||
// Filename: physxLinearInterpolationValues.I
|
||||
// Created by: enn0x (08Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PhysxLinearInterpolationValues::
|
||||
PhysxLinearInterpolationValues() : _min(0.0f), _max(0.0f), _map() {
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PhysxLinearInterpolationValues::
|
||||
~PhysxLinearInterpolationValues() {
|
||||
|
||||
}
|
||||
|
132
panda/src/physx/physxLinearInterpolationValues.cxx
Normal file
132
panda/src/physx/physxLinearInterpolationValues.cxx
Normal file
@ -0,0 +1,132 @@
|
||||
// Filename: physxLinearInterpolationValues.cxx
|
||||
// Created by: enn0x (08Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "physxLinearInterpolationValues.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::clear
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxLinearInterpolationValues::
|
||||
clear() {
|
||||
|
||||
_map.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::insert
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxLinearInterpolationValues::
|
||||
insert(float index, float value) {
|
||||
|
||||
if (_map.empty()) {
|
||||
_min = _max = index;
|
||||
}
|
||||
else {
|
||||
_min = min(_min, index);
|
||||
_max = max(_max, index);
|
||||
}
|
||||
_map[index] = value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::is_valid
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PhysxLinearInterpolationValues::
|
||||
is_valid(float number) const {
|
||||
|
||||
return (number >= _min) && (number <= _max);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::get_size
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
unsigned int PhysxLinearInterpolationValues::
|
||||
get_size() const {
|
||||
|
||||
return _map.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::get_value
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float PhysxLinearInterpolationValues::
|
||||
get_value(float number) const {
|
||||
|
||||
MapType::const_iterator lower = _map.begin();
|
||||
if (number < _min) {
|
||||
return lower->second;
|
||||
}
|
||||
|
||||
MapType::const_iterator upper = _map.end();
|
||||
upper--;
|
||||
if (number > _max) {
|
||||
return upper->second;
|
||||
}
|
||||
|
||||
upper = _map.lower_bound(number);
|
||||
if (upper == lower) {
|
||||
return upper->second;
|
||||
}
|
||||
|
||||
lower = upper;
|
||||
lower--;
|
||||
|
||||
float w1 = number - lower->first;
|
||||
float w2 = upper->first - number;
|
||||
|
||||
return ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::get_value_at_index
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float PhysxLinearInterpolationValues::
|
||||
get_value_at_index(int index) const {
|
||||
|
||||
MapType::const_iterator it = _map.begin();
|
||||
|
||||
for (int i=0; i<index; i++) {
|
||||
++it;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxLinearInterpolationValues::output
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxLinearInterpolationValues::
|
||||
output(ostream &out) const {
|
||||
|
||||
MapType::const_iterator it = _map.begin();
|
||||
|
||||
for (; it != _map.end(); ++it) {
|
||||
cout << it->first << " -> " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
|
57
panda/src/physx/physxLinearInterpolationValues.h
Normal file
57
panda/src/physx/physxLinearInterpolationValues.h
Normal file
@ -0,0 +1,57 @@
|
||||
// Filename: physxLinearInterpolationValues.h
|
||||
// Created by: enn0x (08Feb10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PHYSXLINEARINTERPOLATIONVALUES_H
|
||||
#define PHYSXLINEARINTERPOLATIONVALUES_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "pmap.h"
|
||||
|
||||
#include "physx_includes.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PhysxLinearInterpolationValues
|
||||
// Description :
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAPHYSX PhysxLinearInterpolationValues {
|
||||
|
||||
public:
|
||||
INLINE PhysxLinearInterpolationValues();
|
||||
INLINE ~PhysxLinearInterpolationValues();
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
void clear();
|
||||
void insert(float index, float value);
|
||||
bool is_valid(float number) const;
|
||||
float get_value(float number) const;
|
||||
float get_value_at_index(int index) const;
|
||||
unsigned int get_size() const;
|
||||
|
||||
private:
|
||||
float _min;
|
||||
float _max;
|
||||
|
||||
typedef pmap<float, float> MapType;
|
||||
MapType _map;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const PhysxLinearInterpolationValues &values) {
|
||||
values.output(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
#include "physxLinearInterpolationValues.I"
|
||||
|
||||
#endif // PHYSXLINEARINTERPOLATIONVALUES_H
|
@ -42,4 +42,4 @@ private:
|
||||
|
||||
#include "physxObjectCollection.I"
|
||||
|
||||
#endif // PHYSOBJECTCOLLECTION_H
|
||||
#endif // PHYSXOBJECTCOLLECTION_H
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "physxControllerDesc.h"
|
||||
#include "physxSceneStats2.h"
|
||||
#include "physxConstraintDominance.h"
|
||||
//#include "physxVehicle.h"
|
||||
//#include "physxVehicleDesc.h"
|
||||
|
||||
TypeHandle PhysxScene::_type_handle;
|
||||
|
||||
@ -65,6 +67,11 @@ link(NxScene *scenePtr) {
|
||||
void PhysxScene::
|
||||
unlink() {
|
||||
|
||||
// Destroy vehicles
|
||||
//for (unsigned int i=0; i < _vehicles.size(); i++) {
|
||||
// _vehicles[i]->release();
|
||||
//}
|
||||
|
||||
// Unlink controllers
|
||||
NxU32 nControllers = _cm->getNbControllers();
|
||||
|
||||
@ -131,9 +138,12 @@ unlink() {
|
||||
}
|
||||
|
||||
// Unlink self
|
||||
_cm->purgeControllers();
|
||||
NxReleaseControllerManager(_cm);
|
||||
|
||||
_ptr->userData = NULL;
|
||||
_error_type = ET_released;
|
||||
|
||||
PhysxManager::get_global_ptr()->_scenes.remove(this);
|
||||
}
|
||||
|
||||
@ -172,11 +182,17 @@ simulate(float dt) {
|
||||
|
||||
_pcollector_simulate.start();
|
||||
|
||||
// Update all vehicles
|
||||
//for (unsigned int i=0; i < _vehicles.size(); i++) {
|
||||
// PhysxVehicle *vehicle = _vehicles[i];
|
||||
// vehicle->update_vehicle(dt);
|
||||
//}
|
||||
|
||||
// Update all controllers
|
||||
for (NxU32 i=0; i < _cm->getNbControllers(); i++) {
|
||||
NxController *controllerPtr = _cm->getController(i);
|
||||
PhysxController *controller = (PhysxController *)controllerPtr->getUserData();
|
||||
controller->update(dt);
|
||||
controller->update_controller(dt);
|
||||
}
|
||||
|
||||
_cm->updateControllers();
|
||||
@ -327,7 +343,7 @@ PhysxActor *PhysxScene::
|
||||
create_actor(PhysxActorDesc &desc) {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr(desc.is_valid(),NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
PhysxActor *actor = new PhysxActor();
|
||||
nassertr(actor, NULL);
|
||||
@ -509,7 +525,7 @@ PhysxMaterial *PhysxScene::
|
||||
create_material(PhysxMaterialDesc &desc) {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr(desc.is_valid(),NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
PhysxMaterial *material = new PhysxMaterial();
|
||||
nassertr(material, NULL);
|
||||
@ -634,7 +650,7 @@ PhysxController *PhysxScene::
|
||||
create_controller(PhysxControllerDesc &desc) {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr(desc.is_valid(),NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
PhysxController *controller = PhysxController::factory(desc.ptr()->getType());
|
||||
nassertr(controller, NULL);
|
||||
@ -691,7 +707,7 @@ PhysxJoint *PhysxScene::
|
||||
create_joint(PhysxJointDesc &desc) {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr(desc.is_valid(),NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
PhysxJoint *joint = PhysxJoint::factory(desc.ptr()->getType());
|
||||
nassertr(joint, NULL);
|
||||
@ -751,7 +767,7 @@ create_force_field(PhysxForceFieldDesc &desc) {
|
||||
|
||||
// Create the kernel
|
||||
desc.create_kernel(_ptr);
|
||||
nassertr(desc.is_valid(),NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
// Create the force field
|
||||
PhysxForceField *field = new PhysxForceField();
|
||||
@ -840,6 +856,54 @@ get_force_field_shape_group(unsigned int idx) const {
|
||||
return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxScene::get_num_vehicles
|
||||
// Access: Published
|
||||
// Description: Returns the number of vehicles in the scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
unsigned int PhysxScene::
|
||||
get_num_vehicles() const {
|
||||
|
||||
nassertr(_error_type == ET_ok, -1);
|
||||
return _vehicles.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxScene::create_vehicle
|
||||
// Access: Published
|
||||
// Description: Creates a vehicle in this scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxVehicle *PhysxScene::
|
||||
create_vehicle(PhysxVehicleDesc &desc) {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr(desc.is_valid(), NULL);
|
||||
|
||||
PhysxVehicle *vehicle = new PhysxVehicle();
|
||||
nassertr(vehicle, NULL);
|
||||
|
||||
vehicle->create(this, desc);
|
||||
|
||||
return vehicle;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxScene::get_vehicle
|
||||
// Access: Published
|
||||
// Description: Returns the n-th vehicle from the array of all
|
||||
// the vehicles in the scene.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxVehicle *PhysxScene::
|
||||
get_vehicle(unsigned int idx) const {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
nassertr_always(idx < _vehicles.size(), NULL);
|
||||
|
||||
return _vehicles[idx];
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxScene::get_stats2
|
||||
// Access: Published
|
||||
@ -1545,3 +1609,28 @@ get_dominance_group_pair(unsigned int g1, unsigned int g2) {
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxScene::get_wheel_shape_material
|
||||
// Access: Published
|
||||
// Description: Gets the shared material for all wheel shapes.
|
||||
//
|
||||
// If this material is not already created then
|
||||
// calling this method will create the material.
|
||||
//
|
||||
// Normally users don't need to call this method. It
|
||||
// is used internally by PhysWheel::create_wheel.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PhysxMaterial *PhysxScene::
|
||||
get_wheel_shape_material() {
|
||||
|
||||
nassertr(_error_type == ET_ok, NULL);
|
||||
|
||||
if (_wheelShapeMaterial == NULL) {
|
||||
PhysxMaterialDesc materialDesc;
|
||||
materialDesc.set_flag(PhysxMaterialDesc::MF_disable_friction, true);
|
||||
_wheelShapeMaterial = create_material(materialDesc);
|
||||
}
|
||||
|
||||
return _wheelShapeMaterial;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ class PhysxRay;
|
||||
class PhysxRaycastHit;
|
||||
class PhysxRaycastReport;
|
||||
class PhysxSceneStats2;
|
||||
//class PhysxVehicle;
|
||||
//class PhysxVehicleDesc;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PhysxScene
|
||||
@ -129,6 +131,12 @@ PUBLISHED:
|
||||
PhysxForceFieldShapeGroup *get_force_field_shape_group(unsigned int idx) const;
|
||||
MAKE_SEQ(get_force_field_shape_groups, get_num_force_field_shape_groups, get_force_field_shape_group);
|
||||
|
||||
// Vehicles
|
||||
//unsigned int get_num_vehicles() const;
|
||||
//PhysxVehicle *create_vehicle(PhysxVehicleDesc &desc);
|
||||
//PhysxVehicle *get_vehicle(unsigned int idx) const;
|
||||
//MAKE_SEQ(get_vehicles, get_num_vehicles, get_vehicle);
|
||||
|
||||
// Raycast queries
|
||||
bool raycast_any_shape(const PhysxRay &ray,
|
||||
PhysxShapesType shapesType=ST_all,
|
||||
@ -212,11 +220,15 @@ public:
|
||||
PhysxObjectCollection<PhysxForceField> _forcefields;
|
||||
PhysxObjectCollection<PhysxForceFieldShapeGroup> _ffgroups;
|
||||
PhysxObjectCollection<PhysxController> _controllers;
|
||||
//PhysxObjectCollection<PhysxVehicle> _vehicles;
|
||||
|
||||
PhysxMaterial *get_wheel_shape_material();
|
||||
|
||||
private:
|
||||
NxScene *_ptr;
|
||||
NxControllerManager *_cm;
|
||||
PT(PhysxDebugGeomNode) _debugNode;
|
||||
PT(PhysxMaterial) _wheelShapeMaterial;
|
||||
|
||||
PhysxContactReport _contact_report;
|
||||
PhysxControllerReport _controller_report;
|
||||
|
@ -30,7 +30,7 @@ class PhysxMaterial;
|
||||
// Descriptors for all the different shape types are
|
||||
// derived from this class.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDAPHYSX PhysxShapeDesc : public PhysxEnums {
|
||||
class EXPCL_PANDAPHYSX PhysxShapeDesc : public PhysxEnums, public ReferenceCount {
|
||||
|
||||
PUBLISHED:
|
||||
virtual void set_to_default() = 0;
|
||||
|
@ -22,7 +22,7 @@
|
||||
INLINE PhysxWheelShapeDesc::
|
||||
PhysxWheelShapeDesc() : PhysxShapeDesc() {
|
||||
|
||||
_desc.name = "";
|
||||
set_to_default();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -35,17 +35,6 @@ INLINE PhysxWheelShapeDesc::
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxWheelShapeDesc::set_to_default
|
||||
// Access: Published
|
||||
// Description: (re)sets the structure to the default.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysxWheelShapeDesc::
|
||||
set_to_default() {
|
||||
|
||||
_desc.setToDefault();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxWheelShapeDesc::is_valid
|
||||
// Access: Published
|
||||
|
@ -14,6 +14,20 @@
|
||||
|
||||
#include "physxWheelShapeDesc.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxWheelShapeDesc::set_to_default
|
||||
// Access: Published
|
||||
// Description: (re)sets the structure to the default.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysxWheelShapeDesc::
|
||||
set_to_default() {
|
||||
|
||||
_desc.setToDefault();
|
||||
|
||||
_desc.name = "";
|
||||
_desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysxWheelShapeDesc::set_radius
|
||||
// Access: Published
|
||||
|
@ -32,7 +32,7 @@ PUBLISHED:
|
||||
INLINE PhysxWheelShapeDesc();
|
||||
INLINE ~PhysxWheelShapeDesc();
|
||||
|
||||
INLINE void set_to_default();
|
||||
void set_to_default();
|
||||
INLINE bool is_valid() const;
|
||||
|
||||
void set_radius(float radius);
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "physxJointLimitDesc.cxx"
|
||||
#include "physxJointLimitSoftDesc.cxx"
|
||||
#include "physxKitchen.cxx"
|
||||
#include "physxLinearInterpolationValues.cxx"
|
||||
#include "physxManager.cxx"
|
||||
#include "physxMask.cxx"
|
||||
#include "physxMaterial.cxx"
|
||||
@ -105,5 +106,13 @@
|
||||
#include "physxTriangleMeshShapeDesc.cxx"
|
||||
#include "physxTriggerReport.cxx"
|
||||
#include "physxUtilLib.cxx"
|
||||
//#include "physxVehicle.cxx"
|
||||
//#include "physxVehicleDesc.cxx"
|
||||
//#include "physxVehicleGears.cxx"
|
||||
//#include "physxVehicleGearsDesc.cxx"
|
||||
//#include "physxVehicleMotor.cxx"
|
||||
//#include "physxVehicleMotorDesc.cxx"
|
||||
//#include "physxWheel.cxx"
|
||||
//#include "physxWheelDesc.cxx"
|
||||
#include "physxWheelShape.cxx"
|
||||
#include "physxWheelShapeDesc.cxx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user