new interrogate, minor config changes

This commit is contained in:
David Rose 2004-10-28 18:33:45 +00:00
parent 0c94b63b85
commit 3e548e3663
50 changed files with 2447 additions and 1709 deletions

File diff suppressed because it is too large Load Diff

View File

@ -340,6 +340,8 @@ pop_struct() {
%type <u.expr> no_angle_bracket_const_expr
%type <u.expr> const_expr
%type <u.expr> const_operand
%type <u.expr> formal_const_expr
%type <u.expr> formal_const_operand
/* Precedence rules. */
@ -1211,7 +1213,15 @@ instance_identifier:
{
pop_scope();
$$ = $1;
$$->add_func_modifier($4, $6);
if ($4->is_parameter_expr() && $6 == 0) {
// Oops, this must have been an instance declaration with a
// parameter list, not a function prototype.
$$->add_initializer_modifier($4);
} else {
// This was (probably) a function prototype.
$$->add_func_modifier($4, $6);
}
}
;
@ -1334,6 +1344,13 @@ formal_parameter:
$3->add_modifier(IIT_const);
$$ = new CPPInstance($2, $3, 0, @3.file);
$$->set_initializer($4);
}
| formal_const_expr
{
CPPType *type =
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_parameter));
$$ = new CPPInstance(type, "expr");
$$->set_initializer($1);
}
;
@ -2472,6 +2489,191 @@ const_operand:
}
;
/* This is used for a const_expr as a "formal parameter", which really
means an instance declaration using a parameter list (which looks a
lot like a function prototype). It differs from const_expr mainly
in that it forbids some expressions unless they are parenthesized,
to avoid shift/reduce conflicts with the actual formal parameter
definition. */
formal_const_expr:
formal_const_operand
{
$$ = $1;
}
| '(' full_type ')' const_expr %prec UNARY
{
$$ = new CPPExpression(CPPExpression::typecast_op($2, $4));
}
| KW_STATIC_CAST '<' full_type '>' '(' const_expr_comma ')'
{
$$ = new CPPExpression(CPPExpression::typecast_op($3, $6));
}
| KW_DYNAMIC_CAST '<' full_type '>' '(' const_expr_comma ')'
{
$$ = new CPPExpression(CPPExpression::typecast_op($3, $6));
}
| KW_SIZEOF '(' full_type ')' %prec UNARY
{
$$ = new CPPExpression(CPPExpression::sizeof_func($3));
}
| KW_NEW predefined_type %prec UNARY
{
$$ = new CPPExpression(CPPExpression::new_op($2));
}
| KW_NEW predefined_type '(' optional_const_expr_comma ')' %prec UNARY
{
$$ = new CPPExpression(CPPExpression::new_op($2, $4));
}
| '!' const_expr %prec UNARY
{
$$ = new CPPExpression(UNARY_NOT, $2);
}
| '~' const_expr %prec UNARY
{
$$ = new CPPExpression(UNARY_NEGATE, $2);
}
| '-' const_expr %prec UNARY
{
if ($2->_type == CPPExpression::T_integer) {
$$ = $2;
$$->_u._integer = -$$->_u._integer;
} else if ($2->_type == CPPExpression::T_real) {
$$ = $2;
$$->_u._real = -$$->_u._real;
} else {
$$ = new CPPExpression(UNARY_MINUS, $2);
}
}
| '&' const_expr %prec UNARY
{
$$ = new CPPExpression(UNARY_REF, $2);
}
| formal_const_expr '*' const_expr
{
$$ = new CPPExpression('*', $1, $3);
}
| formal_const_expr '/' const_expr
{
$$ = new CPPExpression('/', $1, $3);
}
| formal_const_expr '%' const_expr
{
$$ = new CPPExpression('%', $1, $3);
}
| formal_const_expr '+' const_expr
{
$$ = new CPPExpression('+', $1, $3);
}
| formal_const_expr '-' const_expr
{
$$ = new CPPExpression('-', $1, $3);
}
| formal_const_expr '|' const_expr
{
$$ = new CPPExpression('|', $1, $3);
}
| formal_const_expr '&' const_expr
{
$$ = new CPPExpression('&', $1, $3);
}
| formal_const_expr OROR const_expr
{
$$ = new CPPExpression(OROR, $1, $3);
}
| formal_const_expr ANDAND const_expr
{
$$ = new CPPExpression(ANDAND, $1, $3);
}
| formal_const_expr EQCOMPARE const_expr
{
$$ = new CPPExpression(EQCOMPARE, $1, $3);
}
| formal_const_expr NECOMPARE const_expr
{
$$ = new CPPExpression(NECOMPARE, $1, $3);
}
| formal_const_expr LECOMPARE const_expr
{
$$ = new CPPExpression(LECOMPARE, $1, $3);
}
| formal_const_expr GECOMPARE const_expr
{
$$ = new CPPExpression(GECOMPARE, $1, $3);
}
| formal_const_expr '<' const_expr
{
$$ = new CPPExpression('<', $1, $3);
}
| formal_const_expr '>' const_expr
{
$$ = new CPPExpression('>', $1, $3);
}
| formal_const_expr LSHIFT const_expr
{
$$ = new CPPExpression(LSHIFT, $1, $3);
}
| formal_const_expr RSHIFT const_expr
{
$$ = new CPPExpression(RSHIFT, $1, $3);
}
| formal_const_expr '?' const_expr ':' const_expr
{
$$ = new CPPExpression('?', $1, $3, $5);
}
| formal_const_expr '[' const_expr ']'
{
$$ = new CPPExpression('[', $1, $3);
}
| formal_const_expr '(' const_expr_comma ')'
{
$$ = new CPPExpression('f', $1, $3);
}
| formal_const_expr '(' ')'
{
$$ = new CPPExpression('f', $1);
}
| formal_const_expr '.' const_expr
{
$$ = new CPPExpression('.', $1, $3);
}
| formal_const_expr POINTSAT const_expr
{
$$ = new CPPExpression(POINTSAT, $1, $3);
}
| '(' const_expr_comma ')'
{
$$ = $2;
}
;
formal_const_operand:
INTEGER
{
$$ = new CPPExpression($1);
}
| KW_TRUE
{
$$ = new CPPExpression(true);
}
| KW_FALSE
{
$$ = new CPPExpression(false);
}
| CHAR
{
$$ = new CPPExpression($1);
}
| REAL
{
$$ = new CPPExpression($1);
}
| string
{
$$ = new CPPExpression($1);
}
;
class_derivation_name:
name
{

View File

@ -25,10 +25,10 @@
#include "cppSimpleType.h"
#include "cppExpression.h"
#include "cppPreprocessor.h"
#include "indent.h"
#include "cppParameterList.h"
#include "cppReferenceType.h"
#include "cppConstType.h"
#include "indent.h"
#include <algorithm>
@ -79,8 +79,20 @@ CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class,
_ident = ii->_ident;
ii->_ident = NULL;
_storage_class = storage_class;
delete ii;
_initializer = NULL;
CPPParameterList *params = ii->get_initializer();
if (params != (CPPParameterList *)NULL) {
// In this case, the instance has a parameter-list initializer, e.g.:
//
// int foo(0);
//
// We really should save this initializer in the instance object.
// But we don't for now, since no one really cares about
// initializers anyway.
}
delete ii;
}
////////////////////////////////////////////////////////////////////
@ -489,6 +501,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
void CPPInstance::
output(ostream &out, int indent_level, CPPScope *scope, bool complete,
int num_default_parameters) const {
assert(_type != NULL);
if (_type->is_parameter_expr()) {
// In this case, the whole thing is really an expression, and not
// an instance at all. This can only happen if we parsed an
// instance declaration while we thought we were parsing a
// function prototype.
out << *_initializer;
return;
}
if (is_template()) {
get_template_scope()->_parameters.write_formal(out, scope);
indent(out, indent_level);
@ -525,12 +548,12 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete,
if (_ident != NULL) {
name = _ident->get_local_name(scope);
}
assert(_type != NULL);
if (_type->as_function_type()) {
_type->as_function_type()->
output_instance(out, indent_level, scope, complete, "", name,
num_default_parameters);
} else {
_type->output_instance(out, indent_level, scope, complete, "", name);
}

View File

@ -78,6 +78,19 @@ scoped_pointer_type(CPPIdentifier *scoping) {
return mod;
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::Modifier::named initializer_type constructor
// Access: Public, Static
// Description: This is used only for instance declarations that turn
// out to be have a parameter list for an initializer.
////////////////////////////////////////////////////////////////////
CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier::
initializer_type(CPPParameterList *params) {
Modifier mod(IIT_initializer);
mod._func_params = params;
return mod;
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::Constructor
// Access: Public
@ -114,7 +127,7 @@ add_modifier(CPPInstanceIdentifierType type) {
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::add_modifier
// Function: CPPInstanceIdentifier::add_func_modifier
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
@ -123,13 +136,18 @@ add_func_modifier(CPPParameterList *params, int flags) {
_modifiers.push_back(Modifier::func_type(params, flags));
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::add_scoped_pointer_modifier
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void CPPInstanceIdentifier::
add_scoped_pointer_modifier(CPPIdentifier *scoping) {
_modifiers.push_back(Modifier::scoped_pointer_type(scoping));
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::add_modifier
// Function: CPPInstanceIdentifier::add_array_modifier
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
@ -138,6 +156,42 @@ add_array_modifier(CPPExpression *expr) {
_modifiers.push_back(Modifier::array_type(expr));
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::add_initializer_modifier
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void CPPInstanceIdentifier::
add_initializer_modifier(CPPParameterList *params) {
_modifiers.push_back(Modifier::initializer_type(params));
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::get_initializer
// Access: Public
// Description: Returns the initializer parameter list that was set
// for this particular instance, e.g. if the instance
// were:
//
// int foo(0);
//
// this would return the parameter list (0). Returns
// NULL if the instance did not use a parameter list
// initializer.
////////////////////////////////////////////////////////////////////
CPPParameterList *CPPInstanceIdentifier::
get_initializer() const {
Modifiers::const_iterator mi;
for (mi = _modifiers.begin(); mi != _modifiers.end(); ++mi) {
const Modifier &mod = (*mi);
if (mod._type == IIT_initializer) {
return mod._func_params;
}
}
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: CPPInstanceIdentifier::get_scope
// Access: Public
@ -216,6 +270,13 @@ r_unroll_type(CPPType *start_type,
}
break;
case IIT_initializer:
// In this case, we have parsed an instance declaration with a set
// of initializers as a parameter list. We lose the initializers
// at this point, but the instance will put it back again.
result = start_type;
break;
default:
cerr << "Internal error--invalid CPPInstanceIdentifier\n";
abort();

View File

@ -41,6 +41,7 @@ enum CPPInstanceIdentifierType {
IIT_const,
IIT_paren,
IIT_func,
IIT_initializer,
};
///////////////////////////////////////////////////////////////////
@ -61,6 +62,9 @@ public:
void add_func_modifier(CPPParameterList *params, int flags);
void add_scoped_pointer_modifier(CPPIdentifier *scoping);
void add_array_modifier(CPPExpression *expr);
void add_initializer_modifier(CPPParameterList *params);
CPPParameterList *get_initializer() const;
CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
CPPPreprocessor *error_sink = NULL) const;
@ -73,6 +77,7 @@ public:
static Modifier func_type(CPPParameterList *params, int flags);
static Modifier array_type(CPPExpression *expr);
static Modifier scoped_pointer_type(CPPIdentifier *scoping);
static Modifier initializer_type(CPPParameterList *params);
CPPInstanceIdentifierType _type;
CPPParameterList *_func_params;

View File

@ -122,6 +122,24 @@ is_tbd() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: CPPParameterList::is_parameter_expr
// Access: Public
// Description: Returns true if any of the types in the parameter
// list turns out to be a constant expression, which is
// a clue that this parameter list is actually intended
// to be an instance declaration.
////////////////////////////////////////////////////////////////////
bool CPPParameterList::
is_parameter_expr() const {
for (int i = 0; i < (int)_parameters.size(); i++) {
if (_parameters[i]->_type->is_parameter_expr()) {
return true;
}
}
return false;
}
////////////////////////////////////////////////////////////////////
// Function: CPPParameterList::is_fully_specified
// Access: Public

View File

@ -30,7 +30,8 @@ class CPPScope;
///////////////////////////////////////////////////////////////////
// Class : CPPParameterList
// Description :
// Description : A list of formal parameters for a function
// declaration.
////////////////////////////////////////////////////////////////////
class CPPParameterList {
public:
@ -43,6 +44,7 @@ public:
bool operator < (const CPPParameterList &other) const;
bool is_tbd() const;
bool is_parameter_expr() const;
bool is_fully_specified() const;
CPPParameterList *substitute_decl(CPPDeclaration::SubstDecl &subst,

View File

@ -44,6 +44,21 @@ is_tbd() const {
return (_type == T_unknown);
}
////////////////////////////////////////////////////////////////////
// Function: CPPSimpleType::is_parameter_expr
// Access: Public, Virtual
// Description: Returns true if the type is a special parameter
// expression type.
//
// This sort of type is created to handle instance
// declarations that initially look like function
// prototypes.
////////////////////////////////////////////////////////////////////
bool CPPSimpleType::
is_parameter_expr() const {
return (_type == T_parameter);
}
////////////////////////////////////////////////////////////////////
// Function: CPPSimpleType::get_preferred_name
// Access: Public, Virtual
@ -116,6 +131,10 @@ output(ostream &out, int, CPPScope *, bool) const {
out << "unknown";
break;
case T_parameter:
out << "parameter";
break;
default:
out << "***invalid type***";
}

View File

@ -37,6 +37,20 @@ public:
T_double,
T_void,
T_unknown,
// T_parameter is a special type which is assigned to expressions
// that are discovered where a formal parameter was expected.
// This is a special case for handling cases like this:
//
// int foo(0);
//
// which really means the same thing as:
//
// int foo = 0;
//
// but it initially looks like a function prototype.
//
T_parameter,
};
enum Flags {
@ -53,6 +67,7 @@ public:
int _flags;
virtual bool is_tbd() const;
virtual bool is_parameter_expr() const;
virtual string get_preferred_name() const;

View File

@ -66,6 +66,21 @@ is_tbd() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: CPPType::is_parameter_expr
// Access: Public, Virtual
// Description: Returns true if the type is a special parameter
// expression type.
//
// This sort of type is created to handle instance
// declarations that initially look like function
// prototypes.
////////////////////////////////////////////////////////////////////
bool CPPType::
is_parameter_expr() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: CPPType::has_typedef_name
// Access: Public

View File

@ -52,6 +52,7 @@ public:
CPPScope *global_scope);
virtual bool is_tbd() const;
virtual bool is_parameter_expr() const;
bool has_typedef_name() const;
string get_typedef_name(CPPScope *scope = NULL) const;

View File

@ -105,7 +105,7 @@ output_c_string(ostream &out, const string &string_name,
}
}
}
out << "\";\nstatic const size_t " << string_name << index
out << "\";\nstatic const unsigned int " << string_name << index
<< "_length = " << data_size << ";\n";
}

View File

@ -33,9 +33,7 @@
TypeHandle Character::_type_handle;
#ifndef CPPPARSER
PStatCollector Character::_anim_pcollector("App:Animation");
#endif
////////////////////////////////////////////////////////////////////
// Function: Character::Copy Constructor

View File

@ -32,10 +32,8 @@
#include "pStatTimer.h"
#include "indent.h"
#ifndef CPPPARSER
PStatCollector CollisionTraverser::_collisions_pcollector("App:Collisions");
PStatCollector CollisionTraverser::_reset_prev_pcollector("App:Collisions:Reset");
#endif
////////////////////////////////////////////////////////////////////
// Function: CollisionTraverser::Constructor

View File

@ -95,7 +95,7 @@ INLINE void TrackerNode::
set_tracker_coordinate_system(CoordinateSystem cs) {
_tracker_cs = cs;
if (_tracker_cs == CS_default) {
_tracker_cs = default_coordinate_system;
_tracker_cs = get_default_coordinate_system();
}
}
@ -121,7 +121,7 @@ INLINE void TrackerNode::
set_graph_coordinate_system(CoordinateSystem cs) {
_graph_cs = cs;
if (_graph_cs == CS_default) {
_graph_cs = default_coordinate_system;
_graph_cs = get_default_coordinate_system();
}
}

View File

@ -40,7 +40,6 @@
#include <sys/time.h>
#endif
#ifndef CPPPARSER
PStatCollector GraphicsEngine::_app_pcollector("App");
PStatCollector GraphicsEngine::_yield_pcollector("App:Yield");
PStatCollector GraphicsEngine::_cull_pcollector("Cull");
@ -53,7 +52,6 @@ PStatCollector GraphicsEngine::_transform_states_pcollector("TransformStates");
PStatCollector GraphicsEngine::_transform_states_unused_pcollector("TransformStates:Unused");
PStatCollector GraphicsEngine::_render_states_pcollector("RenderStates");
PStatCollector GraphicsEngine::_render_states_unused_pcollector("RenderStates:Unused");
#endif // CPPPARSER
////////////////////////////////////////////////////////////////////
// Function: GraphicsEngine::Constructor

View File

@ -27,10 +27,8 @@
TypeHandle GraphicsOutput::_type_handle;
#ifndef CPPPARSER
PStatCollector GraphicsOutput::_make_current_pcollector("Draw:Make current");
PStatCollector GraphicsOutput::_copy_texture_pcollector("Draw:Copy texture");
#endif // CPPPARSER
////////////////////////////////////////////////////////////////////
// Function: GraphicsOutput::Constructor

View File

@ -40,7 +40,6 @@
#include <algorithm>
#ifndef CPPPARSER
PStatCollector GraphicsStateGuardian::_total_texusage_pcollector("Texture usage");
PStatCollector GraphicsStateGuardian::_active_texusage_pcollector("Texture usage:Active");
PStatCollector GraphicsStateGuardian::_total_geom_pcollector("Prepared Geoms");
@ -62,8 +61,6 @@ PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive
PStatCollector GraphicsStateGuardian::_clear_pcollector("Draw:Clear");
PStatCollector GraphicsStateGuardian::_flush_pcollector("Draw:Flush");
#endif
TypeHandle GraphicsStateGuardian::_type_handle;
////////////////////////////////////////////////////////////////////
@ -74,7 +71,7 @@ TypeHandle GraphicsStateGuardian::_type_handle;
GraphicsStateGuardian::
GraphicsStateGuardian(const FrameBufferProperties &properties) {
_properties = properties;
_coordinate_system = default_coordinate_system;
_coordinate_system = get_default_coordinate_system();
_current_display_region = (DisplayRegion*)0L;
_current_lens = (Lens *)NULL;
_needs_reset = true;

View File

@ -63,15 +63,15 @@ ConfigureFn(config_egg) {
init_libegg();
}
const DSearchPath &
get_egg_path() {
static DSearchPath *egg_path = NULL;
return get_config_path("egg-path", egg_path);
}
ConfigVariableSearchPath egg_path
("egg-path",
"The search path along which only egg files are searched. Generally, you "
"should use model-path instead of egg-path.");
// Set this true to support loading of old character animation files, which
// had the convention that the order "phr" implied a reversed roll.
bool egg_support_old_anims = config_egg.GetBool("egg-support-old-anims", true);
ConfigVariableBool egg_support_old_anims
("egg-support-old-anims", true,
"Set this true to support loading of old character animation files, which "
"had the convention that the order \"phr\" implied a reversed roll.");
////////////////////////////////////////////////////////////////////
// Function: init_libegg

View File

@ -21,13 +21,13 @@
#include "pandabase.h"
#include "notifyCategoryProxy.h"
class DSearchPath;
#include "configVariableSearchPath.h"
#include "configVariableBool.h"
NotifyCategoryDecl(egg, EXPCL_PANDAEGG, EXPTP_PANDAEGG);
const DSearchPath &get_egg_path();
extern bool egg_support_old_anims;
extern ConfigVariableSearchPath egg_path;
extern ConfigVariableBool egg_support_old_anims;
extern EXPCL_PANDAEGG void init_libegg();

View File

@ -55,7 +55,7 @@ resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) {
}
vfs->resolve_filename(egg_filename, searchpath, "egg") ||
vfs->resolve_filename(egg_filename, get_egg_path(), "egg") ||
vfs->resolve_filename(egg_filename, egg_path, "egg") ||
vfs->resolve_filename(egg_filename, get_model_path(), "egg");
return vfs->exists(egg_filename);
@ -66,7 +66,7 @@ resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) {
}
egg_filename.resolve_filename(searchpath, "egg") ||
egg_filename.resolve_filename(get_egg_path(), "egg") ||
egg_filename.resolve_filename(egg_path, "egg") ||
egg_filename.resolve_filename(get_model_path(), "egg");
return egg_filename.exists();
@ -278,7 +278,7 @@ write_egg(ostream &out) {
void EggData::
set_coordinate_system(CoordinateSystem new_coordsys) {
if (new_coordsys == CS_default) {
new_coordsys = default_coordinate_system;
new_coordsys = get_default_coordinate_system();
}
if (new_coordsys != _coordsys &&
(_coordsys != CS_default && _coordsys != CS_invalid)) {

View File

@ -80,7 +80,7 @@ calculate_normal(Normald &result, CoordinateSystem cs) const {
}
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (cs == CS_zup_left || cs == CS_yup_left) {
// In a left-handed coordinate system, we must flip the result.

View File

@ -131,7 +131,7 @@ init_libegg2pg() {
cs = CS_default;
}
egg_coordinate_system = (cs == CS_default) ?
default_coordinate_system : cs;
get_default_coordinate_system() : cs;
// Get egg-alpha-mode
string amstr = config_egg2pg.GetString("egg-alpha-mode", "blend");

View File

@ -60,7 +60,7 @@
TypeHandle CLP(GraphicsStateGuardian)::_type_handle;
#if !defined(CPPPARSER) && defined(DO_PSTATS)
#ifdef DO_PSTATS
PStatCollector CLP(GraphicsStateGuardian)::_vertices_display_list_pcollector("Vertices:Display lists");
#endif

View File

@ -65,7 +65,7 @@ void OrthographicLens::
compute_projection_mat() {
CoordinateSystem cs = _cs;
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
float a = 2.0f / (_far_distance - _near_distance);

View File

@ -54,7 +54,7 @@ void PerspectiveLens::
compute_projection_mat() {
CoordinateSystem cs = _cs;
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
float fl = get_focal_length();

View File

@ -20,9 +20,7 @@
#include "textureContext.h"
#include "mutexHolder.h"
#ifndef CPPPARSER
PStatCollector PreparedGraphicsObjects::_total_texusage_pcollector("Texture usage");
#endif // CPPPARSER
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::Constructor

View File

@ -28,9 +28,7 @@
#include "pStatTimer.h"
#include <stdio.h> // For sprintf/snprintf
#ifndef CPPPARSER
PStatCollector FrameRateMeter::_show_fps_pcollector("Cull:Show fps");
#endif // CPPPARSER
TypeHandle FrameRateMeter::_type_handle;

View File

@ -527,7 +527,7 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat,
FLOATNAME(LVecBase3) &hpr,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (linmath_cat.is_debug()) {
@ -649,7 +649,7 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat,
FLOATTYPE roll,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (linmath_cat.is_debug()) {

View File

@ -29,19 +29,18 @@ ConfigureFn(config_linmath) {
init_liblinmath();
}
// Set this true to doublecheck the quaternion-hpr compose and
// decompose operations against the quaternion-matrix and matrix-hpr
// operations. This only has effect if NDEBUG is not defined.
const bool paranoid_hpr_quat = config_linmath.GetBool("paranoid-hpr-quat", false);
ConfigVariableBool paranoid_hpr_quat
("paranoid-hpr-quat", false,
"Set this true to doublecheck the quaternion-hpr compose and "
"decompose operations against the quaternion-matrix and matrix-hpr "
"operations. This only has effect if NDEBUG is not defined.");
// Set this true to compute hpr's correctly. Presently, we apply
// these in the wrong order, and roll is backwards relative to the
// other two. But we can't globally fix this because some of our old
// tools, most notably egg-optchar, depend on the old broken behavior.
// Until we are able to rewrite these tools into the new system, we
// must keep the old behavior; setting this switch lets you use the
// new, correct behavior but you don't get animated characters.
const bool temp_hpr_fix = config_linmath.GetBool("temp-hpr-fix", false);
ConfigVariableBool temp_hpr_fix
("temp-hpr-fix", true,
"Set this true to compute hpr's correctly. Historically, Panda has "
"applied these in the wrong order, and roll was backwards relative "
"to the other two. Set this false if you need compatibility with "
"Panda's old hpr calculations.");
////////////////////////////////////////////////////////////////////
// Function: init_liblinmath
@ -90,14 +89,4 @@ init_liblinmath() {
LQuaterniond::init_type();
LRotationd::init_type();
LOrientationd::init_type();
string csstr = config_linmath.GetString("coordinate-system", "default");
CoordinateSystem cs = parse_coordinate_system_string(csstr);
if (cs == CS_invalid) {
linmath_cat.error()
<< "Unexpected coordinate-system string: " << csstr << "\n";
cs = CS_default;
}
default_coordinate_system = (cs == CS_default) ? CS_zup_right : cs;
}

View File

@ -21,11 +21,12 @@
#include "pandabase.h"
#include "notifyCategoryProxy.h"
#include "configVariableBool.h"
NotifyCategoryDecl(linmath, EXPCL_PANDA, EXPTP_PANDA);
extern const bool paranoid_hpr_quat;
extern EXPCL_PANDA const bool temp_hpr_fix;
extern EXPCL_PANDA ConfigVariableBool paranoid_hpr_quat;
extern EXPCL_PANDA ConfigVariableBool temp_hpr_fix;
extern EXPCL_PANDA void init_liblinmath();

View File

@ -18,14 +18,25 @@
#include "coordinateSystem.h"
#include "config_linmath.h"
#include "configVariableEnum.h"
#include "dconfig.h"
#include "notify.h"
#include <ctype.h>
#include <string>
CoordinateSystem default_coordinate_system;
static ConfigVariableEnum<CoordinateSystem> default_cs
("coordinate-system", CS_zup_right,
"The default coordinate system to use throughout Panda for rendering, "
"user input, and matrix operations, unless specified otherwise.");
CoordinateSystem
get_default_coordinate_system() {
CoordinateSystem cs = default_cs;
return (cs == CS_default || cs == CS_invalid) ? CS_zup_right : cs;
}
CoordinateSystem
parse_coordinate_system_string(const string &str) {
@ -57,10 +68,10 @@ parse_coordinate_system_string(const string &str) {
return CS_invalid;
}
INLINE_LINMATH bool
bool
is_right_handed(CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
switch (cs) {
case CS_zup_right:
@ -106,3 +117,12 @@ operator << (ostream &out, CoordinateSystem cs) {
nassertr(false, out);
return out;
}
istream &
operator >> (istream &in, CoordinateSystem &cs) {
string word;
in >> word;
cs = parse_coordinate_system_string(word);
return in;
}

View File

@ -23,15 +23,13 @@
#include "typedef.h"
#include <string>
BEGIN_PUBLISH
enum CoordinateSystem {
// The CS_default entry does not refer to a particular coordinate
// system, but rather to the value stored in
// default_coordinate_system, which in turn is loaded from the
// Configrc variable "coordinate-system".
// config variable "coordinate-system".
CS_default,
CS_zup_right,
@ -45,16 +43,17 @@ enum CoordinateSystem {
CS_invalid,
};
EXPCL_PANDA CoordinateSystem get_default_coordinate_system();
END_PUBLISH
extern CoordinateSystem EXPCL_PANDA default_coordinate_system;
CoordinateSystem EXPCL_PANDA parse_coordinate_system_string(const string &str);
bool EXPCL_PANDA is_right_handed(CoordinateSystem cs = CS_default);
EXPCL_PANDA CoordinateSystem parse_coordinate_system_string(const string &str);
EXPCL_PANDA bool is_right_handed(CoordinateSystem cs = CS_default);
#define IS_LEFT_HANDED_COORDSYSTEM(cs) ((cs==CS_zup_left) || (cs==CS_yup_left))
ostream EXPCL_PANDA &operator << (ostream &out, CoordinateSystem cs);
EXPCL_PANDA ostream &operator << (ostream &out, CoordinateSystem cs);
EXPCL_PANDA istream &operator >> (istream &in, CoordinateSystem &cs);
#endif

View File

@ -965,7 +965,7 @@ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATNAME(LMatrix3) mat;
@ -1044,7 +1044,7 @@ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATNAME(LMatrix3) mat;

View File

@ -61,7 +61,7 @@ scale_shear_mat(const FLOATNAME(LVecBase3) &scale,
const FLOATNAME(LVecBase3) &shear,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
// We have to match the placement of the shear components in the
@ -134,10 +134,10 @@ scale_shear_mat(const FLOATNAME(LVecBase3) &scale,
const FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3)::
convert_mat(CoordinateSystem from, CoordinateSystem to) {
if (from == CS_default) {
from = default_coordinate_system;
from = get_default_coordinate_system();
}
if (to == CS_default) {
to = default_coordinate_system;
to = get_default_coordinate_system();
}
switch (from) {
case CS_zup_left:

View File

@ -1201,7 +1201,7 @@ rotate_mat(FLOATTYPE angle, FLOATNAME(LVecBase3) axis,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATNAME(LMatrix4) mat;
@ -1297,7 +1297,7 @@ rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis,
FLOATNAME(LMatrix4) &result_mat, CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if(IS_LEFT_HANDED_COORDSYSTEM(cs)) {

View File

@ -63,10 +63,10 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ly_to_rz_mat =
const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4)::
convert_mat(CoordinateSystem from, CoordinateSystem to) {
if (from == CS_default) {
from = default_coordinate_system;
from = get_default_coordinate_system();
}
if (to == CS_default) {
to = default_coordinate_system;
to = get_default_coordinate_system();
}
switch (from) {
case CS_zup_left:

View File

@ -252,7 +252,7 @@ operator / (FLOATTYPE scalar) const {
INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3)::
up(CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
switch (cs) {
case CS_zup_right:
@ -290,7 +290,7 @@ right(CoordinateSystem) {
INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3)::
forward(CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
switch (cs) {
case CS_zup_right:
@ -364,7 +364,7 @@ rfu(FLOATTYPE right_v, FLOATTYPE fwd_v, FLOATTYPE up_v,
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATTYPE vy,vz;
switch(cs) {

View File

@ -29,7 +29,7 @@ BoundingHexahedron::
BoundingHexahedron(const Frustumf &frustum, bool is_ortho,
CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
float fs = 1.0f;

View File

@ -173,7 +173,7 @@ get_perspective_params(FLOATTYPE& xfov, FLOATTYPE& yfov, FLOATTYPE& aspect,
INLINE_MATHUTIL FLOATNAME(LMatrix4) FLOATNAME(Frustum)::
get_perspective_projection_mat(CoordinateSystem cs) const {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATTYPE recip_far_minus_near = 1.0f/(_ffar - _fnear);
@ -235,7 +235,7 @@ get_perspective_projection_mat(CoordinateSystem cs) const {
INLINE_MATHUTIL FLOATNAME(LMatrix4) FLOATNAME(Frustum)::
get_ortho_projection_mat(CoordinateSystem cs) const {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
FLOATTYPE a = 2.0f / (_r - _l);

View File

@ -62,7 +62,7 @@ void
heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd,
const FLOATNAME(LVector3) &up, CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (cs == CS_zup_right || cs == CS_zup_left) {
@ -198,7 +198,7 @@ void
look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd,
const FLOATNAME(LVector3) &up, CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (cs == CS_zup_right || cs == CS_zup_left) {

View File

@ -416,7 +416,7 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) {
}
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (cs != CS_invalid) {

View File

@ -771,7 +771,7 @@ write_egg(Filename filename, CoordinateSystem cs) {
bool ParametricCurveCollection::
write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) {
if (cs == CS_default) {
cs = default_coordinate_system;
cs = get_default_coordinate_system();
}
if (cs != CS_invalid) {

View File

@ -18,11 +18,8 @@
#include "cullBin.h"
#ifndef CPPPARSER
PStatCollector CullBin::_cull_bin_pcollector("Cull:Bins");
PStatCollector CullBin::_draw_bin_pcollector("Draw:Bins");
#endif
TypeHandle CullBin::_type_handle;

View File

@ -34,10 +34,8 @@
#include "geomSphere.h"
#include "portalClipper.h"
#ifndef CPPPARSER
PStatCollector CullTraverser::_nodes_pcollector("Nodes");
PStatCollector CullTraverser::_geom_nodes_pcollector("Nodes:GeomNodes");
#endif // CPPPARSER
TypeHandle CullTraverser::_type_handle;

View File

@ -30,9 +30,7 @@
TypeHandle PolylightEffect::_type_handle;
#ifndef CPPPARSER
PStatCollector PolylightEffect::_cull_pcollector("Cull:Polylight");
#endif /// CPPPARSER
////////////////////////////////////////////////////////////////////
// Function: PolylightEffect::make

View File

@ -41,12 +41,10 @@
PStatClient *PStatClient::_global_pstats = NULL;
#ifndef CPPPARSER
PStatCollector _total_size_pcollector("Memory usage");
PStatCollector _cpp_size_pcollector("Memory usage:C++");
PStatCollector _interpreter_size_pcollector("Memory usage:Interpreter");
PStatCollector _pstats_pcollector("App:PStats");
#endif
////////////////////////////////////////////////////////////////////
// Function: PStatClient::PerThreadData::Constructor

View File

@ -40,7 +40,6 @@ ConfigureDef(config_util);
NotifyCategoryDef(util, "");
NotifyCategoryDef(bam, util_cat);
#ifndef CPPPARSER
ConfigVariableSearchPath model_path
("model-path", "The default directories to search for all models and general files loaded into Panda.");
@ -49,7 +48,6 @@ ConfigVariableSearchPath texture_path
ConfigVariableSearchPath sound_path
("sound-path", "The directories to search for loaded sound and music files.");
#endif // CPPPARSER
ConfigureFn(config_util) {
BamReaderParam::init_type();

View File

@ -360,7 +360,7 @@ apply(double x, double y, bool any_button) {
// To prevent upward drift due to numerical errors, force the
// vertical component of our step to zero (it should be pretty near
// zero anyway).
switch (default_coordinate_system) {
switch (get_default_coordinate_system()) {
case CS_zup_right:
case CS_zup_left:
step[2] = 0.0f;

View File

@ -56,7 +56,7 @@ Trackball(const string &name) :
_mat = LMatrix4f::ident_mat();
_orig = LMatrix4f::ident_mat();
_invert = true;
_cs = default_coordinate_system;
_cs = get_default_coordinate_system();
// We want to track the state of these buttons.
watch_button(MouseButton::one());