mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
remove accidentally added files
This commit is contained in:
parent
c8d3b8dac8
commit
15b1f49c12
@ -1,150 +0,0 @@
|
||||
// Filename: renderAttribRegistry.I
|
||||
// Created by: drose (13Nov08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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: RenderAttribRegistry::get_slot
|
||||
// Access: Published
|
||||
// Description: Returns the slot number assigned to the indicated
|
||||
// TypeHandle, or 0 if no slot number has been assigned.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_slot(TypeHandle type_handle) const {
|
||||
int type_index = type_handle.get_index();
|
||||
if (type_index >= (int)_slots_by_type.size()) {
|
||||
return 0;
|
||||
}
|
||||
return _slots_by_type[type_index];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_max_slots
|
||||
// Access: Published
|
||||
// Description: Returns the maximum number that any slot number is
|
||||
// allowed to grow. Actually, this number will be one
|
||||
// higher than the highest possible slot number. This
|
||||
// puts an upper bound on the number of RenderAttrib
|
||||
// slots that may be allocated, and allows other code to
|
||||
// define an array of slots.
|
||||
//
|
||||
// This number will not change during the lifetime of
|
||||
// the application.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_max_slots() const {
|
||||
return _max_slots;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_num_slots
|
||||
// Access: Published
|
||||
// Description: Returns the number of RenderAttrib slots that have
|
||||
// been allocated. This is one more than the highest
|
||||
// slot number in use.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_num_slots() const {
|
||||
return _registry.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_slot_type
|
||||
// Access: Published
|
||||
// Description: Returns the TypeHandle associated with slot n.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE TypeHandle RenderAttribRegistry::
|
||||
get_slot_type(int slot) const {
|
||||
nassertr(slot >= 0 && slot < (int)_registry.size(), TypeHandle::none());
|
||||
return _registry[slot]._type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_slot_sort
|
||||
// Access: Published
|
||||
// Description: Returns the sort number associated with slot n.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_slot_sort(int slot) const {
|
||||
nassertr(slot >= 0 && slot < (int)_registry.size(), 0);
|
||||
return _registry[slot]._sort;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_num_sorted_slots
|
||||
// Access: Published
|
||||
// Description: Returns the number of entries in the sorted_slots
|
||||
// list.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_num_sorted_slots() const {
|
||||
return _sorted_slots.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_sorted_slot
|
||||
// Access: Published
|
||||
// Description: Returns the nth slot in sorted order. By traversing
|
||||
// this list, you will retrieve all the slot numbers in
|
||||
// order according to their registered sort value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int RenderAttribRegistry::
|
||||
get_sorted_slot(int n) const {
|
||||
nassertr(n >= 0 && n < (int)_sorted_slots.size(), 0);
|
||||
return _sorted_slots[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_global_ptr
|
||||
// Access: Published, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE RenderAttribRegistry *RenderAttribRegistry::
|
||||
get_global_ptr() {
|
||||
if (_global_ptr == (RenderAttribRegistry *)NULL) {
|
||||
init_global_ptr();
|
||||
}
|
||||
return _global_ptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::quick_get_global_ptr
|
||||
// Access: Public, Static
|
||||
// Description: Returns the global_ptr without first ensuring it has
|
||||
// been initialized. Only safe for code that knows it
|
||||
// has already been initialized.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE RenderAttribRegistry *RenderAttribRegistry::
|
||||
quick_get_global_ptr() {
|
||||
return _global_ptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::SortSlots::Constructor
|
||||
// Access: Public
|
||||
// Description: This is an STL function object for sorting the
|
||||
// _sorted_slots list into order by slot sort number.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE RenderAttribRegistry::SortSlots::
|
||||
SortSlots(RenderAttribRegistry *reg) : _reg(reg) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::SortSlots::operator ()
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool RenderAttribRegistry::SortSlots::
|
||||
operator () (int a, int b) const {
|
||||
return _reg->get_slot_sort(a) < _reg->get_slot_sort(b);
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
// Filename: renderAttribRegistry.cxx
|
||||
// Created by: drose (13Nov08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "renderAttribRegistry.h"
|
||||
#include "renderAttrib.h"
|
||||
|
||||
RenderAttribRegistry *RenderAttribRegistry::_global_ptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::Constructor
|
||||
// Access: Private
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
RenderAttribRegistry::
|
||||
RenderAttribRegistry() {
|
||||
ConfigVariableInt max_attribs
|
||||
("max-attribs", SlotMask::get_max_num_bits(),
|
||||
PRC_DESC("This specifies the maximum number of different RenderAttrib "
|
||||
"types that may be defined at runtime. Normally you should "
|
||||
"never need to change this, but if the default value is too "
|
||||
"low for the number of attribs that Panda actually defines, "
|
||||
"you may need to raise this number."));
|
||||
|
||||
// Assign this number once, at startup, and never change it again.
|
||||
_max_slots = max((int)max_attribs, 1);
|
||||
if (_max_slots > SlotMask::get_max_num_bits()) {
|
||||
pgraph_cat->warning()
|
||||
<< "Value for max-attribs too large: cannot exceed "
|
||||
<< SlotMask::get_max_num_bits()
|
||||
<< " in this build. To raise this limit, change the typedef "
|
||||
<< "for SlotMask in renderAttribRegistry.h and recompile.\n";
|
||||
|
||||
_max_slots = SlotMask::get_max_num_bits();
|
||||
}
|
||||
|
||||
// Reserve slot 0 for TypeHandle::none(), and for types that exceed
|
||||
// max_slots.
|
||||
RegistryNode node;
|
||||
node._sort = 0;
|
||||
node._make_default_func = NULL;
|
||||
_registry.push_back(node);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::Destructor
|
||||
// Access: Private
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
RenderAttribRegistry::
|
||||
~RenderAttribRegistry() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::register_slot
|
||||
// Access: Public
|
||||
// Description: Adds the indicated TypeHandle to the registry, if it
|
||||
// is not there already, and returns a unique slot
|
||||
// number in the range 0 < slot < get_max_slots().
|
||||
//
|
||||
// The sort value is an arbitrary integer. In general,
|
||||
// the RenderAttribs will be sorted in order from lowest
|
||||
// sort value to highest sort value, when they are
|
||||
// traversed via the get_num_sorted_slots() /
|
||||
// get_sorted_slot() methods. This will be used to sort
|
||||
// render states, so that heavier RenderAttribs are
|
||||
// changed less frequently. In general, you should
|
||||
// choose sort values such that the heavier
|
||||
// RenderAttribs (that is, those which are more
|
||||
// expensive to change) have lower sort values.
|
||||
//
|
||||
// The make_default_func pointer is a function that may
|
||||
// be called to generate a default RenderAttrib to apply
|
||||
// in the absence of any other attrib of this type.
|
||||
//
|
||||
// register_slot() is intended to be called at
|
||||
// application start for each different RenderAttrib
|
||||
// type in the system, to assign a different integer
|
||||
// slot number to each one.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int RenderAttribRegistry::
|
||||
register_slot(TypeHandle type_handle, int sort,
|
||||
RenderAttribRegistry::MakeDefaultFunc *make_default_func) {
|
||||
int type_index = type_handle.get_index();
|
||||
while (type_index >= (int)_slots_by_type.size()) {
|
||||
_slots_by_type.push_back(0);
|
||||
}
|
||||
|
||||
if (_slots_by_type[type_index] != 0) {
|
||||
// This type has already been registered.
|
||||
return _slots_by_type[type_index];
|
||||
}
|
||||
|
||||
int slot = (int)_registry.size();
|
||||
if (slot >= _max_slots) {
|
||||
pgraph_cat->error()
|
||||
<< "Too many registered RenderAttribs; not registering "
|
||||
<< type_handle << "\n";
|
||||
nassertr(false, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
_slots_by_type[type_index] = slot;
|
||||
|
||||
RegistryNode node;
|
||||
node._type = type_handle;
|
||||
node._sort = sort;
|
||||
node._make_default_func = make_default_func;
|
||||
_registry.push_back(node);
|
||||
|
||||
_sorted_slots.push_back(slot);
|
||||
::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this));
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::set_slot_sort
|
||||
// Access: Published
|
||||
// Description: Changes the sort number associated with slot n.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void RenderAttribRegistry::
|
||||
set_slot_sort(int slot, int sort) {
|
||||
nassertv(slot >= 0 && slot < (int)_registry.size());
|
||||
_registry[slot]._sort = sort;
|
||||
|
||||
// Re-sort the slot list.
|
||||
_sorted_slots.clear();
|
||||
_sorted_slots.reserve(_registry.size() - 1);
|
||||
for (int i = 1; i < (int)_registry.size(); ++i) {
|
||||
_sorted_slots.push_back(i);
|
||||
}
|
||||
::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::get_slot_default
|
||||
// Access: Published
|
||||
// Description: Returns the default RenderAttrib object associated
|
||||
// with slot n. This is the attrib that should be
|
||||
// applied in the absence of any other attrib of this
|
||||
// type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) RenderAttribRegistry::
|
||||
get_slot_default(int slot) const {
|
||||
nassertr(slot >= 0 && slot < (int)_registry.size(), 0);
|
||||
return (*_registry[slot]._make_default_func)();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderAttribRegistry::init_global_ptr
|
||||
// Access: Private, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void RenderAttribRegistry::
|
||||
init_global_ptr() {
|
||||
_global_ptr = new RenderAttribRegistry;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
// Filename: renderAttribRegistry.h
|
||||
// Created by: drose (13Nov08)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RENDERATTRIBREGISTRY_H
|
||||
#define RENDERATTRIBREGISTRY_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "typeHandle.h"
|
||||
#include "vector_int.h"
|
||||
#include "pointerTo.h"
|
||||
#include "bitMask.h"
|
||||
|
||||
class RenderAttrib;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : RenderAttribRegistry
|
||||
// Description : This class is used to associate each RenderAttrib
|
||||
// with a different slot index at runtime, so we can
|
||||
// store a list of RenderAttribs in the RenderState
|
||||
// object, and very quickly look them up by type.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA_PGRAPH RenderAttribRegistry {
|
||||
private:
|
||||
RenderAttribRegistry();
|
||||
~RenderAttribRegistry();
|
||||
|
||||
public:
|
||||
typedef CPT(RenderAttrib) MakeDefaultFunc();
|
||||
|
||||
// This typedef defines the native bitmask type for indicating which
|
||||
// slots are present in a RenderState. It must be wide enough to
|
||||
// allow room for all of the possible RenderAttribs that might
|
||||
// register themselves. Presently, 32 bits is wide enough, but only
|
||||
// barely; when we exceed this limit, we will need to go to a 64-bit
|
||||
// type instead. It will be interesting to see whether a BitMask64
|
||||
// or a DoubleBitMask<BitMask32> will be faster on a 32-bit machine.
|
||||
typedef BitMask32 SlotMask;
|
||||
|
||||
int register_slot(TypeHandle type_handle, int sort,
|
||||
MakeDefaultFunc *make_default_func);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE int get_slot(TypeHandle type_handle) const;
|
||||
INLINE int get_max_slots() const;
|
||||
|
||||
INLINE int get_num_slots() const;
|
||||
INLINE TypeHandle get_slot_type(int slot) const;
|
||||
INLINE int get_slot_sort(int slot) const;
|
||||
void set_slot_sort(int slot, int sort);
|
||||
CPT(RenderAttrib) get_slot_default(int slot) const;
|
||||
|
||||
INLINE int get_num_sorted_slots() const;
|
||||
INLINE int get_sorted_slot(int n) const;
|
||||
|
||||
INLINE static RenderAttribRegistry *get_global_ptr();
|
||||
|
||||
public:
|
||||
INLINE static RenderAttribRegistry *quick_get_global_ptr();
|
||||
|
||||
private:
|
||||
static void init_global_ptr();
|
||||
|
||||
private:
|
||||
int _max_slots;
|
||||
|
||||
class SortSlots {
|
||||
public:
|
||||
INLINE SortSlots(RenderAttribRegistry *reg);
|
||||
INLINE bool operator () (int a, int b) const;
|
||||
RenderAttribRegistry *_reg;
|
||||
};
|
||||
|
||||
class RegistryNode {
|
||||
public:
|
||||
TypeHandle _type;
|
||||
int _sort;
|
||||
MakeDefaultFunc *_make_default_func;
|
||||
};
|
||||
typedef pvector<RegistryNode> Registry;
|
||||
Registry _registry;
|
||||
|
||||
vector_int _slots_by_type;
|
||||
vector_int _sorted_slots;
|
||||
|
||||
static RenderAttribRegistry *_global_ptr;
|
||||
};
|
||||
|
||||
#include "renderAttribRegistry.I"
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user