Panda3D
Functions
geomPrimitive.cxx File Reference

PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University. More...

#include "geomPrimitive.h"
#include "geom.h"
#include "geomPatches.h"
#include "geomVertexData.h"
#include "geomVertexArrayFormat.h"
#include "geomVertexColumn.h"
#include "geomVertexReader.h"
#include "geomVertexWriter.h"
#include "geomVertexRewriter.h"
#include "geomPoints.h"
#include "geomLines.h"
#include "geomTriangles.h"
#include "preparedGraphicsObjects.h"
#include "internalName.h"
#include "bamReader.h"
#include "bamWriter.h"
#include "ioPtaDatagramInt.h"
#include "indent.h"
#include "pStatTimer.h"

Go to the source code of this file.

Functions

 CPT (GeomPrimitive) GeomPrimitive
 Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to triangles, and returns a pointer to the new primitive definition. More...
 
 PT (CopyOnWriteObject) GeomPrimitive
 Required to implement CopyOnWriteObject. More...
 
 PT (GeomVertexArrayData) GeomPrimitive
 The private implementation of modify_vertices(). More...
 

Detailed Description

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."

Author
drose
Date
2005-03-06

Definition in file geomPrimitive.cxx.

Function Documentation

◆ CPT()

CPT ( GeomPrimitive  )

Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to triangles, and returns a pointer to the new primitive definition.

If the decomposition cannot be performed, this might return the original object.

This method is useful for application code that wants to iterate through the set of triangles on the primitive without having to write handlers for each possible kind of primitive type. Returns a new primitive with the shade_model reversed (if it is flat shaded), if possible. If the primitive type cannot be rotated, returns the original primitive, unrotated.

If the current shade_model indicates flat_vertex_last, this should bring the last vertex to the first position; if it indicates flat_vertex_first, this should bring the first vertex to the last position. Duplicates triangles in the primitive so that each triangle is back-to-back with another triangle facing in the opposite direction. Note that this doesn't affect vertex normals, so this operation alone won't work in the presence of lighting (but see SceneGraphReducer::doubleside()).

Also see CullFaceAttrib, which can enable rendering of both sides of a triangle without having to duplicate it (but which doesn't necessarily work in the presence of lighting). Reverses the winding order in the primitive so that each triangle is facing in the opposite direction it was originally. Note that this doesn't affect vertex normals, so this operation alone won't work in the presence of lighting (but see SceneGraphReducer::reverse()).

Also see CullFaceAttrib, which can change the visible direction of a triangle without having to duplicate it (but which doesn't necessarily work in the presence of lighting). Returns a new primitive that is compatible with the indicated shade model, if possible, or NULL if this is not possible.

In most cases, this will return either NULL or the original primitive. In the case of a SM_flat_first_vertex vs. a SM_flat_last_vertex (or vice- versa), however, it will return a rotated primitive. Returns a new GeomPoints primitive that represents each of the vertices in the original primitive, rendered exactly once. If the original primitive is already a GeomPoints primitive, returns the original primitive unchanged. Returns a new GeomLines primitive that represents each of the edges in the original primitive rendered as a line. If the original primitive is already a GeomLines primitive, returns the original primitive unchanged. Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to triangles, puts these in a new GeomPatches object and returns a pointer to the new primitive definition. If the decomposition cannot be performed, this might return the original object.

This method is useful for application code that wants to use tesselation shaders on arbitrary geometry. Adds adjacency information to this primitive. May return null if this type of geometry does not support adjacency information.

Since
1.10.0 Returns the number of bytes consumed by the primitive and its index table(s). Returns true if the primitive data is currently resident in memory. If this returns false, the primitive data will be brought back into memory shortly; try again later. Returns a modifiable pointer to the vertex index list, so application code can directly fiddle with this data. Use with caution, since there are no checks that the data will be left in a stable state.

If this is called on a nonindexed primitive, it will implicitly be converted to an indexed primitive.

If num_vertices is not -1, it specifies an artificial limit to the number of vertices in the array. Otherwise, all of the vertices in the array will be used.

Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!

If the decomposition cannot be performed, this might return the original object.

This method is useful for application code that wants to iterate through the set of triangles on the primitive without having to write handlers for each possible kind of primitive type. The virtual implementation of rotate(). The virtual implementation of doubleside(). The virtual implementation of reverse(). Should be redefined to return true in any primitive that implements append_unused_vertices(). Called when a new primitive is begun (other than the first primitive), this should add some degenerate vertices between primitives, if the primitive type requires that. The second parameter is the first vertex that begins the new primitive.

This method is only called if requires_unused_vertices(), above, returns true.

Definition at line 776 of file geomPrimitive.cxx.

◆ PT() [1/2]

Required to implement CopyOnWriteObject.

Definition at line 56 of file geomPrimitive.cxx.

References Geom::make_copy().

◆ PT() [2/2]

The private implementation of modify_vertices().

Definition at line 2075 of file geomPrimitive.cxx.

References Geom::get_next_modified().