diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 5c24217bff..83e882f87f 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -303,7 +303,7 @@ fill_viz_geom() { << "Recomputing viz for " << *this << "\n"; } - static const int num_slices = 8; + static const int num_slices = 16; static const int num_stacks = 8; GeomTristrip *sphere = new GeomTristrip; diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index 1cbd927e41..a4952a3c33 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -322,7 +322,7 @@ fill_viz_geom() { << "Recomputing viz for " << *this << "\n"; } - static const int num_slices = 8; + static const int num_slices = 16; static const int num_stacks = 8; GeomTristrip *sphere = new GeomTristrip; diff --git a/panda/src/configfiles/panda.prc.pp b/panda/src/configfiles/panda.prc.pp index 28cb0f75a2..d11e459ca3 100644 --- a/panda/src/configfiles/panda.prc.pp +++ b/panda/src/configfiles/panda.prc.pp @@ -74,6 +74,7 @@ egg-object-type-dcs { 1 } # collisions more optimally than regular visible polygons. egg-object-type-barrier { Polyset descend } egg-object-type-sphere { Sphere descend } +egg-object-type-invsphere { InvSphere descend } egg-object-type-tube { Tube descend } # As above, but these are flagged to be "intangible", so that they diff --git a/panda/src/doc/eggSyntax.txt b/panda/src/doc/eggSyntax.txt index 15bb65e4bd..d14072f1b6 100644 --- a/panda/src/doc/eggSyntax.txt +++ b/panda/src/doc/eggSyntax.txt @@ -1117,6 +1117,21 @@ GROUPING ENTRIES The geometry represents a sphere. The vertices in the group are averaged together to determine the sphere's center and radius. + InvSphere + + The geometry represents an inverse sphere. This is the same as + Sphere, with the normal inverted, so that the solid part of an + inverse sphere is the entire world outside of it. Note that an + inverse sphere is in infinitely large solid with a finite hole + cut into it. + + Tube + + The geometry represents a tube. This is a cylinder-like shape + with hemispherical endcaps; it is sometimes called a capsule or + a lozenge in other packages. The smallest tube shape that will + fit around the vertices is used. + The flags may be any zero or more of: diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 174f5c9ca3..746cd5f514 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -813,6 +813,9 @@ string_cs_type(const string &string) { return CST_polyset; } else if (cmp_nocase_uh(string, "sphere") == 0) { return CST_sphere; + } else if (cmp_nocase_uh(string, "inv-sphere") == 0 || + cmp_nocase_uh(string, "invsphere") == 0) { + return CST_inv_sphere; } else if (cmp_nocase_uh(string, "tube") == 0) { return CST_tube; } else { @@ -1185,6 +1188,8 @@ ostream &operator << (ostream &out, EggGroup::CollisionSolidType t) { return out << "Polyset"; case EggGroup::CST_sphere: return out << "Sphere"; + case EggGroup::CST_inv_sphere: + return out << "InvSphere"; case EggGroup::CST_tube: return out << "Tube"; } diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index ec349165b3..c3705ec88c 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -79,11 +79,11 @@ PUBLISHED: CST_polyset = 0x00030000, CST_sphere = 0x00040000, CST_tube = 0x00050000, + CST_inv_sphere = 0x00060000, }; enum CollideFlags { // The bits here must correspond to those in Flags, below. CF_none = 0x00000000, - CF_intangible = 0x00080000, CF_descend = 0x00100000, CF_event = 0x00200000, CF_keep = 0x00400000, @@ -91,6 +91,7 @@ PUBLISHED: CF_center = 0x01000000, CF_turnstile = 0x02000000, CF_level = 0x04000000, + CF_intangible = 0x08000000, }; EggGroup(const string &name = ""); diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index a82a483279..5bec1eb1b6 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -68,6 +68,7 @@ #include "selectiveChildNode.h" #include "collisionNode.h" #include "collisionSphere.h" +#include "collisionInvSphere.h" #include "collisionTube.h" #include "collisionPlane.h" #include "collisionPolygon.h" @@ -2196,6 +2197,10 @@ make_collision_solids(EggGroup *start_group, EggGroup *egg_group, make_collision_sphere(egg_group, cnode, start_group->get_collide_flags()); break; + case EggGroup::CST_inv_sphere: + make_collision_inv_sphere(egg_group, cnode, start_group->get_collide_flags()); + break; + case EggGroup::CST_tube: make_collision_tube(egg_group, cnode, start_group->get_collide_flags()); break; @@ -2301,6 +2306,26 @@ make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, } } +//////////////////////////////////////////////////////////////////// +// Function: EggLoader::make_collision_inv_sphere +// Access: Private +// Description: Creates a single CollisionInvSphere corresponding +// to the polygons associated with this group. +//////////////////////////////////////////////////////////////////// +void EggLoader:: +make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, + EggGroup::CollideFlags flags) { + LPoint3f center; + float radius; + Colorf dummycolor; + if (make_sphere(egg_group, center, radius, dummycolor)) { + CollisionInvSphere *cssphere = + new CollisionInvSphere(center, radius); + apply_collision_flags(cssphere, flags); + cnode->add_solid(cssphere); + } +} + //////////////////////////////////////////////////////////////////// // Function: EggLoader::make_collision_tube // Access: Private diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index a0857a6bc9..13b7a4d3d7 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -138,6 +138,8 @@ private: EggGroup::CollideFlags flags); void make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags); + void make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, + EggGroup::CollideFlags flags); void make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags); void apply_collision_flags(CollisionSolid *solid, diff --git a/panda/src/glxdisplay/Sources.pp b/panda/src/glxdisplay/Sources.pp index 3c473646be..97bf895ee4 100644 --- a/panda/src/glxdisplay/Sources.pp +++ b/panda/src/glxdisplay/Sources.pp @@ -2,7 +2,7 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m -#define USE_PACKAGES gl glx +#define USE_PACKAGES gl glx cg #begin lib_target #define TARGET glxdisplay