32 PStatCollector BulletDebugNode::_pstat_debug(
"App:Bullet:DoPhysics:Debug");
38 BulletDebugNode(
const char *name) :
PandaNode(name) {
41 _debug_world =
nullptr;
45 _drawer._normals =
true;
50 set_overall_hidden(
true);
130 _drawer.setDebugMode(DebugDraw::DBG_NoDebug);
133 int mode = DebugDraw::DBG_DrawText |
134 DebugDraw::DBG_DrawFeaturesText |
135 DebugDraw::DBG_DrawContactPoints;
138 mode |= DebugDraw::DBG_DrawWireframe;
142 mode |= DebugDraw::DBG_DrawConstraints;
143 mode |= DebugDraw::DBG_DrawConstraintLimits;
147 mode |= DebugDraw::DBG_DrawAabb;
150 _drawer.setDebugMode(mode);
172 PT(
Geom) debug_lines;
173 PT(
Geom) debug_triangles;
177 if (_debug_world ==
nullptr) {
181 nassertv(_debug_world !=
nullptr);
185 _drawer._lines.clear();
186 _drawer._triangles.clear();
188 _debug_world->debugDrawWorld();
194 vdata->unclean_set_num_rows(_drawer._lines.size() * 2);
200 for (lit = _drawer._lines.begin(); lit != _drawer._lines.end(); lit++) {
201 const Line &line = *lit;
205 cwriter.
set_data4(LVecBase4(line._color));
206 cwriter.
set_data4(LVecBase4(line._color));
210 prim->set_shade_model(Geom::SM_uniform);
211 prim->add_next_vertices(_drawer._lines.size() * 2);
213 debug_lines =
new Geom(vdata);
214 debug_lines->add_primitive(prim);
215 _debug_lines = debug_lines;
222 vdata->unclean_set_num_rows(_drawer._triangles.size() * 3);
228 for (tit = _drawer._triangles.begin(); tit != _drawer._triangles.end(); tit++) {
229 const Triangle &tri = *tit;
234 cwriter.
set_data4(LVecBase4(tri._color));
235 cwriter.
set_data4(LVecBase4(tri._color));
236 cwriter.
set_data4(LVecBase4(tri._color));
240 prim->set_shade_model(Geom::SM_uniform);
241 prim->add_next_vertices(_drawer._triangles.size() * 3);
243 debug_triangles =
new Geom(vdata);
244 debug_triangles->add_primitive(prim);
245 _debug_triangles = debug_triangles;
249 _drawer._lines.clear();
250 _drawer._triangles.clear();
252 _debug_stale =
false;
254 debug_lines = _debug_lines;
255 debug_triangles = _debug_triangles;
260 trav->_geoms_pcollector.add_level(2);
276 void BulletDebugNode::
277 do_sync_b2p(btDynamicsWorld *world) {
279 _debug_world = world;
286 void BulletDebugNode::DebugDraw::
287 setDebugMode(
int mode) {
295 int BulletDebugNode::DebugDraw::
296 getDebugMode()
const {
304 void BulletDebugNode::DebugDraw::
305 reportErrorWarning(
const char *warning) {
307 bullet_cat.error() << warning << std::endl;
313 void BulletDebugNode::DebugDraw::
314 drawLine(
const btVector3 &from,
const btVector3 &to,
const btVector3 &color) {
316 PN_stdfloat r = color.getX();
317 PN_stdfloat g = color.getY();
318 PN_stdfloat b = color.getZ();
322 if (_normals==
false && r==1.0f && g==1.0f && b==0.0f)
return;
326 line._p0 = LVecBase3((PN_stdfloat)from.getX(),
327 (PN_stdfloat)from.getY(),
328 (PN_stdfloat)from.getZ());
329 line._p1 = LVecBase3((PN_stdfloat)to.getX(),
330 (PN_stdfloat)to.getY(),
331 (PN_stdfloat)to.getZ());
332 line._color = UnalignedLVecBase4((PN_stdfloat)r,
334 (PN_stdfloat)b, 1.0f);
336 _lines.push_back(line);
342 void BulletDebugNode::DebugDraw::
343 drawTriangle(
const btVector3 &v0,
const btVector3 &v1,
const btVector3 &v2,
const btVector3 &color, btScalar) {
345 btScalar r = color.getX();
346 btScalar g = color.getY();
347 btScalar b = color.getZ();
351 tri._p0 = LVecBase3((PN_stdfloat)v0.getX(),
352 (PN_stdfloat)v0.getY(),
353 (PN_stdfloat)v0.getZ());
355 tri._p1 = LVecBase3((PN_stdfloat)v1.getX(),
356 (PN_stdfloat)v1.getY(),
357 (PN_stdfloat)v1.getZ());
359 tri._p2 = LVecBase3((PN_stdfloat)v2.getX(),
360 (PN_stdfloat)v2.getY(),
361 (PN_stdfloat)v2.getZ());
363 tri._color = UnalignedLVecBase4((PN_stdfloat)r,
365 (PN_stdfloat)b, 1.0f);
367 _triangles.push_back(tri);
385 void BulletDebugNode::DebugDraw::
386 drawTriangle(
const btVector3 &v0,
const btVector3 &v1,
const btVector3 &v2,
const btVector3 &n0,
const btVector3 &n1,
const btVector3 &n2,
const btVector3 &color, btScalar alpha) {
387 if (bullet_cat.is_debug()) {
388 bullet_cat.debug() <<
"drawTriangle(2) - not yet implemented!" << std::endl;
395 void BulletDebugNode::DebugDraw::
396 drawContactPoint(
const btVector3 &point,
const btVector3 &normal, btScalar distance,
int lifetime,
const btVector3 &color) {
398 const btVector3 to = point + normal * distance;
399 const btVector3 &from = point;
401 drawLine(from, to, color);
407 void BulletDebugNode::DebugDraw::
408 draw3dText(
const btVector3 &location,
const char *text) {
409 if (bullet_cat.is_debug()) {
410 bullet_cat.debug() <<
"draw3dText - not yet implemented!" << std::endl;
417 void BulletDebugNode::DebugDraw::
418 drawSphere(btScalar radius,
const btTransform &transform,
const btVector3 &color) {
420 btVector3 center = transform.getOrigin();
422 const btVector3 xoffs = transform.getBasis() * btVector3(1, 0, 0);
423 const btVector3 yoffs = transform.getBasis() * btVector3(0, 1, 0);
424 const btVector3 zoffs = transform.getBasis() * btVector3(0, 0, 1);
426 drawArc(center, xoffs, yoffs, radius, radius, 0, SIMD_2_PI, color,
false, 10.0);
427 drawArc(center, yoffs, zoffs, radius, radius, 0, SIMD_2_PI, color,
false, 10.0);
428 drawArc(center, zoffs, xoffs, radius, radius, 0, SIMD_2_PI, color,
false, 10.0);
465 param->fillin(scan, manager);
474 void BulletDebugNode::
476 PandaNode::fillin(scan, manager);
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data)
Adds the node's contents to the CullResult we are building up during the cull traversal,...
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
virtual void draw_mask_changed()
Called after the node's DrawMask has been changed for any reason, this just provides a hook so derive...
static void register_with_read_factory()
Tells the BamReader how to create objects of type BulletDebugNode.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of Node by duplicating insta...
virtual bool safe_to_flatten_below() const
Returns true if a flatten operation may safely continue past this node, or false if nodes below this ...
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
virtual bool safe_to_combine_children() const
Returns true if it is generally safe to combine the children of this PandaNode with each other.
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of Node by calling the xform()...
virtual bool safe_to_modify_transform() const
Returns true if it is safe to automatically adjust the transform on this kind of node.
virtual void record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
SceneSetup * get_scene() const
Returns the SceneSetup object.
The smallest atom of cull.
A class to retrieve the individual data elements previously stored in a Datagram.
bool get_bool()
Extracts a boolean value.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_bool(bool value)
Adds a boolean value to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Defines a series of disconnected line segments.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Defines a series of disconnected triangles.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
void set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row.
A container for geometry primitives.
Similar to MutexHolder, but for a light mutex.
This is a special kind of GeometricBoundingVolume that fills all of space.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
A basic node of the scene graph or data graph.
is_overall_hidden
Returns true if the node has been hidden to all cameras by clearing its overall bit.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
const TransformState * get_cs_world_transform() const
Returns the position from the starting node relative to the camera, in the GSG's internal coordinate ...
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.