54class EXPCL_PANDA_GOBJ Geom :
public CopyOnWriteObject,
public GeomEnums {
56 virtual PT(CopyOnWriteObject) make_cow_copy();
62 Geom(
const Geom ©);
65 void operator = (
const Geom ©);
67 ALLOC_DELETED_CHAIN(Geom);
90 INLINE
bool is_empty()
const;
92 INLINE
size_t get_num_primitives()
const;
94 MAKE_SEQ(get_primitives, get_num_primitives, get_primitive);
103 INLINE PT(Geom) decompose()
const;
104 INLINE PT(Geom) doubleside()
const;
105 INLINE PT(Geom) reverse()
const;
106 INLINE PT(Geom) rotate()
const;
107 INLINE PT(Geom) unify(
int max_indices,
bool preserve_order)
const;
108 INLINE PT(Geom) make_points()
const;
109 INLINE PT(Geom) make_lines()
const;
110 INLINE PT(Geom) make_patches()
const;
111 INLINE PT(Geom) make_adjacency()
const;
128 MAKE_PROPERTY(modified, get_modified);
138 INLINE
void mark_bounds_stale()
const;
139 INLINE
void set_bounds_type(BoundingVolume::BoundsType bounds_type);
145 virtual void output(std::ostream &out)
const;
146 virtual void write(std::ostream &out,
int indent_level = 0)
const;
151 void prepare(PreparedGraphicsObjects *prepared_objects);
152 bool is_prepared(PreparedGraphicsObjects *prepared_objects)
const;
153 bool release(PreparedGraphicsObjects *prepared_objects);
156 GeomContext *
prepare_now(PreparedGraphicsObjects *prepared_objects,
162 bool force,
Thread *current_thread)
const;
167 bool got_mat,
const LMatrix4 &mat,
168 Thread *current_thread)
const;
170 bool &found_any,
Thread *current_thread)
const;
174 bool got_mat,
const LMatrix4 &mat,
176 Thread *current_thread)
const;
183 INLINE
void mark_internal_bounds_stale(CData *cdata);
184 void compute_internal_bounds(CData *cdata,
Thread *current_thread)
const;
186 void do_calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
187 PN_stdfloat &sq_center_dist,
bool &found_any,
189 bool got_mat,
const LMatrix4 &mat,
191 const CData *cdata,
Thread *current_thread)
const;
193 void do_calc_sphere_radius(
const LPoint3 ¢er,
194 PN_stdfloat &sq_radius,
bool &found_any,
196 const CData *cdata,
Thread *current_thread)
const;
198 void clear_prepared(PreparedGraphicsObjects *prepared_objects);
199 bool check_will_be_valid(
const GeomVertexData *vertex_data)
const;
201 void reset_geom_rendering(CData *cdata);
220 class EXPCL_PANDA_GOBJ CDataCache :
public CycleData {
223 INLINE CDataCache(
const CDataCache ©);
224 virtual ~CDataCache();
225 ALLOC_DELETED_CHAIN(CDataCache);
228 return Geom::get_class_type();
234 const Geom *_geom_result;
241 static void init_type() {
246 static TypeHandle _type_handle;
248 typedef CycleDataReader<CDataCache> CDCacheReader;
249 typedef CycleDataWriter<CDataCache> CDCacheWriter;
259 const GeomMunger *modifier);
260 INLINE CacheKey(
const CacheKey ©);
261 INLINE CacheKey(CacheKey &&from)
noexcept;
263 INLINE
bool operator < (
const CacheKey &other)
const;
266 CPT(GeomMunger) _modifier;
269 class CacheEntry :
public GeomCacheEntry {
271 INLINE CacheEntry(Geom *source,
273 const GeomMunger *modifier);
274 INLINE CacheEntry(Geom *source,
const CacheKey &key);
275 INLINE CacheEntry(Geom *source,
CacheKey &&key)
noexcept;
277 ALLOC_DELETED_CHAIN(CacheEntry);
280 virtual void output(std::ostream &out)
const;
291 static void init_type() {
292 GeomCacheEntry::init_type();
294 GeomCacheEntry::get_class_type());
304 class EXPCL_PANDA_GOBJ CData :
public CycleData {
309 ALLOC_DELETED_CHAIN(CData);
315 return Geom::get_class_type();
319 Primitives _primitives;
320 PrimitiveType _primitive_type;
321 ShadeModel _shade_model;
326 int _nested_vertices;
327 bool _internal_bounds_stale;
328 BoundingVolume::BoundsType _bounds_type;
335 static void init_type() {
340 static TypeHandle _type_handle;
343 PipelineCycler<CData> _cycler;
344 typedef CycleDataLockedReader<CData> CDLockedReader;
345 typedef CycleDataReader<CData> CDReader;
346 typedef CycleDataWriter<CData> CDWriter;
347 typedef CycleDataStageReader<CData> CDStageReader;
348 typedef CycleDataStageWriter<CData> CDStageWriter;
351 LightMutex _cache_lock;
355 typedef pmap<PreparedGraphicsObjects *, GeomContext *> Contexts;
358 static UpdateSeq _next_modified;
359 static PStatCollector _draw_primitive_setup_pcollector;
362 static void register_with_read_factory();
365 virtual void finalize(BamReader *manager);
368 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
369 void fillin(DatagramIterator &scan, BamReader *manager);
372 static TypeHandle get_class_type() {
375 static void init_type() {
376 CopyOnWriteObject::init_type();
378 CopyOnWriteObject::get_class_type());
379 CDataCache::init_type();
380 CacheEntry::init_type();
383 virtual TypeHandle get_type()
const {
384 return get_class_type();
386 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
389 static TypeHandle _type_handle;
391 friend class CacheEntry;
392 friend class GeomMunger;
393 friend class GeomContext;
394 friend class GeomPipelineReader;
395 friend class PreparedGraphicsObjects;
405class EXPCL_PANDA_GOBJ GeomPipelineReader :
public GeomEnums {
407 INLINE GeomPipelineReader(
Thread *current_thread);
408 INLINE GeomPipelineReader(
const Geom *
object,
Thread *current_thread);
409 GeomPipelineReader(
const GeomPipelineReader ©) =
delete;
410 INLINE ~GeomPipelineReader();
412 ALLOC_DELETED_CHAIN(GeomPipelineReader);
414 GeomPipelineReader &operator = (
const GeomPipelineReader ©) =
delete;
416 INLINE
void set_object(
const Geom *
object);
417 INLINE
const Geom *get_object()
const;
418 INLINE
Thread *get_current_thread()
const;
420 INLINE PrimitiveType get_primitive_type()
const;
421 INLINE ShadeModel get_shade_model()
const;
422 INLINE
int get_geom_rendering()
const;
424 INLINE
int get_num_primitives()
const;
441 const Geom::CData *_cdata;
447 static void init_type() {
455INLINE std::ostream &operator << (std::ostream &out,
const Geom &obj);
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...
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...
A single page of data maintained by a PipelineCycler.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This is a special class object that holds all the information returned by a particular GSG to indicat...
bool draw(GraphicsStateGuardianBase *gsg, const GeomVertexDataPipelineReader *data_reader, bool force) const
The implementation of Geom::draw().
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
virtual void evict_callback()
Called when the entry is evicted from the cache, this should clean up the owning object appropriately...
A container for geometry primitives.
void clear_cache()
Removes all of the previously-cached results of munge_geom().
void decompose_in_place()
Decomposes all of the primitives within this Geom, leaving the results in place.
bool request_resident() const
Returns true if all the primitive arrays are currently resident in memory.
void prepare(PreparedGraphicsObjects *prepared_objects)
Indicates that the geom should be enqueued to be prepared in the indicated prepared_objects at the be...
void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, bool got_mat, const LMatrix4 &mat, Thread *current_thread) const
Expands min_point and max_point to include all of the vertices in the Geom, if any.
insert_primitive
Inserts a new GeomPrimitive structure to the Geom object.
int get_nested_vertices(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of vertices rendered by all primitives within the Geom.
int release_all()
Frees the context allocated on all objects for which the geom has been declared.
void reverse_in_place()
Reverses all of the primitives within this Geom, leaving the results in place.
bool draw(GraphicsStateGuardianBase *gsg, const GeomVertexData *vertex_data, bool force, Thread *current_thread) const
Actually draws the Geom with the indicated GSG, using the indicated vertex data (which might have bee...
void offset_vertices(const GeomVertexData *data, int offset)
Replaces a Geom's vertex table with a new table, and simultaneously adds the indicated offset to all ...
void make_patches_in_place()
Replaces the GeomPrimitives within this Geom with corresponding GeomPatches.
virtual bool copy_primitives_from(const Geom *other)
Copies the primitives from the indicated Geom into this one.
void clear_primitives()
Removes all the primitives from the Geom object (but keeps the same table of vertices).
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the geom context only on the indicated object, if it exists there.
int make_nonindexed(bool composite_only)
Converts the geom from indexed to nonindexed by duplicating vertices as necessary.
void set_bounds(const BoundingVolume *volume)
Resets the bounding volume so that it is the indicated volume.
void doubleside_in_place()
Doublesides all of the primitives within this Geom, leaving the results in place.
ConstPointerTo< GeomVertexData > get_animated_vertex_data(bool force, Thread *current_thread=Thread::get_current_thread()) const
Returns a GeomVertexData that represents the results of computing the vertex animation on the CPU for...
bool check_valid() const
Verifies that the all of the primitives within the geom reference vertices that actually exist within...
void clear_bounds()
Reverses the effect of a previous call to set_bounds(), and allows the bounding volume to be automati...
remove_primitive
Removes the ith primitive from the list.
void add_primitive(const GeomPrimitive *primitive)
Inserts a new GeomPrimitive structure to the Geom object.
void clear_cache_stage(Thread *current_thread)
Removes all of the previously-cached results of munge_geom(), at the current pipeline stage and upstr...
get_bounds_type
Returns the bounding volume type set with set_bounds_type().
GeomContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the geom on the particular GSG, if it does not already exist.
void make_points_in_place()
Replaces the GeomPrimitives within this Geom with corresponding GeomPoints.
void rotate_in_place()
Rotates all of the primitives within this Geom, leaving the results in place.
void make_lines_in_place()
Replaces the GeomPrimitives within this Geom with corresponding GeomLines, representing a wireframe o...
void unify_in_place(int max_indices, bool preserve_order)
Unifies all of the primitives contained within this Geom into a single (or as few as possible,...
get_shade_model
Returns the shade model common to all of the individual GeomPrimitives that have been added to the ge...
static UpdateSeq get_next_modified()
Returns a monotonically increasing sequence.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the geom has already been prepared or enqueued for preparation on the indicated GSG,...
void make_adjacency_in_place()
Replaces the GeomPrimitives within this Geom with corresponding versions with adjacency information.
get_num_bytes
Returns the number of bytes consumed by the geom and its primitives (but not including its vertex tab...
void transform_vertices(const LMatrix4 &mat)
Applies the indicated transform to all of the vertices in the Geom.
virtual Geom * make_copy() const
Returns a newly-allocated Geom that is a shallow copy of this one.
set_primitive
Replaces the ith GeomPrimitive object stored within the Geom with the new object.
void set_vertex_data(const GeomVertexData *data)
Replaces the Geom's underlying vertex data table with a completely new table.
void set_usage_hint(UsageHint usage_hint)
Changes the UsageHint hint for all of the primitives on this Geom to the same value.
get_primitive_type
Returns the fundamental primitive type that is common to all GeomPrimitives added within the Geom.
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
PointerTo< GeomVertexData > modify_vertex_data()
Returns a modifiable pointer to the GeomVertexData, so that application code may directly maniuplate ...
ConstPointerTo< BoundingVolume > get_bounds(Thread *current_thread=Thread::get_current_thread()) const
Returns the bounding volume for the Geom.
UsageHint get_usage_hint() const
Returns the minimum (i.e.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
Encodes a string name in a hash table, mapping it to a pointer.
A table of objects that are saved within the graphics context for reference by handle later.
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
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 int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a sequence number that increments monotonically.
This is our own Panda specialization on the default STL list.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.