diff --git a/direct/src/deadrec/smoothMover.I b/direct/src/deadrec/smoothMover.I index e6b7cd4041..0f91e90f3a 100644 --- a/direct/src/deadrec/smoothMover.I +++ b/direct/src/deadrec/smoothMover.I @@ -29,7 +29,7 @@ // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_pos(const LVecBase3f &pos) { +set_pos(const LVecBase3 &pos) { return set_x(pos[0]) | set_y(pos[1]) | set_z(pos[2]); } @@ -49,7 +49,7 @@ set_pos(const LVecBase3f &pos) { // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_pos(float x, float y, float z) { +set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return set_x(x) | set_y(y) | set_z(z); } @@ -59,7 +59,7 @@ set_pos(float x, float y, float z) { // Description: Sets the X position only. See set_pos(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_x(float x) { +set_x(PN_stdfloat x) { bool result = (x != _sample._pos[0]); /* if (deadrec_cat.is_debug()) { @@ -76,7 +76,7 @@ set_x(float x) { // Description: Sets the Y position only. See set_pos(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_y(float y) { +set_y(PN_stdfloat y) { bool result = (y != _sample._pos[1]); /* if (deadrec_cat.is_debug()) { @@ -93,7 +93,7 @@ set_y(float y) { // Description: Sets the Z position only. See set_pos(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_z(float z) { +set_z(PN_stdfloat z) { bool result = (z != _sample._pos[2]); /* if (deadrec_cat.is_debug()) { @@ -120,7 +120,7 @@ set_z(float z) { // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_hpr(const LVecBase3f &hpr) { +set_hpr(const LVecBase3 &hpr) { return set_h(hpr[0]) | set_p(hpr[1]) | set_r(hpr[2]); } @@ -140,7 +140,7 @@ set_hpr(const LVecBase3f &hpr) { // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_hpr(float h, float p, float r) { +set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { return set_h(h) | set_p(p) | set_r(r); } @@ -150,7 +150,7 @@ set_hpr(float h, float p, float r) { // Description: Sets the heading only. See set_hpr(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_h(float h) { +set_h(PN_stdfloat h) { bool result = (h != _sample._hpr[0]); /* if (deadrec_cat.is_debug()) { @@ -167,7 +167,7 @@ set_h(float h) { // Description: Sets the pitch only. See set_hpr(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_p(float p) { +set_p(PN_stdfloat p) { bool result = (p != _sample._hpr[1]); /* if (deadrec_cat.is_debug()) { @@ -184,7 +184,7 @@ set_p(float p) { // Description: Sets the roll only. See set_hpr(). //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_r(float r) { +set_r(PN_stdfloat r) { bool result = (r != _sample._hpr[2]); /* if (deadrec_cat.is_debug()) { @@ -211,7 +211,7 @@ set_r(float r) { // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { +set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { return (set_x(pos[0]) | set_y(pos[1]) | set_z(pos[2]) | set_h(hpr[0]) | set_p(hpr[1]) | set_r(hpr[2])); } @@ -232,7 +232,7 @@ set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { // are the same. //////////////////////////////////////////////////////////////////// INLINE bool SmoothMover:: -set_pos_hpr(float x, float y, float z, float h, float p, float r) { +set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { return set_x(x) | set_y(y) | set_z(z) | set_h(h) | set_p(p) | set_r(r); } @@ -245,7 +245,7 @@ set_pos_hpr(float x, float y, float z, float h, float p, float r) { // copied to the sample point table when // mark_position() is called. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &SmoothMover:: +INLINE const LPoint3 &SmoothMover:: get_sample_pos() const { return _sample._pos; } @@ -259,7 +259,7 @@ get_sample_pos() const { // copied to the sample point table when // mark_position() is called. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &SmoothMover:: +INLINE const LVecBase3 &SmoothMover:: get_sample_hpr() const { return _sample._hpr; } @@ -355,7 +355,7 @@ compute_smooth_position() { // Description: Returns the smoothed position as computed by a // previous call to compute_smooth_position(). //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &SmoothMover:: +INLINE const LPoint3 &SmoothMover:: get_smooth_pos() const { return _smooth_pos; } @@ -366,7 +366,7 @@ get_smooth_pos() const { // Description: Returns the smoothed position as computed by a // previous call to compute_smooth_position(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &SmoothMover:: +INLINE const LVecBase3 &SmoothMover:: get_forward_axis() const { return _forward_axis; } @@ -377,7 +377,7 @@ get_forward_axis() const { // Description: Returns the smoothed orientation as computed by a // previous call to compute_smooth_position(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &SmoothMover:: +INLINE const LVecBase3 &SmoothMover:: get_smooth_hpr() const { return _smooth_hpr; } @@ -480,7 +480,7 @@ compute_and_apply_smooth_hpr(NodePath &hpr_node) { // number if the avatar is moving forward, and a // negative number if it is moving backward. //////////////////////////////////////////////////////////////////// -INLINE float SmoothMover:: +INLINE PN_stdfloat SmoothMover:: get_smooth_forward_velocity() const { return _smooth_forward_velocity; } @@ -494,7 +494,7 @@ get_smooth_forward_velocity() const { // number if the avatar is moving right, and a // negative number if it is moving left. //////////////////////////////////////////////////////////////////// -INLINE float SmoothMover:: +INLINE PN_stdfloat SmoothMover:: get_smooth_lateral_velocity() const { return _smooth_lateral_velocity; } @@ -507,7 +507,7 @@ get_smooth_lateral_velocity() const { // second. This may be positive or negative, according // to the direction of rotation. //////////////////////////////////////////////////////////////////// -INLINE float SmoothMover:: +INLINE PN_stdfloat SmoothMover:: get_smooth_rotational_velocity() const { return _smooth_rotational_velocity; } diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index ee6e8ec95b..87e09e874f 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -101,8 +101,8 @@ mark_position() { // We also need to compute the velocity here. if (_smooth_position_known) { - LVector3f pos_delta = _sample._pos - _smooth_pos; - LVecBase3f hpr_delta = _sample._hpr - _smooth_hpr; + LVector3 pos_delta = _sample._pos - _smooth_pos; + LVecBase3 hpr_delta = _sample._hpr - _smooth_hpr; double age = timestamp - _smooth_timestamp; age = min(age, _max_position_age); @@ -583,7 +583,7 @@ write(ostream &out) const { // the indicated timestamp. //////////////////////////////////////////////////////////////////// void SmoothMover:: -set_smooth_pos(const LPoint3f &pos, const LVecBase3f &hpr, +set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, double timestamp) { if (deadrec_cat.is_spam()) { deadrec_cat.spam() @@ -661,8 +661,8 @@ linear_interpolate(int point_before, int point_after, double timestamp) { } double t = (timestamp - point_b._timestamp) / age; - LVector3f pos_delta = point_a._pos - point_b._pos; - LVecBase3f hpr_delta = point_a._hpr - point_b._hpr; + LVector3 pos_delta = point_a._pos - point_b._pos; + LVecBase3 hpr_delta = point_a._hpr - point_b._hpr; if (deadrec_cat.is_spam()) { deadrec_cat.spam() @@ -683,7 +683,7 @@ linear_interpolate(int point_before, int point_after, double timestamp) { // moving object. //////////////////////////////////////////////////////////////////// void SmoothMover:: -compute_velocity(const LVector3f &pos_delta, const LVecBase3f &hpr_delta, +compute_velocity(const LVector3 &pos_delta, const LVecBase3 &hpr_delta, double age) { _smooth_rotational_velocity = hpr_delta[0] / age; @@ -692,9 +692,9 @@ compute_velocity(const LVector3f &pos_delta, const LVecBase3f &hpr_delta, // the velocity vector onto the y axis, as rotated by the current // hpr. if (!_computed_forward_axis) { - LMatrix3f rot_mat; - compose_matrix(rot_mat, LVecBase3f(1.0, 1.0, 1.0), _smooth_hpr); - _forward_axis = LVector3f(0.0, 1.0, 0.0) * rot_mat; + LMatrix3 rot_mat; + compose_matrix(rot_mat, LVecBase3(1.0, 1.0, 1.0), _smooth_hpr); + _forward_axis = LVector3(0.0, 1.0, 0.0) * rot_mat; if (deadrec_cat.is_spam()) { deadrec_cat.spam() @@ -702,10 +702,10 @@ compute_velocity(const LVector3f &pos_delta, const LVecBase3f &hpr_delta, } } - LVector3f lateral_axis = _forward_axis.cross(LVector3f(0.0,0.0,1.0)); + LVector3 lateral_axis = _forward_axis.cross(LVector3(0.0,0.0,1.0)); - float forward_distance = pos_delta.dot(_forward_axis); - float lateral_distance = pos_delta.dot(lateral_axis); + PN_stdfloat forward_distance = pos_delta.dot(_forward_axis); + PN_stdfloat lateral_distance = pos_delta.dot(lateral_axis); _smooth_forward_velocity = forward_distance / age; _smooth_lateral_velocity = lateral_distance / age; diff --git a/direct/src/deadrec/smoothMover.h b/direct/src/deadrec/smoothMover.h index a30fac1df4..663f6623bd 100644 --- a/direct/src/deadrec/smoothMover.h +++ b/direct/src/deadrec/smoothMover.h @@ -54,23 +54,23 @@ PUBLISHED: // mark_position(). The return value of each function is true if // the parameter value has changed, or false if it remains the same // as last time. - INLINE bool set_pos(const LVecBase3f &pos); - INLINE bool set_pos(float x, float y, float z); - INLINE bool set_x(float x); - INLINE bool set_y(float y); - INLINE bool set_z(float z); + INLINE bool set_pos(const LVecBase3 &pos); + INLINE bool set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE bool set_x(PN_stdfloat x); + INLINE bool set_y(PN_stdfloat y); + INLINE bool set_z(PN_stdfloat z); - INLINE bool set_hpr(const LVecBase3f &hpr); - INLINE bool set_hpr(float h, float p, float r); - INLINE bool set_h(float h); - INLINE bool set_p(float p); - INLINE bool set_r(float r); + INLINE bool set_hpr(const LVecBase3 &hpr); + INLINE bool set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE bool set_h(PN_stdfloat h); + INLINE bool set_p(PN_stdfloat p); + INLINE bool set_r(PN_stdfloat r); - INLINE bool set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr); - INLINE bool set_pos_hpr(float x, float y, float z, float h, float p, float r); + INLINE bool set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr); + INLINE bool set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); - INLINE const LPoint3f &get_sample_pos() const; - INLINE const LVecBase3f &get_sample_hpr() const; + INLINE const LPoint3 &get_sample_pos() const; + INLINE const LVecBase3 &get_sample_hpr() const; INLINE void set_phony_timestamp(double timestamp = 0.0, bool period_adjust = false); @@ -86,8 +86,8 @@ PUBLISHED: bool compute_smooth_position(double timestamp); bool get_latest_position(); - INLINE const LPoint3f &get_smooth_pos() const; - INLINE const LVecBase3f &get_smooth_hpr() const; + INLINE const LPoint3 &get_smooth_pos() const; + INLINE const LVecBase3 &get_smooth_hpr() const; INLINE void apply_smooth_pos(NodePath &node) const; INLINE void apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node) const; @@ -97,10 +97,10 @@ PUBLISHED: INLINE void compute_and_apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node); INLINE void compute_and_apply_smooth_hpr(NodePath &hpr_node); - INLINE float get_smooth_forward_velocity() const; - INLINE float get_smooth_lateral_velocity() const; - INLINE float get_smooth_rotational_velocity() const; - INLINE const LVecBase3f &get_forward_axis() const; + INLINE PN_stdfloat get_smooth_forward_velocity() const; + INLINE PN_stdfloat get_smooth_lateral_velocity() const; + INLINE PN_stdfloat get_smooth_rotational_velocity() const; + INLINE const LVecBase3 &get_forward_axis() const; void handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent); @@ -149,11 +149,11 @@ PUBLISHED: void write(ostream &out) const; private: - void set_smooth_pos(const LPoint3f &pos, const LVecBase3f &hpr, + void set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, double timestamp); void linear_interpolate(int point_before, int point_after, double timestamp); - void compute_velocity(const LVector3f &pos_delta, - const LVecBase3f &hpr_delta, + void compute_velocity(const LVector3 &pos_delta, + const LVecBase3 &hpr_delta, double age); void record_timestamp_delay(double timestamp); @@ -164,17 +164,17 @@ public: // issues. class SamplePoint { public: - LPoint3f _pos; - LVecBase3f _hpr; + LPoint3 _pos; + LVecBase3 _hpr; double _timestamp; }; private: SamplePoint _sample; - LPoint3f _smooth_pos; - LVecBase3f _smooth_hpr; - LVector3f _forward_axis; + LPoint3 _smooth_pos; + LVecBase3 _smooth_hpr; + LVector3 _forward_axis; double _smooth_timestamp; bool _smooth_position_known; bool _smooth_position_changed; diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.I b/direct/src/distributed/cDistributedSmoothNodeBase.I index 3edc8f4cfb..c09121fa7b 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.I +++ b/direct/src/distributed/cDistributedSmoothNodeBase.I @@ -72,7 +72,7 @@ d_setSmStop() { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmH(float h) { +d_setSmH(PN_stdfloat h) { //cout << "d_setSmH: " << h << endl; DCPacker packer; begin_send_update(packer, "setSmH"); @@ -86,7 +86,7 @@ d_setSmH(float h) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmZ(float z) { +d_setSmZ(PN_stdfloat z) { //cout << "d_setSmZ: " << z << endl; DCPacker packer; begin_send_update(packer, "setSmZ"); @@ -100,7 +100,7 @@ d_setSmZ(float z) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmXY(float x, float y) { +d_setSmXY(PN_stdfloat x, PN_stdfloat y) { //cout << "d_setSmXY: " << x << ", " << y << endl; DCPacker packer; begin_send_update(packer, "setSmXY"); @@ -115,7 +115,7 @@ d_setSmXY(float x, float y) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmXZ(float x, float z) { +d_setSmXZ(PN_stdfloat x, PN_stdfloat z) { //cout << "d_setSmXZ: " << x << ", " << z << endl; DCPacker packer; begin_send_update(packer, "setSmXZ"); @@ -130,7 +130,7 @@ d_setSmXZ(float x, float z) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmPos(float x, float y, float z) { +d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { //cout << "d_setSmXYZ: " << x << ", " << y << ", " << z << endl; DCPacker packer; begin_send_update(packer, "setSmPos"); @@ -146,7 +146,7 @@ d_setSmPos(float x, float y, float z) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmHpr(float h, float p, float r) { +d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { //cout << "d_setSmHPR: " << h << ", " << p << ", " << r << endl; DCPacker packer; begin_send_update(packer, "setSmHpr"); @@ -162,7 +162,7 @@ d_setSmHpr(float h, float p, float r) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmXYH(float x, float y, float h) { +d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h) { //cout << "d_setSmXYH: " << x << ", " << y << ", " << h << endl; DCPacker packer; begin_send_update(packer, "setSmXYH"); @@ -178,7 +178,7 @@ d_setSmXYH(float x, float y, float h) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmXYZH(float x, float y, float z, float h) { +d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h) { //cout << "d_setSmXYZH: " << x << ", " << y << ", " << z << ", " << h << endl; DCPacker packer; begin_send_update(packer, "setSmXYZH"); @@ -195,7 +195,7 @@ d_setSmXYZH(float x, float y, float z, float h) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmPosHpr(float x, float y, float z, float h, float p, float r) { +d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { //cout << "d_setSmPosHpr: " << x << ", " << y << ", " << z << ", " << h << ", " << p << ", " << r << endl; DCPacker packer; begin_send_update(packer, "setSmPosHpr"); @@ -215,7 +215,7 @@ d_setSmPosHpr(float x, float y, float z, float h, float p, float r) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CDistributedSmoothNodeBase:: -d_setSmPosHprL(float x, float y, float z, float h, float p, float r, PN_uint64 l) { +d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l) { //cout << "d_setSmPosHprL: " << x << ", " << y << ", " << z << ", " << h << ", " << p << ", " << r << l << endl; DCPacker packer; begin_send_update(packer, "setSmPosHprL"); diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 1ca73915fc..b4d141da3b 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -19,7 +19,7 @@ #include "dcmsgtypes.h" #include "config_distributed.h" -static const float smooth_node_epsilon = 0.01; +static const PN_stdfloat smooth_node_epsilon = 0.01; static const double network_time_precision = 100.0; // Matches ClockDelta.py CConnectionRepository *CDistributedSmoothNodeBase::_repository = NULL; @@ -93,8 +93,8 @@ send_everything() { //////////////////////////////////////////////////////////////////// void CDistributedSmoothNodeBase:: broadcast_pos_hpr_full() { - LPoint3f xyz = _node_path.get_pos(); - LVecBase3f hpr = _node_path.get_hpr(); + LPoint3 xyz = _node_path.get_pos(); + LVecBase3 hpr = _node_path.get_hpr(); int flags = 0; @@ -200,8 +200,8 @@ broadcast_pos_hpr_full() { //////////////////////////////////////////////////////////////////// void CDistributedSmoothNodeBase:: broadcast_pos_hpr_xyh() { - LPoint3f xyz = _node_path.get_pos(); - LVecBase3f hpr = _node_path.get_hpr(); + LPoint3 xyz = _node_path.get_pos(); + LVecBase3 hpr = _node_path.get_hpr(); int flags = 0; @@ -252,7 +252,7 @@ broadcast_pos_hpr_xyh() { //////////////////////////////////////////////////////////////////// void CDistributedSmoothNodeBase:: broadcast_pos_hpr_xy() { - LPoint3f xyz = _node_path.get_pos(); + LPoint3 xyz = _node_path.get_pos(); int flags = 0; diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.h b/direct/src/distributed/cDistributedSmoothNodeBase.h index 31e6f70563..15b9032ee3 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.h +++ b/direct/src/distributed/cDistributedSmoothNodeBase.h @@ -61,16 +61,16 @@ private: INLINE static bool only_changed(int flags, int compare); INLINE void d_setSmStop(); - INLINE void d_setSmH(float h); - INLINE void d_setSmZ(float z); - INLINE void d_setSmXY(float x, float y); - INLINE void d_setSmXZ(float x, float z); - INLINE void d_setSmPos(float x, float y, float z); - INLINE void d_setSmHpr(float h, float p, float r); - INLINE void d_setSmXYH(float x, float y, float h); - INLINE void d_setSmXYZH(float x, float y, float z, float h); - INLINE void d_setSmPosHpr(float x, float y, float z, float h, float p, float r); - INLINE void d_setSmPosHprL(float x, float y, float z, float h, float p, float r, PN_uint64 l); + INLINE void d_setSmH(PN_stdfloat h); + INLINE void d_setSmZ(PN_stdfloat z); + INLINE void d_setSmXY(PN_stdfloat x, PN_stdfloat y); + INLINE void d_setSmXZ(PN_stdfloat x, PN_stdfloat z); + INLINE void d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE void d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE void d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h); + INLINE void d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h); + INLINE void d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l); void begin_send_update(DCPacker &packer, const string &field_name); void finish_send_update(DCPacker &packer); @@ -95,8 +95,8 @@ private: static PyObject *_clock_delta; #endif - LPoint3f _store_xyz; - LVecBase3f _store_hpr; + LPoint3 _store_xyz; + LVecBase3 _store_hpr; bool _store_stop; // contains most recently sent location info as // index 0, index 1 contains most recently set location info diff --git a/direct/src/interval/cConstrainHprInterval.cxx b/direct/src/interval/cConstrainHprInterval.cxx index 18ea03e38f..0ebd7e0d95 100644 --- a/direct/src/interval/cConstrainHprInterval.cxx +++ b/direct/src/interval/cConstrainHprInterval.cxx @@ -33,7 +33,7 @@ TypeHandle CConstrainHprInterval::_type_handle; CConstrainHprInterval:: CConstrainHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f hprOffset) : + bool wrt, const LVecBase3 hprOffset) : CConstraintInterval(name, duration), _node(node), _target(target), diff --git a/direct/src/interval/cConstrainHprInterval.h b/direct/src/interval/cConstrainHprInterval.h index f6ac9ba80b..c1034b13e3 100644 --- a/direct/src/interval/cConstrainHprInterval.h +++ b/direct/src/interval/cConstrainHprInterval.h @@ -30,7 +30,7 @@ class EXPCL_DIRECT CConstrainHprInterval : public CConstraintInterval { PUBLISHED: CConstrainHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f hprOffset=LVector3f::zero()); + bool wrt, const LVecBase3 hprOffset=LVector3::zero()); INLINE const NodePath &get_node() const; INLINE const NodePath &get_target() const; @@ -42,7 +42,7 @@ private: NodePath _node; NodePath _target; bool _wrt; - LQuaternionf _quatOffset; + LQuaternion _quatOffset; public: static TypeHandle get_class_type() { diff --git a/direct/src/interval/cConstrainPosHprInterval.cxx b/direct/src/interval/cConstrainPosHprInterval.cxx index b157508bee..14eb9714bf 100644 --- a/direct/src/interval/cConstrainPosHprInterval.cxx +++ b/direct/src/interval/cConstrainPosHprInterval.cxx @@ -34,8 +34,8 @@ TypeHandle CConstrainPosHprInterval::_type_handle; CConstrainPosHprInterval:: CConstrainPosHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f posOffset, - const LVecBase3f hprOffset) : + bool wrt, const LVecBase3 posOffset, + const LVecBase3 hprOffset) : CConstraintInterval(name, duration), _node(node), _target(target), diff --git a/direct/src/interval/cConstrainPosHprInterval.h b/direct/src/interval/cConstrainPosHprInterval.h index cb2b5a4412..13fb173103 100644 --- a/direct/src/interval/cConstrainPosHprInterval.h +++ b/direct/src/interval/cConstrainPosHprInterval.h @@ -31,8 +31,8 @@ class EXPCL_DIRECT CConstrainPosHprInterval : public CConstraintInterval { PUBLISHED: CConstrainPosHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f posOffset=LVector3f::zero(), - const LVecBase3f hprOffset=LVector3f::zero()); + bool wrt, const LVecBase3 posOffset=LVector3::zero(), + const LVecBase3 hprOffset=LVector3::zero()); INLINE const NodePath &get_node() const; INLINE const NodePath &get_target() const; @@ -44,8 +44,8 @@ private: NodePath _node; NodePath _target; bool _wrt; - LVecBase3f _posOffset; - LQuaternionf _quatOffset; + LVecBase3 _posOffset; + LQuaternion _quatOffset; public: static TypeHandle get_class_type() { diff --git a/direct/src/interval/cConstrainPosInterval.cxx b/direct/src/interval/cConstrainPosInterval.cxx index 0f7e71f9fe..09f7286b5d 100644 --- a/direct/src/interval/cConstrainPosInterval.cxx +++ b/direct/src/interval/cConstrainPosInterval.cxx @@ -32,7 +32,7 @@ TypeHandle CConstrainPosInterval::_type_handle; CConstrainPosInterval:: CConstrainPosInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f posOffset) : + bool wrt, const LVecBase3 posOffset) : CConstraintInterval(name, duration), _node(node), _target(target), @@ -66,7 +66,7 @@ priv_step(double t) { } _target.set_pos(_node, _posOffset); } else { - if(_posOffset == LVector3f::zero()) { + if(_posOffset == LVector3::zero()) { _target.set_pos(_node.get_pos()); } else { _target.set_pos(_node.get_pos() + _posOffset); diff --git a/direct/src/interval/cConstrainPosInterval.h b/direct/src/interval/cConstrainPosInterval.h index f8c6f4429d..1782cdc177 100644 --- a/direct/src/interval/cConstrainPosInterval.h +++ b/direct/src/interval/cConstrainPosInterval.h @@ -29,7 +29,7 @@ class EXPCL_DIRECT CConstrainPosInterval : public CConstraintInterval { PUBLISHED: CConstrainPosInterval(const string &name, double duration, const NodePath &node, const NodePath &target, - bool wrt, const LVecBase3f posOffset=LVector3f::zero()); + bool wrt, const LVecBase3 posOffset=LVector3::zero()); INLINE const NodePath &get_node() const; INLINE const NodePath &get_target() const; @@ -41,7 +41,7 @@ private: NodePath _node; NodePath _target; bool _wrt; - LVecBase3f _posOffset; + LVecBase3 _posOffset; public: static TypeHandle get_class_type() { diff --git a/direct/src/interval/cLerpNodePathInterval.I b/direct/src/interval/cLerpNodePathInterval.I index 30b327a68a..08e870fcaf 100644 --- a/direct/src/interval/cLerpNodePathInterval.I +++ b/direct/src/interval/cLerpNodePathInterval.I @@ -46,7 +46,7 @@ get_other() const { // position at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_pos(const LVecBase3f &pos) { +set_start_pos(const LVecBase3 &pos) { nassertv(!pos.is_nan()); _start_pos = pos; _flags |= F_start_pos; @@ -62,7 +62,7 @@ set_start_pos(const LVecBase3f &pos) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_pos(const LVecBase3f &pos) { +set_end_pos(const LVecBase3 &pos) { nassertv(!pos.is_nan()); _end_pos = pos; _flags |= F_end_pos; @@ -79,7 +79,7 @@ set_end_pos(const LVecBase3f &pos) { // is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_hpr(const LVecBase3f &hpr) { +set_start_hpr(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); _start_hpr = hpr; _flags = (_flags & ~(F_slerp_setup | F_start_quat)) | F_start_hpr; @@ -97,7 +97,7 @@ set_start_hpr(const LVecBase3f &hpr) { // the node's rotation will not be affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_hpr(const LVecBase3f &hpr) { +set_end_hpr(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); _end_hpr = hpr; _flags = (_flags & ~F_end_quat) | F_end_hpr; @@ -117,7 +117,7 @@ set_end_hpr(const LVecBase3f &hpr) { // performed in HPR space, componentwise. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_hpr(const LQuaternionf &quat) { +set_end_hpr(const LQuaternion &quat) { nassertv(!quat.is_nan()); _end_hpr = quat.get_hpr(); _flags = (_flags & ~F_end_quat) | F_end_hpr; @@ -134,7 +134,7 @@ set_end_hpr(const LQuaternionf &quat) { // is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_quat(const LQuaternionf &quat) { +set_start_quat(const LQuaternion &quat) { nassertv(!quat.is_nan()); _start_quat = quat; _flags = (_flags & ~(F_slerp_setup | F_start_hpr)) | F_start_quat; @@ -158,7 +158,7 @@ set_start_quat(const LQuaternionf &quat) { // quaternion space, as a spherical lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_quat(const LVecBase3f &hpr) { +set_end_quat(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); _end_quat.set_hpr(hpr); _flags = (_flags & ~(F_slerp_setup | F_end_hpr)) | F_end_quat; @@ -176,7 +176,7 @@ set_end_quat(const LVecBase3f &hpr) { // the node's rotation will not be affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_quat(const LQuaternionf &quat) { +set_end_quat(const LQuaternion &quat) { nassertv(!quat.is_nan()); _end_quat = quat; _flags = (_flags & ~(F_slerp_setup | F_end_hpr)) | F_end_quat; @@ -192,7 +192,7 @@ set_end_quat(const LQuaternionf &quat) { // scale at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_scale(const LVecBase3f &scale) { +set_start_scale(const LVecBase3 &scale) { nassertv(!scale.is_nan()); _start_scale = scale; _flags |= F_start_scale; @@ -208,9 +208,9 @@ set_start_scale(const LVecBase3f &scale) { // scale at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_scale(float scale) { +set_start_scale(PN_stdfloat scale) { nassertv(!cnan(scale)); - set_start_scale(LVecBase3f(scale, scale, scale)); + set_start_scale(LVecBase3(scale, scale, scale)); } //////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ set_start_scale(float scale) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_scale(const LVecBase3f &scale) { +set_end_scale(const LVecBase3 &scale) { nassertv(!scale.is_nan()); _end_scale = scale; _flags |= F_end_scale; @@ -239,9 +239,9 @@ set_end_scale(const LVecBase3f &scale) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_scale(float scale) { +set_end_scale(PN_stdfloat scale) { nassertv(!cnan(scale)); - set_end_scale(LVecBase3f(scale, scale, scale)); + set_end_scale(LVecBase3(scale, scale, scale)); } //////////////////////////////////////////////////////////////////// @@ -254,7 +254,7 @@ set_end_scale(float scale) { // shear at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_shear(const LVecBase3f &shear) { +set_start_shear(const LVecBase3 &shear) { nassertv(!shear.is_nan()); _start_shear = shear; _flags |= F_start_shear; @@ -270,7 +270,7 @@ set_start_shear(const LVecBase3f &shear) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_shear(const LVecBase3f &shear) { +set_end_shear(const LVecBase3 &shear) { nassertv(!shear.is_nan()); _end_shear = shear; _flags |= F_end_shear; @@ -286,7 +286,7 @@ set_end_shear(const LVecBase3f &shear) { // color at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_color(const LVecBase4f &color) { +set_start_color(const LVecBase4 &color) { nassertv(!color.is_nan()); _start_color = color; _flags |= F_start_color; @@ -302,7 +302,7 @@ set_start_color(const LVecBase4f &color) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_color(const LVecBase4f &color) { +set_end_color(const LVecBase4 &color) { nassertv(!color.is_nan()); _end_color = color; _flags |= F_end_color; @@ -318,7 +318,7 @@ set_end_color(const LVecBase4f &color) { // color scale at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_color_scale(const LVecBase4f &color_scale) { +set_start_color_scale(const LVecBase4 &color_scale) { nassertv(!color_scale.is_nan()); _start_color_scale = color_scale; _flags |= F_start_color_scale; @@ -334,7 +334,7 @@ set_start_color_scale(const LVecBase4f &color_scale) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_color_scale(const LVecBase4f &color_scale) { +set_end_color_scale(const LVecBase4 &color_scale) { nassertv(!color_scale.is_nan()); _end_color_scale = color_scale; _flags |= F_end_color_scale; @@ -362,7 +362,7 @@ set_texture_stage(TextureStage *stage) { // UV offset at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_tex_offset(const LVecBase2f &tex_offset) { +set_start_tex_offset(const LVecBase2 &tex_offset) { nassertv(!tex_offset.is_nan()); _start_tex_offset = tex_offset; _flags |= F_start_tex_offset; @@ -378,7 +378,7 @@ set_start_tex_offset(const LVecBase2f &tex_offset) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_tex_offset(const LVecBase2f &tex_offset) { +set_end_tex_offset(const LVecBase2 &tex_offset) { nassertv(!tex_offset.is_nan()); _end_tex_offset = tex_offset; _flags |= F_end_tex_offset; @@ -394,7 +394,7 @@ set_end_tex_offset(const LVecBase2f &tex_offset) { // UV rotate at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_tex_rotate(float tex_rotate) { +set_start_tex_rotate(PN_stdfloat tex_rotate) { nassertv(!cnan(tex_rotate)); _start_tex_rotate = tex_rotate; _flags |= F_start_tex_rotate; @@ -410,7 +410,7 @@ set_start_tex_rotate(float tex_rotate) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_tex_rotate(float tex_rotate) { +set_end_tex_rotate(PN_stdfloat tex_rotate) { nassertv(!cnan(tex_rotate)); _end_tex_rotate = tex_rotate; _flags |= F_end_tex_rotate; @@ -426,7 +426,7 @@ set_end_tex_rotate(float tex_rotate) { // UV scale at the time the lerp is performed. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_start_tex_scale(const LVecBase2f &tex_scale) { +set_start_tex_scale(const LVecBase2 &tex_scale) { nassertv(!tex_scale.is_nan()); _start_tex_scale = tex_scale; _flags |= F_start_tex_scale; @@ -442,7 +442,7 @@ set_start_tex_scale(const LVecBase2f &tex_scale) { // affected by the lerp. //////////////////////////////////////////////////////////////////// INLINE void CLerpNodePathInterval:: -set_end_tex_scale(const LVecBase2f &tex_scale) { +set_end_tex_scale(const LVecBase2 &tex_scale) { nassertv(!tex_scale.is_nan()); _end_tex_scale = tex_scale; _flags |= F_end_tex_scale; diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index de70486cba..4eb3dbdcda 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -141,11 +141,11 @@ priv_step(double t) { transform = _node.get_transform(_other); } - LPoint3f pos; - LVecBase3f hpr; - LQuaternionf quat; - LVecBase3f scale; - LVecBase3f shear; + LPoint3 pos; + LVecBase3 hpr; + LQuaternion quat; + LVecBase3 scale; + LVecBase3 shear; if ((_flags & F_end_pos) != 0) { if ((_flags & F_start_pos) != 0) { @@ -198,7 +198,7 @@ priv_step(double t) { if (_prev_d == 1.0) { _start_quat = _end_quat; } else { - LQuaternionf prev_value = transform->get_quat(); + LQuaternion prev_value = transform->get_quat(); _start_quat = (prev_value - _prev_d * _end_quat) / (1.0 - _prev_d); } setup_slerp(); @@ -412,7 +412,7 @@ priv_step(double t) { // attributes don't interrelate. if ((_flags & F_end_color) != 0) { - Colorf color; + LColor color; if ((_flags & F_start_color) != 0) { lerp_value(color, d, _start_color, _end_color); @@ -436,7 +436,7 @@ priv_step(double t) { } if ((_flags & F_end_color_scale) != 0) { - LVecBase4f color_scale; + LVecBase4 color_scale; if ((_flags & F_start_color_scale) != 0) { lerp_value(color_scale, d, _start_color_scale, _end_color_scale); @@ -472,7 +472,7 @@ priv_step(double t) { } if ((_flags & F_end_tex_offset) != 0) { - LVecBase2f tex_offset; + LVecBase2 tex_offset; if ((_flags & F_start_tex_offset) != 0) { lerp_value(tex_offset, d, _start_tex_offset, _end_tex_offset); @@ -486,7 +486,7 @@ priv_step(double t) { } if ((_flags & F_end_tex_rotate) != 0) { - float tex_rotate; + PN_stdfloat tex_rotate; if ((_flags & F_start_tex_rotate) != 0) { lerp_value(tex_rotate, d, _start_tex_rotate, _end_tex_rotate); @@ -500,7 +500,7 @@ priv_step(double t) { } if ((_flags & F_end_tex_scale) != 0) { - LVecBase2f tex_scale; + LVecBase2 tex_scale; if ((_flags & F_start_tex_scale) != 0) { lerp_value(tex_scale, d, _start_tex_scale, _end_tex_scale); @@ -691,11 +691,11 @@ setup_slerp() { // quaternions is not near one extreme or the other. //////////////////////////////////////////////////////////////////// void CLerpNodePathInterval:: -slerp_basic(LQuaternionf &result, float t) const { +slerp_basic(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); - float ti = 1.0f - t; - float ta = t * _slerp_angle; - float tia = ti * _slerp_angle; + PN_stdfloat ti = 1.0f - t; + PN_stdfloat ta = t * _slerp_angle; + PN_stdfloat tia = ti * _slerp_angle; if (interval_cat.is_spam()) { interval_cat.spam() @@ -716,11 +716,11 @@ slerp_basic(LQuaternionf &result, float t) const { // quaternions approaches zero. //////////////////////////////////////////////////////////////////// void CLerpNodePathInterval:: -slerp_angle_0(LQuaternionf &result, float t) const { +slerp_angle_0(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); - float ti = 1.0f - t; - float ta = t * _slerp_angle; - float tia = ti * _slerp_angle; + PN_stdfloat ti = 1.0f - t; + PN_stdfloat ta = t * _slerp_angle; + PN_stdfloat tia = ti * _slerp_angle; if (interval_cat.is_spam()) { interval_cat.spam() @@ -742,16 +742,16 @@ slerp_angle_0(LQuaternionf &result, float t) const { // the quaternions approaches 180 degrees. //////////////////////////////////////////////////////////////////// void CLerpNodePathInterval:: -slerp_angle_180(LQuaternionf &result, float t) const { +slerp_angle_180(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); if (t < 0.5) { // The first half of the lerp: _start_quat to _slerp_c. t *= 2.0f; - float ti = 1.0f - t; - float ta = t * _slerp_angle; - float tia = ti * _slerp_angle; + PN_stdfloat ti = 1.0f - t; + PN_stdfloat ta = t * _slerp_angle; + PN_stdfloat tia = ti * _slerp_angle; if (interval_cat.is_spam()) { interval_cat.spam() @@ -767,9 +767,9 @@ slerp_angle_180(LQuaternionf &result, float t) const { // The second half of the lerp: _slerp_c to _end_quat. t = t * 2.0f - 1.0f; - float ti = 1.0f - t; - float ta = t * _slerp_angle; - float tia = ti * _slerp_angle; + PN_stdfloat ti = 1.0f - t; + PN_stdfloat ta = t * _slerp_angle; + PN_stdfloat tia = ti * _slerp_angle; if (interval_cat.is_spam()) { interval_cat.spam() diff --git a/direct/src/interval/cLerpNodePathInterval.h b/direct/src/interval/cLerpNodePathInterval.h index 416329836b..eeef2cf12b 100644 --- a/direct/src/interval/cLerpNodePathInterval.h +++ b/direct/src/interval/cLerpNodePathInterval.h @@ -35,31 +35,31 @@ PUBLISHED: INLINE const NodePath &get_node() const; INLINE const NodePath &get_other() const; - INLINE void set_start_pos(const LVecBase3f &pos); - INLINE void set_end_pos(const LVecBase3f &pos); - INLINE void set_start_hpr(const LVecBase3f &hpr); - INLINE void set_end_hpr(const LVecBase3f &hpr); - INLINE void set_end_hpr(const LQuaternionf &quat); - INLINE void set_start_quat(const LQuaternionf &quat); - INLINE void set_end_quat(const LVecBase3f &hpr); - INLINE void set_end_quat(const LQuaternionf &quat); - INLINE void set_start_scale(const LVecBase3f &scale); - INLINE void set_start_scale(float scale); - INLINE void set_end_scale(const LVecBase3f &scale); - INLINE void set_end_scale(float scale); - INLINE void set_start_shear(const LVecBase3f &shear); - INLINE void set_end_shear(const LVecBase3f &shear); - INLINE void set_start_color(const LVecBase4f &color); - INLINE void set_end_color(const LVecBase4f &color); - INLINE void set_start_color_scale(const LVecBase4f &color_scale); - INLINE void set_end_color_scale(const LVecBase4f &color_scale); + INLINE void set_start_pos(const LVecBase3 &pos); + INLINE void set_end_pos(const LVecBase3 &pos); + INLINE void set_start_hpr(const LVecBase3 &hpr); + INLINE void set_end_hpr(const LVecBase3 &hpr); + INLINE void set_end_hpr(const LQuaternion &quat); + INLINE void set_start_quat(const LQuaternion &quat); + INLINE void set_end_quat(const LVecBase3 &hpr); + INLINE void set_end_quat(const LQuaternion &quat); + INLINE void set_start_scale(const LVecBase3 &scale); + INLINE void set_start_scale(PN_stdfloat scale); + INLINE void set_end_scale(const LVecBase3 &scale); + INLINE void set_end_scale(PN_stdfloat scale); + INLINE void set_start_shear(const LVecBase3 &shear); + INLINE void set_end_shear(const LVecBase3 &shear); + INLINE void set_start_color(const LVecBase4 &color); + INLINE void set_end_color(const LVecBase4 &color); + INLINE void set_start_color_scale(const LVecBase4 &color_scale); + INLINE void set_end_color_scale(const LVecBase4 &color_scale); INLINE void set_texture_stage(TextureStage *stage); - INLINE void set_start_tex_offset(const LVecBase2f &tex_offset); - INLINE void set_end_tex_offset(const LVecBase2f &tex_offset); - INLINE void set_start_tex_rotate(float tex_rotate); - INLINE void set_end_tex_rotate(float tex_rotate); - INLINE void set_start_tex_scale(const LVecBase2f &tex_scale); - INLINE void set_end_tex_scale(const LVecBase2f &tex_scale); + INLINE void set_start_tex_offset(const LVecBase2 &tex_offset); + INLINE void set_end_tex_offset(const LVecBase2 &tex_offset); + INLINE void set_start_tex_rotate(PN_stdfloat tex_rotate); + INLINE void set_end_tex_rotate(PN_stdfloat tex_rotate); + INLINE void set_start_tex_scale(const LVecBase2 &tex_scale); + INLINE void set_end_tex_scale(const LVecBase2 &tex_scale); INLINE void set_override(int override); INLINE int get_override() const; @@ -108,30 +108,30 @@ private: }; unsigned int _flags; - LPoint3f _start_pos, _end_pos; - LVecBase3f _start_hpr, _end_hpr; - LQuaternionf _start_quat, _end_quat; - LVecBase3f _start_scale, _end_scale; - LVecBase3f _start_shear, _end_shear; - Colorf _start_color, _end_color; - LVecBase4f _start_color_scale, _end_color_scale; + LPoint3 _start_pos, _end_pos; + LVecBase3 _start_hpr, _end_hpr; + LQuaternion _start_quat, _end_quat; + LVecBase3 _start_scale, _end_scale; + LVecBase3 _start_shear, _end_shear; + LColor _start_color, _end_color; + LVecBase4 _start_color_scale, _end_color_scale; PT(TextureStage) _texture_stage; - LVecBase2f _start_tex_offset, _end_tex_offset; - float _start_tex_rotate, _end_tex_rotate; - LVecBase2f _start_tex_scale, _end_tex_scale; + LVecBase2 _start_tex_offset, _end_tex_offset; + PN_stdfloat _start_tex_rotate, _end_tex_rotate; + LVecBase2 _start_tex_scale, _end_tex_scale; int _override; double _prev_d; - float _slerp_angle; - float _slerp_denom; - LQuaternionf _slerp_c; + PN_stdfloat _slerp_angle; + PN_stdfloat _slerp_denom; + LQuaternion _slerp_c; - void slerp_basic(LQuaternionf &result, float t) const; - void slerp_angle_0(LQuaternionf &result, float t) const; - void slerp_angle_180(LQuaternionf &result, float t) const; + void slerp_basic(LQuaternion &result, PN_stdfloat t) const; + void slerp_angle_0(LQuaternion &result, PN_stdfloat t) const; + void slerp_angle_180(LQuaternion &result, PN_stdfloat t) const; // Define a pointer to one of the above three methods. - void (CLerpNodePathInterval::*_slerp)(LQuaternionf &result, float t) const; + void (CLerpNodePathInterval::*_slerp)(LQuaternion &result, PN_stdfloat t) const; public: static TypeHandle get_class_type() { diff --git a/direct/src/motiontrail/cMotionTrail.cxx b/direct/src/motiontrail/cMotionTrail.cxx index 63c5ba6e3b..4c17726cd6 100644 --- a/direct/src/motiontrail/cMotionTrail.cxx +++ b/direct/src/motiontrail/cMotionTrail.cxx @@ -124,7 +124,7 @@ set_geom_node (PT(GeomNode) geom_node) { // Description: Add a vertex. //////////////////////////////////////////////////////////////////// void CMotionTrail:: -add_vertex (LVector4f *vertex, LVector4f *start_color, LVector4f *end_color, float v) { +add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v) { CMotionTrailVertex motion_trail_vertex; @@ -164,7 +164,7 @@ add_vertex (LVector4f *vertex, LVector4f *start_color, LVector4f *end_color, flo // Applicable only if nurbs is on. //////////////////////////////////////////////////////////////////// void CMotionTrail:: -set_parameters (float sampling_time, float time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, float resolution_distance) { +set_parameters (PN_stdfloat sampling_time, PN_stdfloat time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, PN_stdfloat resolution_distance) { _sampling_time = sampling_time; _time_window = time_window; @@ -180,7 +180,7 @@ set_parameters (float sampling_time, float time_window, bool use_texture, bool c // Description: Check if a sample can be submitted. //////////////////////////////////////////////////////////////////// int CMotionTrail:: -check_for_update (float current_time) { +check_for_update (PN_stdfloat current_time) { int state; @@ -196,7 +196,7 @@ check_for_update (float current_time) { return state; } -float one_minus_x (float x) { +PN_stdfloat one_minus_x (PN_stdfloat x) { x = 1.0 - x; if (x < 0.0) { x = 0.0; @@ -243,26 +243,26 @@ begin_geometry ( ) { //////////////////////////////////////////////////////////////////// // Function: CMotionTrail::add_geometry_quad // Access: Public -// Description: LVector3f vertex version. +// Description: LVector3 vertex version. //////////////////////////////////////////////////////////////////// void CMotionTrail:: -add_geometry_quad (LVector3f &v0, LVector3f &v1, LVector3f &v2, LVector3f &v3, LVector4f &c0, LVector4f &c1, LVector4f &c2, LVector4f &c3, LVector2f &t0, LVector2f &t1, LVector2f &t2, LVector2f &t3) { +add_geometry_quad (LVector3 &v0, LVector3 &v1, LVector3 &v2, LVector3 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3) { - _vertex_writer.add_data3f (v0); - _vertex_writer.add_data3f (v1); - _vertex_writer.add_data3f (v2); - _vertex_writer.add_data3f (v3); + _vertex_writer.add_data3 (v0); + _vertex_writer.add_data3 (v1); + _vertex_writer.add_data3 (v2); + _vertex_writer.add_data3 (v3); - _color_writer.add_data4f (c0); - _color_writer.add_data4f (c1); - _color_writer.add_data4f (c2); - _color_writer.add_data4f (c3); + _color_writer.add_data4 (c0); + _color_writer.add_data4 (c1); + _color_writer.add_data4 (c2); + _color_writer.add_data4 (c3); if (_use_texture) { - _texture_writer.add_data2f (t0); - _texture_writer.add_data2f (t1); - _texture_writer.add_data2f (t2); - _texture_writer.add_data2f (t3); + _texture_writer.add_data2 (t0); + _texture_writer.add_data2 (t1); + _texture_writer.add_data2 (t2); + _texture_writer.add_data2 (t3); } int vertex_index; @@ -284,26 +284,26 @@ add_geometry_quad (LVector3f &v0, LVector3f &v1, LVector3f &v2, LVector3f &v3, L //////////////////////////////////////////////////////////////////// // Function: CMotionTrail::add_geometry_quad // Access: Public -// Description: LVector4f vertex version. +// Description: LVector4 vertex version. //////////////////////////////////////////////////////////////////// void CMotionTrail:: -add_geometry_quad (LVector4f &v0, LVector4f &v1, LVector4f &v2, LVector4f &v3, LVector4f &c0, LVector4f &c1, LVector4f &c2, LVector4f &c3, LVector2f &t0, LVector2f &t1, LVector2f &t2, LVector2f &t3) { +add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3) { - _vertex_writer.add_data3f (v0 [0], v0 [1], v0 [2]); - _vertex_writer.add_data3f (v1 [0], v1 [1], v1 [2]); - _vertex_writer.add_data3f (v2 [0], v2 [1], v2 [2]); - _vertex_writer.add_data3f (v3 [0], v3 [1], v3 [2]); + _vertex_writer.add_data3 (v0 [0], v0 [1], v0 [2]); + _vertex_writer.add_data3 (v1 [0], v1 [1], v1 [2]); + _vertex_writer.add_data3 (v2 [0], v2 [1], v2 [2]); + _vertex_writer.add_data3 (v3 [0], v3 [1], v3 [2]); - _color_writer.add_data4f (c0); - _color_writer.add_data4f (c1); - _color_writer.add_data4f (c2); - _color_writer.add_data4f (c3); + _color_writer.add_data4 (c0); + _color_writer.add_data4 (c1); + _color_writer.add_data4 (c2); + _color_writer.add_data4 (c3); if (_use_texture) { - _texture_writer.add_data2f (t0); - _texture_writer.add_data2f (t1); - _texture_writer.add_data2f (t2); - _texture_writer.add_data2f (t3); + _texture_writer.add_data2 (t0); + _texture_writer.add_data2 (t1); + _texture_writer.add_data2 (t2); + _texture_writer.add_data2 (t3); } int vertex_index; @@ -350,7 +350,7 @@ void CMotionTrail::end_geometry ( ) { // Description: See class header comments. //////////////////////////////////////////////////////////////////// void CMotionTrail:: -update_motion_trail (float current_time, LMatrix4f *transform) { +update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { int debug; int total_frames; @@ -371,15 +371,15 @@ update_motion_trail (float current_time, LMatrix4f *transform) { } int total_vertices; - float color_scale; - LMatrix4f start_transform; - LMatrix4f end_transform; - LMatrix4f inverse_matrix; + PN_stdfloat color_scale; + LMatrix4 start_transform; + LMatrix4 end_transform; + LMatrix4 inverse_matrix; total_vertices = _vertex_list.size ( ); color_scale = _color_scale; if (_fade) { - float elapsed_time; + PN_stdfloat elapsed_time; elapsed_time = current_time - _fade_start_time; if (elapsed_time < 0.0) { @@ -397,7 +397,7 @@ update_motion_trail (float current_time, LMatrix4f *transform) { _last_update_time = current_time; // remove expired frames - float minimum_time; + PN_stdfloat minimum_time; minimum_time = current_time - _time_window; @@ -431,8 +431,8 @@ update_motion_trail (float current_time, LMatrix4f *transform) { if ((total_frames >= 2) && (total_vertices >= 2)) { int total_segments; - float minimum_time; - float delta_time; + PN_stdfloat minimum_time; + PN_stdfloat delta_time; CMotionTrailFrame last_motion_trail_frame; list ::iterator vertex_iterator; @@ -463,13 +463,13 @@ update_motion_trail (float current_time, LMatrix4f *transform) { // nurbs version int total_vertex_segments; - float total_distance; - LVector3f vector; - LVector4f v; - LVector4f v0; - LVector4f v1; - LVector4f v2; - LVector4f v3; + PN_stdfloat total_distance; + LVector3 vector; + LVector4 v; + LVector4 v0; + LVector4 v1; + LVector4 v2; + LVector4 v3; total_vertex_segments = total_vertices - 1; total_distance = 0.0f; @@ -536,7 +536,7 @@ update_motion_trail (float current_time, LMatrix4f *transform) { nurbs_curve_evaluator -> set_vertex (segment_index, v1); if (vertex_segement_index == (total_vertex_segments - 1)) { - float distance; + PN_stdfloat distance; v = v1 - v3; vector.set (v[0], v[1], v[2]); @@ -567,8 +567,8 @@ update_motion_trail (float current_time, LMatrix4f *transform) { nurbs_curve_result_array [index] = nurbs_curve_result; if (debug) { - float nurbs_start_t; - float nurbs_end_t; + PN_stdfloat nurbs_start_t; + PN_stdfloat nurbs_end_t; nurbs_start_t = nurbs_curve_result -> get_start_t(); nurbs_end_t = nurbs_curve_result -> get_end_t(); @@ -578,7 +578,7 @@ update_motion_trail (float current_time, LMatrix4f *transform) { } // create quads from NurbsCurveResult - float total_curve_segments; + PN_stdfloat total_curve_segments; total_curve_segments = (total_distance / _resolution_distance); if (total_curve_segments < total_segments) { @@ -586,35 +586,35 @@ update_motion_trail (float current_time, LMatrix4f *transform) { } { - LVector3f v0; - LVector3f v1; - LVector3f v2; - LVector3f v3; + LVector3 v0; + LVector3 v1; + LVector3 v2; + LVector3 v3; - LVector4f c0; - LVector4f c1; - LVector4f c2; - LVector4f c3; + LVector4 c0; + LVector4 c1; + LVector4 c2; + LVector4 c3; - LVector2f t0; - LVector2f t1; - LVector2f t2; - LVector2f t3; + LVector2 t0; + LVector2 t1; + LVector2 t2; + LVector2 t3; - LVector4f vertex_start_color; - LVector4f vertex_end_color; + LVector4 vertex_start_color; + LVector4 vertex_end_color; - float curve_segment_index; + PN_stdfloat curve_segment_index; curve_segment_index = 0.0; while (curve_segment_index < total_curve_segments) { - float st; - float et; - float start_t; - float end_t; - float color_start_t; - float color_end_t; + PN_stdfloat st; + PN_stdfloat et; + PN_stdfloat start_t; + PN_stdfloat end_t; + PN_stdfloat color_start_t; + PN_stdfloat color_end_t; int vertex_segement_index; @@ -651,10 +651,10 @@ update_motion_trail (float current_time, LMatrix4f *transform) { while (vertex_segement_index < total_vertex_segments) { - float start_nurbs_start_t; - float start_nurbs_end_t; - float end_nurbs_start_t; - float end_nurbs_end_t; + PN_stdfloat start_nurbs_start_t; + PN_stdfloat start_nurbs_end_t; + PN_stdfloat end_nurbs_start_t; + PN_stdfloat end_nurbs_end_t; motion_trail_vertex_start = &_vertex_array [vertex_segement_index]; motion_trail_vertex_end = &_vertex_array [vertex_segement_index + 1]; @@ -667,8 +667,8 @@ update_motion_trail (float current_time, LMatrix4f *transform) { end_nurbs_start_t = end_nurbs_curve_result -> get_start_t(); end_nurbs_end_t = end_nurbs_curve_result -> get_end_t(); - float start_delta_t; - float end_delta_t; + PN_stdfloat start_delta_t; + PN_stdfloat end_delta_t; start_delta_t = (start_nurbs_end_t - start_nurbs_start_t); end_delta_t = (end_nurbs_end_t - end_nurbs_start_t); @@ -718,30 +718,30 @@ update_motion_trail (float current_time, LMatrix4f *transform) { int vertex_segment_index; int total_vertex_segments; - float st; - float et; - float start_t; - float end_t; - float color_start_t; - float color_end_t; + PN_stdfloat st; + PN_stdfloat et; + PN_stdfloat start_t; + PN_stdfloat end_t; + PN_stdfloat color_start_t; + PN_stdfloat color_end_t; - LVector4f v0; - LVector4f v1; - LVector4f v2; - LVector4f v3; + LVector4 v0; + LVector4 v1; + LVector4 v2; + LVector4 v3; - LVector4f c0; - LVector4f c1; - LVector4f c2; - LVector4f c3; + LVector4 c0; + LVector4 c1; + LVector4 c2; + LVector4 c3; - LVector2f t0; - LVector2f t1; - LVector2f t2; - LVector2f t3; + LVector2 t0; + LVector2 t1; + LVector2 t2; + LVector2 t3; - LVector4f vertex_start_color; - LVector4f vertex_end_color; + LVector4 vertex_start_color; + LVector4 vertex_end_color; CMotionTrailFrame motion_trail_frame_start; CMotionTrailFrame motion_trail_frame_end; diff --git a/direct/src/motiontrail/cMotionTrail.h b/direct/src/motiontrail/cMotionTrail.h index 6b11231b00..4e91e26066 100644 --- a/direct/src/motiontrail/cMotionTrail.h +++ b/direct/src/motiontrail/cMotionTrail.h @@ -29,10 +29,10 @@ class CMotionTrailVertex { public: - LVector4f _vertex; - LVector4f _start_color; - LVector4f _end_color; - float _v; + LVector4 _vertex; + LVector4 _start_color; + LVector4 _end_color; + PN_stdfloat _v; PT(NurbsCurveEvaluator) _nurbs_curve_evaluator; }; @@ -40,8 +40,8 @@ public: class CMotionTrailFrame { public: - float _time; - LMatrix4f _transform; + PN_stdfloat _time; + LMatrix4 _transform; }; //////////////////////////////////////////////////////////////////// @@ -98,48 +98,48 @@ PUBLISHED: void enable (bool enable); void set_geom_node (PT(GeomNode) geom_node); - void add_vertex (LVector4f *vertex, LVector4f *start_color, LVector4f *end_color, float v); + void add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v); - void set_parameters (float sampling_time, float time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, float resolution_distance); + void set_parameters (PN_stdfloat sampling_time, PN_stdfloat time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, PN_stdfloat resolution_distance); - int check_for_update (float current_time); - void update_motion_trail (float current_time, LMatrix4f *transform); + int check_for_update (PN_stdfloat current_time); + void update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform); public: void begin_geometry ( ); - void add_geometry_quad (LVector3f &v0, LVector3f &v1, LVector3f &v2, LVector3f &v3, LVector4f &c0, LVector4f &c1, LVector4f &c2, LVector4f &c3, LVector2f &t0, LVector2f &t1, LVector2f &t2, LVector2f &t3); - void add_geometry_quad (LVector4f &v0, LVector4f &v1, LVector4f &v2, LVector4f &v3, LVector4f &c0, LVector4f &c1, LVector4f &c2, LVector4f &c3, LVector2f &t0, LVector2f &t1, LVector2f &t2, LVector2f &t3); + void add_geometry_quad (LVector3 &v0, LVector3 &v1, LVector3 &v2, LVector3 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3); + void add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3); void end_geometry ( ); int _active; int _enable; int _pause; - float _pause_time; + PN_stdfloat _pause_time; int _fade; int _fade_end; - float _fade_time; - float _fade_start_time; - float _fade_color_scale; + PN_stdfloat _fade_time; + PN_stdfloat _fade_start_time; + PN_stdfloat _fade_color_scale; - float _last_update_time; + PN_stdfloat _last_update_time; list _vertex_list; list _frame_list; // parameters - float _color_scale; - float _sampling_time; - float _time_window; + PN_stdfloat _color_scale; + PN_stdfloat _sampling_time; + PN_stdfloat _time_window; bool _square_t; bool _use_texture; int _calculate_relative_matrix; // nurbs parameters bool _use_nurbs; - float _resolution_distance; + PN_stdfloat _resolution_distance; // geom PT(GeomNode) _geom_node; diff --git a/dtool/Config.pp b/dtool/Config.pp index 1fafdb12b2..cf5065600e 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -994,6 +994,14 @@ // compiled-in font). #define COMPILE_IN_DEFAULT_FONT 1 +// Define this true to compile a special version of Panda to use a +// "double" floating-precision type for most internal values, such as +// positions and transforms, instead of the standard single-precision +// "float" type. This does not affect the default numeric type of +// vertices, which is controlled by the runtime config variable +// vertices-float64. Presently *experimental*, do not use. +#define STDFLOAT_DOUBLE + // We use wxWidgets--the C++ library, not the Python library--for // building the application p3dcert, which is needed only when // building the plugin/runtime system. This uses a wx-config program, diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index b55285f5ca..5d2895d511 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -286,6 +286,9 @@ $[cdefine HAVE_SPEEDTREE] /* Define if we want to compile in a default font. */ $[cdefine COMPILE_IN_DEFAULT_FONT] +/* Define to use doubles for graphic values, intead of single-precision floats. */ +$[cdefine STDFLOAT_DOUBLE] + /* Define if we have Maya available. */ $[cdefine HAVE_MAYA] $[cdefine MAYA_PRE_5_0] diff --git a/dtool/src/dtoolbase/numeric_types.h b/dtool/src/dtoolbase/numeric_types.h index 800e187700..daf2bdbc7b 100644 --- a/dtool/src/dtoolbase/numeric_types.h +++ b/dtool/src/dtoolbase/numeric_types.h @@ -49,5 +49,13 @@ typedef unsigned long long int PN_uint64; typedef double PN_float64; typedef float PN_float32; +#ifndef STDFLOAT_DOUBLE +// The default setting--single-precision floats. +typedef float PN_stdfloat; +#else // STDFLOAT_DOUBLE +// The specialty setting--double-precision floats. +typedef double PN_stdfloat; +#endif // STDFLOAT_DOUBLE + #endif diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index efe0d73b29..e6fa8ebb48 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2033,7 +2033,6 @@ CopyAllHeaders('panda/src/lerp') CopyAllHeaders('panda/src/pgraphnodes') CopyAllHeaders('panda/src/pgraph') CopyAllHeaders('panda/src/cull') -CopyAllHeaders('panda/src/effects') CopyAllHeaders('panda/src/chan') CopyAllHeaders('panda/src/char') CopyAllHeaders('panda/src/dgraph') @@ -3062,18 +3061,6 @@ if (not RUNTIME): TargetAdd('libdistort.in', opts=['IMOD:pandafx', 'ILIB:libdistort', 'SRCDIR:panda/src/distort']) TargetAdd('libdistort_igate.obj', input='libdistort.in', opts=["DEPENDENCYONLY"]) -# -# DIRECTORY: panda/src/effects/ -# - -if (not RUNTIME): - OPTS=['DIR:panda/src/effects', 'BUILDING:PANDAFX', 'NVIDIACG'] - TargetAdd('effects_composite.obj', opts=OPTS, input='effects_composite.cxx') - IGATEFILES=GetDirectoryContents('panda/src/effects', ["*.h", "*_composite.cxx"]) - TargetAdd('libeffects.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libeffects.in', opts=['IMOD:pandafx', 'ILIB:libeffects', 'SRCDIR:panda/src/effects']) - TargetAdd('libeffects_igate.obj', input='libeffects.in', opts=["DEPENDENCYONLY"]) - # # DIRECTORY: panda/metalibs/pandafx/ # @@ -3083,7 +3070,6 @@ if (not RUNTIME): TargetAdd('pandafx_pandafx.obj', opts=OPTS, input='pandafx.cxx') TargetAdd('libpandafx_module.obj', input='libdistort.in') - TargetAdd('libpandafx_module.obj', input='libeffects.in') TargetAdd('libpandafx_module.obj', opts=OPTS) TargetAdd('libpandafx_module.obj', opts=['IMOD:pandafx', 'ILIB:libpandafx']) @@ -3091,8 +3077,6 @@ if (not RUNTIME): TargetAdd('libpandafx.dll', input='libpandafx_module.obj') TargetAdd('libpandafx.dll', input='distort_composite.obj') TargetAdd('libpandafx.dll', input='libdistort_igate.obj') - TargetAdd('libpandafx.dll', input='effects_composite.obj') - TargetAdd('libpandafx.dll', input='libeffects_igate.obj') TargetAdd('libpandafx.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandafx.dll', opts=['ADVAPI', 'NVIDIACG']) diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index 27fbefcffa..4d93407710 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -217,7 +217,7 @@ update() { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -void AudioManager::audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { +void AudioManager::audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { // intentionally blank. } @@ -226,7 +226,7 @@ void AudioManager::audio_3d_set_listener_attributes(float px, float py, float pz // Access: Public // Description: //////////////////////////////////////////////////////////////////// -void AudioManager::audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { +void AudioManager::audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { // intentionally blank. } @@ -235,7 +235,7 @@ void AudioManager::audio_3d_get_listener_attributes(float *px, float *py, float // Access: Public // Description: //////////////////////////////////////////////////////////////////// -void AudioManager::audio_3d_set_distance_factor(float factor) { +void AudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) { // intentionally blank. } @@ -244,7 +244,7 @@ void AudioManager::audio_3d_set_distance_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float AudioManager::audio_3d_get_distance_factor() const { +PN_stdfloat AudioManager::audio_3d_get_distance_factor() const { // intentionally blank. return 0.0f; } @@ -254,7 +254,7 @@ float AudioManager::audio_3d_get_distance_factor() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -void AudioManager::audio_3d_set_doppler_factor(float factor) { +void AudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) { // intentionally blank. } @@ -263,7 +263,7 @@ void AudioManager::audio_3d_set_doppler_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float AudioManager::audio_3d_get_doppler_factor() const { +PN_stdfloat AudioManager::audio_3d_get_doppler_factor() const { // intentionally blank. return 0.0f; } @@ -273,7 +273,7 @@ float AudioManager::audio_3d_get_doppler_factor() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -void AudioManager::audio_3d_set_drop_off_factor(float factor) { +void AudioManager::audio_3d_set_drop_off_factor(PN_stdfloat factor) { // intentionally blank. } @@ -282,7 +282,7 @@ void AudioManager::audio_3d_set_drop_off_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float AudioManager::audio_3d_get_drop_off_factor() const { +PN_stdfloat AudioManager::audio_3d_get_drop_off_factor() const { // intentionally blank. return 0.0f; } @@ -356,6 +356,6 @@ write(ostream &out) const { // Description: For use only with Miles. //////////////////////////////////////////////////////////////////// void AudioManager:: -set_speaker_configuration(LVecBase3f *speaker1, LVecBase3f *speaker2, LVecBase3f *speaker3, LVecBase3f *speaker4, LVecBase3f *speaker5, LVecBase3f *speaker6, LVecBase3f *speaker7, LVecBase3f *speaker8, LVecBase3f *speaker9) { +set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *speaker3, LVecBase3 *speaker4, LVecBase3 *speaker5, LVecBase3 *speaker6, LVecBase3 *speaker7, LVecBase3 *speaker8, LVecBase3 *speaker9) { // intentionally blank } diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 1e0f54c05d..fec7689fa2 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -111,8 +111,8 @@ PUBLISHED: // up later, you'll hear the sound playing at that late point. // 0 = minimum; 1.0 = maximum. // inits to 1.0. - virtual void set_volume(float volume) = 0; - virtual float get_volume() const = 0; + virtual void set_volume(PN_stdfloat volume) = 0; + virtual PN_stdfloat get_volume() const = 0; // Turn the manager on or off. // If you play a sound while the manager is inactive, it won't start. @@ -157,34 +157,34 @@ PUBLISHED: // vx, vy, vz are a velocity vector in UNITS PER SECOND (default: meters). // fx, fy and fz are the respective components of a unit forward-vector // ux, uy and uz are the respective components of a unit up-vector - virtual void audio_3d_set_listener_attributes(float px, float py, float pz, - float vx, float vy, float vz, - float fx, float fy, float fz, - float ux, float uy, float uz); - virtual void audio_3d_get_listener_attributes(float *px, float *py, float *pz, - float *vx, float *vy, float *vz, - float *fx, float *fy, float *fz, - float *ux, float *uy, float *uz); + virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, + PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, + PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz); + virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, + PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, + PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, + PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); // Control the "relative scale that sets the distance factor" units for 3D spacialized audio. Default is 1.0 // Fmod uses meters internally, so give a float in Units-per meter // Don't know what Miles uses. // Default is 1.0 which is adjust in panda to be feet. - virtual void audio_3d_set_distance_factor(float factor); - virtual float audio_3d_get_distance_factor() const; + virtual void audio_3d_set_distance_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_distance_factor() const; // Control the presence of the Doppler effect. Default is 1.0 // Exaggerated Doppler, use >1.0 // Diminshed Doppler, use <1.0 - virtual void audio_3d_set_doppler_factor(float factor); - virtual float audio_3d_get_doppler_factor() const; + virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_doppler_factor() const; // Exaggerate or diminish the effect of distance on sound. Default is 1.0 // Valid range is 0 to 10 // Faster drop off, use >1.0 // Slower drop off, use <1.0 - virtual void audio_3d_set_drop_off_factor(float factor); - virtual float audio_3d_get_drop_off_factor() const; + virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_drop_off_factor() const; static Filename get_dls_pathname(); @@ -192,7 +192,7 @@ PUBLISHED: virtual void write(ostream &out) const; // set_speaker_configuration is a Miles only method. - virtual void set_speaker_configuration(LVecBase3f *speaker1, LVecBase3f *speaker2=NULL, LVecBase3f *speaker3=NULL, LVecBase3f *speaker4=NULL, LVecBase3f *speaker5=NULL, LVecBase3f *speaker6=NULL, LVecBase3f *speaker7=NULL, LVecBase3f *speaker8=NULL, LVecBase3f *speaker9=NULL); + virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL); public: static void register_AudioManager_creator(Create_AudioManager_proc* proc); diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index 5de0ebe626..30f8ee8961 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -38,32 +38,32 @@ AudioSound() { void AudioSound:: -set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { +set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { // Intentionally blank. } void AudioSound:: -get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { +get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { // Intentionally blank. } void AudioSound:: -set_3d_min_distance(float dist) { +set_3d_min_distance(PN_stdfloat dist) { // Intentionally blank. } -float AudioSound:: +PN_stdfloat AudioSound:: get_3d_min_distance() const { // Intentionally blank. return 0.0f; } void AudioSound:: -set_3d_max_distance(float dist) { +set_3d_max_distance(PN_stdfloat dist) { // Intentionally blank. } -float AudioSound:: +PN_stdfloat AudioSound:: get_3d_max_distance() const { // Intentionally blank. return 0.0f; @@ -74,7 +74,7 @@ get_3d_max_distance() const { // Access: Published // Description: For use only with FMOD. //////////////////////////////////////////////////////////////////// -float AudioSound:: +PN_stdfloat AudioSound:: get_speaker_mix(int speaker) { // intentionally blank return 0.0; @@ -86,7 +86,7 @@ get_speaker_mix(int speaker) { // Description: For use only with FMOD. //////////////////////////////////////////////////////////////////// void AudioSound:: -set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright) { +set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright) { // intentionally blank } @@ -95,7 +95,7 @@ set_speaker_mix(float frontleft, float frontright, float center, float sub, floa // Access: Published // Description: For use only with Miles. //////////////////////////////////////////////////////////////////// -float AudioSound:: +PN_stdfloat AudioSound:: get_speaker_level(int index) { // intentionally blank return 0.0; @@ -107,7 +107,7 @@ get_speaker_level(int index) { // Description: For use only with Miles. //////////////////////////////////////////////////////////////////// void AudioSound:: -set_speaker_levels(float level1, float level2, float level3, float level4, float level5, float level6, float level7, float level8, float level9) { +set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2, PN_stdfloat level3, PN_stdfloat level4, PN_stdfloat level5, PN_stdfloat level6, PN_stdfloat level7, PN_stdfloat level8, PN_stdfloat level9) { // intentionally blank } diff --git a/panda/src/audio/audioSound.h b/panda/src/audio/audioSound.h index 35e329f239..163111e7e8 100644 --- a/panda/src/audio/audioSound.h +++ b/panda/src/audio/audioSound.h @@ -60,26 +60,26 @@ PUBLISHED: // sound. // - If a sound is playing, calling get_time() repeatedly will // return different results over time. e.g.: - // float percent_complete = s.get_time() / s.length(); - virtual void set_time(float start_time=0.0) = 0; - virtual float get_time() const = 0; + // PN_stdfloat percent_complete = s.get_time() / s.length(); + virtual void set_time(PN_stdfloat start_time=0.0) = 0; + virtual PN_stdfloat get_time() const = 0; // 0 = minimum; 1.0 = maximum. // inits to 1.0. - virtual void set_volume(float volume=1.0) = 0; - virtual float get_volume() const = 0; + virtual void set_volume(PN_stdfloat volume=1.0) = 0; + virtual PN_stdfloat get_volume() const = 0; // -1.0 is hard left // 0.0 is centered // 1.0 is hard right // inits to 0.0. - virtual void set_balance(float balance_right=0.0) = 0; - virtual float get_balance() const = 0; + virtual void set_balance(PN_stdfloat balance_right=0.0) = 0; + virtual PN_stdfloat get_balance() const = 0; - // play_rate is any positive float value. + // play_rate is any positive PN_stdfloat value. // inits to 1.0. - virtual void set_play_rate(float play_rate=1.0f) = 0; - virtual float get_play_rate() const = 0; + virtual void set_play_rate(PN_stdfloat play_rate=1.0f) = 0; + virtual PN_stdfloat get_play_rate() const = 0; // inits to manager's state. virtual void set_active(bool flag=true) = 0; @@ -94,15 +94,15 @@ PUBLISHED: virtual const string& get_name() const = 0; // return: playing time in seconds. - virtual float length() const = 0; + virtual PN_stdfloat length() const = 0; // Controls the position of this sound's emitter. // px, py and pz are the emitter's position. // vx, vy and vz are the emitter's velocity in UNITS PER SECOND (default: meters). - virtual void set_3d_attributes(float px, float py, float pz, - float vx, float vy, float vz); - virtual void get_3d_attributes(float *px, float *py, float *pz, - float *vx, float *vy, float *vz); + virtual void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); + virtual void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, + PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); // Controls the distance (in units) that this sound begins to fall off. @@ -110,15 +110,15 @@ PUBLISHED: // Default is 1.0 // Closer/Faster, <1.0 // Farther/Slower, >1.0 - virtual void set_3d_min_distance(float dist); - virtual float get_3d_min_distance() const; + virtual void set_3d_min_distance(PN_stdfloat dist); + virtual PN_stdfloat get_3d_min_distance() const; // Controls the maximum distance (in units) that this sound stops falling off. // The sound does not stop at that point, it just doesn't get any quieter. // You should rarely need to adjust this. // Default is 1000000000.0 - virtual void set_3d_max_distance(float dist); - virtual float get_3d_max_distance() const; + virtual void set_3d_max_distance(PN_stdfloat dist); + virtual PN_stdfloat get_3d_max_distance() const; // *_speaker_mix and *_speaker_level(s) serve the same purpose. // *_speaker_mix is for use with FMOD. @@ -126,11 +126,11 @@ PUBLISHED: // Both interfaces exist because of a significant difference in the // two APIs. Hopefully the difference can be reconciled into a single // interface at some point. - virtual float get_speaker_mix(int speaker); - virtual void set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright); + virtual PN_stdfloat get_speaker_mix(int speaker); + virtual void set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright); - virtual float get_speaker_level(int index); - virtual void set_speaker_levels(float level1, float level2=-1.0f, float level3=-1.0f, float level4=-1.0f, float level5=-1.0f, float level6=-1.0f, float level7=-1.0f, float level8=-1.0f, float level9=-1.0f); + virtual PN_stdfloat get_speaker_level(int index); + virtual void set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2=-1.0f, PN_stdfloat level3=-1.0f, PN_stdfloat level4=-1.0f, PN_stdfloat level5=-1.0f, PN_stdfloat level6=-1.0f, PN_stdfloat level7=-1.0f, PN_stdfloat level8=-1.0f, PN_stdfloat level9=-1.0f); virtual int get_priority(); virtual void set_priority(int priority); diff --git a/panda/src/audio/filterProperties.I b/panda/src/audio/filterProperties.I index 6262b0f5da..572fdd7006 100644 --- a/panda/src/audio/filterProperties.I +++ b/panda/src/audio/filterProperties.I @@ -29,7 +29,7 @@ clear() { // Description: Add a lowpass filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_lowpass(float cutoff_freq, float resonance_q) { +add_lowpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q) { add_filter(FT_lowpass, cutoff_freq, resonance_q); } @@ -39,7 +39,7 @@ add_lowpass(float cutoff_freq, float resonance_q) { // Description: Add a highpass filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_highpass(float cutoff_freq, float resonance_q) { +add_highpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q) { add_filter(FT_highpass, cutoff_freq, resonance_q); } @@ -49,7 +49,7 @@ add_highpass(float cutoff_freq, float resonance_q) { // Description: Add a echo filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_echo(float drymix, float wetmix, float delay, float decayratio) { +add_echo(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat delay, PN_stdfloat decayratio) { add_filter(FT_echo, drymix, wetmix, delay, decayratio); } @@ -59,7 +59,7 @@ add_echo(float drymix, float wetmix, float delay, float decayratio) { // Description: Add a flange filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_flange(float drymix, float wetmix, float depth, float rate) { +add_flange(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat depth, PN_stdfloat rate) { add_filter(FT_flange, drymix, wetmix, depth, rate); } @@ -69,7 +69,7 @@ add_flange(float drymix, float wetmix, float depth, float rate) { // Description: Add a distort filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_distort(float level) { +add_distort(PN_stdfloat level) { add_filter(FT_distort, level); } @@ -79,7 +79,7 @@ add_distort(float level) { // Description: Add a normalize filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_normalize(float fadetime, float threshold, float maxamp) { +add_normalize(PN_stdfloat fadetime, PN_stdfloat threshold, PN_stdfloat maxamp) { add_filter(FT_normalize, fadetime, threshold, maxamp); } @@ -89,7 +89,7 @@ add_normalize(float fadetime, float threshold, float maxamp) { // Description: Add a parameq filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_parameq(float center_freq, float bandwidth, float gain) { +add_parameq(PN_stdfloat center_freq, PN_stdfloat bandwidth, PN_stdfloat gain) { add_filter(FT_parameq, center_freq, bandwidth, gain); } @@ -99,7 +99,7 @@ add_parameq(float center_freq, float bandwidth, float gain) { // Description: Add a pitchshift filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_pitchshift(float pitch, float fftsize, float overlap) { +add_pitchshift(PN_stdfloat pitch, PN_stdfloat fftsize, PN_stdfloat overlap) { add_filter(FT_pitchshift, pitch, fftsize, overlap); } @@ -109,7 +109,7 @@ add_pitchshift(float pitch, float fftsize, float overlap) { // Description: Add a chorus filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_chorus(float drymix, float wet1, float wet2, float wet3, float delay, float rate, float depth, float feedback) { +add_chorus(PN_stdfloat drymix, PN_stdfloat wet1, PN_stdfloat wet2, PN_stdfloat wet3, PN_stdfloat delay, PN_stdfloat rate, PN_stdfloat depth, PN_stdfloat feedback) { add_filter(FT_chorus, drymix, wet1, wet2, wet3, delay, rate, depth, feedback); } @@ -119,7 +119,7 @@ add_chorus(float drymix, float wet1, float wet2, float wet3, float delay, float // Description: Add a reverb filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_reverb(float drymix, float wetmix, float roomsize, float damp, float width) { +add_reverb(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat roomsize, PN_stdfloat damp, PN_stdfloat width) { add_filter(FT_reverb, drymix, wetmix, roomsize, damp, width); } @@ -129,7 +129,7 @@ add_reverb(float drymix, float wetmix, float roomsize, float damp, float width) // Description: Add a compress filter to the end of the DSP chain. //////////////////////////////////////////////////////////////////// INLINE void FilterProperties:: -add_compress(float threshold, float attack, float release, float gainmakeup) { +add_compress(PN_stdfloat threshold, PN_stdfloat attack, PN_stdfloat release, PN_stdfloat gainmakeup) { add_filter(FT_compress, threshold, attack, release, gainmakeup); } diff --git a/panda/src/audio/filterProperties.cxx b/panda/src/audio/filterProperties.cxx index 27375eaba2..ee86248ebd 100644 --- a/panda/src/audio/filterProperties.cxx +++ b/panda/src/audio/filterProperties.cxx @@ -41,7 +41,7 @@ FilterProperties:: // Description: //////////////////////////////////////////////////////////////////// void FilterProperties:: -add_filter(FilterType t, float a, float b, float c, float d, float e, float f, float g, float h) { +add_filter(FilterType t, PN_stdfloat a, PN_stdfloat b, PN_stdfloat c, PN_stdfloat d, PN_stdfloat e, PN_stdfloat f, PN_stdfloat g, PN_stdfloat h) { FilterConfig conf; conf._type = t; conf._a = a; diff --git a/panda/src/audio/filterProperties.h b/panda/src/audio/filterProperties.h index b3c2e577a1..55788b20a6 100644 --- a/panda/src/audio/filterProperties.h +++ b/panda/src/audio/filterProperties.h @@ -28,17 +28,17 @@ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { FilterProperties(); ~FilterProperties(); INLINE void clear(); - INLINE void add_lowpass(float cutoff_freq, float resonance_q); - INLINE void add_highpass(float cutoff_freq, float resonance_q); - INLINE void add_echo(float drymix, float wetmix, float delay, float decayratio); - INLINE void add_flange(float drymix, float wetmix, float depth, float rate); - INLINE void add_distort(float level); - INLINE void add_normalize(float fadetime, float threshold, float maxamp); - INLINE void add_parameq(float center_freq, float bandwidth, float gain); - INLINE void add_pitchshift(float pitch, float fftsize, float overlap); - INLINE void add_chorus(float drymix, float wet1, float wet2, float wet3, float delay, float rate, float depth, float feedback); - INLINE void add_reverb(float drymix, float wetmix, float roomsize, float damp, float width); - INLINE void add_compress(float threshold, float attack, float release, float gainmakeup); + INLINE void add_lowpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q); + INLINE void add_highpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q); + INLINE void add_echo(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat delay, PN_stdfloat decayratio); + INLINE void add_flange(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat depth, PN_stdfloat rate); + INLINE void add_distort(PN_stdfloat level); + INLINE void add_normalize(PN_stdfloat fadetime, PN_stdfloat threshold, PN_stdfloat maxamp); + INLINE void add_parameq(PN_stdfloat center_freq, PN_stdfloat bandwidth, PN_stdfloat gain); + INLINE void add_pitchshift(PN_stdfloat pitch, PN_stdfloat fftsize, PN_stdfloat overlap); + INLINE void add_chorus(PN_stdfloat drymix, PN_stdfloat wet1, PN_stdfloat wet2, PN_stdfloat wet3, PN_stdfloat delay, PN_stdfloat rate, PN_stdfloat depth, PN_stdfloat feedback); + INLINE void add_reverb(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat roomsize, PN_stdfloat damp, PN_stdfloat width); + INLINE void add_compress(PN_stdfloat threshold, PN_stdfloat attack, PN_stdfloat release, PN_stdfloat gainmakeup); public: @@ -58,14 +58,14 @@ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { struct FilterConfig { FilterType _type; - float _a,_b,_c,_d; - float _e,_f,_g,_h; + PN_stdfloat _a,_b,_c,_d; + PN_stdfloat _e,_f,_g,_h; }; typedef pvector ConfigVector; private: - void add_filter(FilterType t, float a=0, float b=0, float c=0, float d=0, float e=0, float f=0, float g=0, float h=0); + void add_filter(FilterType t, PN_stdfloat a=0, PN_stdfloat b=0, PN_stdfloat c=0, PN_stdfloat d=0, PN_stdfloat e=0, PN_stdfloat f=0, PN_stdfloat g=0, PN_stdfloat h=0); ConfigVector _config; public: diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index d1e6b2edba..8c3f53d51e 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -19,7 +19,7 @@ TypeHandle NullAudioManager::_type_handle; //namespace { //static const string blank=""; - //static float no_listener_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; + //static PN_stdfloat no_listener_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; //} @@ -120,7 +120,7 @@ get_cache_limit() const { // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -set_volume(float) { +set_volume(PN_stdfloat) { // intentionally blank. } @@ -129,7 +129,7 @@ set_volume(float) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float NullAudioManager:: +PN_stdfloat NullAudioManager:: get_volume() const { return 0; } @@ -140,7 +140,7 @@ get_volume() const { // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -set_play_rate(float) { +set_play_rate(PN_stdfloat) { // intentionally blank. } @@ -149,7 +149,7 @@ set_play_rate(float) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float NullAudioManager:: +PN_stdfloat NullAudioManager:: get_play_rate() const { return 0; } @@ -220,7 +220,7 @@ stop_all_sounds() { // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { +audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { // intentionally blank. } @@ -230,7 +230,7 @@ audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float v // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { +audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { // intentionally blank. } @@ -240,7 +240,7 @@ audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, flo // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -audio_3d_set_distance_factor(float factor) { +audio_3d_set_distance_factor(PN_stdfloat factor) { // intentionally blank. } @@ -249,7 +249,7 @@ audio_3d_set_distance_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float NullAudioManager:: +PN_stdfloat NullAudioManager:: audio_3d_get_distance_factor() const { // intentionally blank. return 0.0f; @@ -261,7 +261,7 @@ audio_3d_get_distance_factor() const { // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -audio_3d_set_doppler_factor(float factor) { +audio_3d_set_doppler_factor(PN_stdfloat factor) { // intentionally blank. } @@ -270,7 +270,7 @@ audio_3d_set_doppler_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float NullAudioManager:: +PN_stdfloat NullAudioManager:: audio_3d_get_doppler_factor() const { // intentionally blank. return 0.0f; @@ -282,7 +282,7 @@ audio_3d_get_doppler_factor() const { // Description: //////////////////////////////////////////////////////////////////// void NullAudioManager:: -audio_3d_set_drop_off_factor(float factor) { +audio_3d_set_drop_off_factor(PN_stdfloat factor) { // intentionally blank. } @@ -291,7 +291,7 @@ audio_3d_set_drop_off_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float NullAudioManager:: +PN_stdfloat NullAudioManager:: audio_3d_get_drop_off_factor() const { // intentionally blank. return 0.0f; diff --git a/panda/src/audio/nullAudioManager.h b/panda/src/audio/nullAudioManager.h index 317589641b..d86d913858 100644 --- a/panda/src/audio/nullAudioManager.h +++ b/panda/src/audio/nullAudioManager.h @@ -37,11 +37,11 @@ public: virtual void set_cache_limit(unsigned int); virtual unsigned int get_cache_limit() const; - virtual void set_volume(float); - virtual float get_volume() const; + virtual void set_volume(PN_stdfloat); + virtual PN_stdfloat get_volume() const; - virtual void set_play_rate(float); - virtual float get_play_rate() const; + virtual void set_play_rate(PN_stdfloat); + virtual PN_stdfloat get_play_rate() const; virtual void set_active(bool); virtual bool get_active() const; @@ -53,23 +53,23 @@ public: virtual void stop_all_sounds(); - virtual void audio_3d_set_listener_attributes(float px, float py, float pz, - float vx, float vy, float vz, - float fx, float fy, float fz, - float ux, float uy, float uz); - virtual void audio_3d_get_listener_attributes(float *px, float *py, float *pz, - float *vx, float *vy, float *vz, - float *fx, float *fy, float *fz, - float *ux, float *uy, float *uz); + virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, + PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, + PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz); + virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, + PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, + PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, + PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); - virtual void audio_3d_set_distance_factor(float factor); - virtual float audio_3d_get_distance_factor() const; + virtual void audio_3d_set_distance_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_distance_factor() const; - virtual void audio_3d_set_doppler_factor(float factor); - virtual float audio_3d_get_doppler_factor() const; + virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_doppler_factor() const; - virtual void audio_3d_set_drop_off_factor(float factor); - virtual float audio_3d_get_drop_off_factor() const; + virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_drop_off_factor() const; public: diff --git a/panda/src/audio/nullAudioSound.cxx b/panda/src/audio/nullAudioSound.cxx index d3f1783d6a..64e0fdf222 100644 --- a/panda/src/audio/nullAudioSound.cxx +++ b/panda/src/audio/nullAudioSound.cxx @@ -19,7 +19,7 @@ TypeHandle NullAudioSound::_type_handle; namespace { static const string blank=""; - // static float no_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; + // static PN_stdfloat no_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; } //////////////////////////////////////////////////////////////////// @@ -59,35 +59,35 @@ unsigned long NullAudioSound::get_loop_count() const { return 0; } -void NullAudioSound::set_time(float) { +void NullAudioSound::set_time(PN_stdfloat) { // Intentionally blank. } -float NullAudioSound::get_time() const { +PN_stdfloat NullAudioSound::get_time() const { return 0; } -void NullAudioSound::set_volume(float) { +void NullAudioSound::set_volume(PN_stdfloat) { // Intentionally blank. } -float NullAudioSound::get_volume() const { +PN_stdfloat NullAudioSound::get_volume() const { return 0; } -void NullAudioSound::set_balance(float) { +void NullAudioSound::set_balance(PN_stdfloat) { // Intentionally blank. } -float NullAudioSound::get_balance() const { +PN_stdfloat NullAudioSound::get_balance() const { return 0; } -void NullAudioSound::set_play_rate(float) { +void NullAudioSound::set_play_rate(PN_stdfloat) { // Intentionally blank. } -float NullAudioSound::get_play_rate() const { +PN_stdfloat NullAudioSound::get_play_rate() const { return 0; } @@ -111,32 +111,32 @@ const string& NullAudioSound::get_name() const { return blank; } -float NullAudioSound::length() const { +PN_stdfloat NullAudioSound::length() const { return 0; } -void NullAudioSound::set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { +void NullAudioSound::set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { // Intentionally blank. } -void NullAudioSound::get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { +void NullAudioSound::get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { // Intentionally blank. } -void NullAudioSound::set_3d_min_distance(float dist) { +void NullAudioSound::set_3d_min_distance(PN_stdfloat dist) { // Intentionally blank. } -float NullAudioSound::get_3d_min_distance() const { +PN_stdfloat NullAudioSound::get_3d_min_distance() const { // Intentionally blank. return 0.0f; } -void NullAudioSound::set_3d_max_distance(float dist) { +void NullAudioSound::set_3d_max_distance(PN_stdfloat dist) { // Intentionally blank. } -float NullAudioSound::get_3d_max_distance() const { +PN_stdfloat NullAudioSound::get_3d_max_distance() const { // Intentionally blank. return 0.0f; } diff --git a/panda/src/audio/nullAudioSound.h b/panda/src/audio/nullAudioSound.h index c53cee3064..d3bbd5801b 100644 --- a/panda/src/audio/nullAudioSound.h +++ b/panda/src/audio/nullAudioSound.h @@ -39,17 +39,17 @@ public: void set_loop_count(unsigned long); unsigned long get_loop_count() const; - void set_time(float); - float get_time() const; + void set_time(PN_stdfloat); + PN_stdfloat get_time() const; - void set_volume(float); - float get_volume() const; + void set_volume(PN_stdfloat); + PN_stdfloat get_volume() const; - void set_balance(float); - float get_balance() const; + void set_balance(PN_stdfloat); + PN_stdfloat get_balance() const; - void set_play_rate(float); - float get_play_rate() const; + void set_play_rate(PN_stdfloat); + PN_stdfloat get_play_rate() const; void set_active(bool); bool get_active() const; @@ -59,14 +59,14 @@ public: const string& get_name() const; - float length() const; + PN_stdfloat length() const; - void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz); - void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz); - void set_3d_min_distance(float dist); - float get_3d_min_distance() const; - void set_3d_max_distance(float dist); - float get_3d_max_distance() const; + void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); + void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); + void set_3d_min_distance(PN_stdfloat dist); + PN_stdfloat get_3d_min_distance() const; + void set_3d_max_distance(PN_stdfloat dist); + PN_stdfloat get_3d_max_distance() const; AudioSound::SoundStatus status() const; diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index ecbb89dbfa..e12497dd80 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -50,11 +50,11 @@ bool FmodAudioManager::_system_is_valid = false; // Since Panda use feet we need to compensate for that with a factor of 3.28 // // This can be overwritten. You just need to call -// audio_3d_set_distance_factor(float factor) and set your new factor. +// audio_3d_set_distance_factor(PN_stdfloat factor) and set your new factor. -float FmodAudioManager::_doppler_factor = 1; -float FmodAudioManager::_distance_factor = 3.28; -float FmodAudioManager::_drop_off_factor = 1; +PN_stdfloat FmodAudioManager::_doppler_factor = 1; +PN_stdfloat FmodAudioManager::_distance_factor = 3.28; +PN_stdfloat FmodAudioManager::_drop_off_factor = 1; //////////////////////////////////////////////////////////////////// @@ -517,13 +517,13 @@ setSpeakerSetup(AudioManager::SpeakerModeCategory cat) { } //////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::set_volume(float volume) +// Function: FmodAudioManager::set_volume(PN_stdfloat volume) // Access: Public // Description: Sets the volume of the AudioManager. // It is not an override, but a multiplier. //////////////////////////////////////////////////////////////////// void FmodAudioManager:: -set_volume(float volume) { +set_volume(PN_stdfloat volume) { FMOD_RESULT result; result = _channelgroup->setVolume(volume); fmod_audio_errcheck("_channelgroup->setVolume()", result); @@ -534,13 +534,13 @@ set_volume(float volume) { // Access: Public // Description: Returns the AudioManager's volume. //////////////////////////////////////////////////////////////////// -float FmodAudioManager:: +PN_stdfloat FmodAudioManager:: get_volume() const { float volume; FMOD_RESULT result; result = _channelgroup->getVolume(&volume); fmod_audio_errcheck("_channelgroup->getVolume()", result); - return volume; + return (PN_stdfloat)volume; } //////////////////////////////////////////////////////////////////// @@ -620,7 +620,7 @@ update() { // I told you, so you can't say I didn't. //////////////////////////////////////////////////////////////////// void FmodAudioManager:: -audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { +audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { audio_debug("FmodAudioManager::audio_3d_set_listener_attributes()"); FMOD_RESULT result; @@ -652,7 +652,7 @@ audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float v // Description: Get position of the "ear" that picks up 3d sounds //////////////////////////////////////////////////////////////////// void FmodAudioManager:: -audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { +audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { audio_error("audio3dGetListenerAttributes: currently unimplemented. Get the attributes of the attached object"); } @@ -665,7 +665,7 @@ audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, flo // its sound-spacialization calculations) //////////////////////////////////////////////////////////////////// void FmodAudioManager:: -audio_3d_set_distance_factor(float factor) { +audio_3d_set_distance_factor(PN_stdfloat factor) { audio_debug( "FmodAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")" ); FMOD_RESULT result; @@ -684,7 +684,7 @@ audio_3d_set_distance_factor(float factor) { // Description: Gets units per meter (Fmod uses meters internally for // its sound-spacialization calculations) //////////////////////////////////////////////////////////////////// -float FmodAudioManager:: +PN_stdfloat FmodAudioManager:: audio_3d_get_distance_factor() const { audio_debug("FmodAudioManager::audio_3d_get_distance_factor()"); @@ -698,7 +698,7 @@ audio_3d_get_distance_factor() const { // Defaults to 1.0 //////////////////////////////////////////////////////////////////// void FmodAudioManager:: -audio_3d_set_doppler_factor(float factor) { +audio_3d_set_doppler_factor(PN_stdfloat factor) { audio_debug("FmodAudioManager::audio_3d_set_doppler_factor(factor="<1.0 // Diminshed Doppler, use <1.0 - virtual void audio_3d_set_doppler_factor(float factor); - virtual float audio_3d_get_doppler_factor() const; + virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_doppler_factor() const; // Exaggerate or diminish the effect of distance on sound. Default is 1.0 // Faster drop off, use >1.0 // Slower drop off, use <1.0 - virtual void audio_3d_set_drop_off_factor(float factor); - virtual float audio_3d_get_drop_off_factor() const; + virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_drop_off_factor() const; //THESE ARE NOT USED ANYMORE. //THEY ARE ONLY HERE BECAUSE THEY are still needed by Miles. @@ -175,9 +175,9 @@ private: static bool _system_is_valid; - static float _distance_factor; - static float _doppler_factor; - static float _drop_off_factor; + static PN_stdfloat _distance_factor; + static PN_stdfloat _doppler_factor; + static PN_stdfloat _drop_off_factor; FMOD::ChannelGroup *_channelgroup; diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index d652871249..61397eb05b 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -349,7 +349,7 @@ get_loop_count() const { // immediatey. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_time(float start_time) { +set_time(PN_stdfloat start_time) { _start_time = start_time; if (status() == PLAYING) { @@ -363,7 +363,7 @@ set_time(float start_time) { // Access: public // Description: Gets the play position within the sound //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_time() const { FMOD_RESULT result; unsigned int current_time; @@ -382,13 +382,13 @@ get_time() const { } //////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_volume(float vol) +// Function: FmodAudioSound::set_volume(PN_stdfloat vol) // Access: public // Description: 0.0 to 1.0 scale of volume converted to Fmod's // internal 0.0 to 255.0 scale. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_volume(float vol) { +set_volume(PN_stdfloat vol) { _volume = vol; set_volume_on_channel(); } @@ -398,7 +398,7 @@ set_volume(float vol) { // Access: public // Description: Gets the current volume of a sound. 1 is Max. O is Min. //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_volume() const { return _volume; } @@ -482,12 +482,12 @@ set_volume_on_channel() { } //////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_balance(float bal) +// Function: FmodAudioSound::set_balance(PN_stdfloat bal) // Access: public // Description: -1.0 to 1.0 scale //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_balance(float bal) { +set_balance(PN_stdfloat bal) { _balance = bal; set_speaker_mix_or_balance_on_channel(); } @@ -499,13 +499,13 @@ set_balance(float bal) { // -1 should be all the way left. // 1 is all the way to the right. //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_balance() const { return _balance; } //////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_play_rate(float rate) +// Function: FmodAudioSound::set_play_rate(PN_stdfloat rate) // Access: public // Description: Sets the speed at which a sound plays back. // The rate is a multiple of the sound, normal playback speed. @@ -515,7 +515,7 @@ get_balance() const { // sound's time to its end to hear a song play backwards. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_play_rate(float rate) { +set_play_rate(PN_stdfloat rate) { _playrate = rate; set_play_rate_on_channel(); } @@ -525,7 +525,7 @@ set_play_rate(float rate) { // Access: public // Description: //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_play_rate() const { return _playrate; } @@ -538,7 +538,7 @@ get_play_rate() const { void FmodAudioSound:: set_play_rate_on_channel() { FMOD_RESULT result; - float frequency = _sampleFrequency * _playrate; + PN_stdfloat frequency = _sampleFrequency * _playrate; if (_channel != 0) { result = _channel->setFrequency( frequency ); @@ -566,7 +566,7 @@ get_name() const { // Description: Get length // FMOD returns the time in MS so we have to convert to seconds. //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: length() const { FMOD_RESULT result; unsigned int length; @@ -593,7 +593,7 @@ length() const { // I told you, so you can't say I didn't. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { +set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { _location.x = px; _location.y = pz; _location.z = py; @@ -635,7 +635,7 @@ set_3d_attributes_on_channel() { // Currently unimplemented. Get the attributes of the attached object. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { +get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { audio_error("get3dAttributes: Currently unimplemented. Get the attributes of the attached object."); } @@ -646,7 +646,7 @@ get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float * // affects the rate it falls off. //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_3d_min_distance(float dist) { +set_3d_min_distance(PN_stdfloat dist) { FMOD_RESULT result; _min_dist = dist; @@ -660,7 +660,7 @@ set_3d_min_distance(float dist) { // Access: public // Description: Get the distance that this sound begins to fall off //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_3d_min_distance() const { return _min_dist; } @@ -671,7 +671,7 @@ get_3d_min_distance() const { // Description: Set the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_3d_max_distance(float dist) { +set_3d_max_distance(PN_stdfloat dist) { FMOD_RESULT result; _max_dist = dist; @@ -685,7 +685,7 @@ set_3d_max_distance(float dist) { // Access: public // Description: Get the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_3d_max_distance() const { return _max_dist; } @@ -701,7 +701,7 @@ get_3d_max_distance() const { // BTW This will also work in Stereo speaker systems, but since // PANDA/FMOD has a balance [pan] function what is the point? //////////////////////////////////////////////////////////////////// -float FmodAudioSound:: +PN_stdfloat FmodAudioSound:: get_speaker_mix(AudioManager::SpeakerId speaker) { if (_channel == 0) { return 0.0; @@ -750,7 +750,7 @@ get_speaker_mix(AudioManager::SpeakerId speaker) { // //////////////////////////////////////////////////////////////////// void FmodAudioSound:: -set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright) { +set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright) { _mix[AudioManager::SPK_frontleft] = frontleft; _mix[AudioManager::SPK_frontright] = frontright; _mix[AudioManager::SPK_center] = center; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 9fc858e9ab..e624fc9192 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -105,47 +105,47 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { // 0 = beginning; length() = end. // inits to 0.0. - void set_time(float start_time=0.0); - float get_time() const; + void set_time(PN_stdfloat start_time=0.0); + PN_stdfloat get_time() const; // 0 = minimum; 1.0 = maximum. // inits to 1.0. - void set_volume(float volume=1.0); - float get_volume() const; + void set_volume(PN_stdfloat volume=1.0); + PN_stdfloat get_volume() const; // -1.0 is hard left // 0.0 is centered // 1.0 is hard right // inits to 0.0. - void set_balance(float balance_right=0.0); - float get_balance() const; + void set_balance(PN_stdfloat balance_right=0.0); + PN_stdfloat get_balance() const; // play_rate is any positive float value. // inits to 1.0. - void set_play_rate(float play_rate=1.0f); - float get_play_rate() const; + void set_play_rate(PN_stdfloat play_rate=1.0f); + PN_stdfloat get_play_rate() const; const string &get_name() const; // return: playing time in seconds. - float length() const; + PN_stdfloat length() const; // Controls the position of this sound's emitter. // pos is a pointer to an xyz triplet of the emitter's position. // vel is a pointer to an xyz triplet of the emitter's velocity. - void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz); - void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz); + void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); + void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); - void set_3d_min_distance(float dist); - float get_3d_min_distance() const; + void set_3d_min_distance(PN_stdfloat dist); + PN_stdfloat get_3d_min_distance() const; - void set_3d_max_distance(float dist); - float get_3d_max_distance() const; + void set_3d_max_distance(PN_stdfloat dist); + PN_stdfloat get_3d_max_distance() const; AudioSound::SoundStatus status() const; - virtual float get_speaker_mix(AudioManager::SpeakerId speaker); - virtual void set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright); + virtual PN_stdfloat get_speaker_mix(AudioManager::SpeakerId speaker); + virtual void set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright); void set_active(bool active=true); bool get_active() const; @@ -175,8 +175,8 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { FMOD_VECTOR _location; FMOD_VECTOR _velocity; - float _min_dist; - float _max_dist; + PN_stdfloat _min_dist; + PN_stdfloat _max_dist; void start_playing(); void set_volume_on_channel(); @@ -192,7 +192,7 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { bool _active; bool _paused; - float _start_time; + PN_stdfloat _start_time; string _finished_event; diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 961f0dcd6a..e0198f2ae7 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -304,7 +304,7 @@ get_cache_limit() const { // Description: set the overall volume //////////////////////////////////////////////////////////////////// void MilesAudioManager:: -set_volume(float volume) { +set_volume(PN_stdfloat volume) { audio_debug("MilesAudioManager::set_volume(volume="<_digital_driver, px, pz, py); - AIL_listener_3D_velocity(mgr->_digital_driver, vx, vz, vy); - AIL_listener_3D_orientation(mgr->_digital_driver, fx, fz, fy, ux, uz, uy); + float lpx, lpy, lpz, lvx, lvy, lvz, lfx, lfy, lfz, lux, luy, luz; + AIL_listener_3D_position(mgr->_digital_driver, &lpx, &lpz, &lpy); + AIL_listener_3D_velocity(mgr->_digital_driver, &lvx, &lvz, &lvy); + AIL_listener_3D_orientation(mgr->_digital_driver, &lfx, &lfz, &lfy, &lux, &luz, &luy); + + *px = lpx; + *py = lpy; + *pz = lpz; + *vx = lvx; + *vy = lvy; + *vz = lvz; + *fx = lfx; + *fy = lfy; + *fz = lfz; + *ux = lux; + *uy = luy; + *uz = luz; } //////////////////////////////////////////////////////////////////// @@ -471,7 +485,7 @@ void MilesAudioManager::audio_3d_get_listener_attributes(float *px, float *py, f // Description: Set factor to allow user to easily work in a // different scale. 1.0 represents meters. //////////////////////////////////////////////////////////////////// -void MilesAudioManager::audio_3d_set_distance_factor(float factor) { +void MilesAudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) { audio_debug("MilesAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")"); GlobalMilesManager *mgr = GlobalMilesManager::get_global_ptr(); @@ -483,7 +497,7 @@ void MilesAudioManager::audio_3d_set_distance_factor(float factor) { // Access: Public // Description: Get factor controlling working units. //////////////////////////////////////////////////////////////////// -float MilesAudioManager::audio_3d_get_distance_factor() const { +PN_stdfloat MilesAudioManager::audio_3d_get_distance_factor() const { audio_debug("MilesAudioManager::audio_3d_get_distance_factor()"); GlobalMilesManager *mgr = GlobalMilesManager::get_global_ptr(); @@ -496,7 +510,7 @@ float MilesAudioManager::audio_3d_get_distance_factor() const { // Description: Exaggerates or diminishes the Doppler effect. // Defaults to 1.0 //////////////////////////////////////////////////////////////////// -void MilesAudioManager::audio_3d_set_doppler_factor(float factor) { +void MilesAudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) { audio_debug("MilesAudioManager::audio_3d_set_doppler_factor(factor="< _raw_data; bool _has_length; - float _length; // in seconds. + PN_stdfloat _length; // in seconds. }; typedef pmap SoundMap; SoundMap _sounds; @@ -147,8 +147,8 @@ private: typedef pdeque LRU; LRU _lru; // State: - float _volume; - float _play_rate; + PN_stdfloat _volume; + PN_stdfloat _play_rate; bool _active; int _cache_limit; bool _cleanup_required; diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index 9516634759..1efd7b2720 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -154,7 +154,7 @@ stop() { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSample:: +PN_stdfloat MilesAudioSample:: get_time() const { if (_sample == 0) { if (_got_start_time) { @@ -165,7 +165,7 @@ get_time() const { S32 current_ms; AIL_sample_ms_position(_sample, NULL, ¤t_ms); - float time = float(current_ms * 0.001f); + PN_stdfloat time = PN_stdfloat(current_ms * 0.001f); return time; } @@ -176,7 +176,7 @@ get_time() const { // Description: //////////////////////////////////////////////////////////////////// void MilesAudioSample:: -set_volume(float volume) { +set_volume(PN_stdfloat volume) { miles_audio_debug("set_volume(volume="<get_play_rate(); // wave and mp3 use sample rate (e.g. 44100) - S32 speed = (S32)(play_rate * (float)_original_playback_rate); + S32 speed = (S32)(play_rate * (PN_stdfloat)_original_playback_rate); AIL_set_sample_playback_rate(_sample, speed); audio_debug(" play_rate for this wav or mp3 is now " << speed); } @@ -242,7 +242,7 @@ set_play_rate(float play_rate) { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSample:: +PN_stdfloat MilesAudioSample:: length() const { return _sd->get_length(); } @@ -311,7 +311,7 @@ output(ostream &out) const { // Y and Z are switched to translate from Miles's // coordinate system. //////////////////////////////////////////////////////////////////// -void MilesAudioSample::set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { +void MilesAudioSample::set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { audio_debug("MilesAudioSample::set_3d_attributes() Setting a sound's 3D Coordinates."); if(_sample != 0) { @@ -327,12 +327,19 @@ void MilesAudioSample::set_3d_attributes(float px, float py, float pz, float vx, // Access: public // Description: Get position and velocity of this sound. //////////////////////////////////////////////////////////////////// -void MilesAudioSample::get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { +void MilesAudioSample::get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { audio_debug("MilesAudioSample::get_3d_attributes()."); if(_sample != 0) { - AIL_sample_3D_position(_sample, px, pz, py); - AIL_sample_3D_velocity(_sample, vx, vz, vy); + float lpx, lpy, lpz, lvx, lvy, lvz; + AIL_sample_3D_position(_sample, &lpx, &lpz, &lpy); + AIL_sample_3D_velocity(_sample, &lvx, &lvz, &lvy); + *px = lpx; + *py = lpy; + *pz = lpz; + *vx = lvx; + *vy = lvy; + *vz = lvz; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_attributes()."); } @@ -346,7 +353,7 @@ void MilesAudioSample::get_3d_attributes(float *px, float *py, float *pz, float // the distance between the sound and the listener is // doubled, the volume is halved, and vice versa. //////////////////////////////////////////////////////////////////// -void MilesAudioSample::set_3d_min_distance(float dist) { +void MilesAudioSample::set_3d_min_distance(PN_stdfloat dist) { audio_debug("MilesAudioSample::set_3d_min_distance() Setting the sound's 3D min distance ( min= " << dist << " ) "); if(_sample != 0) { @@ -367,13 +374,13 @@ void MilesAudioSample::set_3d_min_distance(float dist) { // Access: public // Description: Get the distance that this sound begins to fall off. //////////////////////////////////////////////////////////////////// -float MilesAudioSample::get_3d_min_distance() const { +PN_stdfloat MilesAudioSample::get_3d_min_distance() const { audio_debug("MilesAudioSample::get_3d_min_distance() "); if(_sample != 0) { float min_dist; AIL_sample_3D_distances(_sample, NULL, &min_dist, NULL); - return min_dist; + return (PN_stdfloat)min_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_min_distance()."); return -1.0; @@ -388,7 +395,7 @@ float MilesAudioSample::get_3d_min_distance() const { // the rate at which the sound falls off, but only // the distance at which it gets clipped. //////////////////////////////////////////////////////////////////// -void MilesAudioSample::set_3d_max_distance(float dist) { +void MilesAudioSample::set_3d_max_distance(PN_stdfloat dist) { audio_debug("MilesAudioSample::set_3d_max_distance() Setting the sound's 3D max distance ( max= " << dist << " ) "); if(_sample != 0) { @@ -410,13 +417,13 @@ void MilesAudioSample::set_3d_max_distance(float dist) { // Description: Get the distance at which this sound is clipped to // silence. //////////////////////////////////////////////////////////////////// -float MilesAudioSample::get_3d_max_distance() const { +PN_stdfloat MilesAudioSample::get_3d_max_distance() const { audio_debug("MilesAudioSample::get_3d_max_distance() "); if(_sample != 0) { float max_dist; AIL_sample_3D_distances(_sample, &max_dist, NULL, NULL); - return max_dist; + return (PN_stdfloat)max_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_max_distance()."); return -1.0; @@ -459,7 +466,7 @@ float MilesAudioSample::get_3d_max_distance() const { // TOP_BACK_RIGHT // //////////////////////////////////////////////////////////////////// -float MilesAudioSample:: +PN_stdfloat MilesAudioSample:: get_speaker_level(int index) { audio_debug("MilesAudioSample::get_speaker_level(" << index << ")"); @@ -468,7 +475,7 @@ get_speaker_level(int index) { float *levels = AIL_sample_channel_levels(_sample, &numLevels); if(index < numLevels) { - return levels[index]; + return (PN_stdfloat)levels[index]; } else { audio_error("index out of range in MilesAudioSample::get_speaker_level. numLevels: " << numLevels); return -1.0; @@ -519,7 +526,7 @@ get_speaker_level(int index) { // //////////////////////////////////////////////////////////////////// void MilesAudioSample:: -set_speaker_levels(float level1, float level2, float level3, float level4, float level5, float level6, float level7, float level8, float level9) { +set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2, PN_stdfloat level3, PN_stdfloat level4, PN_stdfloat level5, PN_stdfloat level6, PN_stdfloat level7, PN_stdfloat level8, PN_stdfloat level9) { audio_debug("MilesAudioSample::set_speaker_levels()"); if(_sample != 0) { @@ -589,12 +596,12 @@ finish_callback(HSAMPLE sample) { // Description: Sets the start time of an already allocated sample. //////////////////////////////////////////////////////////////////// void MilesAudioSample:: -do_set_time(float time) { +do_set_time(PN_stdfloat time) { miles_audio_debug("do_set_time(time="< max_time) { milesAudio_cat.warning() << "set_time(" << time << ") requested for sound of length " diff --git a/panda/src/audiotraits/milesAudioSample.h b/panda/src/audiotraits/milesAudioSample.h index 2efe6bb37a..5b23593940 100644 --- a/panda/src/audiotraits/milesAudioSample.h +++ b/panda/src/audiotraits/milesAudioSample.h @@ -40,13 +40,13 @@ public: virtual void play(); virtual void stop(); - virtual float get_time() const; + virtual PN_stdfloat get_time() const; - virtual void set_volume(float volume=1.0f); - virtual void set_balance(float balance_right=0.0f); - virtual void set_play_rate(float play_rate=1.0f); + virtual void set_volume(PN_stdfloat volume=1.0f); + virtual void set_balance(PN_stdfloat balance_right=0.0f); + virtual void set_play_rate(PN_stdfloat play_rate=1.0f); - virtual float length() const; + virtual PN_stdfloat length() const; virtual AudioSound::SoundStatus status() const; @@ -57,20 +57,20 @@ public: // Spatialized sound was originally added for FMOD, so there are parts of the // interface in the Miles implementation that are a little more awkward than // they would be otherwise. - void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz); - void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz); - void set_3d_min_distance(float dist); - float get_3d_min_distance() const; - void set_3d_max_distance(float dist); - float get_3d_max_distance() const; + void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); + void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); + void set_3d_min_distance(PN_stdfloat dist); + PN_stdfloat get_3d_min_distance() const; + void set_3d_max_distance(PN_stdfloat dist); + PN_stdfloat get_3d_max_distance() const; - virtual float get_speaker_level(int index); - virtual void set_speaker_levels(float level1, float level2=-1.0f, float level3=-1.0f, float level4=-1.0f, float level5=-1.0f, float level6=-1.0f, float level7=-1.0f, float level8=-1.0f, float level9=-1.0f); + virtual PN_stdfloat get_speaker_level(int index); + virtual void set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2=-1.0f, PN_stdfloat level3=-1.0f, PN_stdfloat level4=-1.0f, PN_stdfloat level5=-1.0f, PN_stdfloat level6=-1.0f, PN_stdfloat level7=-1.0f, PN_stdfloat level8=-1.0f, PN_stdfloat level9=-1.0f); private: void internal_stop(); static void AILCALLBACK finish_callback(HSAMPLE sample); - void do_set_time(float time); + void do_set_time(PN_stdfloat time); PT(MilesAudioManager::SoundData) _sd; HSAMPLE _sample; diff --git a/panda/src/audiotraits/milesAudioSequence.cxx b/panda/src/audiotraits/milesAudioSequence.cxx index 8260a01ddc..05789fe64c 100644 --- a/panda/src/audiotraits/milesAudioSequence.cxx +++ b/panda/src/audiotraits/milesAudioSequence.cxx @@ -144,7 +144,7 @@ stop() { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSequence:: +PN_stdfloat MilesAudioSequence:: get_time() const { if (_sequence == 0) { if (_got_start_time) { @@ -155,7 +155,7 @@ get_time() const { S32 current_ms; AIL_sequence_ms_position(_sequence, NULL, ¤t_ms); - float time = float(current_ms * 0.001f); + PN_stdfloat time = PN_stdfloat(current_ms * 0.001f); return time; } @@ -166,7 +166,7 @@ get_time() const { // Description: //////////////////////////////////////////////////////////////////// void MilesAudioSequence:: -set_volume(float volume) { +set_volume(PN_stdfloat volume) { miles_audio_debug("set_volume(volume="<_raw_data[0], 0); S32 length_ms; AIL_sequence_ms_position(_sequence, &length_ms, NULL); - float time = (float)length_ms * 0.001f; + PN_stdfloat time = (PN_stdfloat)length_ms * 0.001f; mgr->release_sequence(_sequence_index, this); _sequence = 0; _sequence_index = 0; diff --git a/panda/src/audiotraits/milesAudioSequence.h b/panda/src/audiotraits/milesAudioSequence.h index a16000282f..272eb433fa 100644 --- a/panda/src/audiotraits/milesAudioSequence.h +++ b/panda/src/audiotraits/milesAudioSequence.h @@ -39,13 +39,13 @@ public: virtual void play(); virtual void stop(); - virtual float get_time() const; + virtual PN_stdfloat get_time() const; - virtual void set_volume(float volume=1.0f); - virtual void set_balance(float balance_right=0.0f); - virtual void set_play_rate(float play_rate=1.0f); + virtual void set_volume(PN_stdfloat volume=1.0f); + virtual void set_balance(PN_stdfloat balance_right=0.0f); + virtual void set_play_rate(PN_stdfloat play_rate=1.0f); - virtual float length() const; + virtual PN_stdfloat length() const; virtual AudioSound::SoundStatus status() const; @@ -54,7 +54,7 @@ public: private: void internal_stop(); static void AILCALLBACK finish_callback(HSEQUENCE sequence); - void do_set_time(float time); + void do_set_time(PN_stdfloat time); void determine_length(); PT(MilesAudioManager::SoundData) _sd; diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index b2204326f8..ec1d440e4e 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -106,7 +106,7 @@ get_loop_count() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSound:: +PN_stdfloat MilesAudioSound:: get_volume() const { return _volume; } @@ -116,7 +116,7 @@ get_volume() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSound:: +PN_stdfloat MilesAudioSound:: get_balance() const { return _balance; } @@ -126,7 +126,7 @@ get_balance() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioSound:: +PN_stdfloat MilesAudioSound:: get_play_rate() const { return _play_rate; } @@ -137,7 +137,7 @@ get_play_rate() const { // Description: //////////////////////////////////////////////////////////////////// void MilesAudioSound:: -set_time(float time) { +set_time(PN_stdfloat time) { miles_audio_debug("set_time(time="<get_play_rate(); // wave and mp3 use sample rate (e.g. 44100) - S32 speed = (S32)(play_rate * (float)_original_playback_rate); + S32 speed = (S32)(play_rate * (PN_stdfloat)_original_playback_rate); AIL_set_sample_playback_rate(sample, speed); audio_debug(" play_rate for this wav or mp3 is now " << speed); } @@ -237,7 +237,7 @@ set_play_rate(float play_rate) { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float MilesAudioStream:: +PN_stdfloat MilesAudioStream:: length() const { if (!_got_length) { if (_stream == 0) { @@ -247,7 +247,7 @@ length() const { S32 length_ms; AIL_stream_ms_position(_stream, &length_ms, NULL); - _length = (float)length_ms * 0.001f; + _length = (PN_stdfloat)length_ms * 0.001f; _got_length = true; } @@ -322,7 +322,7 @@ finish_callback(HSTREAM stream) { // Description: Sets the start time of an already allocated stream. //////////////////////////////////////////////////////////////////// void MilesAudioStream:: -do_set_time(float time) { +do_set_time(PN_stdfloat time) { nassertv(_stream != 0); S32 time_ms = (S32)(1000.0f * time); diff --git a/panda/src/audiotraits/milesAudioStream.h b/panda/src/audiotraits/milesAudioStream.h index eb4b794a9b..1b19d5181b 100644 --- a/panda/src/audiotraits/milesAudioStream.h +++ b/panda/src/audiotraits/milesAudioStream.h @@ -40,13 +40,13 @@ public: virtual void play(); virtual void stop(); - virtual float get_time() const; + virtual PN_stdfloat get_time() const; - virtual void set_volume(float volume=1.0f); - virtual void set_balance(float balance_right=0.0f); - virtual void set_play_rate(float play_rate=1.0f); + virtual void set_volume(PN_stdfloat volume=1.0f); + virtual void set_balance(PN_stdfloat balance_right=0.0f); + virtual void set_play_rate(PN_stdfloat play_rate=1.0f); - virtual float length() const; + virtual PN_stdfloat length() const; virtual AudioSound::SoundStatus status() const; @@ -54,12 +54,12 @@ public: private: static void AILCALLBACK finish_callback(HSTREAM stream); - void do_set_time(float time); + void do_set_time(PN_stdfloat time); Filename _path; HSTREAM _stream; S32 _original_playback_rate; - mutable float _length; + mutable PN_stdfloat _length; mutable bool _got_length; public: diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 34b7db9296..3b71b38841 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -482,12 +482,12 @@ release_sound(OpenALAudioSound* audioSound) { } //////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_volume(float volume) +// Function: OpenALAudioManager::set_volume(PN_stdfloat volume) // Access: Public // Description: // Sets listener gain //////////////////////////////////////////////////////////////////// -void OpenALAudioManager::set_volume(float volume) { +void OpenALAudioManager::set_volume(PN_stdfloat volume) { if (_volume!=volume) { _volume = volume; @@ -514,7 +514,7 @@ void OpenALAudioManager::set_volume(float volume) { // Description: // Gets listener gain //////////////////////////////////////////////////////////////////// -float OpenALAudioManager:: +PN_stdfloat OpenALAudioManager:: get_volume() const { return _volume; } @@ -525,7 +525,7 @@ get_volume() const { // Description: set the overall play rate //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -set_play_rate(float play_rate) { +set_play_rate(PN_stdfloat play_rate) { if (_play_rate!=play_rate) { _play_rate = play_rate; // Tell our AudioSounds to adjust: @@ -541,7 +541,7 @@ set_play_rate(float play_rate) { // Access: Public // Description: get the overall speed/pitch/play rate //////////////////////////////////////////////////////////////////// -float OpenALAudioManager:: +PN_stdfloat OpenALAudioManager:: get_play_rate() const { return _play_rate; } @@ -590,7 +590,7 @@ get_active() const { // I told you, so you can't say I didn't. //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) { +audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { _position[0] = px; _position[1] = pz; _position[2] = -py; @@ -625,7 +625,7 @@ audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float v // Description: Get position of the "ear" that picks up 3d sounds //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) { +audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { *px = _position[0]; *py = -_position[2]; *pz = _position[1]; @@ -654,7 +654,7 @@ audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, flo // OpenAL's default speed of sound is 343.3 m/s == 1126.3 ft/s //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -audio_3d_set_distance_factor(float factor) { +audio_3d_set_distance_factor(PN_stdfloat factor) { _distance_factor = factor; make_current(); @@ -685,7 +685,7 @@ audio_3d_set_distance_factor(float factor) { // Access: Public // Description: Sets units per foot //////////////////////////////////////////////////////////////////// -float OpenALAudioManager:: +PN_stdfloat OpenALAudioManager:: audio_3d_get_distance_factor() const { return _distance_factor; } @@ -697,7 +697,7 @@ audio_3d_get_distance_factor() const { // Defaults to 1.0 //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -audio_3d_set_doppler_factor(float factor) { +audio_3d_set_doppler_factor(PN_stdfloat factor) { _doppler_factor = factor; make_current(); @@ -712,7 +712,7 @@ audio_3d_set_doppler_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float OpenALAudioManager:: +PN_stdfloat OpenALAudioManager:: audio_3d_get_doppler_factor() const { return _doppler_factor; } @@ -724,7 +724,7 @@ audio_3d_get_doppler_factor() const { // Defaults to 1.0 //////////////////////////////////////////////////////////////////// void OpenALAudioManager:: -audio_3d_set_drop_off_factor(float factor) { +audio_3d_set_drop_off_factor(PN_stdfloat factor) { _drop_off_factor = factor; AllSounds::iterator i=_all_sounds.begin(); @@ -738,7 +738,7 @@ audio_3d_set_drop_off_factor(float factor) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float OpenALAudioManager:: +PN_stdfloat OpenALAudioManager:: audio_3d_get_drop_off_factor() const { return _drop_off_factor; } diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index 1cb5b20f82..e7d14f22c9 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -63,11 +63,11 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { virtual void set_cache_limit(unsigned int count); virtual unsigned int get_cache_limit() const; - virtual void set_volume(float); - virtual float get_volume() const; + virtual void set_volume(PN_stdfloat); + virtual PN_stdfloat get_volume() const; - void set_play_rate(float play_rate); - float get_play_rate() const; + void set_play_rate(PN_stdfloat play_rate); + PN_stdfloat get_play_rate() const; virtual void set_active(bool); virtual bool get_active() const; @@ -78,34 +78,34 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { // fx, fy and fz are the respective components of a unit forward-vector // ux, uy and uz are the respective components of a unit up-vector // These changes will NOT be invoked until audio_3d_update() is called. - virtual void audio_3d_set_listener_attributes(float px, float py, float pz, - float vx, float xy, float xz, - float fx, float fy, float fz, - float ux, float uy, float uz); + virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz, + PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, + PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz); - virtual void audio_3d_get_listener_attributes(float *px, float *py, float *pz, - float *vx, float *vy, float *vz, - float *fx, float *fy, float *fz, - float *ux, float *uy, float *uz); + virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, + PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, + PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, + PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); // Control the "relative distance factor" for 3D spacialized audio in units-per-foot. Default is 1.0 // OpenAL has no distance factor but we use this as a scale // on the min/max distances of sounds to preserve FMOD compatibility. // Also, adjusts the speed of sound to compensate for unit difference. - virtual void audio_3d_set_distance_factor(float factor); - virtual float audio_3d_get_distance_factor() const; + virtual void audio_3d_set_distance_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_distance_factor() const; // Control the presence of the Doppler effect. Default is 1.0 // Exaggerated Doppler, use >1.0 // Diminshed Doppler, use <1.0 - virtual void audio_3d_set_doppler_factor(float factor); - virtual float audio_3d_get_doppler_factor() const; + virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_doppler_factor() const; // Exaggerate or diminish the effect of distance on sound. Default is 1.0 // Faster drop off, use >1.0 // Slower drop off, use <1.0 - virtual void audio_3d_set_drop_off_factor(float factor); - virtual float audio_3d_get_drop_off_factor() const; + virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); + virtual PN_stdfloat audio_3d_get_drop_off_factor() const; virtual void set_concurrent_sound_limit(unsigned int limit = 0); virtual unsigned int get_concurrent_sound_limit() const; @@ -184,8 +184,8 @@ private: // State: int _cache_limit; - float _volume; - float _play_rate; + PN_stdfloat _volume; + PN_stdfloat _play_rate; bool _active; bool _cleanup_required; // keep a count for startup and shutdown: @@ -205,9 +205,9 @@ private: typedef pset SourceCache; static SourceCache *_al_sources; - float _distance_factor; - float _doppler_factor; - float _drop_off_factor; + PN_stdfloat _distance_factor; + PN_stdfloat _doppler_factor; + PN_stdfloat _drop_off_factor; ALfloat _position[3]; ALfloat _velocity[3]; diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index b4df2a5da0..9de51fa971 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -130,7 +130,7 @@ void OpenALAudioSound:: play() { if (_manager == 0) return; - float px,py,pz,vx,vy,vz; + PN_stdfloat px,py,pz,vx,vy,vz; if (!_active) { _paused = true; @@ -535,7 +535,7 @@ push_fresh_buffers() { // start from the specified offset. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_time(float time) { +set_time(PN_stdfloat time) { _start_time = time; } @@ -544,7 +544,7 @@ set_time(float time) { // Access: public // Description: Gets the play position within the sound //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_time() const { if (_manager == 0) { return 0.0; @@ -570,13 +570,13 @@ cache_time(double rtc) { } //////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_volume(float vol) +// Function: OpenALAudioSound::set_volume(PN_stdfloat vol) // Access: public // Description: 0.0 to 1.0 scale of volume converted to Fmod's // internal 0.0 to 255.0 scale. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_volume(float volume) { +set_volume(PN_stdfloat volume) { _volume=volume; if (_source) { @@ -593,18 +593,18 @@ set_volume(float volume) { // Access: public // Description: Gets the current volume of a sound. 1 is Max. O is Min. //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_volume() const { return _volume; } //////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_balance(float bal) +// Function: OpenALAudioSound::set_balance(PN_stdfloat bal) // Access: public // Description: -1.0 to 1.0 scale //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_balance(float balance_right) { +set_balance(PN_stdfloat balance_right) { audio_debug("OpenALAudioSound::set_balance() not implemented"); } @@ -615,21 +615,21 @@ set_balance(float balance_right) { // -1 should be all the way left. // 1 is all the way to the right. //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_balance() const { audio_debug("OpenALAudioSound::get_balance() not implemented"); return 0; } //////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_play_rate(float rate) +// Function: OpenALAudioSound::set_play_rate(PN_stdfloat rate) // Access: public // Description: Sets the speed at which a sound plays back. // The rate is a multiple of the sound, normal playback speed. // IE 2 would play back 2 times fast, 3 would play 3 times, and so on. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_play_rate(float play_rate) { +set_play_rate(PN_stdfloat play_rate) { _play_rate = play_rate; if (_source) { alSourcef(_source, AL_PITCH, play_rate); @@ -641,7 +641,7 @@ set_play_rate(float play_rate) { // Access: public // Description: //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_play_rate() const { return _play_rate; } @@ -651,7 +651,7 @@ get_play_rate() const { // Access: public // Description: Get length //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: length() const { return _length; } @@ -673,7 +673,7 @@ length() const { // coordinates from Panda to OpenAL and back. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { +set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { _location[0] = px; _location[1] = pz; _location[2] = -py; @@ -700,7 +700,7 @@ set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz) { // Currently unimplemented. Get the attributes of the attached object. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz) { +get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { *px = _location[0]; *py = -_location[2]; *pz = _location[1]; @@ -717,7 +717,7 @@ get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float * // affects the rate it falls off. //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_3d_min_distance(float dist) { +set_3d_min_distance(PN_stdfloat dist) { _min_dist = dist; if (_source) { @@ -734,7 +734,7 @@ set_3d_min_distance(float dist) { // Access: public // Description: Get the distance that this sound begins to fall off //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_3d_min_distance() const { return _min_dist; } @@ -745,7 +745,7 @@ get_3d_min_distance() const { // Description: Set the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_3d_max_distance(float dist) { +set_3d_max_distance(PN_stdfloat dist) { _max_dist = dist; if (_source) { @@ -762,7 +762,7 @@ set_3d_max_distance(float dist) { // Access: public // Description: Get the distance that this sound stops falling off //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_3d_max_distance() const { return _max_dist; } @@ -774,7 +774,7 @@ get_3d_max_distance() const { // Defaults to 1.0 //////////////////////////////////////////////////////////////////// void OpenALAudioSound:: -set_3d_drop_off_factor(float factor) { +set_3d_drop_off_factor(PN_stdfloat factor) { _drop_off_factor = factor; if (_source) { @@ -792,7 +792,7 @@ set_3d_drop_off_factor(float factor) { // Description: Control the effect distance has on audability. // Defaults to 1.0 //////////////////////////////////////////////////////////////////// -float OpenALAudioSound:: +PN_stdfloat OpenALAudioSound:: get_3d_drop_off_factor() const { return _drop_off_factor; } diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index aac7aca3dd..3d04677ec3 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -61,25 +61,25 @@ public: // 0 = beginning; length() = end. // inits to 0.0. - void set_time(float time=0.0); - float get_time() const; + void set_time(PN_stdfloat time=0.0); + PN_stdfloat get_time() const; // 0 = minimum; 1.0 = maximum. // inits to 1.0. - void set_volume(float volume=1.0); - float get_volume() const; + void set_volume(PN_stdfloat volume=1.0); + PN_stdfloat get_volume() const; // -1.0 is hard left // 0.0 is centered // 1.0 is hard right // inits to 0.0. - void set_balance(float balance_right=0.0); - float get_balance() const; + void set_balance(PN_stdfloat balance_right=0.0); + PN_stdfloat get_balance() const; // play_rate is any positive float value. // inits to 1.0. - void set_play_rate(float play_rate=1.0f); - float get_play_rate() const; + void set_play_rate(PN_stdfloat play_rate=1.0f); + PN_stdfloat get_play_rate() const; // inits to manager's state. void set_active(bool active=true); @@ -94,22 +94,22 @@ public: const string &get_name() const; // return: playing time in seconds. - float length() const; + PN_stdfloat length() const; // Controls the position of this sound's emitter. // pos is a pointer to an xyz triplet of the emitter's position. // vel is a pointer to an xyz triplet of the emitter's velocity. - void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz); - void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz); + void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); + void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); - void set_3d_min_distance(float dist); - float get_3d_min_distance() const; + void set_3d_min_distance(PN_stdfloat dist); + PN_stdfloat get_3d_min_distance() const; - void set_3d_max_distance(float dist); - float get_3d_max_distance() const; + void set_3d_max_distance(PN_stdfloat dist); + PN_stdfloat get_3d_max_distance() const; - void set_3d_drop_off_factor(float factor); - float get_3d_drop_off_factor() const; + void set_3d_drop_off_factor(PN_stdfloat factor); + PN_stdfloat get_3d_drop_off_factor() const; AudioSound::SoundStatus status() const; @@ -150,7 +150,7 @@ private: }; int _playing_loops; - float _playing_rate; + PN_stdfloat _playing_rate; pdeque _stream_queued; int _loops_completed; @@ -158,17 +158,17 @@ private: ALuint _source; PT(OpenALAudioManager) _manager; - float _volume; // 0..1.0 - float _balance; // -1..1 - float _play_rate; // 0..1.0 + PN_stdfloat _volume; // 0..1.0 + PN_stdfloat _balance; // -1..1 + PN_stdfloat _play_rate; // 0..1.0 bool _positional; ALfloat _location[3]; ALfloat _velocity[3]; - float _min_dist; - float _max_dist; - float _drop_off_factor; + PN_stdfloat _min_dist; + PN_stdfloat _max_dist; + PN_stdfloat _drop_off_factor; double _length; int _loop_count; @@ -189,7 +189,7 @@ private: // during the AudioManager update. Updates need // to be atomic, because get_time can be called // in the cull thread. - float _current_time; + PN_stdfloat _current_time; // This is the string that throw_event() will throw // when the sound finishes playing. It is not triggered diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index 017768c85a..e1357a120f 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -22,7 +22,7 @@ #include "lpoint3.h" #include "geom.h" -#include "pta_LVecBase3f.h" +#include "pta_LVecBase3.h" //////////////////////////////////////////////////////////////////// // Class : BulletConvexHullShape diff --git a/panda/src/bullet/bulletConvexPointCloudShape.h b/panda/src/bullet/bulletConvexPointCloudShape.h index 1f1cd52568..179dc65f9a 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.h +++ b/panda/src/bullet/bulletConvexPointCloudShape.h @@ -21,7 +21,7 @@ #include "bulletShape.h" #include "geom.h" -#include "pta_LVecBase3f.h" +#include "pta_LVecBase3.h" //////////////////////////////////////////////////////////////////// // Class : BulletConvexPointCloudShape diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 41d464dd7d..31ceea7daf 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -28,7 +28,7 @@ #include "boundingBox.h" #include "nurbsCurveEvaluator.h" #include "nurbsSurfaceEvaluator.h" -#include "pta_LVecBase3f.h" +#include "pta_LVecBase3.h" class BulletSoftBodyConfig; class BulletSoftBodyMaterial; diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index c48e5f648a..2dc5fb010a 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -24,7 +24,7 @@ #include "nodePath.h" #include "lpoint3.h" #include "geom.h" -#include "pta_LVecBase3f.h" +#include "pta_LVecBase3.h" #include "pta_int.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/chan/animBundle.I b/panda/src/chan/animBundle.I index a09f12c79f..df38d209cb 100644 --- a/panda/src/chan/animBundle.I +++ b/panda/src/chan/animBundle.I @@ -18,7 +18,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE AnimBundle:: -AnimBundle(const string &name, float fps, int num_frames) : AnimGroup(name) { +AnimBundle(const string &name, PN_stdfloat fps, int num_frames) : AnimGroup(name) { _fps = fps; _num_frames = num_frames; _root = this; diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index 7380d9147f..49c71fef97 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -89,7 +89,7 @@ make_copy(AnimGroup *parent) const { void AnimBundle:: write_datagram(BamWriter *manager, Datagram &me) { AnimGroup::write_datagram(manager, me); - me.add_float32(_fps); + me.add_stdfloat(_fps); me.add_uint16(_num_frames); } @@ -104,7 +104,7 @@ write_datagram(BamWriter *manager, Datagram &me) { void AnimBundle:: fillin(DatagramIterator &scan, BamReader *manager) { AnimGroup::fillin(scan, manager); - _fps = scan.get_float32(); + _fps = scan.get_stdfloat(); _num_frames = scan.get_uint16(); } diff --git a/panda/src/chan/animBundle.h b/panda/src/chan/animBundle.h index 3699b84fc3..5beff2b9b8 100644 --- a/panda/src/chan/animBundle.h +++ b/panda/src/chan/animBundle.h @@ -33,7 +33,7 @@ protected: AnimBundle(AnimGroup *parent, const AnimBundle ©); PUBLISHED: - INLINE AnimBundle(const string &name, float fps, int num_frames); + INLINE AnimBundle(const string &name, PN_stdfloat fps, int num_frames); PT(AnimBundle) copy_bundle() const; @@ -48,7 +48,7 @@ protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; private: - float _fps; + PN_stdfloat _fps; int _num_frames; public: diff --git a/panda/src/chan/animChannel.I b/panda/src/chan/animChannel.I index 582a2e0945..9f3d983de9 100644 --- a/panda/src/chan/animChannel.I +++ b/panda/src/chan/animChannel.I @@ -116,7 +116,7 @@ get_value_no_scale_shear(int frame, ValueType &value) { //////////////////////////////////////////////////////////////////// template void AnimChannel:: -get_scale(int, LVecBase3f &scale) { +get_scale(int, LVecBase3 &scale) { nassertv(false); } @@ -129,7 +129,7 @@ get_scale(int, LVecBase3f &scale) { //////////////////////////////////////////////////////////////////// template void AnimChannel:: -get_hpr(int, LVecBase3f &hpr) { +get_hpr(int, LVecBase3 &hpr) { nassertv(false); } @@ -142,7 +142,7 @@ get_hpr(int, LVecBase3f &hpr) { //////////////////////////////////////////////////////////////////// template void AnimChannel:: -get_quat(int, LQuaternionf &quat) { +get_quat(int, LQuaternion &quat) { nassertv(false); } @@ -155,7 +155,7 @@ get_quat(int, LQuaternionf &quat) { //////////////////////////////////////////////////////////////////// template void AnimChannel:: -get_pos(int, LVecBase3f &pos) { +get_pos(int, LVecBase3 &pos) { nassertv(false); } @@ -168,7 +168,7 @@ get_pos(int, LVecBase3f &pos) { //////////////////////////////////////////////////////////////////// template void AnimChannel:: -get_shear(int, LVecBase3f &shear) { +get_shear(int, LVecBase3 &shear) { nassertv(false); } diff --git a/panda/src/chan/animChannel.cxx b/panda/src/chan/animChannel.cxx index 24f2313c18..c85faed849 100644 --- a/panda/src/chan/animChannel.cxx +++ b/panda/src/chan/animChannel.cxx @@ -29,9 +29,9 @@ //////////////////////////////////////////////////////////////////// void ACMatrixSwitchType:: output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { - LVecBase3f scale, shear, hpr, translate; + LVecBase3 scale, shear, hpr, translate; if (decompose_matrix(value, scale, shear, hpr, translate)) { - if (!scale.almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f))) { + if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { if (IS_NEARLY_EQUAL(scale[0], scale[1]) && IS_NEARLY_EQUAL(scale[1], scale[2])) { out << " scale " << scale[0]; @@ -39,15 +39,15 @@ output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { out << " scale " << scale; } } - if (!shear.almost_equal(LVecBase3f(0.0f, 0.0f, 0.0f))) { + if (!shear.almost_equal(LVecBase3(0.0f, 0.0f, 0.0f))) { out << " shear " << shear; } - if (!hpr.almost_equal(LVecBase3f(0.0f, 0.0f, 0.0f))) { + if (!hpr.almost_equal(LVecBase3(0.0f, 0.0f, 0.0f))) { out << " hpr " << hpr; } - if (!translate.almost_equal(LVecBase3f(0.0f, 0.0f, 0.0f))) { + if (!translate.almost_equal(LVecBase3(0.0f, 0.0f, 0.0f))) { out << " trans " << translate; } diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index c58df62e27..408f356ecd 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -46,11 +46,11 @@ PUBLISHED: // These transform-component methods only have meaning for matrix types. virtual void get_value_no_scale_shear(int frame, ValueType &value); - virtual void get_scale(int frame, LVecBase3f &scale); - virtual void get_hpr(int frame, LVecBase3f &hpr); - virtual void get_quat(int frame, LQuaternionf &quat); - virtual void get_pos(int frame, LVecBase3f &pos); - virtual void get_shear(int frame, LVecBase3f &shear); + virtual void get_scale(int frame, LVecBase3 &scale); + virtual void get_hpr(int frame, LVecBase3 &hpr); + virtual void get_quat(int frame, LQuaternion &quat); + virtual void get_pos(int frame, LVecBase3 &pos); + virtual void get_shear(int frame, LVecBase3 &shear); virtual TypeHandle get_value_type() const; @@ -80,10 +80,10 @@ private: class EXPCL_PANDA_CHAN ACMatrixSwitchType { public: - typedef LMatrix4f ValueType; + typedef LMatrix4 ValueType; static const char *get_channel_type_name() { return "AnimChannelMatrix"; } - static const char *get_fixed_channel_type_name() { return "AnimChannelFixed"; } - static const char *get_part_type_name() { return "MovingPart"; } + static const char *get_fixed_channel_type_name() { return "AnimChannelFixed"; } + static const char *get_part_type_name() { return "MovingPart"; } static void output_value(ostream &out, const ValueType &value); static void write_datagram(Datagram &dest, ValueType& me) @@ -102,20 +102,20 @@ typedef AnimChannel AnimChannelMatrix; class EXPCL_PANDA_CHAN ACScalarSwitchType { public: - typedef float ValueType; + typedef PN_stdfloat ValueType; static const char *get_channel_type_name() { return "AnimChannelScalar"; } static const char *get_fixed_channel_type_name() { return "AnimChannelScalarFixed"; } - static const char *get_part_type_name() { return "MovingPart"; } + static const char *get_part_type_name() { return "MovingPart"; } static void output_value(ostream &out, ValueType value) { out << value; } static void write_datagram(Datagram &dest, ValueType& me) { - dest.add_float32(me); + dest.add_stdfloat(me); } static void read_datagram(DatagramIterator &source, ValueType& me) { - me = source.get_float32(); + me = source.get_stdfloat(); } }; diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index fd2e9b3b7f..a41fc3f99c 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -89,7 +89,7 @@ has_changed(int, double, int, double) { // Description: Gets the value of the channel at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_value(int, LMatrix4f &mat) { +get_value(int, LMatrix4 &mat) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -103,12 +103,12 @@ get_value(int, LMatrix4f &mat) { // without any scale or shear information. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_value_no_scale_shear(int, LMatrix4f &mat) { +get_value_no_scale_shear(int, LMatrix4 &mat) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } if (_value->has_scale() || _value->has_shear()) { - compose_matrix(mat, LVecBase3f(1.0f, 1.0f, 1.0f), + compose_matrix(mat, LVecBase3(1.0f, 1.0f, 1.0f), _value->get_hpr(), _value->get_pos()); } else { mat = _value->get_mat(); @@ -121,7 +121,7 @@ get_value_no_scale_shear(int, LMatrix4f &mat) { // Description: Gets the scale value at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_scale(int, LVecBase3f &scale) { +get_scale(int, LVecBase3 &scale) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -136,7 +136,7 @@ get_scale(int, LVecBase3f &scale) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_hpr(int, LVecBase3f &hpr) { +get_hpr(int, LVecBase3 &hpr) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -151,7 +151,7 @@ get_hpr(int, LVecBase3f &hpr) { // this only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_quat(int, LQuaternionf &quat) { +get_quat(int, LQuaternion &quat) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -166,7 +166,7 @@ get_quat(int, LQuaternionf &quat) { // only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_pos(int, LVecBase3f &pos) { +get_pos(int, LVecBase3 &pos) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -181,7 +181,7 @@ get_pos(int, LVecBase3f &pos) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -get_shear(int, LVecBase3f &shear) { +get_shear(int, LVecBase3 &shear) { if (_value_node != (PandaNode *)NULL) { _value = _value_node->get_transform(); } @@ -194,7 +194,7 @@ get_shear(int, LVecBase3f &shear) { // Description: Explicitly sets the matrix value. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixDynamic:: -set_value(const LMatrix4f &value) { +set_value(const LMatrix4 &value) { _value = TransformState::make_mat(value); _value_node.clear(); } diff --git a/panda/src/chan/animChannelMatrixDynamic.h b/panda/src/chan/animChannelMatrixDynamic.h index 705e4b2876..e71fcbd861 100644 --- a/panda/src/chan/animChannelMatrixDynamic.h +++ b/panda/src/chan/animChannelMatrixDynamic.h @@ -44,17 +44,17 @@ public: virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); - virtual void get_value(int frame, LMatrix4f &mat); + virtual void get_value(int frame, LMatrix4 &mat); - virtual void get_value_no_scale_shear(int frame, LMatrix4f &value); - virtual void get_scale(int frame, LVecBase3f &scale); - virtual void get_hpr(int frame, LVecBase3f &hpr); - virtual void get_quat(int frame, LQuaternionf &quat); - virtual void get_pos(int frame, LVecBase3f &pos); - virtual void get_shear(int frame, LVecBase3f &shear); + virtual void get_value_no_scale_shear(int frame, LMatrix4 &value); + virtual void get_scale(int frame, LVecBase3 &scale); + virtual void get_hpr(int frame, LVecBase3 &hpr); + virtual void get_quat(int frame, LQuaternion &quat); + virtual void get_pos(int frame, LVecBase3 &pos); + virtual void get_shear(int frame, LVecBase3 &shear); PUBLISHED: - void set_value(const LMatrix4f &value); + void set_value(const LMatrix4 &value); void set_value(const TransformState *value); void set_value_node(PandaNode *node); diff --git a/panda/src/chan/animChannelMatrixFixed.cxx b/panda/src/chan/animChannelMatrixFixed.cxx index 513d37a028..289d879bbc 100644 --- a/panda/src/chan/animChannelMatrixFixed.cxx +++ b/panda/src/chan/animChannelMatrixFixed.cxx @@ -40,7 +40,7 @@ AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : // Description: //////////////////////////////////////////////////////////////////// AnimChannelMatrixFixed:: -AnimChannelMatrixFixed(const string &name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) : +AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : AnimChannel(name), _pos(pos), _hpr(hpr), _scale(scale) { @@ -63,8 +63,8 @@ has_changed(int, double, int, double) { // Description: //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_value(int, LMatrix4f &value) { - compose_matrix(value, _scale, LVecBase3f::zero(), _hpr, _pos); +get_value(int, LMatrix4 &value) { + compose_matrix(value, _scale, LVecBase3::zero(), _hpr, _pos); } //////////////////////////////////////////////////////////////////// @@ -74,8 +74,8 @@ get_value(int, LMatrix4f &value) { // without any scale or shear information. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_value_no_scale_shear(int, LMatrix4f &mat) { - compose_matrix(mat, LVecBase3f(1.0f, 1.0f, 1.0f), LVecBase3f::zero(), +get_value_no_scale_shear(int, LMatrix4 &mat) { + compose_matrix(mat, LVecBase3(1.0f, 1.0f, 1.0f), LVecBase3::zero(), _hpr, _pos); } @@ -85,7 +85,7 @@ get_value_no_scale_shear(int, LMatrix4f &mat) { // Description: Gets the scale value at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_scale(int, LVecBase3f &scale) { +get_scale(int, LVecBase3 &scale) { scale = _scale; } @@ -97,7 +97,7 @@ get_scale(int, LVecBase3f &scale) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_hpr(int, LVecBase3f &hpr) { +get_hpr(int, LVecBase3 &hpr) { hpr = _hpr; } @@ -109,7 +109,7 @@ get_hpr(int, LVecBase3f &hpr) { // this only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_quat(int, LQuaternionf &quat) { +get_quat(int, LQuaternion &quat) { quat.set_hpr(_hpr); } @@ -121,7 +121,7 @@ get_quat(int, LQuaternionf &quat) { // only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_pos(int, LVecBase3f &pos) { +get_pos(int, LVecBase3 &pos) { pos = _pos; } @@ -133,8 +133,8 @@ get_pos(int, LVecBase3f &pos) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixFixed:: -get_shear(int, LVecBase3f &shear) { - shear = LVecBase3f::zero(); +get_shear(int, LVecBase3 &shear) { + shear = LVecBase3::zero(); } //////////////////////////////////////////////////////////////////// @@ -184,7 +184,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { //////////////////////////////////////////////////////////////////// TypedWritable *AnimChannelMatrixFixed:: make_from_bam(const FactoryParams ¶ms) { - AnimChannelMatrixFixed *chan = new AnimChannelMatrixFixed("", LVecBase3f::zero(), LVecBase3f::zero(), LVecBase3f::zero()); + AnimChannelMatrixFixed *chan = new AnimChannelMatrixFixed("", LVecBase3::zero(), LVecBase3::zero(), LVecBase3::zero()); DatagramIterator scan; BamReader *manager; diff --git a/panda/src/chan/animChannelMatrixFixed.h b/panda/src/chan/animChannelMatrixFixed.h index 2e5ce5c52f..b367df0105 100644 --- a/panda/src/chan/animChannelMatrixFixed.h +++ b/panda/src/chan/animChannelMatrixFixed.h @@ -32,22 +32,22 @@ protected: AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©); public: - AnimChannelMatrixFixed(const string &name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale); + AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); - virtual void get_value(int frame, LMatrix4f &value); - virtual void get_value_no_scale_shear(int frame, LMatrix4f &value); - virtual void get_scale(int frame, LVecBase3f &scale); - virtual void get_hpr(int frame, LVecBase3f &hpr); - virtual void get_quat(int frame, LQuaternionf &quat); - virtual void get_pos(int frame, LVecBase3f &pos); - virtual void get_shear(int frame, LVecBase3f &shear); + virtual void get_value(int frame, LMatrix4 &value); + virtual void get_value_no_scale_shear(int frame, LMatrix4 &value); + virtual void get_scale(int frame, LVecBase3 &scale); + virtual void get_hpr(int frame, LVecBase3 &hpr); + virtual void get_quat(int frame, LQuaternion &quat); + virtual void get_pos(int frame, LVecBase3 &pos); + virtual void get_shear(int frame, LVecBase3 &shear); virtual void output(ostream &out) const; private: - LVecBase3f _pos, _hpr, _scale; + LVecBase3 _pos, _hpr, _scale; public: static void register_with_read_factory(); diff --git a/panda/src/chan/animChannelMatrixXfmTable.I b/panda/src/chan/animChannelMatrixXfmTable.I index d11bb1faf4..0c0830fc54 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.I +++ b/panda/src/chan/animChannelMatrixXfmTable.I @@ -30,11 +30,11 @@ is_valid_id(char table_id) { // Description: Returns a pointer to the indicated subtable's data, // if it exists, or NULL if it does not. //////////////////////////////////////////////////////////////////// -INLINE CPTA_float AnimChannelMatrixXfmTable:: +INLINE CPTA_stdfloat AnimChannelMatrixXfmTable:: get_table(char table_id) const { int table_index = get_table_index(table_id); if (table_index < 0) { - return CPTA_float(get_class_type()); + return CPTA_stdfloat(get_class_type()); } return _tables[table_index]; } @@ -51,7 +51,7 @@ has_table(char table_id) const { if (table_index < 0) { return false; } - return !(_tables[table_index] == (const float *)NULL); + return !(_tables[table_index] == (const PN_stdfloat *)NULL); } //////////////////////////////////////////////////////////////////// @@ -88,7 +88,7 @@ get_table_id(int table_index) { // Description: Returns the default value the indicated table is // expected to have in the absence of any data. //////////////////////////////////////////////////////////////////// -INLINE float AnimChannelMatrixXfmTable:: +INLINE PN_stdfloat AnimChannelMatrixXfmTable:: get_default_value(int table_index) { nassertr(table_index >= 0 && table_index < num_matrix_components, 0.0); return matrix_component_defaults[table_index]; diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index 81deb2f7ac..af6ba5e1da 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -36,7 +36,7 @@ TypeHandle AnimChannelMatrixXfmTable::_type_handle; AnimChannelMatrixXfmTable:: AnimChannelMatrixXfmTable() { for (int i = 0; i < num_matrix_components; i++) { - _tables[i] = CPTA_float(get_class_type()); + _tables[i] = CPTA_stdfloat(get_class_type()); } } @@ -67,7 +67,7 @@ AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name) : AnimChannelMatrix(parent, name) { for (int i = 0; i < num_matrix_components; i++) { - _tables[i] = CPTA_float(get_class_type()); + _tables[i] = CPTA_stdfloat(get_class_type()); } } @@ -125,8 +125,8 @@ has_changed(int last_frame, double last_frac, // Description: Gets the value of the channel at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_value(int frame, LMatrix4f &mat) { - float components[num_matrix_components]; +get_value(int frame, LMatrix4 &mat) { + PN_stdfloat components[num_matrix_components]; for (int i = 0; i < num_matrix_components; i++) { if (_tables[i].empty()) { @@ -146,8 +146,8 @@ get_value(int frame, LMatrix4f &mat) { // without any scale or shear information. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_value_no_scale_shear(int frame, LMatrix4f &mat) { - float components[num_matrix_components]; +get_value_no_scale_shear(int frame, LMatrix4 &mat) { + PN_stdfloat components[num_matrix_components]; components[0] = 1.0f; components[1] = 1.0f; components[2] = 1.0f; @@ -172,7 +172,7 @@ get_value_no_scale_shear(int frame, LMatrix4f &mat) { // Description: Gets the scale value at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_scale(int frame, LVecBase3f &scale) { +get_scale(int frame, LVecBase3 &scale) { for (int i = 0; i < 3; i++) { if (_tables[i].empty()) { scale[i] = 1.0f; @@ -190,7 +190,7 @@ get_scale(int frame, LVecBase3f &scale) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_hpr(int frame, LVecBase3f &hpr) { +get_hpr(int frame, LVecBase3 &hpr) { for (int i = 0; i < 3; i++) { if (_tables[i + 6].empty()) { hpr[i] = 0.0f; @@ -208,8 +208,8 @@ get_hpr(int frame, LVecBase3f &hpr) { // this only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_quat(int frame, LQuaternionf &quat) { - LVecBase3f hpr; +get_quat(int frame, LQuaternion &quat) { + LVecBase3 hpr; for (int i = 0; i < 3; i++) { if (_tables[i + 6].empty()) { hpr[i] = 0.0f; @@ -229,7 +229,7 @@ get_quat(int frame, LQuaternionf &quat) { // only makes sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_pos(int frame, LVecBase3f &pos) { +get_pos(int frame, LVecBase3 &pos) { for (int i = 0; i < 3; i++) { if (_tables[i + 9].empty()) { pos[i] = 0.0f; @@ -247,7 +247,7 @@ get_pos(int frame, LVecBase3f &pos) { // sense for a matrix-type channel. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -get_shear(int frame, LVecBase3f &shear) { +get_shear(int frame, LVecBase3 &shear) { for (int i = 0; i < 3; i++) { if (_tables[i + 3].empty()) { shear[i] = 0.0f; @@ -267,7 +267,7 @@ get_shear(int frame, LVecBase3f &shear) { // one, or get_num_frames() frames. //////////////////////////////////////////////////////////////////// void AnimChannelMatrixXfmTable:: -set_table(char table_id, const CPTA_float &table) { +set_table(char table_id, const CPTA_stdfloat &table) { int num_frames = _root->get_num_frames(); if (table.size() > 1 && (int)table.size() < num_frames) { @@ -295,7 +295,7 @@ set_table(char table_id, const CPTA_float &table) { void AnimChannelMatrixXfmTable:: clear_all_tables() { for (int i = 0; i < num_matrix_components; i++) { - _tables[i] = CPTA_float(get_class_type()); + _tables[i] = CPTA_stdfloat(get_class_type()); } } @@ -388,7 +388,7 @@ write_datagram(BamWriter *manager, Datagram &me) { for (int i = 0; i < num_matrix_components; i++) { me.add_uint16(_tables[i].size()); for(int j = 0; j < (int)_tables[i].size(); j++) { - me.add_float32(_tables[i][j]); + me.add_stdfloat(_tables[i][j]); } } @@ -407,16 +407,16 @@ write_datagram(BamWriter *manager, Datagram &me) { // Now, write out the joint angles. For these we need to build up // a HPR array. - pvector hprs; + pvector hprs; int hprs_length = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size()); hprs.reserve(hprs_length); for (i = 0; i < hprs_length; i++) { - float h = _tables[6].empty() ? 0.0f : _tables[6][i % _tables[6].size()]; - float p = _tables[7].empty() ? 0.0f : _tables[7][i % _tables[7].size()]; - float r = _tables[8].empty() ? 0.0f : _tables[8][i % _tables[8].size()]; - hprs.push_back(LVecBase3f(h, p, r)); + PN_stdfloat h = _tables[6].empty() ? 0.0f : _tables[6][i % _tables[6].size()]; + PN_stdfloat p = _tables[7].empty() ? 0.0f : _tables[7][i % _tables[7].size()]; + PN_stdfloat r = _tables[8].empty() ? 0.0f : _tables[8][i % _tables[8].size()]; + hprs.push_back(LVecBase3(h, p, r)); } - const LVecBase3f *hprs_array = NULL; + const LVecBase3 *hprs_array = NULL; if (hprs_length != 0) { hprs_array = &hprs[0]; } @@ -450,9 +450,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (int i = 0; i < num_matrix_components; i++) { int size = scan.get_uint16(); - PTA_float ind_table(get_class_type()); + PTA_stdfloat ind_table(get_class_type()); for (int j = 0; j < size; j++) { - ind_table.push_back(scan.get_float32()); + ind_table.push_back(scan.get_stdfloat()); } _tables[i] = ind_table; } @@ -462,7 +462,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { size_t num_hprs = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size()); - LVecBase3f default_hpr(0.0, 0.0, 0.0); + LVecBase3 default_hpr(0.0, 0.0, 0.0); if (!_tables[6].empty()) { default_hpr[0] = _tables[6][0]; } @@ -473,20 +473,20 @@ fillin(DatagramIterator &scan, BamReader *manager) { default_hpr[2] = _tables[8][0]; } - PTA_float h_table = PTA_float::empty_array(num_hprs, get_class_type()); - PTA_float p_table = PTA_float::empty_array(num_hprs, get_class_type()); - PTA_float r_table = PTA_float::empty_array(num_hprs, get_class_type()); + PTA_stdfloat h_table = PTA_stdfloat::empty_array(num_hprs, get_class_type()); + PTA_stdfloat p_table = PTA_stdfloat::empty_array(num_hprs, get_class_type()); + PTA_stdfloat r_table = PTA_stdfloat::empty_array(num_hprs, get_class_type()); for (size_t hi = 0; hi < num_hprs; hi++) { - float h = (hi < _tables[6].size() ? _tables[6][hi] : default_hpr[0]); - float p = (hi < _tables[7].size() ? _tables[7][hi] : default_hpr[1]); - float r = (hi < _tables[8].size() ? _tables[8][hi] : default_hpr[2]); + PN_stdfloat h = (hi < _tables[6].size() ? _tables[6][hi] : default_hpr[0]); + PN_stdfloat p = (hi < _tables[7].size() ? _tables[7][hi] : default_hpr[1]); + PN_stdfloat r = (hi < _tables[8].size() ? _tables[8][hi] : default_hpr[2]); - LVecBase3f hpr; + LVecBase3 hpr; if (temp_hpr_fix) { - hpr = old_to_new_hpr(LVecBase3f(h, p, r)); + hpr = old_to_new_hpr(LVecBase3(h, p, r)); } else { - hpr = new_to_old_hpr(LVecBase3f(h, p, r)); + hpr = new_to_old_hpr(LVecBase3(h, p, r)); } h_table[hi] = hpr[0]; p_table[hi] = hpr[1]; @@ -512,29 +512,29 @@ fillin(DatagramIterator &scan, BamReader *manager) { int i; // First, read in the scales and shears. for (i = 0; i < 6; i++) { - PTA_float ind_table = PTA_float::empty_array(0, get_class_type()); + PTA_stdfloat ind_table = PTA_stdfloat::empty_array(0, get_class_type()); compressor.read_reals(scan, ind_table.v()); _tables[i] = ind_table; } // Read in the HPR array and store it back in the joint angles. - pvector hprs; + pvector hprs; compressor.read_hprs(scan, hprs, new_hpr); - PTA_float h_table = PTA_float::empty_array(hprs.size(), get_class_type()); - PTA_float p_table = PTA_float::empty_array(hprs.size(), get_class_type()); - PTA_float r_table = PTA_float::empty_array(hprs.size(), get_class_type()); + PTA_stdfloat h_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type()); + PTA_stdfloat p_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type()); + PTA_stdfloat r_table = PTA_stdfloat::empty_array(hprs.size(), get_class_type()); for (i = 0; i < (int)hprs.size(); i++) { if (!new_hpr && temp_hpr_fix) { // Convert the old HPR form to the new HPR form. - LVecBase3f hpr = old_to_new_hpr(hprs[i]); + LVecBase3 hpr = old_to_new_hpr(hprs[i]); h_table[i] = hpr[0]; p_table[i] = hpr[1]; r_table[i] = hpr[2]; } else if (new_hpr && !temp_hpr_fix) { // Convert the new HPR form to the old HPR form. - LVecBase3f hpr = new_to_old_hpr(hprs[i]); + LVecBase3 hpr = new_to_old_hpr(hprs[i]); h_table[i] = hpr[0]; p_table[i] = hpr[1]; r_table[i] = hpr[2]; @@ -552,7 +552,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { // Now read in the translations. for (i = 9; i < num_matrix_components; i++) { - PTA_float ind_table = PTA_float::empty_array(0, get_class_type()); + PTA_stdfloat ind_table = PTA_stdfloat::empty_array(0, get_class_type()); compressor.read_reals(scan, ind_table.v()); _tables[i] = ind_table; } diff --git a/panda/src/chan/animChannelMatrixXfmTable.h b/panda/src/chan/animChannelMatrixXfmTable.h index 3ebade9078..0198e68726 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.h +++ b/panda/src/chan/animChannelMatrixXfmTable.h @@ -20,7 +20,7 @@ #include "animChannel.h" #include "pointerToArray.h" -#include "pta_float.h" +#include "pta_stdfloat.h" #include "compose_matrix.h" //////////////////////////////////////////////////////////////////// @@ -43,20 +43,20 @@ PUBLISHED: public: virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); - virtual void get_value(int frame, LMatrix4f &mat); + virtual void get_value(int frame, LMatrix4 &mat); - virtual void get_value_no_scale_shear(int frame, LMatrix4f &value); - virtual void get_scale(int frame, LVecBase3f &scale); - virtual void get_hpr(int frame, LVecBase3f &hpr); - virtual void get_quat(int frame, LQuaternionf &quat); - virtual void get_pos(int frame, LVecBase3f &pos); - virtual void get_shear(int frame, LVecBase3f &shear); + virtual void get_value_no_scale_shear(int frame, LMatrix4 &value); + virtual void get_scale(int frame, LVecBase3 &scale); + virtual void get_hpr(int frame, LVecBase3 &hpr); + virtual void get_quat(int frame, LQuaternion &quat); + virtual void get_pos(int frame, LVecBase3 &pos); + virtual void get_shear(int frame, LVecBase3 &shear); PUBLISHED: static INLINE bool is_valid_id(char table_id); - void set_table(char table_id, const CPTA_float &table); - INLINE CPTA_float get_table(char table_id) const; + void set_table(char table_id, const CPTA_stdfloat &table); + INLINE CPTA_stdfloat get_table(char table_id) const; void clear_all_tables(); INLINE bool has_table(char table_id) const; @@ -70,9 +70,9 @@ protected: INLINE static char get_table_id(int table_index); static int get_table_index(char table_id); - INLINE static float get_default_value(int table_index); + INLINE static PN_stdfloat get_default_value(int table_index); - CPTA_float _tables[num_matrix_components]; + CPTA_stdfloat _tables[num_matrix_components]; public: static void register_with_read_factory(); diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index a287aa2ecd..bcfc8011d3 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -96,7 +96,7 @@ has_changed(int, double, int, double) { // Description: Gets the value of the channel at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelScalarDynamic:: -get_value(int, float &value) { +get_value(int, PN_stdfloat &value) { if (_value_node != (PandaNode *)NULL) { value = _value->get_pos()[0]; @@ -111,7 +111,7 @@ get_value(int, float &value) { // Description: Explicitly sets the value. //////////////////////////////////////////////////////////////////// void AnimChannelScalarDynamic:: -set_value(float value) { +set_value(PN_stdfloat value) { _float_value = value; _value_node.clear(); _value_changed = true; @@ -127,7 +127,7 @@ set_value(float value) { void AnimChannelScalarDynamic:: set_value_node(PandaNode *value_node) { if (_value_node == (PandaNode *)NULL) { - _last_value = TransformState::make_pos(LVecBase3f(_float_value, 0.0f, 0.0f)); + _last_value = TransformState::make_pos(LVecBase3(_float_value, 0.0f, 0.0f)); } _value_node = value_node; @@ -162,7 +162,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { AnimChannelScalar::write_datagram(manager, dg); manager->write_pointer(dg, _value_node); manager->write_pointer(dg, _value); - dg.add_float32(_float_value); + dg.add_stdfloat(_float_value); } //////////////////////////////////////////////////////////////////// @@ -199,7 +199,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); manager->read_pointer(scan); - _float_value = scan.get_float32(); + _float_value = scan.get_stdfloat(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/chan/animChannelScalarDynamic.h b/panda/src/chan/animChannelScalarDynamic.h index 085ad69d9b..fc4a914d84 100644 --- a/panda/src/chan/animChannelScalarDynamic.h +++ b/panda/src/chan/animChannelScalarDynamic.h @@ -44,10 +44,10 @@ public: virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); - virtual void get_value(int frame, float &value); + virtual void get_value(int frame, PN_stdfloat &value); PUBLISHED: - void set_value(float value); + void set_value(PN_stdfloat value); void set_value_node(PandaNode *node); protected: @@ -64,7 +64,7 @@ private: // This is used only if we are using the explicit set_value() // interface. bool _value_changed; - float _float_value; + PN_stdfloat _float_value; public: static void register_with_read_factory(); diff --git a/panda/src/chan/animChannelScalarTable.I b/panda/src/chan/animChannelScalarTable.I index b9b65cc635..586e2c2e59 100644 --- a/panda/src/chan/animChannelScalarTable.I +++ b/panda/src/chan/animChannelScalarTable.I @@ -19,7 +19,7 @@ // Description: Returns a pointer to the table's data, // if it exists, or NULL if it does not. //////////////////////////////////////////////////////////////////// -INLINE CPTA_float AnimChannelScalarTable:: +INLINE CPTA_stdfloat AnimChannelScalarTable:: get_table() const { return _table; } @@ -31,7 +31,7 @@ get_table() const { //////////////////////////////////////////////////////////////////// INLINE bool AnimChannelScalarTable:: has_table() const { - return _table != (const float *)NULL; + return _table != (const PN_stdfloat *)NULL; } diff --git a/panda/src/chan/animChannelScalarTable.cxx b/panda/src/chan/animChannelScalarTable.cxx index 7b39562fc0..0290a649ca 100644 --- a/panda/src/chan/animChannelScalarTable.cxx +++ b/panda/src/chan/animChannelScalarTable.cxx @@ -99,7 +99,7 @@ has_changed(int last_frame, double last_frac, // Description: Gets the value of the channel at the indicated frame. //////////////////////////////////////////////////////////////////// void AnimChannelScalarTable:: -get_value(int frame, float &value) { +get_value(int frame, PN_stdfloat &value) { if (_table.empty()) { value = 0.0f; } else { @@ -114,7 +114,7 @@ get_value(int frame, float &value) { // Description: Assigns the data table. //////////////////////////////////////////////////////////////////// void AnimChannelScalarTable:: -set_table(const CPTA_float &table) { +set_table(const CPTA_stdfloat &table) { int num_frames = _root->get_num_frames(); if (table.size() > 1 && (int)table.size() < num_frames) { @@ -181,7 +181,7 @@ write_datagram(BamWriter *manager, Datagram &me) { // Write out everything the old way, as floats. me.add_uint16(_table.size()); for(int i = 0; i < (int)_table.size(); i++) { - me.add_float32(_table[i]); + me.add_stdfloat(_table[i]); } } else { @@ -193,7 +193,7 @@ write_datagram(BamWriter *manager, Datagram &me) { // only to the nearest 1000th for this purpose, because floats // aren't very good at being precisely equal to each other. static const int max_values = 16; - static const float scale = 1000.0f; + static const PN_stdfloat scale = 1000.0f; pmap index; int i; @@ -213,17 +213,17 @@ write_datagram(BamWriter *manager, Datagram &me) { if (index_length > 0) { // We need to write the index in order by its index number; for // this, we need to invert the index. - vector_float reverse_index(index_length); + vector_stdfloat reverse_index(index_length); pmap::iterator mi; for (mi = index.begin(); mi != index.end(); ++mi) { - float f = (float)(*mi).first / scale; + PN_stdfloat f = (PN_stdfloat)(*mi).first / scale; int i = (*mi).second; nassertv(i >= 0 && i < (int)reverse_index.size()); reverse_index[i] = f; } for (i = 0; i < index_length; i++) { - me.add_float32(reverse_index[i]); + me.add_stdfloat(reverse_index[i]); } // Now write out the actual channels. We write these two at a @@ -284,13 +284,13 @@ fillin(DatagramIterator& scan, BamReader* manager) { bool wrote_compressed = scan.get_bool(); - PTA_float temp_table = PTA_float::empty_array(0, get_class_type()); + PTA_stdfloat temp_table = PTA_stdfloat::empty_array(0, get_class_type()); if (!wrote_compressed) { // Regular floats. int size = scan.get_uint16(); for(int i = 0; i < size; i++) { - temp_table.push_back(scan.get_float32()); + temp_table.push_back(scan.get_stdfloat()); } } else { @@ -301,11 +301,11 @@ fillin(DatagramIterator& scan, BamReader* manager) { if (index_length < 0xff) { // Discrete. Read in the index. if (index_length > 0) { - float *index = (float *)alloca(index_length * sizeof(float)); + PN_stdfloat *index = (PN_stdfloat *)alloca(index_length * sizeof(PN_stdfloat)); int i; for (i = 0; i < index_length; i++) { - index[i] = scan.get_float32(); + index[i] = scan.get_stdfloat(); } // Now read in the channel values. diff --git a/panda/src/chan/animChannelScalarTable.h b/panda/src/chan/animChannelScalarTable.h index 23090f52d0..5b18307466 100644 --- a/panda/src/chan/animChannelScalarTable.h +++ b/panda/src/chan/animChannelScalarTable.h @@ -20,7 +20,7 @@ #include "animChannel.h" #include "pointerToArray.h" -#include "pta_float.h" +#include "pta_stdfloat.h" //////////////////////////////////////////////////////////////////// // Class : AnimChannelScalarTable @@ -38,11 +38,11 @@ public: virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); - virtual void get_value(int frame, float &value); + virtual void get_value(int frame, PN_stdfloat &value); PUBLISHED: - void set_table(const CPTA_float &table); - INLINE CPTA_float get_table() const; + void set_table(const CPTA_stdfloat &table); + INLINE CPTA_stdfloat get_table() const; INLINE bool has_table() const; INLINE void clear_table(); @@ -54,7 +54,7 @@ protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; protected: - CPTA_float _table; + CPTA_stdfloat _table; public: static void register_with_read_factory(); diff --git a/panda/src/chan/animPreloadTable.I b/panda/src/chan/animPreloadTable.I index 2f429a0316..1907da6637 100644 --- a/panda/src/chan/animPreloadTable.I +++ b/panda/src/chan/animPreloadTable.I @@ -51,7 +51,7 @@ get_basename(int n) const { // Description: Returns the frame rate stored for the nth animation // record. //////////////////////////////////////////////////////////////////// -INLINE float AnimPreloadTable:: +INLINE PN_stdfloat AnimPreloadTable:: get_base_frame_rate(int n) const { nassertr(n >= 0 && n < (int)_anims.size(), 0.0f); consider_sort(); diff --git a/panda/src/chan/animPreloadTable.cxx b/panda/src/chan/animPreloadTable.cxx index adfff95096..ee8a57732e 100644 --- a/panda/src/chan/animPreloadTable.cxx +++ b/panda/src/chan/animPreloadTable.cxx @@ -116,7 +116,7 @@ remove_anim(int n) { // numbers. //////////////////////////////////////////////////////////////////// void AnimPreloadTable:: -add_anim(const string &basename, float base_frame_rate, int num_frames) { +add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames) { AnimRecord record; record._basename = basename; record._base_frame_rate = base_frame_rate; @@ -198,7 +198,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { for (ai = _anims.begin(); ai != _anims.end(); ++ai) { const AnimRecord &record = (*ai); dg.add_string(record._basename); - dg.add_float32(record._base_frame_rate); + dg.add_stdfloat(record._base_frame_rate); dg.add_int32(record._num_frames); } } @@ -234,7 +234,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (int i = 0; i < num_anims; ++i) { AnimRecord record; record._basename = scan.get_string(); - record._base_frame_rate = scan.get_float32(); + record._base_frame_rate = scan.get_stdfloat(); record._num_frames = scan.get_int32(); _anims.push_back(record); } diff --git a/panda/src/chan/animPreloadTable.h b/panda/src/chan/animPreloadTable.h index 8289583a1c..44dda276e1 100644 --- a/panda/src/chan/animPreloadTable.h +++ b/panda/src/chan/animPreloadTable.h @@ -44,7 +44,7 @@ public: INLINE bool operator < (const AnimRecord &other) const; string _basename; - float _base_frame_rate; + PN_stdfloat _base_frame_rate; int _num_frames; }; @@ -59,12 +59,12 @@ PUBLISHED: int find_anim(const string &basename) const; INLINE string get_basename(int n) const; - INLINE float get_base_frame_rate(int n) const; + INLINE PN_stdfloat get_base_frame_rate(int n) const; INLINE int get_num_frames(int n) const; void clear_anims(); void remove_anim(int n); - void add_anim(const string &basename, float base_frame_rate, int num_frames); + void add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames); void add_anims_from(const AnimPreloadTable *other); virtual void output(ostream &out) const; diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 69b3e7c351..8d35a75f49 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -128,7 +128,7 @@ ConfigureFn(config_chan) { // be initialized. We have to do it explicitly here since template // statics don't necessarily resolve very well across dynamic // libraries. - LMatrix4f::init_type(); + LMatrix4::init_type(); //Registration of writeable object's creation //functions with BamReader's factory diff --git a/panda/src/chan/movingPartMatrix.I b/panda/src/chan/movingPartMatrix.I index 90e4598e33..af12e643dc 100644 --- a/panda/src/chan/movingPartMatrix.I +++ b/panda/src/chan/movingPartMatrix.I @@ -32,7 +32,7 @@ MovingPartMatrix(const MovingPartMatrix ©) : //////////////////////////////////////////////////////////////////// INLINE MovingPartMatrix:: MovingPartMatrix(PartGroup *parent, const string &name, - const LMatrix4f &default_value) + const LMatrix4 &default_value) : MovingPart(parent, name, default_value) { } diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index 760077964d..ad9b836fcf 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -48,7 +48,7 @@ MovingPartMatrix:: //////////////////////////////////////////////////////////////////// AnimChannelBase *MovingPartMatrix:: make_default_channel() const { - LVecBase3f pos, hpr, scale, shear; + LVecBase3 pos, hpr, scale, shear; decompose_matrix(_default_value, pos, hpr, scale, shear); return new AnimChannelMatrixFixed(get_name(), pos, hpr, scale); } @@ -93,13 +93,13 @@ get_blend_value(const PartBundle *root) { case PartBundle::BT_linear: { // An ordinary, linear blend. - LMatrix4f net_value = LMatrix4f::zeros_mat(); - float net_effect = 0.0f; + LMatrix4 net_value = LMatrix4::zeros_mat(); + PN_stdfloat net_effect = 0.0f; PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); int channel_index = control->get_channel_index(); @@ -114,7 +114,7 @@ get_blend_value(const PartBundle *root) { net_value += v * effect; } else { // Blend between successive frames. - float frac = (float)control->get_frac(); + PN_stdfloat frac = (PN_stdfloat)control->get_frac(); net_value += v * (effect * (1.0f - frac)); channel->get_value(control->get_next_frame(), v); @@ -142,15 +142,15 @@ get_blend_value(const PartBundle *root) { // artificially-introduced scales, and then reapply the // scales and shears. - LMatrix4f net_value = LMatrix4f::zeros_mat(); - LVecBase3f scale(0.0f, 0.0f, 0.0f); - LVecBase3f shear(0.0f, 0.0f, 0.0f); - float net_effect = 0.0f; + LMatrix4 net_value = LMatrix4::zeros_mat(); + LVecBase3 scale(0.0f, 0.0f, 0.0f); + LVecBase3 shear(0.0f, 0.0f, 0.0f); + PN_stdfloat net_effect = 0.0f; PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); ChannelType *channel = NULL; @@ -161,7 +161,7 @@ get_blend_value(const PartBundle *root) { if (channel != (ChannelType *)NULL) { int frame = control->get_frame(); ValueType v; - LVecBase3f iscale, ishear; + LVecBase3 iscale, ishear; channel->get_value_no_scale_shear(frame, v); channel->get_scale(frame, iscale); channel->get_shear(frame, ishear); @@ -173,8 +173,8 @@ get_blend_value(const PartBundle *root) { shear += ishear * effect; } else { // Blend between successive frames. - float frac = (float)control->get_frac(); - float e0 = effect * (1.0f - frac); + PN_stdfloat frac = (PN_stdfloat)control->get_frac(); + PN_stdfloat e0 = effect * (1.0f - frac); net_value += v * e0; scale += iscale * e0; shear += ishear * e0; @@ -183,7 +183,7 @@ get_blend_value(const PartBundle *root) { channel->get_value_no_scale_shear(next_frame, v); channel->get_scale(next_frame, iscale); channel->get_shear(next_frame, ishear); - float e1 = effect * frac; + PN_stdfloat e1 = effect * frac; net_value += v * e1; scale += iscale * e1; shear += ishear * e1; @@ -204,7 +204,7 @@ get_blend_value(const PartBundle *root) { // Now rebuild the matrix with the correct scale values. - LVector3f false_scale, false_shear, hpr, translate; + LVector3 false_scale, false_shear, hpr, translate; decompose_matrix(net_value, false_scale, false_shear, hpr, translate); compose_matrix(_value, scale, shear, hpr, translate); } @@ -214,16 +214,16 @@ get_blend_value(const PartBundle *root) { case PartBundle::BT_componentwise: { // Componentwise linear, including componentwise H, P, and R. - LVecBase3f scale(0.0f, 0.0f, 0.0f); - LVecBase3f hpr(0.0f, 0.0f, 0.0f); - LVecBase3f pos(0.0f, 0.0f, 0.0f); - LVecBase3f shear(0.0f, 0.0f, 0.0f); - float net_effect = 0.0f; + LVecBase3 scale(0.0f, 0.0f, 0.0f); + LVecBase3 hpr(0.0f, 0.0f, 0.0f); + LVecBase3 pos(0.0f, 0.0f, 0.0f); + LVecBase3 shear(0.0f, 0.0f, 0.0f); + PN_stdfloat net_effect = 0.0f; PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); ChannelType *channel = NULL; @@ -233,7 +233,7 @@ get_blend_value(const PartBundle *root) { } if (channel != (ChannelType *)NULL) { int frame = control->get_frame(); - LVecBase3f iscale, ihpr, ipos, ishear; + LVecBase3 iscale, ihpr, ipos, ishear; channel->get_scale(frame, iscale); channel->get_hpr(frame, ihpr); channel->get_pos(frame, ipos); @@ -247,8 +247,8 @@ get_blend_value(const PartBundle *root) { shear += ishear * effect; } else { // Blend between successive frames. - float frac = (float)control->get_frac(); - float e0 = effect * (1.0f - frac); + PN_stdfloat frac = (PN_stdfloat)control->get_frac(); + PN_stdfloat e0 = effect * (1.0f - frac); scale += iscale * e0; hpr += ihpr * e0; @@ -260,7 +260,7 @@ get_blend_value(const PartBundle *root) { channel->get_hpr(next_frame, ihpr); channel->get_pos(next_frame, ipos); channel->get_shear(next_frame, ishear); - float e1 = effect * frac; + PN_stdfloat e1 = effect * frac; scale += iscale * e1; hpr += ihpr * e1; @@ -291,16 +291,16 @@ get_blend_value(const PartBundle *root) { { // Componentwise linear, except for rotation, which is a // quaternion. - LVecBase3f scale(0.0f, 0.0f, 0.0f); - LQuaternionf quat(0.0f, 0.0f, 0.0f, 0.0f); - LVecBase3f pos(0.0f, 0.0f, 0.0f); - LVecBase3f shear(0.0f, 0.0f, 0.0f); - float net_effect = 0.0f; + LVecBase3 scale(0.0f, 0.0f, 0.0f); + LQuaternion quat(0.0f, 0.0f, 0.0f, 0.0f); + LVecBase3 pos(0.0f, 0.0f, 0.0f); + LVecBase3 shear(0.0f, 0.0f, 0.0f); + PN_stdfloat net_effect = 0.0f; PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); ChannelType *channel = NULL; @@ -310,8 +310,8 @@ get_blend_value(const PartBundle *root) { } if (channel != (ChannelType *)NULL) { int frame = control->get_frame(); - LVecBase3f iscale, ipos, ishear; - LQuaternionf iquat; + LVecBase3 iscale, ipos, ishear; + LQuaternion iquat; channel->get_scale(frame, iscale); channel->get_quat(frame, iquat); channel->get_pos(frame, ipos); @@ -326,8 +326,8 @@ get_blend_value(const PartBundle *root) { } else { // Blend between successive frames. - float frac = (float)control->get_frac(); - float e0 = effect * (1.0f - frac); + PN_stdfloat frac = (PN_stdfloat)control->get_frac(); + PN_stdfloat e0 = effect * (1.0f - frac); scale += iscale * e0; quat += iquat * e0; @@ -339,7 +339,7 @@ get_blend_value(const PartBundle *root) { channel->get_quat(next_frame, iquat); channel->get_pos(next_frame, ipos); channel->get_shear(next_frame, ishear); - float e1 = effect * frac; + PN_stdfloat e1 = effect * frac; scale += iscale * e1; quat += iquat * e1; @@ -365,7 +365,7 @@ get_blend_value(const PartBundle *root) { // assuming all of the input quaternions were already // normalized. - _value = LMatrix4f::scale_shear_mat(scale, shear) * quat; + _value = LMatrix4::scale_shear_mat(scale, shear) * quat; _value.set_row(3, pos); } } @@ -384,7 +384,7 @@ get_blend_value(const PartBundle *root) { // PartBundle::freeze_joint(). //////////////////////////////////////////////////////////////////// bool MovingPartMatrix:: -apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) { +apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { _forced_channel = new AnimChannelMatrixFixed(get_name(), pos, hpr, scale); return true; } diff --git a/panda/src/chan/movingPartMatrix.h b/panda/src/chan/movingPartMatrix.h index 909b83b9c1..3c32aadd33 100644 --- a/panda/src/chan/movingPartMatrix.h +++ b/panda/src/chan/movingPartMatrix.h @@ -35,13 +35,13 @@ protected: public: INLINE MovingPartMatrix(PartGroup *parent, const string &name, - const LMatrix4f &default_value); + const LMatrix4 &default_value); virtual ~MovingPartMatrix(); virtual AnimChannelBase *make_default_channel() const; virtual void get_blend_value(const PartBundle *root); - virtual bool apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale); + virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); virtual bool apply_control(PandaNode *node); protected: diff --git a/panda/src/chan/movingPartScalar.I b/panda/src/chan/movingPartScalar.I index c42eb7526f..51d28abb35 100644 --- a/panda/src/chan/movingPartScalar.I +++ b/panda/src/chan/movingPartScalar.I @@ -32,7 +32,7 @@ MovingPartScalar(const MovingPartScalar ©) : //////////////////////////////////////////////////////////////////// INLINE MovingPartScalar:: MovingPartScalar(PartGroup *parent, const string &name, - const float &default_value) + const PN_stdfloat &default_value) : MovingPart(parent, name, default_value) { } diff --git a/panda/src/chan/movingPartScalar.cxx b/panda/src/chan/movingPartScalar.cxx index b2291f8a4a..4fc34e79dc 100644 --- a/panda/src/chan/movingPartScalar.cxx +++ b/panda/src/chan/movingPartScalar.cxx @@ -71,12 +71,12 @@ get_blend_value(const PartBundle *root) { } else { // A blend of two or more values. _value = 0.0f; - float net = 0.0f; + PN_stdfloat net = 0.0f; PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); ChannelType *channel = NULL; @@ -93,7 +93,7 @@ get_blend_value(const PartBundle *root) { _value += v * effect; } else { // Blend between successive frames. - float frac = (float)control->get_frac(); + PN_stdfloat frac = (PN_stdfloat)control->get_frac(); _value += v * (effect * (1.0f - frac)); channel->get_value(control->get_next_frame(), v); @@ -124,7 +124,7 @@ get_blend_value(const PartBundle *root) { // PartBundle::freeze_joint(). //////////////////////////////////////////////////////////////////// bool MovingPartScalar:: -apply_freeze_scalar(float value) { +apply_freeze_scalar(PN_stdfloat value) { _forced_channel = new AnimChannelFixed(get_name(), value); return true; } diff --git a/panda/src/chan/movingPartScalar.h b/panda/src/chan/movingPartScalar.h index 5f27941f7b..9dd41d4ccc 100644 --- a/panda/src/chan/movingPartScalar.h +++ b/panda/src/chan/movingPartScalar.h @@ -34,12 +34,12 @@ protected: public: INLINE MovingPartScalar(PartGroup *parent, const string &name, - const float &default_value = 0); + const PN_stdfloat &default_value = 0); virtual ~MovingPartScalar(); virtual void get_blend_value(const PartBundle *root); - virtual bool apply_freeze_scalar(float value); + virtual bool apply_freeze_scalar(PN_stdfloat value); virtual bool apply_control(PandaNode *node); protected: diff --git a/panda/src/chan/partBundle.I b/panda/src/chan/partBundle.I index 090f441f9c..ab3af47d6e 100644 --- a/panda/src/chan/partBundle.I +++ b/panda/src/chan/partBundle.I @@ -154,7 +154,7 @@ get_frame_blend_flag() const { // applied at the root of the animated hierarchy. //////////////////////////////////////////////////////////////////// INLINE void PartBundle:: -set_root_xform(const LMatrix4f &root_xform) { +set_root_xform(const LMatrix4 &root_xform) { nassertv(Thread::get_current_pipeline_stage() == 0); CDWriter cdata(_cycler); cdata->_root_xform = root_xform; @@ -168,7 +168,7 @@ set_root_xform(const LMatrix4f &root_xform) { // animated hierarchy. //////////////////////////////////////////////////////////////////// INLINE void PartBundle:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(Thread::get_current_pipeline_stage() == 0); CDWriter cdata(_cycler); cdata->_root_xform = cdata->_root_xform * mat; @@ -182,7 +182,7 @@ xform(const LMatrix4f &mat) { // Description: Returns the transform matrix which is implicitly // applied at the root of the animated hierarchy. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &PartBundle:: +INLINE const LMatrix4 &PartBundle:: get_root_xform() const { CDReader cdata(_cycler); return cdata->_root_xform; @@ -229,7 +229,7 @@ get_node(int n) const { // animation. //////////////////////////////////////////////////////////////////// void PartBundle:: -set_control_effect(AnimControl *control, float effect) { +set_control_effect(AnimControl *control, PN_stdfloat effect) { nassertv(Thread::get_current_pipeline_stage() == 0); CDWriter cdata(_cycler); @@ -243,7 +243,7 @@ set_control_effect(AnimControl *control, float effect) { // by the indicated AnimControl and its associated // animation. See set_control_effect(). //////////////////////////////////////////////////////////////////// -INLINE float PartBundle:: +INLINE PN_stdfloat PartBundle:: get_control_effect(AnimControl *control) const { CDReader cdata(_cycler); return do_get_control_effect(control, cdata); diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 948fc7cdda..11a9edcaaf 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -356,7 +356,7 @@ load_bind_anim(Loader *loader, const Filename &filename, // The animation is present in the table, so we can perform an // asynchronous load-and-bind. - float frame_rate = anim_preload->get_base_frame_rate(anim_index); + PN_stdfloat frame_rate = anim_preload->get_base_frame_rate(anim_index); int num_frames = anim_preload->get_num_frames(anim_index); PT(AnimControl) control = new AnimControl(basename, this, frame_rate, num_frames); @@ -394,7 +394,7 @@ wait_pending() { cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; - float effect = (*cbi).second; + PN_stdfloat effect = (*cbi).second; if (effect != 0.0f) { control->wait_pending(); } @@ -441,7 +441,7 @@ freeze_joint(const string &joint_name, const TransformState *transform) { // or does not exist. //////////////////////////////////////////////////////////////////// bool PartBundle:: -freeze_joint(const string &joint_name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) { +freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { PartGroup *child = find_child(joint_name); if (child == (PartGroup *)NULL) { return false; @@ -467,7 +467,7 @@ freeze_joint(const string &joint_name, const LVecBase3f &pos, const LVecBase3f & // or does not exist. //////////////////////////////////////////////////////////////////// bool PartBundle:: -freeze_joint(const string &joint_name, float value) { +freeze_joint(const string &joint_name, PN_stdfloat value) { PartGroup *child = find_child(joint_name); if (child == (PartGroup *)NULL) { return false; @@ -709,7 +709,7 @@ remove_node(PartBundleNode *node) { // Description: The private implementation of set_control_effect(). //////////////////////////////////////////////////////////////////// void PartBundle:: -do_set_control_effect(AnimControl *control, float effect, CData *cdata) { +do_set_control_effect(AnimControl *control, PN_stdfloat effect, CData *cdata) { nassertv(control->get_part() == this); if (effect == 0.0f) { @@ -744,7 +744,7 @@ do_set_control_effect(AnimControl *control, float effect, CData *cdata) { // Access: Private // Description: The private implementation of get_control_effect(). //////////////////////////////////////////////////////////////////// -float PartBundle:: +PN_stdfloat PartBundle:: do_get_control_effect(AnimControl *control, const CData *cdata) const { nassertr(control->get_part() == this, 0.0f); @@ -920,7 +920,7 @@ CData() { _blend_type = anim_blend_type; _anim_blend_flag = false; _frame_blend_flag = interpolate_frames; - _root_xform = LMatrix4f::ident_mat(); + _root_xform = LMatrix4::ident_mat(); _last_control_set = NULL; _net_blend = 0.0f; _anim_changed = false; diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index a8441c21c0..d4d46f5816 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -51,7 +51,7 @@ public: // This is passed down through the MovingParts during the // do_update() call to specify the channels that are in effect. - typedef pmap ChannelBlend; + typedef pmap ChannelBlend; protected: // The copy constructor is protected; use make_copy() or copy_subgraph(). @@ -109,9 +109,9 @@ PUBLISHED: INLINE void set_frame_blend_flag(bool frame_blend_flag); INLINE bool get_frame_blend_flag() const; - INLINE void set_root_xform(const LMatrix4f &root_xform); - INLINE void xform(const LMatrix4f &mat); - INLINE const LMatrix4f &get_root_xform() const; + INLINE void set_root_xform(const LMatrix4 &root_xform); + INLINE void xform(const LMatrix4 &mat); + INLINE const LMatrix4 &get_root_xform() const; PT(PartBundle) apply_transform(const TransformState *transform); INLINE int get_num_nodes() const; @@ -119,8 +119,8 @@ PUBLISHED: MAKE_SEQ(get_nodes, get_num_nodes, get_node); void clear_control_effects(); - INLINE void set_control_effect(AnimControl *control, float effect); - INLINE float get_control_effect(AnimControl *control) const; + INLINE void set_control_effect(AnimControl *control, PN_stdfloat effect); + INLINE PN_stdfloat get_control_effect(AnimControl *control) const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level) const; @@ -136,8 +136,8 @@ PUBLISHED: void wait_pending(); bool freeze_joint(const string &joint_name, const TransformState *transform); - bool freeze_joint(const string &joint_name, const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale); - bool freeze_joint(const string &joint_name, float value); + bool freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); + bool freeze_joint(const string &joint_name, PN_stdfloat value); bool control_joint(const string &joint_name, PandaNode *node); bool release_joint(const string &joint_name); @@ -161,8 +161,8 @@ protected: private: class CData; - void do_set_control_effect(AnimControl *control, float effect, CData *cdata); - float do_get_control_effect(AnimControl *control, const CData *cdata) const; + void do_set_control_effect(AnimControl *control, PN_stdfloat effect, CData *cdata); + PN_stdfloat do_get_control_effect(AnimControl *control, const CData *cdata) const; void recompute_net_blend(CData *cdata); void clear_and_stop_intersecting(AnimControl *control, CData *cdata); @@ -192,10 +192,10 @@ private: BlendType _blend_type; bool _anim_blend_flag; bool _frame_blend_flag; - LMatrix4f _root_xform; + LMatrix4 _root_xform; AnimControl *_last_control_set; ChannelBlend _blend; - float _net_blend; + PN_stdfloat _net_blend; bool _anim_changed; double _last_update; }; diff --git a/panda/src/chan/partBundleNode.cxx b/panda/src/chan/partBundleNode.cxx index 5f5ff3dc0e..60508d7d01 100644 --- a/panda/src/chan/partBundleNode.cxx +++ b/panda/src/chan/partBundleNode.cxx @@ -72,12 +72,12 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void PartBundleNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { // With plain xform(), we can't attempt to share bundles across // different nodes. Better to use apply_attribs_to_vertices(), // instead. - if (mat.almost_equal(LMatrix4f::ident_mat())) { + if (mat.almost_equal(LMatrix4::ident_mat())) { // Don't bother. return; } diff --git a/panda/src/chan/partBundleNode.h b/panda/src/chan/partBundleNode.h index 71db6a4ba2..0cda9eb1de 100644 --- a/panda/src/chan/partBundleNode.h +++ b/panda/src/chan/partBundleNode.h @@ -48,7 +48,7 @@ public: virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); PUBLISHED: INLINE int get_num_bundles() const; diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index a9d6928c8d..16dab291b7 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -225,7 +225,7 @@ apply_freeze(const TransformState *transform) { // directly. //////////////////////////////////////////////////////////////////// bool PartGroup:: -apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale) { +apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { return false; } @@ -241,7 +241,7 @@ apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase // directly. //////////////////////////////////////////////////////////////////// bool PartGroup:: -apply_freeze_scalar(float value) { +apply_freeze_scalar(PN_stdfloat value) { return false; } @@ -551,7 +551,7 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *, // joint. //////////////////////////////////////////////////////////////////// void PartGroup:: -do_xform(const LMatrix4f &mat, const LMatrix4f &inv_mat) { +do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -733,7 +733,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (manager->get_file_minor_ver() == 11) { // Skip over the old freeze-joint information, no longer stored here scan.get_bool(); - LMatrix4f mat; + LMatrix4 mat; mat.read_datagram(scan); } diff --git a/panda/src/chan/partGroup.h b/panda/src/chan/partGroup.h index 25e2125218..a32540bb86 100644 --- a/panda/src/chan/partGroup.h +++ b/panda/src/chan/partGroup.h @@ -80,8 +80,8 @@ PUBLISHED: void sort_descendants(); bool apply_freeze(const TransformState *transform); - virtual bool apply_freeze_matrix(const LVecBase3f &pos, const LVecBase3f &hpr, const LVecBase3f &scale); - virtual bool apply_freeze_scalar(float value); + virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); + virtual bool apply_freeze_scalar(PN_stdfloat value); virtual bool apply_control(PandaNode *node); virtual bool clear_forced_channel(); virtual AnimChannelBase *get_forced_channel() const; @@ -99,7 +99,7 @@ public: virtual bool do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread); - virtual void do_xform(const LMatrix4f &mat, const LMatrix4f &inv_mat); + virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat); virtual void determine_effective_channels(const CycleData *root_cdata); protected: diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 25b2a1356c..9be6fe87d5 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -199,15 +199,15 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { int this_frame = ClockObject::get_global_clock()->get_frame_count(); CPT(TransformState) rel_transform = get_rel_transform(trav, data); - LPoint3f center = _lod_center * rel_transform->get_mat(); - float dist2 = center.dot(center); + LPoint3 center = _lod_center * rel_transform->get_mat(); + PN_stdfloat dist2 = center.dot(center); if (this_frame != _view_frame || dist2 < _view_distance2) { _view_frame = this_frame; _view_distance2 = dist2; // Now compute the lod delay. - float dist = sqrt(dist2); + PN_stdfloat dist = sqrt(dist2); double delay = 0.0; if (dist > _lod_near_distance) { delay = _lod_delay_factor * (dist - _lod_near_distance) / (_lod_far_distance - _lod_near_distance); @@ -249,7 +249,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // node's transform. //////////////////////////////////////////////////////////////////// CPT(TransformState) Character:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, bool &found_any, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { // This method is overridden by Character solely to provide a hook // to force the joints to update before computing the bounding @@ -375,9 +375,9 @@ merge_bundles(PartBundleHandle *old_bundle_handle, // given frame, the closest one counts. //////////////////////////////////////////////////////////////////// void Character:: -set_lod_animation(const LPoint3f ¢er, - float far_distance, float near_distance, - float delay_factor) { +set_lod_animation(const LPoint3 ¢er, + PN_stdfloat far_distance, PN_stdfloat near_distance, + PN_stdfloat delay_factor) { nassertv(far_distance >= near_distance); nassertv(delay_factor >= 0.0f); _lod_center = center; @@ -400,7 +400,7 @@ set_lod_animation(const LPoint3f ¢er, //////////////////////////////////////////////////////////////////// void Character:: clear_lod_animation() { - _lod_center = LPoint3f::zero(); + _lod_center = LPoint3::zero(); _lod_far_distance = 0.0f; _lod_near_distance = 0.0f; _lod_delay_factor = 0.0f; diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 675e487dba..91c2f2bce2 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -53,7 +53,7 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual CPT(TransformState) - calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const; @@ -66,9 +66,9 @@ PUBLISHED: void merge_bundles(PartBundleHandle *old_bundle_handle, PartBundleHandle *other_bundle_handle); - void set_lod_animation(const LPoint3f ¢er, - float far_distance, float near_distance, - float delay_factor); + void set_lod_animation(const LPoint3 ¢er, + PN_stdfloat far_distance, PN_stdfloat near_distance, + PN_stdfloat delay_factor); void clear_lod_animation(); CharacterJoint *find_joint(const string &name) const; @@ -139,10 +139,10 @@ private: int _view_frame; double _view_distance2; - LPoint3f _lod_center; - float _lod_far_distance; - float _lod_near_distance; - float _lod_delay_factor; + LPoint3 _lod_center; + PN_stdfloat _lod_far_distance; + PN_stdfloat _lod_near_distance; + PN_stdfloat _lod_delay_factor; bool _do_lod_animation; // Statistics diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index c08290586d..bb2ead57bd 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -57,7 +57,7 @@ CharacterJoint(const CharacterJoint ©) : CharacterJoint:: CharacterJoint(Character *character, PartBundle *root, PartGroup *parent, const string &name, - const LMatrix4f &default_value) : + const LMatrix4 &default_value) : MovingPartMatrix(parent, name, default_value), _character(character) { @@ -191,7 +191,7 @@ update_internals(PartBundle *root, PartGroup *parent, bool self_changed, // joint. //////////////////////////////////////////////////////////////////// void CharacterJoint:: -do_xform(const LMatrix4f &mat, const LMatrix4f &inv_mat) { +do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { _initial_net_transform_inverse = inv_mat * _initial_net_transform_inverse; MovingPartMatrix::do_xform(mat, inv_mat); @@ -421,7 +421,7 @@ get_local_transforms() { // indicated matrix. //////////////////////////////////////////////////////////////////// void CharacterJoint:: -get_transform(LMatrix4f &transform) const { +get_transform(LMatrix4 &transform) const { transform = _value; } @@ -433,7 +433,7 @@ get_transform(LMatrix4f &transform) const { // the indicated matrix. //////////////////////////////////////////////////////////////////// void CharacterJoint:: -get_net_transform(LMatrix4f &transform) const { +get_net_transform(LMatrix4 &transform) const { transform = _net_transform; } diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index e0eb5a8df7..dc57b09d08 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -38,7 +38,7 @@ protected: PUBLISHED: CharacterJoint(Character *character, PartBundle *root, PartGroup *parent, const string &name, - const LMatrix4f &default_value); + const LMatrix4 &default_value); virtual ~CharacterJoint(); public: @@ -48,7 +48,7 @@ public: virtual bool update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread); - virtual void do_xform(const LMatrix4f &mat, const LMatrix4f &inv_mat); + virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat); PUBLISHED: bool add_net_transform(PandaNode *node); @@ -63,8 +63,8 @@ PUBLISHED: void clear_local_transforms(); NodePathCollection get_local_transforms(); - void get_transform(LMatrix4f &transform) const; - void get_net_transform(LMatrix4f &transform) const; + void get_transform(LMatrix4 &transform) const; + void get_net_transform(LMatrix4 &transform) const; Character *get_character() const; @@ -104,8 +104,8 @@ public: PT(PandaNode) _geom_node; // These are filled in as the joint animates. - LMatrix4f _net_transform; - LMatrix4f _initial_net_transform_inverse; + LMatrix4 _net_transform; + LMatrix4 _initial_net_transform_inverse; public: virtual TypeHandle get_type() const { diff --git a/panda/src/char/characterVertexSlider.cxx b/panda/src/char/characterVertexSlider.cxx index 72645be4e0..f3a0580db6 100644 --- a/panda/src/char/characterVertexSlider.cxx +++ b/panda/src/char/characterVertexSlider.cxx @@ -64,7 +64,7 @@ CharacterVertexSlider:: // Access: Published, Virtual // Description: Returns the current slider value. //////////////////////////////////////////////////////////////////// -float CharacterVertexSlider:: +PN_stdfloat CharacterVertexSlider:: get_slider() const { return _char_slider->_value; } diff --git a/panda/src/char/characterVertexSlider.h b/panda/src/char/characterVertexSlider.h index f47f85bb2b..6bc0de14ae 100644 --- a/panda/src/char/characterVertexSlider.h +++ b/panda/src/char/characterVertexSlider.h @@ -36,7 +36,7 @@ PUBLISHED: INLINE const CharacterSlider *get_char_slider() const; - virtual float get_slider() const; + virtual PN_stdfloat get_slider() const; private: PT(CharacterSlider) _char_slider; diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index db203c8d17..033af96736 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -67,7 +67,7 @@ JointVertexTransform:: // Description: Stores the transform's matrix in the indicated object. //////////////////////////////////////////////////////////////////// void JointVertexTransform:: -get_matrix(LMatrix4f &matrix) const { +get_matrix(LMatrix4 &matrix) const { check_matrix(); matrix = _matrix; } @@ -83,7 +83,7 @@ get_matrix(LMatrix4f &matrix) const { // previous. //////////////////////////////////////////////////////////////////// void JointVertexTransform:: -mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const { +mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { check_matrix(); result.multiply(_matrix, previous); } @@ -97,7 +97,7 @@ mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const { // result of several blended transforms. //////////////////////////////////////////////////////////////////// void JointVertexTransform:: -accumulate_matrix(LMatrix4f &accum, float weight) const { +accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { check_matrix(); accum._m.m._00 += _matrix._m.m._00 * weight; diff --git a/panda/src/char/jointVertexTransform.h b/panda/src/char/jointVertexTransform.h index 7add735a21..7e41221e46 100644 --- a/panda/src/char/jointVertexTransform.h +++ b/panda/src/char/jointVertexTransform.h @@ -45,9 +45,9 @@ PUBLISHED: INLINE const CharacterJoint *get_joint() const; - virtual void get_matrix(LMatrix4f &matrix) const; - virtual void mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const; - virtual void accumulate_matrix(LMatrix4f &accum, float weight) const; + virtual void get_matrix(LMatrix4 &matrix) const; + virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const; + virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const; virtual void output(ostream &out) const; @@ -57,7 +57,7 @@ private: PT(CharacterJoint) _joint; - LMatrix4f _matrix; + LMatrix4 _matrix; bool _matrix_stale; LightMutex _lock; diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index d14bda7e8c..52728e86c1 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -184,7 +184,7 @@ make_vertex_columns(GeomVertexArrayFormat *format) const { nassertr(_column_name != NULL, 0); - format->add_column(_column_name, _num_bound_params, GeomEnums::NT_float32, _column_contents); + format->add_column(_column_name, _num_bound_params, GeomEnums::NT_stdfloat, _column_contents); return 1; } diff --git a/panda/src/collada/colladaInput.h b/panda/src/collada/colladaInput.h index fa0813909d..110d20911e 100644 --- a/panda/src/collada/colladaInput.h +++ b/panda/src/collada/colladaInput.h @@ -18,7 +18,7 @@ #include "config_collada.h" #include "referenceCount.h" #include "pvector.h" -#include "pta_LVecBase4f.h" +#include "pta_LVecBase4.h" #include "internalName.h" #include "geomEnums.h" diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index 46b3d4aec3..f2dcc32ff2 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -468,7 +468,7 @@ load_light(domLight &light, PandaNode *parent) { lnode = DCAST(LightNode, alight); domFloat3 &color = ambient->getColor()->getValue(); - alight->set_color(Colorf(color[0], color[1], color[2], 1.0)); + alight->set_color(LColor(color[0], color[1], color[2], 1.0)); } // Check for a directional light. @@ -478,7 +478,7 @@ load_light(domLight &light, PandaNode *parent) { lnode = DCAST(LightNode, dlight); domFloat3 &color = directional->getColor()->getValue(); - dlight->set_color(Colorf(color[0], color[1], color[2], 1.0)); + dlight->set_color(LColor(color[0], color[1], color[2], 1.0)); dlight->set_direction(LVector3f(0, 0, -1)); } @@ -489,7 +489,7 @@ load_light(domLight &light, PandaNode *parent) { lnode = DCAST(LightNode, plight); domFloat3 &color = point->getColor()->getValue(); - plight->set_color(Colorf(color[0], color[1], color[2], 1.0)); + plight->set_color(LColor(color[0], color[1], color[2], 1.0)); LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = point->getConstant_attenuation(); @@ -515,7 +515,7 @@ load_light(domLight &light, PandaNode *parent) { lnode = DCAST(LightNode, slight); domFloat3 &color = spot->getColor()->getValue(); - slight->set_color(Colorf(color[0], color[1], color[2], 1.0)); + slight->set_color(LColor(color[0], color[1], color[2], 1.0)); LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = spot->getConstant_attenuation(); diff --git a/panda/src/collada/colladaLoader.h b/panda/src/collada/colladaLoader.h index bb77f7d1fa..d3d75b25a4 100644 --- a/panda/src/collada/colladaLoader.h +++ b/panda/src/collada/colladaLoader.h @@ -21,7 +21,7 @@ #include "pandaNode.h" #include "modelRoot.h" #include "pvector.h" -#include "pta_LVecBase4f.h" +#include "pta_LVecBase4.h" class ColladaBindMaterial; class BamCacheRecord; diff --git a/panda/src/collide/Sources.pp b/panda/src/collide/Sources.pp index 315b80cdfe..0cdc91b31c 100644 --- a/panda/src/collide/Sources.pp +++ b/panda/src/collide/Sources.pp @@ -22,7 +22,6 @@ collisionHandlerPusher.I collisionHandlerPusher.h \ collisionHandlerFluidPusher.I collisionHandlerFluidPusher.h \ collisionHandlerQueue.h \ - collisionDSSolid.I collisionDSSolid.h \ collisionInvSphere.I collisionInvSphere.h \ collisionLine.I collisionLine.h \ collisionLevelStateBase.I collisionLevelStateBase.h \ @@ -57,7 +56,6 @@ collisionHandlerQueue.cxx \ collisionLevelStateBase.cxx \ collisionLevelState.cxx \ - collisionDSSolid.cxx \ collisionInvSphere.cxx \ collisionLine.cxx \ collisionNode.cxx \ @@ -88,7 +86,6 @@ collisionHandlerPusher.I collisionHandlerPusher.h \ collisionHandlerFluidPusher.I collisionHandlerFluidPusher.h \ collisionHandlerQueue.h \ - collisionDSSolid.I collisionDSSolid.h \ collisionInvSphere.I collisionInvSphere.h \ collisionLevelStateBase.I collisionLevelStateBase.h \ collisionLevelState.I collisionLevelState.h \ diff --git a/panda/src/collide/collide_composite1.cxx b/panda/src/collide/collide_composite1.cxx index a122709180..d66b71b18c 100644 --- a/panda/src/collide/collide_composite1.cxx +++ b/panda/src/collide/collide_composite1.cxx @@ -11,7 +11,6 @@ #include "collisionHandlerPusher.cxx" #include "collisionHandlerFluidPusher.cxx" #include "collisionHandlerQueue.cxx" -#include "collisionDSSolid.cxx" #include "collisionInvSphere.cxx" #include "collisionLevelStateBase.cxx" #include "collisionLevelState.cxx" diff --git a/panda/src/collide/collisionBox.I b/panda/src/collide/collisionBox.I index 41f28fa020..05b120c234 100644 --- a/panda/src/collide/collisionBox.I +++ b/panda/src/collide/collisionBox.I @@ -20,11 +20,11 @@ // of each of the sides of box from the Center. //////////////////////////////////////////////////////////////////// INLINE CollisionBox:: -CollisionBox(const LPoint3f ¢er, float x, float y, float z) : +CollisionBox(const LPoint3 ¢er, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) : _center(center), _x(x), _y(y), _z(z) { - _min = LPoint3f(_center.get_x() - _x, _center.get_y() - _y, _center.get_z() - _z); - _max = LPoint3f(_center.get_x() + _x, _center.get_y() + _y, _center.get_z() + _z); + _min = LPoint3(_center.get_x() - _x, _center.get_y() - _y, _center.get_z() - _z); + _max = LPoint3(_center.get_x() + _x, _center.get_y() + _y, _center.get_z() + _z); _radius = sqrt(_x*_x + _y*_y + _z*_z); for(int v = 0; v < 8; v++) _vertex[v] = get_point_aabb(v); @@ -39,7 +39,7 @@ CollisionBox(const LPoint3f ¢er, float x, float y, float z) : // Description: Create the Box by Specifying the Diagonal Points //////////////////////////////////////////////////////////////////// INLINE CollisionBox:: -CollisionBox(const LPoint3f &min, const LPoint3f &max) : +CollisionBox(const LPoint3 &min, const LPoint3 &max) : _min(min), _max(max) { _center = (_min + _max) / 2; @@ -60,9 +60,9 @@ CollisionBox(const LPoint3f &min, const LPoint3f &max) : // Description: Center as three separate co-ordinate points //////////////////////////////////////////////////////////////////// INLINE CollisionBox:: -CollisionBox(float cx, float cy, float cz, float x, float y, float z) +CollisionBox(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { - CollisionBox(LPoint3f(cx, cy, cz), x, y, z); + CollisionBox(LPoint3(cx, cy, cz), x, y, z); } //////////////////////////////////////////////////////////////////// @@ -115,7 +115,7 @@ flush_level() { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionBox:: -set_center(const LPoint3f ¢er) { +set_center(const LPoint3 ¢er) { _center = center; mark_internal_bounds_stale(); mark_viz_stale(); @@ -127,8 +127,8 @@ set_center(const LPoint3f ¢er) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionBox:: -set_center(float x, float y, float z) { - set_center(LPoint3f(x, y, z)); +set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_center(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -136,7 +136,7 @@ set_center(float x, float y, float z) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionBox:: +INLINE const LPoint3 &CollisionBox:: get_center() const { return _center; } @@ -146,7 +146,7 @@ get_center() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float CollisionBox:: +INLINE PN_stdfloat CollisionBox:: get_radius() const { return _radius; } @@ -166,9 +166,9 @@ get_num_points() const { // Access: Published // Description: Returns the nth vertex of the OBB. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f CollisionBox:: +INLINE_MATHUTIL LPoint3 CollisionBox:: get_point(int n) const { - nassertr(n >= 0 && n < 8, LPoint3f::zero()); + nassertr(n >= 0 && n < 8, LPoint3::zero()); return _vertex[n]; } @@ -178,14 +178,14 @@ get_point(int n) const { // Access: Published // Description: Returns the nth vertex of the Axis Aligned Bounding Box. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f CollisionBox:: +INLINE_MATHUTIL LPoint3 CollisionBox:: get_point_aabb(int n) const { - nassertr(n >= 0 && n < 8, LPoint3f::zero()); + nassertr(n >= 0 && n < 8, LPoint3::zero()); // We do some trickery assuming that _min and _max are consecutive // in memory. - const LPoint3f *a = &_min; - return LPoint3f(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); + const LPoint3 *a = &_min; + return LPoint3(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); } //////////////////////////////////////////////////////////////////// @@ -203,9 +203,9 @@ get_num_planes() const { // Access: Published // Description: Returns the nth face of the rectangular solid. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL Planef CollisionBox:: +INLINE_MATHUTIL LPlane CollisionBox:: get_plane(int n) const { - nassertr(n >= 0 && n < 6, Planef()); + nassertr(n >= 0 && n < 6, LPlane()); return _planes[n]; } @@ -214,10 +214,10 @@ get_plane(int n) const { // Access: Published // Description: Creates the nth face of the rectangular solid. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL Planef CollisionBox:: +INLINE_MATHUTIL LPlane CollisionBox:: set_plane(int n) const { - nassertr(n >= 0 && n < 6, Planef()); - return Planef(get_point(plane_def[n][0]), + nassertr(n >= 0 && n < 6, LPlane()); + return LPlane(get_point(plane_def[n][0]), get_point(plane_def[n][1]), get_point(plane_def[n][2])); } @@ -229,7 +229,7 @@ set_plane(int n) const { // Description: Returns true if the 2-d v1 is to the right of v2. //////////////////////////////////////////////////////////////////// INLINE bool CollisionBox:: -is_right(const LVector2f &v1, const LVector2f &v2) { +is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 1.0e-6f; } @@ -241,10 +241,10 @@ is_right(const LVector2f &v1, const LVector2f &v2) { // result is negative if p is left of the line, positive // if it is right of the line. //////////////////////////////////////////////////////////////////// -INLINE float CollisionBox:: -dist_to_line(const LPoint2f &p, - const LPoint2f &f, const LVector2f &v) { - LVector2f v1 = (p - f); +INLINE PN_stdfloat CollisionBox:: +dist_to_line(const LPoint2 &p, + const LPoint2 &f, const LVector2 &v) { + LVector2 v1 = (p - f); return (v1[0] * v[1] - v1[1] * v[0]); } @@ -255,10 +255,10 @@ dist_to_line(const LPoint2f &p, // the polygon's plane, returns the corresponding point // in the polygon's 2-d definition space. //////////////////////////////////////////////////////////////////// -INLINE LPoint2f CollisionBox:: -to_2d(const LVecBase3f &point3d, int plane) const { - LPoint3f point = LPoint3f(point3d) * _to_2d_mat[plane]; - return LPoint2f(point[0], point[2]); +INLINE LPoint2 CollisionBox:: +to_2d(const LVecBase3 &point3d, int plane) const { + LPoint3 point = LPoint3(point3d) * _to_2d_mat[plane]; + return LPoint2(point[0], point[2]); } //////////////////////////////////////////////////////////////////// @@ -269,7 +269,7 @@ to_2d(const LVecBase3f &point3d, int plane) const { // into the 3-d (X, 0, Z) plane. //////////////////////////////////////////////////////////////////// INLINE void CollisionBox:: -calc_to_3d_mat(LMatrix4f &to_3d_mat,int plane) const { +calc_to_3d_mat(LMatrix4 &to_3d_mat,int plane) const { // We have to be explicit about the coordinate system--we // specifically mean CS_zup_right, because that points the forward // vector down the Y axis and moves the coords in (X, 0, Z). We @@ -279,7 +279,7 @@ calc_to_3d_mat(LMatrix4f &to_3d_mat,int plane) const { // The up vector, on the other hand, is completely arbitrary. look_at(to_3d_mat, -get_plane(plane).get_normal(), - LVector3f(0.0f, 0.0f, 1.0f), CS_zup_right); + LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); to_3d_mat.set_row(3, get_plane(plane).get_point()); } @@ -298,7 +298,7 @@ calc_to_3d_mat(LMatrix4f &to_3d_mat,int plane) const { // numerical precision. //////////////////////////////////////////////////////////////////// INLINE void CollisionBox:: -rederive_to_3d_mat(LMatrix4f &to_3d_mat, int plane) const { +rederive_to_3d_mat(LMatrix4 &to_3d_mat, int plane) const { to_3d_mat.invert_from(_to_2d_mat[plane]); } @@ -308,9 +308,9 @@ rederive_to_3d_mat(LMatrix4f &to_3d_mat, int plane) const { // Description: Extrude the indicated point in the polygon's 2-d // definition space back into 3-d coordinates. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f CollisionBox:: -to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat) { - return LPoint3f(point2d[0], 0.0f, point2d[1]) * to_3d_mat; +INLINE LPoint3 CollisionBox:: +to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat) { + return LPoint3(point2d[0], 0.0f, point2d[1]) * to_3d_mat; } //////////////////////////////////////////////////////////////////// @@ -319,7 +319,7 @@ to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat) { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionBox::PointDef:: -PointDef(const LPoint2f &p, const LVector2f &v) : _p(p), _v(v) { +PointDef(const LPoint2 &p, const LVector2 &v) : _p(p), _v(v) { } //////////////////////////////////////////////////////////////////// @@ -328,7 +328,7 @@ PointDef(const LPoint2f &p, const LVector2f &v) : _p(p), _v(v) { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionBox::PointDef:: -PointDef(float x, float y) : _p(x, y), _v(0.0f, 0.0f) { +PointDef(PN_stdfloat x, PN_stdfloat y) : _p(x, y), _v(0.0f, 0.0f) { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 93fe1ae97e..5c774d4a13 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -67,7 +67,7 @@ make_copy() { void CollisionBox:: setup_box(){ for(int plane = 0; plane < 6; plane++) { - LPoint3f array[4]; + LPoint3 array[4]; array[0] = get_point(plane_def[plane][0]); array[1] = get_point(plane_def[plane][1]); array[2] = get_point(plane_def[plane][2]); @@ -83,7 +83,7 @@ setup_box(){ // make up this side //////////////////////////////////////////////////////////////////// void CollisionBox:: -setup_points(const LPoint3f *begin, const LPoint3f *end, int plane) { +setup_points(const LPoint3 *begin, const LPoint3 *end, int plane) { int num_points = end - begin; nassertv(num_points >= 3); @@ -91,7 +91,7 @@ setup_points(const LPoint3f *begin, const LPoint3f *end, int plane) { // Construct a matrix that rotates the points from the (X,0,Z) plane // into the 3-d plane. - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; calc_to_3d_mat(to_3d_mat, plane); // And the inverse matrix rotates points from 3-d space into the 2-d @@ -100,9 +100,9 @@ setup_points(const LPoint3f *begin, const LPoint3f *end, int plane) { // Now project all of the points onto the 2-d plane. - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { - LPoint3f point = (*pi) * _to_2d_mat[plane]; + LPoint3 point = (*pi) * _to_2d_mat[plane]; _points[plane].push_back(PointDef(point[0], point[2])); } @@ -113,7 +113,7 @@ setup_points(const LPoint3f *begin, const LPoint3f *end, int plane) { // Now make sure the points define a convex polygon. if (is_concave()) { collide_cat.error() << "Invalid concave CollisionPolygon defined:\n"; - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { collide_cat.error(false) << " " << (*pi) << "\n"; } @@ -143,7 +143,7 @@ test_intersection(const CollisionEntry &entry) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionBox:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _center = _center * mat; for(int v = 0; v < 8; v++) _vertex[v] = _vertex[v] * mat; @@ -166,7 +166,7 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionBox:: +LPoint3 CollisionBox:: get_collision_origin() const { return _center; } @@ -176,7 +176,7 @@ get_collision_origin() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f CollisionBox:: +LPoint3 CollisionBox:: get_min() const { return _min; } @@ -186,7 +186,7 @@ get_min() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f CollisionBox:: +LPoint3 CollisionBox:: get_max() const { return _max; } @@ -196,7 +196,7 @@ get_max() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f CollisionBox:: +LPoint3 CollisionBox:: get_approx_center() const { return (_min + _max) * 0.5f; } @@ -259,26 +259,26 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); + const LMatrix4 &wrt_mat = wrt_space->get_mat(); - LPoint3f orig_center = sphere->get_center() * wrt_mat; - LPoint3f from_center = orig_center; + LPoint3 orig_center = sphere->get_center() * wrt_mat; + LPoint3 from_center = orig_center; bool moved_from_center = false; - float t = 1.0f; - LPoint3f contact_point(from_center); - float actual_t = 1.0f; + PN_stdfloat t = 1.0f; + LPoint3 contact_point(from_center); + PN_stdfloat actual_t = 1.0f; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius_2 = from_radius_v.length_squared(); - float from_radius = csqrt(from_radius_2); + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius_2 = from_radius_v.length_squared(); + PN_stdfloat from_radius = csqrt(from_radius_2); int ip; - float max_dist = 0.0; - float dist = 0.0; + PN_stdfloat max_dist = 0.0; + PN_stdfloat dist = 0.0; bool intersect; - Planef plane; - LVector3f normal; + LPlane plane; + LVector3 normal; for(ip = 0, intersect = false; ip < 6 && !intersect; ip++) { plane = get_plane( ip ); @@ -289,13 +289,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // If we have a delta between the previous position and the // current position, we use that to determine some more properties // of the collision. - LPoint3f b = from_center; - LPoint3f a = sphere->get_center() * wrt_prev_space->get_mat(); - LVector3f delta = b - a; + LPoint3 b = from_center; + LPoint3 a = sphere->get_center() * wrt_prev_space->get_mat(); + LVector3 delta = b - a; // First, there is no collision if the "from" object is definitely // moving in the same direction as the plane's normal. - float dot = delta.dot(plane.get_normal()); + PN_stdfloat dot = delta.dot(plane.get_normal()); if (dot > 0.1f) { continue; // no intersection } @@ -313,13 +313,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // direction of the plane normal // t = ratio of (distance from start pos to plane) to (distance // from start pos to end pos), along axis of plane normal - float dist_to_p = plane.dist_to_plane(a); + PN_stdfloat dist_to_p = plane.dist_to_plane(a); t = (dist_to_p / -dot); // also compute the actual contact point and time of contact // for handlers that need it actual_t = ((dist_to_p - from_radius) / -dot); - actual_t = min(1.0f, max(0.0f, actual_t)); + actual_t = min((PN_stdfloat)1.0, max((PN_stdfloat)0.0, actual_t)); contact_point = a + (actual_t * delta); if (t >= 1.0f) { @@ -361,8 +361,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { continue; } - LPoint2f p = to_2d(from_center - dist * plane.get_normal(), ip); - float edge_dist = 0.0f; + LPoint2 p = to_2d(from_center - dist * plane.get_normal(), ip); + PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -407,7 +407,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // edge. if (edge_dist >= 0.0f) { - float max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, 0.0f); + PN_stdfloat max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, (PN_stdfloat)0.0); max_dist = csqrt(max_dist_2); } @@ -428,12 +428,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) new_entry = new CollisionEntry(entry); - float into_depth = max_dist - dist; + PN_stdfloat into_depth = max_dist - dist; if (moved_from_center) { // We have to base the depth of intersection on the sphere's final // resting point, not the point from which we tested the // intersection. - float orig_dist; + PN_stdfloat orig_dist; plane.intersects_line(orig_dist, orig_center, -normal); into_depth = max_dist - orig_dist; } @@ -458,17 +458,17 @@ PT(CollisionEntry) CollisionBox:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; int i, j; - float t; - float near_t = 0.0; + PN_stdfloat t; + PN_stdfloat near_t = 0.0; bool intersect; - Planef plane; - Planef near_plane; + LPlane plane; + LPlane near_plane; //Returns the details about the first plane of the box that the ray //intersects. @@ -485,8 +485,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const { // the ray is entirely in front of the plane. continue; } - LPoint3f plane_point = from_origin + t * from_direction; - LPoint2f p = to_2d(plane_point, i); + LPoint3 plane_point = from_origin + t * from_direction; + LPoint2 p = to_2d(plane_point, i); if (!point_is_inside(p, _points[i])){ continue; @@ -519,9 +519,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + near_t * from_direction; + LPoint3 into_intersection_point = from_origin + near_t * from_direction; - LVector3f normal = + LVector3 normal = (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : near_plane.get_normal(); @@ -541,18 +541,18 @@ PT(CollisionEntry) CollisionBox:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *seg; DCAST_INTO_R(seg, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = seg->get_point_a() * wrt_mat; - LPoint3f from_extent = seg->get_point_b() * wrt_mat; - LVector3f from_direction = from_extent - from_origin; + LPoint3 from_origin = seg->get_point_a() * wrt_mat; + LPoint3 from_extent = seg->get_point_b() * wrt_mat; + LVector3 from_direction = from_extent - from_origin; int i, j; - float t; - float near_t = 0.0; + PN_stdfloat t; + PN_stdfloat near_t = 0.0; bool intersect; - Planef plane; - Planef near_plane; + LPlane plane; + LPlane near_plane; //Returns the details about the first plane of the box that the //segment intersects. @@ -570,8 +570,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { // entirely in front of or behind the plane. continue; } - LPoint3f plane_point = from_origin + t * from_direction; - LPoint2f p = to_2d(plane_point, i); + LPoint3 plane_point = from_origin + t * from_direction; + LPoint2 p = to_2d(plane_point, i); if (!point_is_inside(p, _points[i])){ continue; @@ -604,9 +604,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + near_t * from_direction; + LPoint3 into_intersection_point = from_origin + near_t * from_direction; - LVector3f normal = + LVector3 normal = (has_effective_normal() && seg->get_respect_effective_normal()) ? get_effective_normal() : near_plane.get_normal(); @@ -649,7 +649,7 @@ fill_viz_geom() { for(int i = 0; i < 6; i++) { for(int j = 0; j < 4; j++) - vertex.add_data3f(get_point(plane_def[i][j])); + vertex.add_data3(get_point(plane_def[i][j])); PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); body->add_consecutive_vertices(i*4, 4); @@ -690,7 +690,7 @@ apply_clip_plane(CollisionBox::Points &new_points, CPT(TransformState) new_transform = net_transform->invert_compose(plane_path.get_net_transform()); - Planef plane = plane_node->get_plane() * new_transform->get_mat(); + LPlane plane = plane_node->get_plane() * new_transform->get_mat(); if (first_plane) { first_plane = false; if (!clip_polygon(new_points, _points[plane_no], plane, plane_no)) { @@ -727,14 +727,14 @@ apply_clip_plane(CollisionBox::Points &new_points, bool CollisionBox:: clip_polygon(CollisionBox::Points &new_points, const CollisionBox::Points &source_points, - const Planef &plane, int plane_no) const { + const LPlane &plane, int plane_no) const { new_points.clear(); if (source_points.empty()) { return true; } - LPoint3f from3d; - LVector3f delta3d; + LPoint3 from3d; + LVector3 delta3d; if (!plane.intersects_plane(from3d, delta3d, get_plane(plane_no))) { // The clipping plane is parallel to the polygon. The polygon is // either all in or all out. @@ -749,12 +749,12 @@ clip_polygon(CollisionBox::Points &new_points, // Project the line of intersection into the 2-d plane. Now we have // a 2-d clipping line. - LPoint2f from2d = to_2d(from3d,plane_no); - LVector2f delta2d = to_2d(delta3d,plane_no); + LPoint2 from2d = to_2d(from3d,plane_no); + LVector2 delta2d = to_2d(delta3d,plane_no); - float a = -delta2d[1]; - float b = delta2d[0]; - float c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; + PN_stdfloat a = -delta2d[1]; + PN_stdfloat b = delta2d[0]; + PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; // Now walk through the points. Any point on the left of our line // gets removed, and the line segment clipped at the point of @@ -765,12 +765,12 @@ clip_polygon(CollisionBox::Points &new_points, // number of vertices, or keep them the same number.) new_points.reserve(source_points.size() + 1); - LPoint2f last_point = source_points.back()._p; + LPoint2 last_point = source_points.back()._p; bool last_is_in = !is_right(last_point - from2d, delta2d); bool all_in = last_is_in; Points::const_iterator pi; for (pi = source_points.begin(); pi != source_points.end(); ++pi) { - const LPoint2f &this_point = (*pi)._p; + const LPoint2 &this_point = (*pi)._p; bool this_is_in = !is_right(this_point - from2d, delta2d); // There appears to be a compiler bug in gcc 4.0: we need to @@ -779,11 +779,11 @@ clip_polygon(CollisionBox::Points &new_points, if (crossed_over) { // We have just crossed over the clipping line. Find the point // of intersection. - LVector2f d = this_point - last_point; - float denom = (a * d[0] + b * d[1]); + LVector2 d = this_point - last_point; + PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { - float t = -(a * last_point[0] + b * last_point[1] + c) / denom; - LPoint2f p = last_point + t * d; + PN_stdfloat t = -(a * last_point[0] + b * last_point[1] + c) / denom; + LPoint2 p = last_point + t * d; new_points.push_back(PointDef(p[0], p[1])); last_is_in = this_is_in; @@ -812,8 +812,8 @@ clip_polygon(CollisionBox::Points &new_points, // vector. The result is negative if the point is // within the polygon. //////////////////////////////////////////////////////////////////// -float CollisionBox:: -dist_to_polygon(const LPoint2f &p, const CollisionBox::Points &points) const { +PN_stdfloat CollisionBox:: +dist_to_polygon(const LPoint2 &p, const CollisionBox::Points &points) const { // We know that that the polygon is convex and is defined with the // points in counterclockwise order. Therefore, we simply compare @@ -824,11 +824,11 @@ dist_to_polygon(const LPoint2f &p, const CollisionBox::Points &points) const { // therefore return an arbitrary negative result. bool got_dist = false; - float best_dist = -1.0f; + PN_stdfloat best_dist = -1.0f; size_t num_points = points.size(); for (size_t i = 0; i < num_points - 1; ++i) { - float d = dist_to_line_segment(p, points[i]._p, points[i + 1]._p, + PN_stdfloat d = dist_to_line_segment(p, points[i]._p, points[i + 1]._p, points[i]._v); if (d >= 0.0f) { if (!got_dist || d < best_dist) { @@ -838,7 +838,7 @@ dist_to_polygon(const LPoint2f &p, const CollisionBox::Points &points) const { } } - float d = dist_to_line_segment(p, points[num_points - 1]._p, points[0]._p, + PN_stdfloat d = dist_to_line_segment(p, points[num_points - 1]._p, points[0]._p, points[num_points - 1]._v); if (d >= 0.0f) { if (!got_dist || d < best_dist) { @@ -862,18 +862,18 @@ dist_to_polygon(const LPoint2f &p, const CollisionBox::Points &points) const { // would be for a straight distance-to-line test). If // the result is negative, we don't bother. //////////////////////////////////////////////////////////////////// -float CollisionBox:: -dist_to_line_segment(const LPoint2f &p, - const LPoint2f &f, const LPoint2f &t, - const LVector2f &v) { - LVector2f v1 = (p - f); - float d = (v1[0] * v[1] - v1[1] * v[0]); +PN_stdfloat CollisionBox:: +dist_to_line_segment(const LPoint2 &p, + const LPoint2 &f, const LPoint2 &t, + const LVector2 &v) { + LVector2 v1 = (p - f); + PN_stdfloat d = (v1[0] * v[1] - v1[1] * v[0]); if (d < 0.0f) { return d; } // Compute the nearest point on the line. - LPoint2f q = p + LVector2f(-v[1], v[0]) * d; + LPoint2 q = p + LVector2(-v[1], v[0]) * d; // Now constrain that point to the line segment. if (v[0] > 0.0f) { @@ -976,7 +976,7 @@ dist_to_line_segment(const LPoint2f &p, // polygon's 2-d space, false otherwise. //////////////////////////////////////////////////////////////////// bool CollisionBox:: -point_is_inside(const LPoint2f &p, const CollisionBox::Points &points) const { +point_is_inside(const LPoint2 &p, const CollisionBox::Points &points) const { // We insist that the polygon be convex. This makes things a bit simpler. // In the case of a convex polygon, defined with points in counterclockwise // order, a point is interior to the polygon iff the point is not right of @@ -994,26 +994,6 @@ point_is_inside(const LPoint2f &p, const CollisionBox::Points &points) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::compute_point -// Access: Protected -// Description: Returns a point on the surface of the sphere. -// latitude and longitude range from 0.0 to 1.0. This -// is used by fill_viz_geom() to create a visible -// representation of the sphere. -//////////////////////////////////////////////////////////////////// -Vertexf CollisionBox:: -compute_point(float latitude, float longitude) const { - float s1, c1; - csincos(latitude * MathNumbers::pi_f, &s1, &c1); - - float s2, c2; - csincos(longitude * 2.0f * MathNumbers::pi_f, &s2, &c2); - - Vertexf p(s1 * c2, s1 * s2, c1); - return p * get_radius() + get_center(); -} - //////////////////////////////////////////////////////////////////// // Function: CollisionBox::compute_vectors // Access: Private, Static @@ -1055,10 +1035,10 @@ write_datagram(BamWriter *manager, Datagram &me) { for(int i=0; i < 8; i++) { _vertex[i].write_datagram(me); } - me.add_float32(_radius); - me.add_float32(_x); - me.add_float32(_y); - me.add_float32(_z); + me.add_stdfloat(_radius); + me.add_stdfloat(_x); + me.add_stdfloat(_y); + me.add_stdfloat(_z); for(int i=0; i < 6; i++) { _planes[i].write_datagram(me); } @@ -1107,10 +1087,10 @@ fillin(DatagramIterator& scan, BamReader* manager) { for(int i=0; i < 8; i++) { _vertex[i].read_datagram(scan); } - _radius = scan.get_float32(); - _x = scan.get_float32(); - _y = scan.get_float32(); - _z = scan.get_float32(); + _radius = scan.get_stdfloat(); + _x = scan.get_stdfloat(); + _y = scan.get_stdfloat(); + _z = scan.get_stdfloat(); for(int i=0; i < 6; i++) { _planes[i].read_datagram(scan); } @@ -1120,8 +1100,8 @@ fillin(DatagramIterator& scan, BamReader* manager) { for(int i=0; i < 6; i++) { size_t size = scan.get_uint16(); for (size_t j = 0; j < size; j++) { - LPoint2f p; - LVector2f v; + LPoint2 p; + LVector2 v; p.read_datagram(scan); v.read_datagram(scan); _points[i].push_back(PointDef(p, v)); diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index 6575d6384c..a43979aa91 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -28,13 +28,13 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionBox : public CollisionSolid { PUBLISHED: - INLINE CollisionBox(const LPoint3f ¢er, - float x, float y, float z); - INLINE CollisionBox(float cx, float cy, float cz, - float x, float y, float z); - INLINE CollisionBox(const LPoint3f &min, const LPoint3f &max); + INLINE CollisionBox(const LPoint3 ¢er, + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE CollisionBox(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE CollisionBox(const LPoint3 &min, const LPoint3 &max); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; protected: INLINE CollisionBox(); @@ -45,31 +45,31 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); virtual void output(ostream &out) const; - virtual LPoint3f get_approx_center() const; - virtual LPoint3f get_min() const; - virtual LPoint3f get_max() const; + virtual LPoint3 get_approx_center() const; + virtual LPoint3 get_min() const; + virtual LPoint3 get_max() const; INLINE static void flush_level(); void setup_box(); PUBLISHED: INLINE_MATHUTIL int get_num_points() const; - INLINE_MATHUTIL LPoint3f get_point_aabb(int n) const; - INLINE_MATHUTIL LPoint3f get_point(int n) const; + INLINE_MATHUTIL LPoint3 get_point_aabb(int n) const; + INLINE_MATHUTIL LPoint3 get_point(int n) const; INLINE_MATHUTIL int get_num_planes() const; - INLINE_MATHUTIL Planef set_plane(int n) const; - INLINE_MATHUTIL Planef get_plane(int n) const; - INLINE void set_center(const LPoint3f ¢er); - INLINE void set_center(float x, float y, float z); - INLINE const LPoint3f &get_center() const; - INLINE float get_radius() const; + INLINE_MATHUTIL LPlane set_plane(int n) const; + INLINE_MATHUTIL LPlane get_plane(int n) const; + INLINE void set_center(const LPoint3 ¢er); + INLINE void set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_center() const; + INLINE PN_stdfloat get_radius() const; protected: virtual PT(BoundingVolume) compute_internal_bounds() const; @@ -84,16 +84,13 @@ protected: virtual void fill_viz_geom(); -protected: - Vertexf compute_point(float latitude, float longitude) const; - private: - LPoint3f _center; - LPoint3f _min; - LPoint3f _max; - float _x, _y, _z, _radius; - LPoint3f _vertex[8]; // Each of the Eight Vertices of the Box - Planef _planes[6]; //Points to each of the six sides of the Box + LPoint3 _center; + LPoint3 _min; + LPoint3 _max; + PN_stdfloat _x, _y, _z, _radius; + LPoint3 _vertex[8]; // Each of the Eight Vertices of the Box + LPlane _planes[6]; //Points to each of the six sides of the Box static const int plane_def[6][4]; @@ -101,23 +98,23 @@ private: static PStatCollector _test_pcollector; private: - INLINE static bool is_right(const LVector2f &v1, const LVector2f &v2); - INLINE static float dist_to_line(const LPoint2f &p, - const LPoint2f &f, const LVector2f &v); - static float dist_to_line_segment(const LPoint2f &p, - const LPoint2f &f, const LPoint2f &t, - const LVector2f &v); + INLINE static bool is_right(const LVector2 &v1, const LVector2 &v2); + INLINE static PN_stdfloat dist_to_line(const LPoint2 &p, + const LPoint2 &f, const LVector2 &v); + static PN_stdfloat dist_to_line_segment(const LPoint2 &p, + const LPoint2 &f, const LPoint2 &t, + const LVector2 &v); public: class PointDef { public: - INLINE PointDef(const LPoint2f &p, const LVector2f &v); - INLINE PointDef(float x, float y); + INLINE PointDef(const LPoint2 &p, const LVector2 &v); + INLINE PointDef(PN_stdfloat x, PN_stdfloat y); INLINE PointDef(const PointDef ©); INLINE void operator = (const PointDef ©); - LPoint2f _p; // the point in 2-d space - LVector2f _v; // the normalized vector to the next point + LPoint2 _p; // the point in 2-d space + LVector2 _v; // the normalized vector to the next point }; typedef pvector Points; @@ -125,23 +122,23 @@ public: void draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, const Points &points) const; - bool point_is_inside(const LPoint2f &p, const Points &points) const; - float dist_to_polygon(const LPoint2f &p, const Points &points) const; + bool point_is_inside(const LPoint2 &p, const Points &points) const; + PN_stdfloat dist_to_polygon(const LPoint2 &p, const Points &points) const; - void setup_points(const LPoint3f *begin, const LPoint3f *end, int plane); - INLINE LPoint2f to_2d(const LVecBase3f &point3d, int plane) const; - INLINE void calc_to_3d_mat(LMatrix4f &to_3d_mat, int plane) const; - INLINE void rederive_to_3d_mat(LMatrix4f &to_3d_mat, int plane) const; - INLINE static LPoint3f to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat); - LPoint3f legacy_to_3d(const LVecBase2f &point2d, int axis) const; + void setup_points(const LPoint3 *begin, const LPoint3 *end, int plane); + INLINE LPoint2 to_2d(const LVecBase3 &point3d, int plane) const; + INLINE void calc_to_3d_mat(LMatrix4 &to_3d_mat, int plane) const; + INLINE void rederive_to_3d_mat(LMatrix4 &to_3d_mat, int plane) const; + INLINE static LPoint3 to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat); + LPoint3 legacy_to_3d(const LVecBase2 &point2d, int axis) const; bool clip_polygon(Points &new_points, const Points &source_points, - const Planef &plane,int plane_no) const; + const LPlane &plane,int plane_no) const; bool apply_clip_plane(Points &new_points, const ClipPlaneAttrib *cpa, const TransformState *net_transform, int plane_no) const; private: Points _points[6]; // one set of points for each of the six planes that make up the box - LMatrix4f _to_2d_mat[6]; + LMatrix4 _to_2d_mat[6]; public: INLINE Points get_plane_points( int n ); diff --git a/panda/src/collide/collisionDSSolid.I b/panda/src/collide/collisionDSSolid.I deleted file mode 100755 index cca23f4d9d..0000000000 --- a/panda/src/collide/collisionDSSolid.I +++ /dev/null @@ -1,294 +0,0 @@ -// Filename: collisionDSSolid.I -// Created by: Dave Schuyler (05Apr06) -// Based on collision tube by: drose -// -//////////////////////////////////////////////////////////////////// -// -// 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: Collision::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE CollisionDSSolid:: -CollisionDSSolid( - const LPoint3f ¢er_a, float radius_a, - const LPoint3f ¢er_b, float radius_b, - const Planef &plane_a, const Planef &plane_b) : - _center_a(center_a), _radius_a(radius_a), - _center_b(center_b), _radius_b(radius_b), - _plane_a(plane_a), _plane_b(plane_b), - _lens_radius(0.0f) -{ - recalc_internals(); - nassertv(_radius_a >= 0.0f); - nassertv(_radius_b >= 0.0f); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE CollisionDSSolid:: -CollisionDSSolid( - float ax, float ay, float az, - float radius_a, - float bx, float by, float bz, - float radius_b, - const Planef &plane_a, const Planef &plane_b) : - _center_a(ax, ay, az), _radius_a(radius_a), - _center_b(bx, by, bz), _radius_b(radius_b), - _plane_a(plane_a), _plane_b(plane_b), - _lens_radius(0.0f) -{ - recalc_internals(); - nassertv(_radius_a >= 0.0f); - nassertv(_radius_b >= 0.0f); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::Default constructor -// Access: Private -// Description: Creates an invalid tube. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// -INLINE CollisionDSSolid:: -CollisionDSSolid() { -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE CollisionDSSolid:: -CollisionDSSolid(const CollisionDSSolid ©) : - CollisionSolid(copy), - _center_a(copy._center_a), - _radius_a(copy._radius_a), - _center_b(copy._center_b), - _radius_b(copy._radius_b), - _plane_a(copy._plane_a), - _plane_b(copy._plane_b) -{ - recalc_internals(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_center_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_center_a(const LPoint3f &a) { - _center_a = a; - recalc_internals(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_center_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_center_a(float x, float y, float z) { - set_center_a(LPoint3f(x, y, z)); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_center_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionDSSolid:: -get_center_a() const { - return _center_a; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_center_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_center_b(const LPoint3f &b) { - _center_b = b; - recalc_internals(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_center_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_center_b(float x, float y, float z) { - set_center_b(LPoint3f(x, y, z)); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_center_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionDSSolid:: -get_center_b() const { - return _center_b; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_radius_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_radius_a(float radius) { - nassertv(radius >= 0.0f); - _radius_a = radius; - - // We don't need to call recalc_internals(), since the radius - // doesn't change either of those properties. - mark_internal_bounds_stale(); - mark_viz_stale(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_radius_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float CollisionDSSolid:: -get_radius_a() const { - return _radius_a; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_radius_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_radius_b(float radius) { - nassertv(radius >= 0.0f); - _radius_b = radius; - - // We don't need to call recalc_internals(), since the radius - // doesn't change either of those properties. - mark_internal_bounds_stale(); - mark_viz_stale(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_radius_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float CollisionDSSolid:: -get_radius_b() const { - return _radius_b; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_normal_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE LVector3f CollisionDSSolid:: -get_normal_a() const { - return _plane_a.get_normal(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::dist_to_plane_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float CollisionDSSolid:: -dist_to_plane_a(const LPoint3f &point) const { - return _plane_a.dist_to_plane(point); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_plane_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_plane_a(const Planef &plane) { - _plane_a = plane; - mark_internal_bounds_stale(); - mark_viz_stale(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_plane_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE const Planef &CollisionDSSolid:: -get_plane_a() const { - return _plane_a; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_normal_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE LVector3f CollisionDSSolid:: -get_normal_b() const { - return _plane_b.get_normal(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::dist_to_plane_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float CollisionDSSolid:: -dist_to_plane_b(const LPoint3f &point) const { - return _plane_b.dist_to_plane(point); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::set_plane_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CollisionDSSolid:: -set_plane_b(const Planef &plane) { - _plane_b = plane; - mark_internal_bounds_stale(); - mark_viz_stale(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_plane_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE const Planef &CollisionDSSolid:: -get_plane_b() const { - return _plane_b; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_lens_radius -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -INLINE float CollisionDSSolid:: -get_lens_radius() const { - return _lens_radius; -} - diff --git a/panda/src/collide/collisionDSSolid.cxx b/panda/src/collide/collisionDSSolid.cxx deleted file mode 100755 index e2a629b048..0000000000 --- a/panda/src/collide/collisionDSSolid.cxx +++ /dev/null @@ -1,627 +0,0 @@ -// Filename: collisionDSSolid.cxx -// Created by: Dave Schuyler (05Apr06) -// Based on collision tube by: drose -// -//////////////////////////////////////////////////////////////////// -// -// 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 "collisionDSSolid.h" -#include "collisionSphere.h" -#include "collisionLine.h" -#include "collisionRay.h" -#include "collisionSegment.h" -#include "collisionHandler.h" -#include "collisionEntry.h" -#include "boundingSphere.h" -#include "config_collide.h" -#include "look_at.h" -#include "geom.h" -#include "geomNode.h" -#include "geometricBoundingVolume.h" -#include "datagram.h" -#include "datagramIterator.h" -#include "bamReader.h" -#include "bamWriter.h" -#include "cmath.h" -#include "transformState.h" -#include "geom.h" -#include "geomTristrips.h" -#include "geomTrifans.h" -#include "geomLinestrips.h" -#include "geomVertexWriter.h" - -PStatCollector CollisionDSSolid::_volume_pcollector( - "Collision Volumes:CollisionDSSolid"); -PStatCollector CollisionDSSolid::_test_pcollector( - "Collision Tests:CollisionDSSolid"); -TypeHandle CollisionDSSolid::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -CollisionSolid *CollisionDSSolid:: -make_copy() { - return new CollisionDSSolid(*this); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -PT(CollisionEntry) CollisionDSSolid:: -test_intersection(const CollisionEntry &entry) const { - return entry.get_into()->test_intersection_from_ds_solid(entry); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -xform(const LMatrix4f &mat) { - _center_a = _center_a * mat; - _center_b = _center_b * mat; - _plane_a = _plane_a * mat; - _plane_b = _plane_b * mat; - - // This is a little cheesy and fails miserably in the presence of a - // non-uniform scale. - LVector3f radius_v = LVector3f(_radius_a, 0.0f, 0.0f) * mat; - _radius_a = length(radius_v); - - recalc_internals(); - CollisionSolid::xform(mat); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// -LPoint3f CollisionDSSolid:: -get_collision_origin() const { - #if 1 - LVector3f vec = _center_b - _center_a; - float distance = vec.length(); - if (vec.normalize()) { - // "Let" a few variables - float dist_squared = distance * distance; - float dist_doubled = 2.0f * distance; - float radius_a_squared = _radius_a * _radius_a; - float radius_b_squared = _radius_b * _radius_b; - float n = dist_squared - radius_a_squared + radius_b_squared; - - // Get the lens center point on the intersection plane between - // sphere A and sphere B - LVector3f lens_center = _center_a + vec * (n / dist_doubled); - return lens_center; - } else { - // Since both spheres are in the same place, just return - // either of the centers - return _center_a; - } - #else - LVector3f vec = _center_b - _center_a; - return _center_a + (vec * 0.5); - #endif -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// -PStatCollector &CollisionDSSolid:: -get_volume_pcollector() { - return _volume_pcollector; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// -PStatCollector &CollisionDSSolid:: -get_test_pcollector() { - return _test_pcollector; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -output(ostream &out) const { - out << "DSSolid, a (" - << _center_a << "), ra " - << _radius_a << ", b (" - << _center_b << "), rb " - << _radius_b << ", pa (" - << _plane_a << "), pb " - << _plane_b << ")"; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -PT(BoundingVolume) CollisionDSSolid:: -compute_internal_bounds() const { - PT(BoundingVolume) bound = CollisionSolid::compute_internal_bounds(); - - if (bound->is_of_type(GeometricBoundingVolume::get_class_type())) { - GeometricBoundingVolume *gbound; - DCAST_INTO_R(gbound, bound, bound); - - LVector3f vec = _center_b - _center_a; - float distance = vec.length(); - if (vec.normalize()) { - // There is some distance between the centers, so the intersection - // between them is some kind of lens. - - // "Let" a few variables - float dist_squared = distance * distance; - float dist_doubled = 2.0f * distance; - float radius_a_squared = _radius_a * _radius_a; - float radius_b_squared = _radius_b * _radius_b; - float n = dist_squared - radius_a_squared + radius_b_squared; - float m = 4.0f * dist_squared * radius_a_squared - (n * n); - - cerr<<"distance:"< 0.0f); - - // Get the lens center point on the intersection plane between - // sphere A and sphere B - LPoint3f lens_center = _center_a + vec * (n / dist_doubled); - _lens_radius = (1.0f / dist_doubled) * sqrt(m); - cerr<<"lens_center:"<extend_by(&sphere); - } else { - // Both endpoints are coincident; therefore, the bounding volume - // is a sphere. - //TODO: account for cutting planes (which could make the sphere - // smaller, which is an optimization). - BoundingSphere sphere(_center_a, _radius_a); - gbound->extend_by(&sphere); - } - } - - return bound; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -PT(CollisionEntry) CollisionDSSolid:: -test_intersection_from_sphere(const CollisionEntry &entry) const { - const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), 0); - cerr<<"CollisionDSSolid::test_intersection_from_ds_solid\n"; - - CPT(TransformState) wrt_space = entry.get_wrt_space(); - - const LMatrix4f &wrt_mat = wrt_space->get_mat(); - - LPoint3f from_a = sphere->get_center() * wrt_mat; - LPoint3f from_b = from_a; - - LVector3f from_direction = from_b - from_a; - - LPoint3f from_center = sphere->get_center() * wrt_mat; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius = length(from_radius_v); - - LPoint3f sa_into_center = get_center_a(); - float sa_into_radius = get_radius_a(); - LVector3f sa_vec = from_center - sa_into_center; - float sa_distance_squared = dot(sa_vec, sa_vec); - float sa_and_from_radii_squared = ( - sa_into_radius + from_radius) * (sa_into_radius + from_radius); - if (sa_distance_squared > sa_and_from_radii_squared) { - // No intersection. - return NULL; - } - - LPoint3f sb_into_center = get_center_b(); - float sb_into_radius = get_radius_b(); - LVector3f sb_vec = from_center - sb_into_center; - float sb_distance_squared = dot(sb_vec, sb_vec); - float sb_and_from_radii_squared = ( - sb_into_radius + from_radius) * (sb_into_radius + from_radius); - if (sb_distance_squared > sb_and_from_radii_squared) { - // No intersection. - return NULL; - } - - float pa_distance = dist_to_plane_a(from_center); - if (pa_distance > from_radius) { - // No intersection. - return NULL; - } - - float pb_distance = dist_to_plane_b(from_center); - if (pb_distance > from_radius) { - // No intersection. - return NULL; - } - - if (collide_cat.is_debug()) { - collide_cat.debug() - << "intersection detected from " << entry.get_from_node_path() - << " into " << entry.get_into_node_path() << "\n"; - } - - LVector3f surface_normal; - LPoint3f surface_point; - float spheres = sqrtf(sa_distance_squared) - sqrtf(sb_distance_squared); - float planes = pa_distance - pb_distance; - if (spheres > planes) { - if (spheres > 0) { - // sphere_a is the furthest - cerr<<"sphere_a is the furthest"<<"\n"; - float vec_length = sa_vec.length(); - if (IS_NEARLY_ZERO(vec_length)) { - // The centers are coincident, use an arbitrary normal. - surface_normal.set(1.0, 0.0, 0.0); - } else { - surface_normal = sa_vec / vec_length; - } - surface_point = sa_into_center + surface_normal * sa_into_radius; - } else { - // sphere_b is the furthest - cerr<<"sphere_b is the furthest"<<"\n"; - float vec_length = sb_vec.length(); - if (IS_NEARLY_ZERO(vec_length)) { - // The centers are coincident, use an arbitrary normal. - surface_normal.set(1.0, 0.0, 0.0); - } else { - surface_normal = sb_vec / vec_length; - } - surface_point = sb_into_center + surface_normal * sb_into_radius; - } - } else { - if (planes > 0) { - // plane_a is the furthest - cerr<<"plane_a is the furthest"<<"\n"; - surface_normal = _plane_a.get_normal(); - surface_point = from_center - surface_normal * pa_distance; - } else { - // plane_b is the furthest - cerr<<"plane_b is the furthest"<<"\n"; - surface_normal = _plane_b.get_normal(); - surface_point = from_center - surface_normal * pb_distance; - } - } - - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - new_entry->set_surface_normal(surface_normal); - new_entry->set_surface_point(surface_point); - new_entry->set_interior_point(from_center - surface_normal * from_radius); - return new_entry; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -fill_viz_geom() { - if (collide_cat.is_debug()) { - collide_cat.debug() - << "Recomputing viz for " << *this << "\n"; - } - - // Generate the vertices such that we draw a shape with one sphere - // at (0, 0, 0), and another at (0, length, 0). Then we'll rotate - // and translate it into place with the appropriate look_at matrix. - LVector3f direction = _center_b - _center_a; - float half_length = direction.length() * 0.5f; - - // "Let" a few variables - float distance = direction.length(); - float dist_squared = distance * distance; - float dist_doubled = 2.0f * distance; - float radius_a_squared = _radius_a * _radius_a; - float radius_b_squared = _radius_b * _radius_b; - float triangle_height = ( - dist_squared - radius_a_squared + radius_b_squared) / dist_doubled; - - // Get (half) the angle from _center_a to the lens edge on the - // intersection plane between sphere A and sphere B - float half_arc_angle_a = acos(triangle_height / _radius_a); - float half_arc_angle_b = acos(triangle_height / _radius_b); - - PT(GeomVertexData) vdata = new GeomVertexData( - "collision", GeomVertexFormat::get_v3(), Geom::UH_static); - GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - - PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); - // Generate the first endcap. - static const int num_slices = 8; - static const int num_rings = 4; - int ri, si; - for (ri = 0; ri < num_rings; ++ri) { - for (si = 0; si <= num_slices; ++si) { - vertex.add_data3f(calc_sphere2_vertex( - ri, si, num_rings, num_slices, -half_length, half_arc_angle_a)); - vertex.add_data3f(calc_sphere2_vertex( - ri + 1, si, num_rings, num_slices, -half_length, half_arc_angle_a)); - } - strip->add_next_vertices((num_slices + 1) * 2); - strip->close_primitive(); - } - - // Add plane A - calc_plane(_plane_a); - - // Add plane B - calc_plane(_plane_b); - - // And the second endcap. - for (ri = num_rings - 1; ri >= 0; --ri) { - for (si = 0; si <= num_slices; ++si) { - vertex.add_data3f(calc_sphere1_vertex( - ri + 1, si, num_rings, num_slices, half_length, half_arc_angle_b)); - vertex.add_data3f(calc_sphere1_vertex( - ri, si, num_rings, num_slices, half_length, half_arc_angle_b)); - } - strip->add_next_vertices((num_slices + 1) * 2); - strip->close_primitive(); - } - - PT(Geom) geom = new Geom(vdata); - geom->add_primitive(strip); - - #if 0 - // Now transform the vertices to their actual location. - LMatrix4f mat; - look_at(mat, direction, LVector3f(0.0f, 0.0f, 1.0f), CS_zup_right); - mat.set_row(3, _ceneter_a); - geom->transform_vertices(mat); - #endif - - _viz_geom->add_geom(geom, get_solid_viz_state()); - _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::calc_plane -// Access: Private -// Description: Calculates a plane, for use in generating the -// viz geometry. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -calc_plane(const Planef &plane) { - LPoint3f cp; - LVector3f p1, p2, p3, p4; - - LVector3f normal = plane.get_normal(); - float D = plane[3]; - - if (fabs(normal[0]) > fabs(normal[1]) && - fabs(normal[0]) > fabs(normal[2])) { - // X has the largest coefficient. - cp.set(-D / normal[0], 0.0f, 0.0f); - p1 = LPoint3f(-(normal[1] + normal[2] + D)/normal[0], 1.0f, 1.0f) - cp; - - } else if (fabs(normal[1]) > fabs(normal[2])) { - // Y has the largest coefficient. - cp.set(0.0f, -D / normal[1], 0.0f); - p1 = LPoint3f(1.0f, -(normal[0] + normal[2] + D)/normal[1], 1.0f) - cp; - - } else { - // Z has the largest coefficient. - cp.set(0.0f, 0.0f, -D / normal[2]); - p1 = LPoint3f(1.0f, 1.0f, -(normal[0] + normal[1] + D)/normal[2]) - cp; - } - - p1.normalize(); - p2 = cross(normal, p1); - p3 = cross(normal, p2); - p4 = cross(normal, p3); - - static const double plane_scale = 100.0; - - PT(GeomVertexData) vdata = new GeomVertexData - ("collision", GeomVertexFormat::get_v3(), - Geom::UH_static); - GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - - vertex.add_data3f(cp + p1 * plane_scale); - vertex.add_data3f(cp + p2 * plane_scale); - vertex.add_data3f(cp + p3 * plane_scale); - vertex.add_data3f(cp + p4 * plane_scale); - - PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); - body->add_consecutive_vertices(0, 4); - body->close_primitive(); - - PT(GeomLinestrips) border = new GeomLinestrips(Geom::UH_static); - border->add_consecutive_vertices(0, 4); - border->add_vertex(0); - border->close_primitive(); - - PT(Geom) geom1 = new Geom(vdata); - geom1->add_primitive(body); - - PT(Geom) geom2 = new Geom(vdata); - geom2->add_primitive(border); - - _viz_geom->add_geom(geom1, get_solid_viz_state()); - _viz_geom->add_geom(geom2, get_wireframe_viz_state()); - - _bounds_viz_geom->add_geom(geom1, get_solid_bounds_viz_state()); - _bounds_viz_geom->add_geom(geom2, get_wireframe_bounds_viz_state()); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::calc_sphere1_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// first endcap hemisphere, for use in generating the -// viz geometry. -//////////////////////////////////////////////////////////////////// -Vertexf CollisionDSSolid:: -calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices, - float length, float angle) { - float r = (float)ri / (float)num_rings; - float s = (float)si / (float)num_slices; - - // Find the point on the rim, based on the slice. - float theta = s * 2.0f * MathNumbers::pi_f; - float y_rim = ccos(theta); - float z_rim = csin(theta); - - // Now pull that point in towards the pole, based on the ring. - float phi = r * angle; - float to_pole = csin(phi); - - float x = length -_radius_a * ccos(phi); - float y = _radius_a * y_rim * to_pole; - float z = _radius_a * z_rim * to_pole; - - return Vertexf(x, y, z); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::calc_sphere2_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// second endcap hemisphere, for use in generating the -// viz geometry. -//////////////////////////////////////////////////////////////////// -Vertexf CollisionDSSolid:: -calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, - float length, float angle) { - float r = (float)ri / (float)num_rings; - float s = (float)si / (float)num_slices; - - // Find the point on the rim, based on the slice. - float theta = s * 2.0f * MathNumbers::pi_f; - float y_rim = ccos(theta); - float z_rim = csin(theta); - - // Now pull that point in towards the pole, based on the ring. - float phi = r * angle; - float to_pole = csin(phi); - - float x = length + _radius_b * ccos(phi); - float y = _radius_b * y_rim * to_pole; - float z = _radius_b * z_rim * to_pole; - - return Vertexf(x, y, z); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::recalc_internals -// Access: Private -// Description: Should be called internally to recompute the matrix -// and length when the properties of the tube have -// changed. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -recalc_internals() { - mark_viz_stale(); - mark_internal_bounds_stale(); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionDSSolid. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -register_with_read_factory() { - BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -write_datagram(BamWriter *manager, Datagram &dg) { - CollisionSolid::write_datagram(manager, dg); - _center_a.write_datagram(dg); - dg.add_float32(_radius_a); - _center_b.write_datagram(dg); - dg.add_float32(_radius_b); - _plane_a.write_datagram(dg); - _plane_b.write_datagram(dg); -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionDSSolid is encountered -// in the Bam file. It should create the CollisionDSSolid -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// -TypedWritable *CollisionDSSolid:: -make_from_bam(const FactoryParams ¶ms) { - CollisionDSSolid *node = new CollisionDSSolid(); - DatagramIterator scan; - BamReader *manager; - - parse_params(params, scan, manager); - node->fillin(scan, manager); - - return node; -} - -//////////////////////////////////////////////////////////////////// -// Function: CollisionDSSolid::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionDSSolid. -//////////////////////////////////////////////////////////////////// -void CollisionDSSolid:: -fillin(DatagramIterator &scan, BamReader *manager) { - CollisionSolid::fillin(scan, manager); - _center_a.read_datagram(scan); - _radius_a = scan.get_float32(); - _center_b.read_datagram(scan); - _radius_b = scan.get_float32(); - _plane_a.read_datagram(scan); - _plane_b.read_datagram(scan); - recalc_internals(); -} diff --git a/panda/src/collide/collisionDSSolid.h b/panda/src/collide/collisionDSSolid.h deleted file mode 100755 index 7df14ef59d..0000000000 --- a/panda/src/collide/collisionDSSolid.h +++ /dev/null @@ -1,154 +0,0 @@ -// Filename: CollisionDSSolid.h -// Created by: Dave Schuyler (05Apr06) -// Based on collision tube by: drose -// -//////////////////////////////////////////////////////////////////// -// -// 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 COLLISIONDSSOLID_H -#define COLLISIONDSSOLID_H - -#include "pandabase.h" -#include "plane.h" -#include "collisionSolid.h" - -//////////////////////////////////////////////////////////////////// -// Class : CollisionDSSolid -// Description : A collision volume or object made up of the intersection -// of two spheres (potentially a lens) and two half-spaces -// (planes). -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_COLLIDE CollisionDSSolid: public CollisionSolid { -PUBLISHED: - INLINE CollisionDSSolid( - const LPoint3f ¢er_a, float radius_a, - const LPoint3f ¢er_b, float radius_b, - const Planef &plane_a, const Planef &plane_b); - INLINE CollisionDSSolid( - float ax, float ay, float az, float radius_a, - float bx, float by, float bz, float radius_b, - const Planef &plane_a, const Planef &plane_b); - - virtual LPoint3f get_collision_origin() const; - -protected: - INLINE CollisionDSSolid(); - -public: - INLINE CollisionDSSolid(const CollisionDSSolid ©); - virtual CollisionSolid *make_copy(); - - virtual PT(CollisionEntry) - test_intersection(const CollisionEntry &entry) const; - - INLINE float get_lens_radius() const; - - virtual void xform(const LMatrix4f &mat); - - virtual PStatCollector &get_volume_pcollector(); - virtual PStatCollector &get_test_pcollector(); - - virtual void output(ostream &out) const; - -PUBLISHED: - // Sphere a - INLINE void set_center_a(const LPoint3f ¢er); - INLINE void set_center_a(float x, float y, float z); - INLINE const LPoint3f &get_center_a() const; - - INLINE void set_radius_a(float radius); - INLINE float get_radius_a() const; - - // Sphere b - INLINE void set_center_b(const LPoint3f ¢er); - INLINE void set_center_b(float x, float y, float z); - INLINE const LPoint3f &get_center_b() const; - - INLINE void set_radius_b(float radius); - INLINE float get_radius_b() const; - - // Plane a - INLINE LVector3f get_normal_a() const; - INLINE float dist_to_plane_a(const LPoint3f &point) const; - - INLINE void set_plane_a(const Planef &plane); - INLINE const Planef &get_plane_a() const; - - // Plane b - INLINE LVector3f get_normal_b() const; - INLINE float dist_to_plane_b(const LPoint3f &point) const; - - INLINE void set_plane_b(const Planef &plane); - INLINE const Planef &get_plane_b() const; - -protected: - virtual PT(BoundingVolume) compute_internal_bounds() const; - - virtual PT(CollisionEntry) - test_intersection_from_sphere(const CollisionEntry &entry) const; - - virtual void fill_viz_geom(); - -protected: - void recalc_internals(); - Vertexf compute_point(float latitude, float longitude) const; - -private: - LPoint3f _center_a; - float _radius_a; - LPoint3f _center_b; - float _radius_b; - Planef _plane_a; - Planef _plane_b; - - mutable float _lens_radius; - - static PStatCollector _volume_pcollector; - static PStatCollector _test_pcollector; - - void calc_plane(const Planef &plane); - Vertexf calc_sphere1_vertex( - int ri, int si, int num_rings, int num_slices, float length, - float angle); - Vertexf calc_sphere2_vertex( - int ri, int si, int num_rings, int num_slices, float length, - float angle); - -public: - static void register_with_read_factory(); - virtual void write_datagram(BamWriter *manager, Datagram &me); - -protected: - static TypedWritable *make_CollisionSphere(const FactoryParams ¶ms); - static TypedWritable *make_from_bam(const FactoryParams ¶ms); - void fillin(DatagramIterator &scan, BamReader *manager); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - CollisionSolid::init_type(); - register_type(_type_handle, "CollisionDSSolid", - CollisionSolid::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "collisionDSSolid.I" - -#endif diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index a2e781b4f3..e2dc757119 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -130,7 +130,7 @@ get_into_node_path() const { // other CollisionEntries //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_t(float t) { +set_t(PN_stdfloat t) { nassertv(!cnan(t)); _t = t; } @@ -141,7 +141,7 @@ set_t(float t) { // Description: returns time value for this collision relative to // other CollisionEntries //////////////////////////////////////////////////////////////////// -INLINE float CollisionEntry:: +INLINE PN_stdfloat CollisionEntry:: get_t() const { return _t; } @@ -193,7 +193,7 @@ get_respect_prev_transform() const { // the "into" object. //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_surface_point(const LPoint3f &point) { +set_surface_point(const LPoint3 &point) { nassertv(!point.is_nan()); _surface_point = point; _flags |= F_has_surface_point; @@ -209,7 +209,7 @@ set_surface_point(const LPoint3f &point) { // the "into" object. //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_surface_normal(const LVector3f &normal) { +set_surface_normal(const LVector3 &normal) { nassertv(!normal.is_nan()); _surface_normal = normal; _flags |= F_has_surface_normal; @@ -229,7 +229,7 @@ set_surface_normal(const LVector3f &normal) { // the "into" object. //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_interior_point(const LPoint3f &point) { +set_interior_point(const LPoint3 &point) { nassertv(!point.is_nan()); _interior_point = point; _flags |= F_has_interior_point; @@ -284,7 +284,7 @@ has_interior_point() const { // the "into" object. //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_contact_pos(const LPoint3f &pos) { +set_contact_pos(const LPoint3 &pos) { nassertv(!pos.is_nan()); _contact_pos = pos; _flags |= F_has_contact_pos; @@ -300,7 +300,7 @@ set_contact_pos(const LPoint3f &pos) { // the "into" object. //////////////////////////////////////////////////////////////////// INLINE void CollisionEntry:: -set_contact_normal(const LVector3f &normal) { +set_contact_normal(const LVector3 &normal) { nassertv(!normal.is_nan()); _contact_normal = normal; _flags |= F_has_contact_normal; @@ -377,7 +377,7 @@ get_wrt_prev_space() const { // Description: Returns the relative transform of the from node as // seen from the into node. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &CollisionEntry:: +INLINE const LMatrix4 &CollisionEntry:: get_wrt_mat() const { return get_wrt_space()->get_mat(); } @@ -388,7 +388,7 @@ get_wrt_mat() const { // Description: Returns the relative transform of the into node as // seen from the from node. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &CollisionEntry:: +INLINE const LMatrix4 &CollisionEntry:: get_inv_wrt_mat() const { return get_inv_wrt_space()->get_mat(); } @@ -401,7 +401,7 @@ get_inv_wrt_mat() const { // (according to set_prev_transform(), set_fluid_pos(), // etc.) //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &CollisionEntry:: +INLINE const LMatrix4 &CollisionEntry:: get_wrt_prev_mat() const { return get_wrt_prev_space()->get_mat(); } diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 6d412e7d71..229cb3eb8b 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -77,9 +77,9 @@ operator = (const CollisionEntry ©) { // The point will be converted into whichever coordinate // space the caller specifies. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionEntry:: +LPoint3 CollisionEntry:: get_surface_point(const NodePath &space) const { - nassertr(has_surface_point(), LPoint3f::zero()); + nassertr(has_surface_point(), LPoint3::zero()); CPT(TransformState) transform = _into_node_path.get_transform(space); return _surface_point * transform->get_mat(); } @@ -93,9 +93,9 @@ get_surface_point(const NodePath &space) const { // The normal will be converted into whichever coordinate // space the caller specifies. //////////////////////////////////////////////////////////////////// -LVector3f CollisionEntry:: +LVector3 CollisionEntry:: get_surface_normal(const NodePath &space) const { - nassertr(has_surface_normal(), LVector3f::zero()); + nassertr(has_surface_normal(), LVector3::zero()); CPT(TransformState) transform = _into_node_path.get_transform(space); return _surface_normal * transform->get_mat(); } @@ -114,7 +114,7 @@ get_surface_normal(const NodePath &space) const { // The point will be converted into whichever coordinate // space the caller specifies. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionEntry:: +LPoint3 CollisionEntry:: get_interior_point(const NodePath &space) const { if (!has_interior_point()) { return get_surface_point(space); @@ -134,21 +134,21 @@ get_interior_point(const NodePath &space) const { // or false if any one of them is not. //////////////////////////////////////////////////////////////////// bool CollisionEntry:: -get_all(const NodePath &space, LPoint3f &surface_point, - LVector3f &surface_normal, LPoint3f &interior_point) const { +get_all(const NodePath &space, LPoint3 &surface_point, + LVector3 &surface_normal, LPoint3 &interior_point) const { CPT(TransformState) transform = _into_node_path.get_transform(space); - const LMatrix4f &mat = transform->get_mat(); + const LMatrix4 &mat = transform->get_mat(); bool all_ok = true; if (!has_surface_point()) { - surface_point = LPoint3f::zero(); + surface_point = LPoint3::zero(); all_ok = false; } else { surface_point = _surface_point * mat; } if (!has_surface_normal()) { - surface_normal = LVector3f::zero(); + surface_normal = LVector3::zero(); all_ok = false; } else { surface_normal = _surface_normal * mat; @@ -173,9 +173,9 @@ get_all(const NodePath &space, LPoint3f &surface_point, // The position will be converted into whichever coordinate // space the caller specifies. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionEntry:: +LPoint3 CollisionEntry:: get_contact_pos(const NodePath &space) const { - nassertr(has_contact_pos(), LPoint3f::zero()); + nassertr(has_contact_pos(), LPoint3::zero()); CPT(TransformState) transform = _into_node_path.get_transform(space); return _contact_pos * transform->get_mat(); } @@ -189,9 +189,9 @@ get_contact_pos(const NodePath &space) const { // The normal will be converted into whichever coordinate // space the caller specifies. //////////////////////////////////////////////////////////////////// -LVector3f CollisionEntry:: +LVector3 CollisionEntry:: get_contact_normal(const NodePath &space) const { - nassertr(has_contact_normal(), LVector3f::zero()); + nassertr(has_contact_normal(), LVector3::zero()); CPT(TransformState) transform = _into_node_path.get_transform(space); return _contact_normal * transform->get_mat(); } @@ -207,21 +207,21 @@ get_contact_normal(const NodePath &space) const { // or false if any one of them is not. //////////////////////////////////////////////////////////////////// bool CollisionEntry:: -get_all_contact_info(const NodePath &space, LPoint3f &contact_pos, - LVector3f &contact_normal) const { +get_all_contact_info(const NodePath &space, LPoint3 &contact_pos, + LVector3 &contact_normal) const { CPT(TransformState) transform = _into_node_path.get_transform(space); - const LMatrix4f &mat = transform->get_mat(); + const LMatrix4 &mat = transform->get_mat(); bool all_ok = true; if (!has_contact_pos()) { - contact_pos = LPoint3f::zero(); + contact_pos = LPoint3::zero(); all_ok = false; } else { contact_pos = _contact_pos * mat; } if (!has_contact_normal()) { - contact_normal = LVector3f::zero(); + contact_normal = LVector3::zero(); all_ok = false; } else { contact_normal = _contact_normal * mat; diff --git a/panda/src/collide/collisionEntry.h b/panda/src/collide/collisionEntry.h index 629fb38d15..5225ff1117 100644 --- a/panda/src/collide/collisionEntry.h +++ b/panda/src/collide/collisionEntry.h @@ -59,40 +59,40 @@ PUBLISHED: INLINE NodePath get_from_node_path() const; INLINE NodePath get_into_node_path() const; - INLINE void set_t(float t); - INLINE float get_t() const; + INLINE void set_t(PN_stdfloat t); + INLINE PN_stdfloat get_t() const; INLINE bool collided() const; INLINE void reset_collided(); INLINE bool get_respect_prev_transform() const; - INLINE void set_surface_point(const LPoint3f &point); - INLINE void set_surface_normal(const LVector3f &normal); - INLINE void set_interior_point(const LPoint3f &point); + INLINE void set_surface_point(const LPoint3 &point); + INLINE void set_surface_normal(const LVector3 &normal); + INLINE void set_interior_point(const LPoint3 &point); INLINE bool has_surface_point() const; INLINE bool has_surface_normal() const; INLINE bool has_interior_point() const; - INLINE void set_contact_pos(const LPoint3f &pos); - INLINE void set_contact_normal(const LVector3f &normal); + INLINE void set_contact_pos(const LPoint3 &pos); + INLINE void set_contact_normal(const LVector3 &normal); INLINE bool has_contact_pos() const; INLINE bool has_contact_normal() const; - LPoint3f get_surface_point(const NodePath &space) const; - LVector3f get_surface_normal(const NodePath &space) const; - LPoint3f get_interior_point(const NodePath &space) const; + LPoint3 get_surface_point(const NodePath &space) const; + LVector3 get_surface_normal(const NodePath &space) const; + LPoint3 get_interior_point(const NodePath &space) const; bool get_all(const NodePath &space, - LPoint3f &surface_point, - LVector3f &surface_normal, - LPoint3f &interior_point) const; + LPoint3 &surface_point, + LVector3 &surface_normal, + LPoint3 &interior_point) const; - LPoint3f get_contact_pos(const NodePath &space) const; - LVector3f get_contact_normal(const NodePath &space) const; + LPoint3 get_contact_pos(const NodePath &space) const; + LVector3 get_contact_normal(const NodePath &space) const; bool get_all_contact_info(const NodePath &space, - LPoint3f &contact_pos, - LVector3f &contact_normal) const; + LPoint3 &contact_pos, + LVector3 &contact_normal) const; void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; @@ -102,9 +102,9 @@ public: INLINE CPT(TransformState) get_inv_wrt_space() const; INLINE CPT(TransformState) get_wrt_prev_space() const; - INLINE const LMatrix4f &get_wrt_mat() const; - INLINE const LMatrix4f &get_inv_wrt_mat() const; - INLINE const LMatrix4f &get_wrt_prev_mat() const; + INLINE const LMatrix4 &get_wrt_mat() const; + INLINE const LMatrix4 &get_inv_wrt_mat() const; + INLINE const LMatrix4 &get_wrt_prev_mat() const; INLINE const ClipPlaneAttrib *get_into_clip_planes() const; @@ -121,7 +121,7 @@ private: NodePath _from_node_path; NodePath _into_node_path; CPT(ClipPlaneAttrib) _into_clip_planes; - float _t; + PN_stdfloat _t; enum Flags { F_has_surface_point = 0x0001, @@ -135,12 +135,12 @@ private: int _flags; - LPoint3f _surface_point; - LVector3f _surface_normal; - LPoint3f _interior_point; + LPoint3 _surface_point; + LVector3 _surface_normal; + LPoint3 _interior_point; - LPoint3f _contact_pos; - LVector3f _contact_normal; + LPoint3 _contact_pos; + LVector3 _contact_normal; public: static TypeHandle get_class_type() { diff --git a/panda/src/collide/collisionFloorMesh.I b/panda/src/collide/collisionFloorMesh.I index 04599f8ff9..3ee05b3e0d 100755 --- a/panda/src/collide/collisionFloorMesh.I +++ b/panda/src/collide/collisionFloorMesh.I @@ -52,7 +52,7 @@ flush_level() { // Description: store away a vertex to index against //////////////////////////////////////////////////////////////////// INLINE void CollisionFloorMesh:: -add_vertex(const LPoint3f &vert) { +add_vertex(const LPoint3 &vert) { _vertices.push_back(vert); } @@ -61,7 +61,7 @@ get_num_vertices() const { return _vertices.size(); } -INLINE const LPoint3f CollisionFloorMesh:: +INLINE const LPoint3 CollisionFloorMesh:: get_vertex(unsigned int index) const { return _vertices[index]; } diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index f8fbf96d0d..65d21d61ef 100755 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -54,19 +54,19 @@ make_copy() { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionFloorMesh:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { - pvector::iterator vi; + pvector::iterator vi; for (vi=_vertices.begin();vi!=_vertices.end();++vi) { - LPoint3f pt = (*vi) * mat; + LPoint3 pt = (*vi) * mat; (*vi).set(pt[0],pt[1],pt[2]); } pvector::iterator ti; for (ti=_triangles.begin();ti!=_triangles.end();++ti) { CollisionFloorMesh::TriangleIndices tri = *ti; - LPoint3f v1 = _vertices[tri.p1]; - LPoint3f v2 = _vertices[tri.p2]; - LPoint3f v3 = _vertices[tri.p3]; + LPoint3 v1 = _vertices[tri.p1]; + LPoint3 v2 = _vertices[tri.p2]; + LPoint3 v3 = _vertices[tri.p3]; tri.min_x=min(min(v1[0],v2[0]),v3[0]); tri.max_x=max(max(v1[0],v2[0]),v3[0]); @@ -84,12 +84,12 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionFloorMesh:: +LPoint3 CollisionFloorMesh:: get_collision_origin() const { // No real sensible origin exists for a plane. We return 0, 0, 0, // without even bothering to ensure that that point exists on the // plane. - return LPoint3f::origin(); + return LPoint3::origin(); } //////////////////////////////////////////////////////////////////// @@ -114,11 +114,11 @@ compute_internal_bounds() const { } - pvector::const_iterator pi = _vertices.begin(); - LPoint3f p = (*pi); + pvector::const_iterator pi = _vertices.begin(); + LPoint3 p = (*pi); - LPoint3f x = p; - LPoint3f n = p; + LPoint3 x = p; + LPoint3 n = p; for (++pi; pi != _vertices.end(); ++pi) { p = *pi; @@ -143,7 +143,7 @@ PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - LPoint3f from_origin = ray->get_origin() * entry.get_wrt_mat(); + LPoint3 from_origin = ray->get_origin() * entry.get_wrt_mat(); double fx = from_origin[0]; double fy = from_origin[1]; @@ -157,13 +157,13 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } //okay, there's a good chance we'll be colliding - LPoint3f p0 = _vertices[tri.p1]; - LPoint3f p1 = _vertices[tri.p2]; - LPoint3f p2 = _vertices[tri.p3]; - float p0x = p0[0]; - float p0y = p0[1]; - float e0x, e0y, e1x, e1y, e2x, e2y; - float u, v; + LPoint3 p0 = _vertices[tri.p1]; + LPoint3 p1 = _vertices[tri.p2]; + LPoint3 p2 = _vertices[tri.p3]; + PN_stdfloat p0x = p0[0]; + PN_stdfloat p0y = p0[1]; + PN_stdfloat e0x, e0y, e1x, e1y, e2x, e2y; + PN_stdfloat u, v; e0x = fx - p0x; e0y = fy - p0y; e1x = p1[0] - p0x; e1y = p1[1] - p0y; @@ -176,7 +176,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { v = (e0y - (e2y * u)) / e1y; if (v < 0.0) continue; } else { - float d = (e2y * e1x) - (e2x * e1y); + PN_stdfloat d = (e2y * e1x) - (e2x * e1y); if (d == 0.0) continue; u = ((e0y * e1x) - (e0x * e1y)) / d; if (u < 0.0 || u > 1.0) continue; @@ -185,16 +185,16 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } if (u + v <= 0.0 || u + v > 1.0) continue; //we collided!! - float mag = u + v; - float p0z = p0[2]; + PN_stdfloat mag = u + v; + PN_stdfloat p0z = p0[2]; - float uz = (p2[2] - p0z) * mag; - float vz = (p1[2] - p0z) * mag; - float finalz = p0z + vz + (((uz - vz) * u) / (u + v)); + PN_stdfloat uz = (p2[2] - p0z) * mag; + PN_stdfloat vz = (p1[2] - p0z) * mag; + PN_stdfloat finalz = p0z + vz + (((uz - vz) * u) / (u + v)); PT(CollisionEntry) new_entry = new CollisionEntry(entry); - new_entry->set_surface_normal(LPoint3f(0, 0, 1)); - new_entry->set_surface_point(LPoint3f(fx, fy, finalz)); + new_entry->set_surface_normal(LPoint3(0, 0, 1)); + new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } return NULL; @@ -210,13 +210,13 @@ PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; DCAST_INTO_R(sphere, entry.get_from(), 0); - LPoint3f from_origin = sphere->get_center() * entry.get_wrt_mat(); + LPoint3 from_origin = sphere->get_center() * entry.get_wrt_mat(); double fx = from_origin[0]; double fy = from_origin[1]; - float fz = float(from_origin[2]); - float rad = sphere->get_radius(); + PN_stdfloat fz = PN_stdfloat(from_origin[2]); + PN_stdfloat rad = sphere->get_radius(); CollisionFloorMesh::Triangles::const_iterator ti; for (ti = _triangles.begin(); ti < _triangles.end(); ++ti) { TriangleIndices tri = *ti; @@ -226,13 +226,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } //okay, there's a good chance we'll be colliding - LPoint3f p0 = _vertices[tri.p1]; - LPoint3f p1 = _vertices[tri.p2]; - LPoint3f p2 = _vertices[tri.p3]; - float p0x = p0[0]; - float p0y = p0[1]; - float e0x, e0y, e1x, e1y, e2x, e2y; - float u, v; + LPoint3 p0 = _vertices[tri.p1]; + LPoint3 p1 = _vertices[tri.p2]; + LPoint3 p2 = _vertices[tri.p3]; + PN_stdfloat p0x = p0[0]; + PN_stdfloat p0y = p0[1]; + PN_stdfloat e0x, e0y, e1x, e1y, e2x, e2y; + PN_stdfloat u, v; e0x = fx - p0x; e0y = fy - p0y; e1x = p1[0] - p0x; e1y = p1[1] - p0y; @@ -245,7 +245,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { v = (e0y - (e2y * u)) / e1y; if (v < 0.0) continue; } else { - float d = (e2y * e1x) - (e2x * e1y); + PN_stdfloat d = (e2y * e1x) - (e2x * e1y); if (d == 0.0) continue; u = ((e0y * e1x) - (e0x * e1y)) / d; if (u < 0.0 || u > 1.0) continue; @@ -254,19 +254,19 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } if (u + v <= 0.0 || u + v > 1.0) continue; //we collided!! - float mag = u + v; - float p0z = p0[2]; + PN_stdfloat mag = u + v; + PN_stdfloat p0z = p0[2]; - float uz = (p2[2] - p0z) * mag; - float vz = (p1[2] - p0z) * mag; - float finalz = p0z+vz+(((uz - vz) *u)/(u+v)); - float dz = fz - finalz; + PN_stdfloat uz = (p2[2] - p0z) * mag; + PN_stdfloat vz = (p1[2] - p0z) * mag; + PN_stdfloat finalz = p0z+vz+(((uz - vz) *u)/(u+v)); + PN_stdfloat dz = fz - finalz; if(dz > rad) return NULL; PT(CollisionEntry) new_entry = new CollisionEntry(entry); - new_entry->set_surface_normal(LPoint3f(0, 0, 1)); - new_entry->set_surface_point(LPoint3f(fx, fy, finalz)); + new_entry->set_surface_normal(LPoint3(0, 0, 1)); + new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } return NULL; @@ -296,10 +296,10 @@ fill_viz_geom() { PT(GeomTriangles) mesh = new GeomTriangles(Geom::UH_static); PT(GeomLinestrips) wire = new GeomLinestrips(Geom::UH_static); pvector::iterator ti; - pvector::iterator vi; + pvector::iterator vi; for (vi = _vertices.begin(); vi != _vertices.end(); vi++) { - LPoint3f vert = *vi; - vertex.add_data3f(vert); + LPoint3 vert = *vi; + vertex.add_data3(vert); } for (ti = _triangles.begin(); ti != _triangles.end(); ++ti) { CollisionFloorMesh::TriangleIndices tri = *ti; @@ -368,10 +368,10 @@ write_datagram(BamWriter *manager, Datagram &me) me.add_uint32(_triangles[i].p1); me.add_uint32(_triangles[i].p2); me.add_uint32(_triangles[i].p3); - me.add_float32(_triangles[i].min_x); - me.add_float32(_triangles[i].max_x); - me.add_float32(_triangles[i].min_y); - me.add_float32(_triangles[i].max_y); + me.add_stdfloat(_triangles[i].min_x); + me.add_stdfloat(_triangles[i].max_x); + me.add_stdfloat(_triangles[i].min_y); + me.add_stdfloat(_triangles[i].max_y); } } @@ -390,7 +390,7 @@ fillin(DatagramIterator& scan, BamReader* manager) CollisionSolid::fillin(scan, manager); unsigned int num_verts = scan.get_uint16(); for (size_t i = 0; i < num_verts; i++) { - LPoint3f vert; + LPoint3 vert; vert.read_datagram(scan); _vertices.push_back(vert); @@ -403,10 +403,10 @@ fillin(DatagramIterator& scan, BamReader* manager) tri.p2 = scan.get_uint32(); tri.p3 = scan.get_uint32(); - tri.min_x=scan.get_float32(); - tri.max_x=scan.get_float32(); - tri.min_y=scan.get_float32(); - tri.max_y=scan.get_float32(); + tri.min_x=scan.get_stdfloat(); + tri.max_x=scan.get_stdfloat(); + tri.min_y=scan.get_stdfloat(); + tri.max_y=scan.get_stdfloat(); _triangles.push_back(tri); } } @@ -459,9 +459,9 @@ add_triangle(unsigned int pointA, unsigned int pointB, unsigned int pointC) { tri.p1 = pointA; tri.p2 = pointB; tri.p3 = pointC; - LPoint3f v1 = _vertices[pointA]; - LPoint3f v2 = _vertices[pointB]; - LPoint3f v3 = _vertices[pointC]; + LPoint3 v1 = _vertices[pointA]; + LPoint3 v2 = _vertices[pointB]; + LPoint3 v3 = _vertices[pointC]; tri.min_x=min(min(v1[0],v2[0]),v3[0]); tri.max_x=max(max(v1[0],v2[0]),v3[0]); diff --git a/panda/src/collide/collisionFloorMesh.h b/panda/src/collide/collisionFloorMesh.h index df1c21f542..5f38298d69 100755 --- a/panda/src/collide/collisionFloorMesh.h +++ b/panda/src/collide/collisionFloorMesh.h @@ -20,8 +20,7 @@ #include "collisionPlane.h" #include "clipPlaneAttrib.h" #include "look_at.h" - -#include "vector_LPoint2f.h" +#include "pvector.h" class GeomNode; @@ -36,10 +35,10 @@ public: unsigned int p1; unsigned int p2; unsigned int p3; - float min_x; - float max_x; - float min_y; - float max_y; + PN_stdfloat min_x; + PN_stdfloat max_x; + PN_stdfloat min_y; + PN_stdfloat max_y; } TriangleIndices; @@ -47,17 +46,17 @@ PUBLISHED: INLINE CollisionFloorMesh(); - INLINE void add_vertex(const LPoint3f &vert); + INLINE void add_vertex(const LPoint3 &vert); void add_triangle(unsigned int pointA, unsigned int pointB, unsigned int pointC); INLINE const unsigned int get_num_vertices() const; - INLINE const LPoint3f get_vertex(unsigned int index) const; + INLINE const LPoint3 get_vertex(unsigned int index) const; MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); INLINE const unsigned int get_num_triangles() const; INLINE const LPoint3d get_triangle(unsigned int index) const; MAKE_SEQ(get_triangles, get_num_triangles, get_triangle); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; public: CollisionFloorMesh(const CollisionFloorMesh ©); @@ -65,7 +64,7 @@ public: public: - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); @@ -86,7 +85,7 @@ protected: virtual void fill_viz_geom(); private: - typedef pvector< LPoint3f > Vertices; + typedef pvector< LPoint3 > Vertices; typedef pvector< TriangleIndices > Triangles; diff --git a/panda/src/collide/collisionGeom.I b/panda/src/collide/collisionGeom.I index de09795f39..e1f2b4b6e6 100644 --- a/panda/src/collide/collisionGeom.I +++ b/panda/src/collide/collisionGeom.I @@ -19,8 +19,8 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionGeom:: -CollisionGeom(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c) : +CollisionGeom(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c) : CollisionPolygon(a, b, c) { } diff --git a/panda/src/collide/collisionGeom.h b/panda/src/collide/collisionGeom.h index 2ce954922e..84730b98c1 100644 --- a/panda/src/collide/collisionGeom.h +++ b/panda/src/collide/collisionGeom.h @@ -32,8 +32,8 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionGeom : public CollisionPolygon { private: - INLINE CollisionGeom(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c); + INLINE CollisionGeom(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c); INLINE CollisionGeom(const CollisionGeom ©); public: diff --git a/panda/src/collide/collisionHandlerFloor.I b/panda/src/collide/collisionHandlerFloor.I index 08f933e1ff..a094532b65 100644 --- a/panda/src/collide/collisionHandlerFloor.I +++ b/panda/src/collide/collisionHandlerFloor.I @@ -21,7 +21,7 @@ // actual height at which to set the collider. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerFloor:: -set_offset(float offset) { +set_offset(PN_stdfloat offset) { _offset = offset; } @@ -32,7 +32,7 @@ set_offset(float offset) { // the highest detected collision point to determine the // actual height at which to set the collider. //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerFloor:: +INLINE PN_stdfloat CollisionHandlerFloor:: get_offset() const { return _offset; } @@ -44,7 +44,7 @@ get_offset() const { // the highest collision point //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerFloor:: -set_reach(float reach) { +set_reach(PN_stdfloat reach) { _reach = reach; } @@ -54,7 +54,7 @@ set_reach(float reach) { // Description: Returns the reach to add to (or subtract from) // the highest collision point //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerFloor:: +INLINE PN_stdfloat CollisionHandlerFloor:: get_reach() const { return _reach; } @@ -68,7 +68,7 @@ get_reach() const { // instantly teleport any distance. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerFloor:: -set_max_velocity(float max_velocity) { +set_max_velocity(PN_stdfloat max_velocity) { _max_velocity = max_velocity; } @@ -79,7 +79,7 @@ set_max_velocity(float max_velocity) { // be allowed to descend towards a floor below it, in // units per second. See set_max_velocity(). //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerFloor:: +INLINE PN_stdfloat CollisionHandlerFloor:: get_max_velocity() const { return _max_velocity; } diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index fbfad59168..c86933d696 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -53,7 +53,7 @@ CollisionHandlerFloor:: // // //////////////////////////////////////////////////////////////////// -float CollisionHandlerFloor:: +PN_stdfloat CollisionHandlerFloor:: set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries) { // Get the maximum height for all collisions with this node. // This is really the distance to-the-ground, so it will @@ -62,8 +62,8 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod // the avatar is right-side-up (or the ray is plumb)). bool got_max = false; bool got_min = false; - float max_height = 0.0f; - float min_height = 0.0f; + PN_stdfloat max_height = 0.0f; + PN_stdfloat min_height = 0.0f; CollisionEntry *highest = NULL; CollisionEntry *lowest = NULL; @@ -74,13 +74,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { - LPoint3f point = entry->get_surface_point(target_node_path); + LPoint3 point = entry->get_surface_point(target_node_path); if (collide_cat.is_debug()) { collide_cat.debug() << "Intersection point detected at " << point << "\n"; } - float height = point[2]; + PN_stdfloat height = point[2]; if (height < _offset + _reach && (!got_max || height > max_height)) { got_max = true; @@ -165,7 +165,7 @@ handle_entries() { #if 0 // Get the maximum height for all collisions with this node. bool got_max = false; - float max_height = 0.0f; + PN_stdfloat max_height = 0.0f; CollisionEntry *max_entry = NULL; Entries::const_iterator ei; @@ -175,13 +175,13 @@ handle_entries() { nassertr(from_node_path == entry->get_from_node_path(), false); if (entry->has_surface_point()) { - LPoint3f point = entry->get_surface_point(def._target); + LPoint3 point = entry->get_surface_point(def._target); if (collide_cat.is_debug()) { collide_cat.debug() << "Intersection point detected at " << point << "\n"; } - float height = point[2]; + PN_stdfloat height = point[2]; if (!got_max || height > max_height) { got_max = true; max_height = height; @@ -195,12 +195,12 @@ handle_entries() { _current_colliding.insert(max_entry); // Now set our height accordingly. - float adjust = max_height + _offset; + PN_stdfloat adjust = max_height + _offset; #else - float max_height = set_highest_collision(def._target, from_node_path, entries); + PN_stdfloat max_height = set_highest_collision(def._target, from_node_path, entries); // Now set our height accordingly. - float adjust = max_height + _offset; + PN_stdfloat adjust = max_height + _offset; #endif if (!IS_THRESHOLD_ZERO(adjust, 0.001)) { if (collide_cat.is_debug()) { @@ -209,18 +209,18 @@ handle_entries() { } if (adjust < 0.0f && _max_velocity != 0.0f) { - float max_adjust = + PN_stdfloat max_adjust = _max_velocity * ClockObject::get_global_clock()->get_dt(); adjust = max(adjust, -max_adjust); } CPT(TransformState) trans = def._target.get_transform(); - LVecBase3f pos = trans->get_pos(); + LVecBase3 pos = trans->get_pos(); pos[2] += adjust; def._target.set_transform(trans->set_pos(pos)); def.updated_transform(); - apply_linear_force(def, LVector3f(0.0f, 0.0f, adjust)); + apply_linear_force(def, LVector3(0.0f, 0.0f, adjust)); } else { if (collide_cat.is_spam()) { collide_cat.spam() @@ -240,5 +240,5 @@ handle_entries() { // Description: //////////////////////////////////////////////////////////////////// void CollisionHandlerFloor:: -apply_linear_force(ColliderDef &def, const LVector3f &force) { +apply_linear_force(ColliderDef &def, const LVector3 &force) { } diff --git a/panda/src/collide/collisionHandlerFloor.h b/panda/src/collide/collisionHandlerFloor.h index f686c5d9ed..931cec023d 100644 --- a/panda/src/collide/collisionHandlerFloor.h +++ b/panda/src/collide/collisionHandlerFloor.h @@ -33,24 +33,24 @@ PUBLISHED: CollisionHandlerFloor(); virtual ~CollisionHandlerFloor(); - INLINE void set_offset(float offset); - INLINE float get_offset() const; + INLINE void set_offset(PN_stdfloat offset); + INLINE PN_stdfloat get_offset() const; - INLINE void set_reach(float reach); - INLINE float get_reach() const; + INLINE void set_reach(PN_stdfloat reach); + INLINE PN_stdfloat get_reach() const; - INLINE void set_max_velocity(float max_vel); - INLINE float get_max_velocity() const; + INLINE void set_max_velocity(PN_stdfloat max_vel); + INLINE PN_stdfloat get_max_velocity() const; protected: - float set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries); + PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries); virtual bool handle_entries(); - virtual void apply_linear_force(ColliderDef &def, const LVector3f &force); + virtual void apply_linear_force(ColliderDef &def, const LVector3 &force); private: - float _offset; - float _reach; - float _max_velocity; + PN_stdfloat _offset; + PN_stdfloat _reach; + PN_stdfloat _max_velocity; public: diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 3d5a85010d..b3bb2f6141 100755 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -132,35 +132,35 @@ handle_entries() { Entries entries(*orig_entries); // this is the original position delta for the entire frame, before collision response - LVector3f M(from_node_path.get_pos_delta(wrt_node)); + LVector3 M(from_node_path.get_pos_delta(wrt_node)); // this is used to track position deltas every time we collide against a solid - LVector3f N(M); + LVector3 N(M); - const LPoint3f orig_pos(from_node_path.get_pos(wrt_node)); + const LPoint3 orig_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) prev_trans(from_node_path.get_prev_transform(wrt_node)); - const LPoint3f orig_prev_pos(prev_trans->get_pos()); + const LPoint3 orig_prev_pos(prev_trans->get_pos()); // currently we only support spheres as the collider const CollisionSphere *sphere; DCAST_INTO_R(sphere, entries.front()->get_from(), 0); from_node_path.set_pos(wrt_node, 0,0,0); - LPoint3f sphere_offset = (sphere->get_center() * + LPoint3 sphere_offset = (sphere->get_center() * from_node_path.get_transform(wrt_node)->get_mat()); from_node_path.set_pos(wrt_node, orig_pos); // this will hold the final calculated position at each iteration - LPoint3f candidate_final_pos(orig_pos); + LPoint3 candidate_final_pos(orig_pos); // this holds the position before reacting to collisions - LPoint3f uncollided_pos(candidate_final_pos); + LPoint3 uncollided_pos(candidate_final_pos); // unit vector facing back into original direction of motion - LVector3f reverse_vec(-M); + LVector3 reverse_vec(-M); reverse_vec.normalize(); // unit vector pointing out to the right relative to the direction of motion, // looking into the direction of motion - const LVector3f right_unit(LVector3f::up().cross(reverse_vec)); + const LVector3 right_unit(LVector3::up().cross(reverse_vec)); // iterate until the mover runs out of movement or gets stuck while (true) { @@ -182,8 +182,8 @@ handle_entries() { } // move back to initial contact position - LPoint3f contact_pos; - LVector3f contact_normal; + LPoint3 contact_pos; + LVector3 contact_normal; if (!C->get_all_contact_info(wrt_node, contact_pos, contact_normal)) { collide_cat.warning() @@ -197,14 +197,14 @@ handle_entries() { uncollided_pos = candidate_final_pos; candidate_final_pos = contact_pos; - LVector3f proj_surface_normal(contact_normal); + LVector3 proj_surface_normal(contact_normal); - LVector3f norm_proj_surface_normal(proj_surface_normal); + LVector3 norm_proj_surface_normal(proj_surface_normal); norm_proj_surface_normal.normalize(); - LVector3f blocked_movement(uncollided_pos - contact_pos); + LVector3 blocked_movement(uncollided_pos - contact_pos); - float push_magnitude(-blocked_movement.dot(proj_surface_normal)); + PN_stdfloat push_magnitude(-blocked_movement.dot(proj_surface_normal)); if (push_magnitude < 0.0f) { // don't ever push into plane candidate_final_pos = contact_pos; @@ -220,9 +220,9 @@ handle_entries() { from_node_path.set_prev_transform(wrt_node, prev_trans); { - const LPoint3f new_pos(from_node_path.get_pos(wrt_node)); + const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) new_prev_trans(from_node_path.get_prev_transform(wrt_node)); - const LPoint3f new_prev_pos(new_prev_trans->get_pos()); + const LPoint3 new_prev_pos(new_prev_trans->get_pos()); } // recalculate the position delta @@ -254,8 +254,8 @@ handle_entries() { prev_trans = prev_trans->set_pos(orig_prev_pos); from_node_path.set_prev_transform(wrt_node, prev_trans); - LVector3f net_shove(candidate_final_pos - orig_pos); - LVector3f force_normal(net_shove); + LVector3 net_shove(candidate_final_pos - orig_pos); + LVector3 force_normal(net_shove); force_normal.normalize(); // This is the part where the node actually gets moved: diff --git a/panda/src/collide/collisionHandlerGravity.I b/panda/src/collide/collisionHandlerGravity.I index e749ba5d53..a82771b3de 100755 --- a/panda/src/collide/collisionHandlerGravity.I +++ b/panda/src/collide/collisionHandlerGravity.I @@ -21,7 +21,7 @@ // actual height at which to set the collider. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -set_offset(float offset) { +set_offset(PN_stdfloat offset) { _offset = offset; } @@ -32,7 +32,7 @@ set_offset(float offset) { // the highest detected collision point to determine the // actual height at which to set the collider. //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_offset() const { return _offset; } @@ -44,7 +44,7 @@ get_offset() const { // the highest collision point //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -set_reach(float reach) { +set_reach(PN_stdfloat reach) { _reach = reach; } @@ -54,7 +54,7 @@ set_reach(float reach) { // Description: Returns the reach to add to (or subtract from) // the highest collision point //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_reach() const { return _reach; } @@ -70,7 +70,7 @@ get_reach() const { // // See Also: is_in_outer_space() //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_airborne_height() const { return _airborne_height; } @@ -98,7 +98,7 @@ is_on_ground() const { // Normally I avoid polling, but we are calling // is_on_ground() frequently anyway. //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_impact_velocity() const { return _impact_velocity; } @@ -108,7 +108,7 @@ get_impact_velocity() const { // Access : Public // Description : //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &CollisionHandlerGravity:: +INLINE const LVector3 &CollisionHandlerGravity:: get_contact_normal() const { return _contact_normal; } @@ -122,7 +122,7 @@ get_contact_normal() const { // even in cpp. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -add_velocity(float velocity) { +add_velocity(PN_stdfloat velocity) { _current_velocity += velocity; } @@ -132,7 +132,7 @@ add_velocity(float velocity) { // Description: Sets the current vertical velocity. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -set_velocity(float velocity) { +set_velocity(PN_stdfloat velocity) { _current_velocity = velocity; } @@ -151,7 +151,7 @@ set_velocity(float velocity) { // // See Also: is_on_ground() and get_gravity() //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_velocity() const { return _current_velocity; } @@ -162,7 +162,7 @@ get_velocity() const { // Description: Sets the linear gravity force (always plumb). //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -set_gravity(float gravity) { +set_gravity(PN_stdfloat gravity) { _gravity = gravity; } @@ -171,7 +171,7 @@ set_gravity(float gravity) { // Access: Public // Description: Gets the linear gravity force (always plumb). //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_gravity() const { return _gravity; } @@ -185,7 +185,7 @@ get_gravity() const { // instantly teleport any distance. //////////////////////////////////////////////////////////////////// INLINE void CollisionHandlerGravity:: -set_max_velocity(float max_velocity) { +set_max_velocity(PN_stdfloat max_velocity) { _max_velocity = max_velocity; } @@ -196,7 +196,7 @@ set_max_velocity(float max_velocity) { // be allowed to descend towards a floor below it, in // units per second. See set_max_velocity(). //////////////////////////////////////////////////////////////////// -INLINE float CollisionHandlerGravity:: +INLINE PN_stdfloat CollisionHandlerGravity:: get_max_velocity() const { return _max_velocity; } diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index 00f50ce107..3fbeaf2c4b 100755 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -32,10 +32,10 @@ CollisionHandlerGravity() { _reach = 1.0f; _airborne_height = 0.0f; _impact_velocity = 0.0f; - _gravity = 32.174f; + _gravity = 32.174; _current_velocity = 0.0f; _max_velocity = 400.0f; - _contact_normal = LVector3f::zero(); + _contact_normal = LVector3::zero(); _legacy_mode = false; } @@ -61,11 +61,11 @@ CollisionHandlerGravity:: //////////////////////////////////////////////////////////////////// #define OLD_COLLISION_HANDLER_GRAVITY 0 #if OLD_COLLISION_HANDLER_GRAVITY -float CollisionHandlerGravity:: +PN_stdfloat CollisionHandlerGravity:: set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries) { // Get the maximum height for all collisions with this node. bool got_max = false; - float max_height = 0.0f; + PN_stdfloat max_height = 0.0f; CollisionEntry *highest = NULL; Entries::const_iterator ei; @@ -75,13 +75,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { - LPoint3f point = entry->get_surface_point(target_node_path); + LPoint3 point = entry->get_surface_point(target_node_path); if (collide_cat.is_debug()) { collide_cat.debug() << "Intersection point detected at " << point << "\n"; } - float height = point[2]; + PN_stdfloat height = point[2]; if (!got_max || height > max_height) { got_max = true; max_height = height; @@ -112,7 +112,7 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod return max_height; } #else -float CollisionHandlerGravity:: +PN_stdfloat CollisionHandlerGravity:: set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries) { // Get the maximum height for all collisions with this node. // This is really the distance to-the-ground, so it will @@ -121,8 +121,8 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod // the avatar is right-side-up (or the ray is plumb)). bool got_max = false; bool got_min = false; - float max_height = 0.0f; - float min_height = 0.0f; + PN_stdfloat max_height = 0.0f; + PN_stdfloat min_height = 0.0f; CollisionEntry *highest = NULL; CollisionEntry *lowest = NULL; @@ -135,12 +135,12 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { - LPoint3f point = entry->get_surface_point(target_node_path); + LPoint3 point = entry->get_surface_point(target_node_path); if (collide_cat.is_debug()) { collide_cat.debug() << "Intersection point detected at " << point << "\n"; } - float height = point[2]; + PN_stdfloat height = point[2]; if(height < _offset + _reach) { valid_entries.push_back(entry); if (!got_max || height > max_height) { @@ -245,13 +245,13 @@ handle_entries() { okflag = false; } else { ColliderDef &def = (*ci).second; - float max_height = set_highest_collision(def._target, from_node_path, entries); + PN_stdfloat max_height = set_highest_collision(def._target, from_node_path, entries); // Now set our height accordingly. #if OLD_COLLISION_HANDLER_GRAVITY - float adjust = max_height + _offset; + PN_stdfloat adjust = max_height + _offset; #else - float adjust = max_height + _offset; + PN_stdfloat adjust = max_height + _offset; #endif if (_current_velocity > 0.0f || !IS_THRESHOLD_ZERO(adjust, 0.001)) { if (collide_cat.is_debug()) { @@ -262,15 +262,15 @@ handle_entries() { if (_current_velocity > 0.0f || adjust) { // ...we have a vertical thrust, // ...or the node is above the floor, so it is airborne. - float dt = ClockObject::get_global_clock()->get_dt(); + PN_stdfloat dt = ClockObject::get_global_clock()->get_dt(); // Fyi, the sign of _gravity is reversed. I think it makes the get_*() set_*() // more intuitive to do it this way. - float gravity_adjust = _current_velocity * dt + 0.5 * -_gravity * dt * dt; + PN_stdfloat gravity_adjust = _current_velocity * dt + 0.5 * -_gravity * dt * dt; if (adjust > 0.0f) { // ...the node is under the floor, so it has landed. // Keep the adjust to bring us up to the ground and // then add the gravity_adjust to get us airborne: - adjust += max(0.0f, gravity_adjust); + adjust += max((PN_stdfloat)0.0, gravity_adjust); } else { // ...the node is above the floor, so it is airborne. adjust = max(adjust, gravity_adjust); @@ -292,12 +292,12 @@ handle_entries() { } CPT(TransformState) trans = def._target.get_transform(); - LVecBase3f pos = trans->get_pos(); + LVecBase3 pos = trans->get_pos(); pos[2] += adjust; def._target.set_transform(trans->set_pos(pos)); def.updated_transform(); - apply_linear_force(def, LVector3f(0.0f, 0.0f, adjust)); + apply_linear_force(def, LVector3(0.0f, 0.0f, adjust)); } else { // _impact_velocity = _current_velocity; _current_velocity = _airborne_height = 0.0f; @@ -318,5 +318,5 @@ handle_entries() { // Description: //////////////////////////////////////////////////////////////////// void CollisionHandlerGravity:: -apply_linear_force(ColliderDef &def, const LVector3f &force) { +apply_linear_force(ColliderDef &def, const LVector3 &force) { } diff --git a/panda/src/collide/collisionHandlerGravity.h b/panda/src/collide/collisionHandlerGravity.h index 426314f169..fccf527c8c 100755 --- a/panda/src/collide/collisionHandlerGravity.h +++ b/panda/src/collide/collisionHandlerGravity.h @@ -33,44 +33,44 @@ PUBLISHED: CollisionHandlerGravity(); virtual ~CollisionHandlerGravity(); - INLINE void set_offset(float offset); - INLINE float get_offset() const; + INLINE void set_offset(PN_stdfloat offset); + INLINE PN_stdfloat get_offset() const; - INLINE void set_reach(float reach); - INLINE float get_reach() const; + INLINE void set_reach(PN_stdfloat reach); + INLINE PN_stdfloat get_reach() const; - INLINE float get_airborne_height() const; + INLINE PN_stdfloat get_airborne_height() const; INLINE bool is_on_ground() const; - INLINE float get_impact_velocity() const; - INLINE const LVector3f &get_contact_normal() const; + INLINE PN_stdfloat get_impact_velocity() const; + INLINE const LVector3 &get_contact_normal() const; - INLINE void add_velocity(float velocity); - INLINE void set_velocity(float velocity); - INLINE float get_velocity() const; + INLINE void add_velocity(PN_stdfloat velocity); + INLINE void set_velocity(PN_stdfloat velocity); + INLINE PN_stdfloat get_velocity() const; - INLINE void set_gravity(float gravity); - INLINE float get_gravity() const; + INLINE void set_gravity(PN_stdfloat gravity); + INLINE PN_stdfloat get_gravity() const; - INLINE void set_max_velocity(float max_vel); - INLINE float get_max_velocity() const; + INLINE void set_max_velocity(PN_stdfloat max_vel); + INLINE PN_stdfloat get_max_velocity() const; INLINE void set_legacy_mode(bool legacy_mode); INLINE bool get_legacy_mode() const; protected: - float set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries); + PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries); virtual bool handle_entries(); - virtual void apply_linear_force(ColliderDef &def, const LVector3f &force); + virtual void apply_linear_force(ColliderDef &def, const LVector3 &force); private: - float _offset; - float _reach; - float _airborne_height; - float _impact_velocity; - float _gravity; - float _current_velocity; - float _max_velocity; - LVector3f _contact_normal; + PN_stdfloat _offset; + PN_stdfloat _reach; + PN_stdfloat _airborne_height; + PN_stdfloat _impact_velocity; + PN_stdfloat _gravity; + PN_stdfloat _current_velocity; + PN_stdfloat _max_velocity; + LVector3 _contact_normal; bool _legacy_mode; diff --git a/panda/src/collide/collisionHandlerHighestEvent.cxx b/panda/src/collide/collisionHandlerHighestEvent.cxx index 89c9fd525c..912ee90fd9 100755 --- a/panda/src/collide/collisionHandlerHighestEvent.cxx +++ b/panda/src/collide/collisionHandlerHighestEvent.cxx @@ -65,7 +65,7 @@ begin_group() { void CollisionHandlerHighestEvent:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); - LVector3f vec = + LVector3 vec = entry->get_surface_point(entry->get_from_node_path()) - entry->get_from()->get_collision_origin(); double dist = vec.length_squared(); diff --git a/panda/src/collide/collisionHandlerPhysical.cxx b/panda/src/collide/collisionHandlerPhysical.cxx index 562555f74f..2c1a4f3104 100644 --- a/panda/src/collide/collisionHandlerPhysical.cxx +++ b/panda/src/collide/collisionHandlerPhysical.cxx @@ -75,8 +75,8 @@ add_entry(CollisionEntry *entry) { return; } - LPoint3f point = entry->get_surface_point(_center); - LVector3f normal = entry->get_surface_normal(_center); + LPoint3 point = entry->get_surface_point(_center); + LVector3 normal = entry->get_surface_normal(_center); if (point.dot(normal) > 0) { return; } diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index 52c2e163b8..3dbb4131b4 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -70,7 +70,7 @@ protected: }; virtual bool handle_entries()=0; - virtual void apply_linear_force(ColliderDef &def, const LVector3f &force)=0; + virtual void apply_linear_force(ColliderDef &def, const LVector3 &force)=0; virtual bool validate_target(const NodePath &target); diff --git a/panda/src/collide/collisionHandlerPusher.cxx b/panda/src/collide/collisionHandlerPusher.cxx index 1e5489673f..67c686e561 100644 --- a/panda/src/collide/collisionHandlerPusher.cxx +++ b/panda/src/collide/collisionHandlerPusher.cxx @@ -30,8 +30,8 @@ TypeHandle CollisionHandlerPusher::_type_handle; //////////////////////////////////////////////////////////////////// class ShoveData { public: - LVector3f _vector; - float _length; + LVector3 _vector; + PN_stdfloat _length; bool _valid; CollisionEntry *_entry; }; @@ -105,9 +105,9 @@ handle_entries() { nassertr(entry != (CollisionEntry *)NULL, false); nassertr(from_node_path == entry->get_from_node_path(), false); - LPoint3f surface_point; - LVector3f normal; - LPoint3f interior_point; + LPoint3 surface_point; + LVector3 normal; + LPoint3 interior_point; if (!entry->get_all(def._target, surface_point, normal, interior_point)) { #ifndef NDEBUG @@ -162,7 +162,7 @@ handle_entries() { for (sj = shoves.begin(); sj != si; ++sj) { ShoveData &sd2 = (*sj); if (sd2._valid) { - float d = sd._vector.dot(sd2._vector); + PN_stdfloat d = sd._vector.dot(sd2._vector); if (collide_cat.is_debug()) { collide_cat.debug() << "Considering dot product " << d << "\n"; @@ -223,8 +223,8 @@ handle_entries() { } // Now we can determine the net shove. - LVector3f net_shove(0.0f, 0.0f, 0.0f); - LVector3f force_normal(0.0f, 0.0f, 0.0f); + LVector3 net_shove(0.0f, 0.0f, 0.0f); + LVector3 force_normal(0.0f, 0.0f, 0.0f); for (si = shoves.begin(); si != shoves.end(); ++si) { const ShoveData &sd = (*si); if (sd._valid) { @@ -243,7 +243,7 @@ handle_entries() { // This is the part where the node actually gets moved: CPT(TransformState) trans = def._target.get_transform(); - LVecBase3f pos = trans->get_pos(); + LVecBase3 pos = trans->get_pos(); pos += net_shove * trans->get_mat(); def._target.set_transform(trans->set_pos(pos)); def.updated_transform(); @@ -267,8 +267,8 @@ handle_entries() { // some work with the ColliderDef and the force vector. //////////////////////////////////////////////////////////////////// void CollisionHandlerPusher:: -apply_net_shove(ColliderDef &def, const LVector3f &net_shove, - const LVector3f &force_normal) { +apply_net_shove(ColliderDef &def, const LVector3 &net_shove, + const LVector3 &force_normal) { } //////////////////////////////////////////////////////////////////// @@ -278,5 +278,5 @@ apply_net_shove(ColliderDef &def, const LVector3f &net_shove, // some work with the ColliderDef and the force vector. //////////////////////////////////////////////////////////////////// void CollisionHandlerPusher:: -apply_linear_force(ColliderDef &def, const LVector3f &force_normal) { +apply_linear_force(ColliderDef &def, const LVector3 &force_normal) { } diff --git a/panda/src/collide/collisionHandlerPusher.h b/panda/src/collide/collisionHandlerPusher.h index 990793008f..2a690e297d 100644 --- a/panda/src/collide/collisionHandlerPusher.h +++ b/panda/src/collide/collisionHandlerPusher.h @@ -37,9 +37,9 @@ PUBLISHED: protected: virtual bool handle_entries(); virtual void apply_net_shove( - ColliderDef &def, const LVector3f &net_shove, - const LVector3f &force_normal); - virtual void apply_linear_force(ColliderDef &def, const LVector3f &force); + ColliderDef &def, const LVector3 &net_shove, + const LVector3 &force_normal); + virtual void apply_linear_force(ColliderDef &def, const LVector3 &force); bool _horizontal; diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index f1e16104af..1a1bba4b6c 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -23,7 +23,7 @@ class CollisionEntrySorter { public: CollisionEntrySorter(CollisionEntry *entry) { _entry = entry; - LVector3f vec = + LVector3 vec = entry->get_surface_point(entry->get_from_node_path()) - entry->get_from()->get_collision_origin(); _dist2 = vec.length_squared(); @@ -33,7 +33,7 @@ public: } CollisionEntry *_entry; - float _dist2; + PN_stdfloat _dist2; }; //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionInvSphere.I b/panda/src/collide/collisionInvSphere.I index 60e2250320..12823f352a 100644 --- a/panda/src/collide/collisionInvSphere.I +++ b/panda/src/collide/collisionInvSphere.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionInvSphere:: -CollisionInvSphere(const LPoint3f ¢er, float radius) : +CollisionInvSphere(const LPoint3 ¢er, PN_stdfloat radius) : CollisionSphere(center, radius) { } @@ -30,7 +30,7 @@ CollisionInvSphere(const LPoint3f ¢er, float radius) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionInvSphere:: -CollisionInvSphere(float cx, float cy, float cz, float radius) : +CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) : CollisionSphere(cx, cy, cz, radius) { } diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 24d5f3cfbb..893d950d48 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -111,18 +111,18 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; DCAST_INTO_R(sphere, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_center = sphere->get_center() * wrt_mat; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius = length(from_radius_v); + LPoint3 from_center = sphere->get_center() * wrt_mat; + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); - LPoint3f into_center = get_center(); - float into_radius = get_radius(); + LPoint3 into_center = get_center(); + PN_stdfloat into_radius = get_radius(); - LVector3f vec = from_center - into_center; - float dist2 = dot(vec, vec); + LVector3 vec = from_center - into_center; + PN_stdfloat dist2 = dot(vec, vec); if (dist2 < (into_radius - from_radius) * (into_radius - from_radius)) { // No intersection--the sphere is within the hollow. return NULL; @@ -135,8 +135,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f surface_normal; - float vec_length = vec.length(); + LVector3 surface_normal; + PN_stdfloat vec_length = vec.length(); if (IS_NEARLY_ZERO(vec_length)) { // If we don't have a collision normal (e.g. the centers are // exactly coincident), then make up an arbitrary normal--any one @@ -146,7 +146,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { surface_normal = vec / -vec_length; } - LVector3f normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : surface_normal; + LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : surface_normal; new_entry->set_surface_normal(normal); new_entry->set_surface_point(into_center - surface_normal * into_radius); @@ -165,10 +165,10 @@ test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = line->get_origin() * wrt_mat; - LVector3f from_direction = line->get_direction() * wrt_mat; + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -184,13 +184,13 @@ test_intersection_from_line(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t2 * from_direction; + LPoint3 into_intersection_point = from_origin + t2 * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && line->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(-normal); } @@ -208,10 +208,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -229,14 +229,14 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point; + LPoint3 into_intersection_point; into_intersection_point = from_origin + t2 * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && ray->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(-normal); } @@ -254,11 +254,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_a = segment->get_point_a() * wrt_mat; - LPoint3f from_b = segment->get_point_b() * wrt_mat; - LVector3f from_direction = from_b - from_a; + LPoint3 from_a = segment->get_point_a() * wrt_mat; + LPoint3 from_b = segment->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { @@ -298,13 +298,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_a + t * from_direction; + LPoint3 into_intersection_point = from_a + t * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && segment->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(-normal); } @@ -335,15 +335,15 @@ fill_viz_geom() { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); for (int sl = 0; sl < num_slices; ++sl) { - float longitude0 = (float)sl / (float)num_slices; - float longitude1 = (float)(sl + 1) / (float)num_slices; - vertex.add_data3f(compute_point(0.0, longitude0)); + PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; + PN_stdfloat longitude1 = (PN_stdfloat)(sl + 1) / (PN_stdfloat)num_slices; + vertex.add_data3(compute_point(0.0, longitude0)); for (int st = 1; st < num_stacks; ++st) { - float latitude = (float)st / (float)num_stacks; - vertex.add_data3f(compute_point(latitude, longitude1)); - vertex.add_data3f(compute_point(latitude, longitude0)); + PN_stdfloat latitude = (PN_stdfloat)st / (PN_stdfloat)num_stacks; + vertex.add_data3(compute_point(latitude, longitude1)); + vertex.add_data3(compute_point(latitude, longitude0)); } - vertex.add_data3f(compute_point(1.0, longitude0)); + vertex.add_data3(compute_point(1.0, longitude0)); strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); diff --git a/panda/src/collide/collisionInvSphere.h b/panda/src/collide/collisionInvSphere.h index 6629e0ea95..d358dccc40 100644 --- a/panda/src/collide/collisionInvSphere.h +++ b/panda/src/collide/collisionInvSphere.h @@ -30,8 +30,8 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionInvSphere : public CollisionSphere { PUBLISHED: - INLINE CollisionInvSphere(const LPoint3f ¢er, float radius); - INLINE CollisionInvSphere(float cx, float cy, float cz, float radius); + INLINE CollisionInvSphere(const LPoint3 ¢er, PN_stdfloat radius); + INLINE CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius); protected: INLINE CollisionInvSphere(); diff --git a/panda/src/collide/collisionLevelState.I b/panda/src/collide/collisionLevelState.I index f72d20a4fd..6ce77c24ed 100644 --- a/panda/src/collide/collisionLevelState.I +++ b/panda/src/collide/collisionLevelState.I @@ -270,7 +270,7 @@ apply_transform() { return false; } - const LMatrix4f &mat = inv_transform->get_mat(); + const LMatrix4 &mat = inv_transform->get_mat(); // Now build the new bounding volumes list. BoundingVolumes new_bounds; diff --git a/panda/src/collide/collisionLevelStateBase.cxx b/panda/src/collide/collisionLevelStateBase.cxx index 5441314456..7561c80e43 100644 --- a/panda/src/collide/collisionLevelStateBase.cxx +++ b/panda/src/collide/collisionLevelStateBase.cxx @@ -71,19 +71,19 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { // motion relative to each object it is considering a collision // with. That makes things complicated! if (bv->as_bounding_sphere()) { - LPoint3f pos_delta = def._node_path.get_pos_delta(root); + LPoint3 pos_delta = def._node_path.get_pos_delta(root); - //LVector3f cap(pos_delta); + //LVector3 cap(pos_delta); //if(cap.length()>fluid_cap_amount) { - // pos_delta=LPoint3f(cap/cap.length())*fluid_cap_amount; + // pos_delta=LPoint3(cap/cap.length())*fluid_cap_amount; //} - if (pos_delta != LVector3f::zero()) { + if (pos_delta != LVector3::zero()) { // If the node has a delta, we have to include the starting // position in the volume as well. We only do this for bounding // spheres, since (a) other kinds of volumes may not extend so // well, and (b) we've only implemented fluid-motion detection // for CollisionSpheres anyway. - LMatrix4f inv_trans = LMatrix4f::translate_mat(-pos_delta); + LMatrix4 inv_trans = LMatrix4::translate_mat(-pos_delta); PT(GeometricBoundingVolume) gbv_prev; gbv_prev = DCAST(GeometricBoundingVolume, bv->make_copy()); diff --git a/panda/src/collide/collisionLine.I b/panda/src/collide/collisionLine.I index 8e8ee17874..d07309629c 100644 --- a/panda/src/collide/collisionLine.I +++ b/panda/src/collide/collisionLine.I @@ -31,7 +31,7 @@ CollisionLine() { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionLine:: -CollisionLine(const LPoint3f &origin, const LVector3f &direction) : +CollisionLine(const LPoint3 &origin, const LVector3 &direction) : CollisionRay(origin, direction) { } @@ -42,8 +42,8 @@ CollisionLine(const LPoint3f &origin, const LVector3f &direction) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionLine:: -CollisionLine(float ox, float oy, float oz, - float dx, float dy, float dz) : +CollisionLine(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, + PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz) : CollisionRay(ox, oy, oz, dx, dy, dz) { } diff --git a/panda/src/collide/collisionLine.cxx b/panda/src/collide/collisionLine.cxx index a547bf94a3..15ef5717fa 100644 --- a/panda/src/collide/collisionLine.cxx +++ b/panda/src/collide/collisionLine.cxx @@ -86,10 +86,10 @@ fill_viz_geom() { for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points - 0.5) * 2.0; - vertex.add_data3f(get_origin() + t * scale * get_direction()); + vertex.add_data3(get_origin() + t * scale * get_direction()); - color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) + - fabs(t) * Colorf(0.0f, 0.0f, 0.0f, -1.0f)); + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 1.0f) + + fabs(t) * LColor(0.0f, 0.0f, 0.0f, -1.0f)); } PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); diff --git a/panda/src/collide/collisionLine.h b/panda/src/collide/collisionLine.h index 127b54e1a0..06fc60473f 100644 --- a/panda/src/collide/collisionLine.h +++ b/panda/src/collide/collisionLine.h @@ -28,9 +28,9 @@ class EXPCL_PANDA_COLLIDE CollisionLine : public CollisionRay { PUBLISHED: INLINE CollisionLine(); - INLINE CollisionLine(const LPoint3f &origin, const LVector3f &direction); - INLINE CollisionLine(float ox, float oy, float oz, - float dx, float dy, float dz); + INLINE CollisionLine(const LPoint3 &origin, const LVector3 &direction); + INLINE CollisionLine(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, + PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz); public: INLINE CollisionLine(const CollisionLine ©); diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 191dbcb5bc..d347c5b85a 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -109,10 +109,10 @@ preserve_name() const { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void CollisionNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); - if (mat.almost_equal(LMatrix4f::ident_mat())) { + if (mat.almost_equal(LMatrix4::ident_mat())) { return; } @@ -371,7 +371,7 @@ get_last_pos_state() { static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make - (ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, 0.5f)), + (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } diff --git a/panda/src/collide/collisionNode.h b/panda/src/collide/collisionNode.h index d34d69657a..0d2b594fd2 100644 --- a/panda/src/collide/collisionNode.h +++ b/panda/src/collide/collisionNode.h @@ -41,7 +41,7 @@ public: virtual ~CollisionNode(); virtual PandaNode *make_copy() const; virtual bool preserve_name() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PandaNode *combine_with(PandaNode *other); virtual CollideMask get_legal_collide_mask() const; diff --git a/panda/src/collide/collisionParabola.I b/panda/src/collide/collisionParabola.I index 307bd0916c..295e5d43f0 100644 --- a/panda/src/collide/collisionParabola.I +++ b/panda/src/collide/collisionParabola.I @@ -31,7 +31,7 @@ CollisionParabola() : // t2 in the parametric space of the parabola. //////////////////////////////////////////////////////////////////// INLINE CollisionParabola:: -CollisionParabola(const Parabolaf ¶bola, float t1, float t2) : +CollisionParabola(const LParabola ¶bola, PN_stdfloat t1, PN_stdfloat t2) : _parabola(parabola), _t1(t1), _t2(t2) { @@ -55,7 +55,7 @@ CollisionParabola(const CollisionParabola ©) : // Description: Replaces the parabola specified by this solid. //////////////////////////////////////////////////////////////////// INLINE void CollisionParabola:: -set_parabola(const Parabolaf ¶bola) { +set_parabola(const LParabola ¶bola) { _parabola = parabola; mark_internal_bounds_stale(); mark_viz_stale(); @@ -66,7 +66,7 @@ set_parabola(const Parabolaf ¶bola) { // Access: Public // Description: Returns the parabola specified by this solid. //////////////////////////////////////////////////////////////////// -INLINE const Parabolaf &CollisionParabola:: +INLINE const LParabola &CollisionParabola:: get_parabola() const { return _parabola; } @@ -77,7 +77,7 @@ get_parabola() const { // Description: Changes the starting point on the parabola. //////////////////////////////////////////////////////////////////// INLINE void CollisionParabola:: -set_t1(float t1) { +set_t1(PN_stdfloat t1) { _t1 = t1; mark_internal_bounds_stale(); mark_viz_stale(); @@ -88,7 +88,7 @@ set_t1(float t1) { // Access: Public // Description: Returns the starting point on the parabola. //////////////////////////////////////////////////////////////////// -INLINE float CollisionParabola:: +INLINE PN_stdfloat CollisionParabola:: get_t1() const { return _t1; } @@ -99,7 +99,7 @@ get_t1() const { // Description: Changes the ending point on the parabola. //////////////////////////////////////////////////////////////////// INLINE void CollisionParabola:: -set_t2(float t2) { +set_t2(PN_stdfloat t2) { _t2 = t2; mark_internal_bounds_stale(); mark_viz_stale(); @@ -110,7 +110,7 @@ set_t2(float t2) { // Access: Public // Description: Returns the ending point on the parabola. //////////////////////////////////////////////////////////////////// -INLINE float CollisionParabola:: +INLINE PN_stdfloat CollisionParabola:: get_t2() const { return _t2; } diff --git a/panda/src/collide/collisionParabola.cxx b/panda/src/collide/collisionParabola.cxx index 3ff18294ba..6beea29da0 100644 --- a/panda/src/collide/collisionParabola.cxx +++ b/panda/src/collide/collisionParabola.cxx @@ -38,7 +38,7 @@ TypeHandle CollisionParabola::_type_handle; // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionParabola:: +LPoint3 CollisionParabola:: get_collision_origin() const { return _parabola.calc_point(_t1); } @@ -70,7 +70,7 @@ test_intersection(const CollisionEntry &entry) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionParabola:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _parabola.xform(mat); mark_viz_stale(); @@ -118,15 +118,15 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// PT(BoundingVolume) CollisionParabola:: compute_internal_bounds() const { - LPoint3f p1 = _parabola.calc_point(get_t1()); - LPoint3f p2 = _parabola.calc_point(get_t2()); - LVector3f pdelta = p2 - p1; + LPoint3 p1 = _parabola.calc_point(get_t1()); + LPoint3 p2 = _parabola.calc_point(get_t2()); + LVector3 pdelta = p2 - p1; // If p1 and p2 are sufficiently close, just put a sphere around // them. - float d2 = pdelta.length_squared(); + PN_stdfloat d2 = pdelta.length_squared(); if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) { - LPoint3f pmid = (p1 + p2) * 0.5f; + LPoint3 pmid = (p1 + p2) * 0.5f; return new BoundingSphere(pmid, csqrt(d2) * 0.5f); } @@ -143,40 +143,40 @@ compute_internal_bounds() const { // We have to be explicit about the coordinate system--we // specifically mean CS_zup_right here, to make the YZ plane. - LMatrix4f from_parabola; + LMatrix4 from_parabola; look_at(from_parabola, pdelta, -_parabola.get_a(), CS_zup_right); from_parabola.set_row(3, p1); // The matrix that computes from world space to parabola space is // the inverse of that which we just computed. - LMatrix4f to_parabola; + LMatrix4 to_parabola; to_parabola.invert_from(from_parabola); // Now convert the parabola itself into parabola space. - Parabolaf psp = _parabola; + LParabola psp = _parabola; psp.xform(to_parabola); - LPoint3f pp2 = psp.calc_point(get_t2()); - float max_y = pp2[1]; + LPoint3 pp2 = psp.calc_point(get_t2()); + PN_stdfloat max_y = pp2[1]; // We compute a few points along the parabola to attempt to get the // minmax. - float min_z = 0.0f; - float max_z = 0.0f; + PN_stdfloat min_z = 0.0f; + PN_stdfloat max_z = 0.0f; int num_points = collision_parabola_bounds_sample; for (int i = 0; i < num_points; ++i) { double t = (double)(i + 1) / (double)(num_points + 1); - LPoint3f p = psp.calc_point(get_t1() + t * (get_t2() - get_t1())); + LPoint3 p = psp.calc_point(get_t1() + t * (get_t2() - get_t1())); min_z = min(min_z, p[2]); max_z = max(max_z, p[2]); } // That gives us a simple bounding volume in parabola space. PT(BoundingHexahedron) volume = - new BoundingHexahedron(LPoint3f(-0.01, max_y, min_z), LPoint3f(0.01, max_y, min_z), - LPoint3f(0.01, max_y, max_z), LPoint3f(-0.01, max_y, max_z), - LPoint3f(-0.01, 0, min_z), LPoint3f(0.01, 0, min_z), - LPoint3f(0.01, 0, max_z), LPoint3f(-0.01, 0, max_z)); + new BoundingHexahedron(LPoint3(-0.01, max_y, min_z), LPoint3(0.01, max_y, min_z), + LPoint3(0.01, max_y, max_z), LPoint3(-0.01, max_y, max_z), + LPoint3(-0.01, 0, min_z), LPoint3(0.01, 0, min_z), + LPoint3(0.01, 0, max_z), LPoint3(-0.01, 0, max_z)); // And convert that back into real space. volume->xform(from_parabola); return volume.p(); @@ -205,10 +205,10 @@ fill_viz_geom() { for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points); - vertex.add_data3f(_parabola.calc_point(_t1 + t * (_t2 - _t1))); + vertex.add_data3(_parabola.calc_point(_t1 + t * (_t2 - _t1))); - color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 0.0f) + - t * Colorf(0.0f, 0.0f, 0.0f, 1.0f)); + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 0.0f) + + t * LColor(0.0f, 0.0f, 0.0f, 1.0f)); } PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); @@ -242,8 +242,8 @@ void CollisionParabola:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSolid::write_datagram(manager, me); _parabola.write_datagram(me); - me.add_float32(_t1); - me.add_float32(_t2); + me.add_stdfloat(_t1); + me.add_stdfloat(_t2); } //////////////////////////////////////////////////////////////////// @@ -274,6 +274,6 @@ void CollisionParabola:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSolid::fillin(scan, manager); _parabola.read_datagram(scan); - _t1 = scan.get_float32(); - _t2 = scan.get_float32(); + _t1 = scan.get_stdfloat(); + _t2 = scan.get_stdfloat(); } diff --git a/panda/src/collide/collisionParabola.h b/panda/src/collide/collisionParabola.h index 44fc97eea8..a9f48f7ccf 100644 --- a/panda/src/collide/collisionParabola.h +++ b/panda/src/collide/collisionParabola.h @@ -35,9 +35,9 @@ class LensNode; class EXPCL_PANDA_COLLIDE CollisionParabola : public CollisionSolid { PUBLISHED: INLINE CollisionParabola(); - INLINE CollisionParabola(const Parabolaf ¶bola, float t1, float t2); + INLINE CollisionParabola(const LParabola ¶bola, PN_stdfloat t1, PN_stdfloat t2); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; public: INLINE CollisionParabola(const CollisionParabola ©); @@ -46,7 +46,7 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); @@ -54,14 +54,14 @@ public: virtual void output(ostream &out) const; PUBLISHED: - INLINE void set_parabola(const Parabolaf ¶bola); - INLINE const Parabolaf &get_parabola() const; + INLINE void set_parabola(const LParabola ¶bola); + INLINE const LParabola &get_parabola() const; - INLINE void set_t1(float t1); - INLINE float get_t1() const; + INLINE void set_t1(PN_stdfloat t1); + INLINE PN_stdfloat get_t1() const; - INLINE void set_t2(float t2); - INLINE float get_t2() const; + INLINE void set_t2(PN_stdfloat t2); + INLINE PN_stdfloat get_t2() const; protected: virtual PT(BoundingVolume) compute_internal_bounds() const; @@ -70,8 +70,8 @@ protected: virtual void fill_viz_geom(); private: - Parabolaf _parabola; - float _t1, _t2; + LParabola _parabola; + PN_stdfloat _t1, _t2; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/collide/collisionPlane.I b/panda/src/collide/collisionPlane.I index 1efd76d7c2..60a408ff5f 100644 --- a/panda/src/collide/collisionPlane.I +++ b/panda/src/collide/collisionPlane.I @@ -30,7 +30,7 @@ CollisionPlane() { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPlane:: -CollisionPlane(const Planef &plane) : +CollisionPlane(const LPlane &plane) : _plane(plane) { } @@ -63,7 +63,7 @@ flush_level() { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE LVector3f CollisionPlane:: +INLINE LVector3 CollisionPlane:: get_normal() const { return _plane.get_normal(); } @@ -73,8 +73,8 @@ get_normal() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float CollisionPlane:: -dist_to_plane(const LPoint3f &point) const { +INLINE PN_stdfloat CollisionPlane:: +dist_to_plane(const LPoint3 &point) const { return _plane.dist_to_plane(point); } @@ -84,7 +84,7 @@ dist_to_plane(const LPoint3f &point) const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionPlane:: -set_plane(const Planef &plane) { +set_plane(const LPlane &plane) { _plane = plane; mark_internal_bounds_stale(); mark_viz_stale(); @@ -95,7 +95,7 @@ set_plane(const Planef &plane) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const Planef &CollisionPlane:: +INLINE const LPlane &CollisionPlane:: get_plane() const { return _plane; } diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index f376ea3810..e5bb1a5038 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -54,7 +54,7 @@ make_copy() { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionPlane:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _plane = _plane * mat; CollisionSolid::xform(mat); } @@ -67,12 +67,12 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionPlane:: +LPoint3 CollisionPlane:: get_collision_origin() const { // No real sensible origin exists for a plane. We return 0, 0, 0, // without even bothering to ensure that that point exists on the // plane. - return LPoint3f::origin(); + return LPoint3::origin(); } //////////////////////////////////////////////////////////////////// @@ -129,14 +129,14 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; DCAST_INTO_R(sphere, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_center = sphere->get_center() * wrt_mat; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius = length(from_radius_v); + LPoint3 from_center = sphere->get_center() * wrt_mat; + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); - float dist = dist_to_plane(from_center); + PN_stdfloat dist = dist_to_plane(from_center); if (dist > from_radius) { // No intersection. return NULL; @@ -149,7 +149,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = ( + LVector3 normal = ( has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); @@ -170,12 +170,12 @@ test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = line->get_origin() * wrt_mat; - LVector3f from_direction = line->get_direction() * wrt_mat; + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; - float t; + PN_stdfloat t; if (!_plane.intersects_line(t, from_origin, from_direction)) { // No intersection. The line is parallel to the plane. @@ -195,9 +195,9 @@ test_intersection_from_line(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t * from_direction; + LPoint3 into_intersection_point = from_origin + t * from_direction; - LVector3f normal = + LVector3 normal = (has_effective_normal() && line->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); @@ -217,12 +217,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; - float t; + PN_stdfloat t; if (_plane.dist_to_plane(from_origin) < 0.0f) { // The origin of the ray is behind the plane, so we don't need to @@ -249,9 +249,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t * from_direction; + LPoint3 into_intersection_point = from_origin + t * from_direction; - LVector3f normal = + LVector3 normal = (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); @@ -271,13 +271,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_a = segment->get_point_a() * wrt_mat; - LPoint3f from_b = segment->get_point_b() * wrt_mat; + LPoint3 from_a = segment->get_point_a() * wrt_mat; + LPoint3 from_b = segment->get_point_b() * wrt_mat; - float dist_a = _plane.dist_to_plane(from_a); - float dist_b = _plane.dist_to_plane(from_b); + PN_stdfloat dist_a = _plane.dist_to_plane(from_a); + PN_stdfloat dist_b = _plane.dist_to_plane(from_b); if (dist_a >= 0.0f && dist_b >= 0.0f) { // Entirely in front of the plane means no intersection. @@ -291,11 +291,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = (has_effective_normal() && segment->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && segment->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); - float t; - LVector3f from_direction = from_b - from_a; + PN_stdfloat t; + LVector3 from_direction = from_b - from_a; if (_plane.intersects_line(t, from_a, from_direction)) { // It intersects the plane. if (t >= 0.0f && t <= 1.0f) { @@ -332,20 +332,20 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; DCAST_INTO_R(parabola, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); // Convert the parabola into local coordinate space. - Parabolaf local_p(parabola->get_parabola()); + LParabola local_p(parabola->get_parabola()); local_p.xform(wrt_mat); - float t; + PN_stdfloat t; if (_plane.dist_to_plane(local_p.calc_point(parabola->get_t1())) < 0.0f) { // The first point in the parabola is behind the plane, so we // don't need to test further. t = parabola->get_t1(); } else { - float t1, t2; + PN_stdfloat t1, t2; if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. The infinite parabola is entirely in front // of the plane. @@ -379,9 +379,9 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = local_p.calc_point(t); + LPoint3 into_intersection_point = local_p.calc_point(t); - LVector3f normal = (has_effective_normal() && parabola->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && parabola->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); new_entry->set_surface_point(into_intersection_point); @@ -415,27 +415,27 @@ fill_viz_geom() { // coefficent. The first corner will be diagonal in the other two // dimensions. - LPoint3f cp; - LVector3f p1, p2, p3, p4; + LPoint3 cp; + LVector3 p1, p2, p3, p4; - LVector3f normal = get_normal(); - float D = _plane[3]; + LVector3 normal = get_normal(); + PN_stdfloat D = _plane[3]; if (fabs(normal[0]) > fabs(normal[1]) && fabs(normal[0]) > fabs(normal[2])) { // X has the largest coefficient. cp.set(-D / normal[0], 0.0f, 0.0f); - p1 = LPoint3f(-(normal[1] + normal[2] + D)/normal[0], 1.0f, 1.0f) - cp; + p1 = LPoint3(-(normal[1] + normal[2] + D)/normal[0], 1.0f, 1.0f) - cp; } else if (fabs(normal[1]) > fabs(normal[2])) { // Y has the largest coefficient. cp.set(0.0f, -D / normal[1], 0.0f); - p1 = LPoint3f(1.0f, -(normal[0] + normal[2] + D)/normal[1], 1.0f) - cp; + p1 = LPoint3(1.0f, -(normal[0] + normal[2] + D)/normal[1], 1.0f) - cp; } else { // Z has the largest coefficient. cp.set(0.0f, 0.0f, -D / normal[2]); - p1 = LPoint3f(1.0f, 1.0f, -(normal[0] + normal[1] + D)/normal[2]) - cp; + p1 = LPoint3(1.0f, 1.0f, -(normal[0] + normal[1] + D)/normal[2]) - cp; } p1.normalize(); @@ -450,10 +450,10 @@ fill_viz_geom() { Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(cp + p1 * plane_scale); - vertex.add_data3f(cp + p2 * plane_scale); - vertex.add_data3f(cp + p3 * plane_scale); - vertex.add_data3f(cp + p4 * plane_scale); + vertex.add_data3(cp + p1 * plane_scale); + vertex.add_data3(cp + p2 * plane_scale); + vertex.add_data3(cp + p3 * plane_scale); + vertex.add_data3(cp + p4 * plane_scale); PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); body->add_consecutive_vertices(0, 4); diff --git a/panda/src/collide/collisionPlane.h b/panda/src/collide/collisionPlane.h index 1d3d8b5eb6..c24f7b7b6b 100644 --- a/panda/src/collide/collisionPlane.h +++ b/panda/src/collide/collisionPlane.h @@ -31,15 +31,15 @@ protected: INLINE CollisionPlane(); PUBLISHED: - INLINE CollisionPlane(const Planef &plane); + INLINE CollisionPlane(const LPlane &plane); INLINE CollisionPlane(const CollisionPlane ©); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; public: virtual CollisionSolid *make_copy(); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); @@ -49,11 +49,11 @@ public: INLINE static void flush_level(); PUBLISHED: - INLINE LVector3f get_normal() const; - INLINE float dist_to_plane(const LPoint3f &point) const; + INLINE LVector3 get_normal() const; + INLINE PN_stdfloat dist_to_plane(const LPoint3 &point) const; - INLINE void set_plane(const Planef &plane); - INLINE const Planef &get_plane() const; + INLINE void set_plane(const LPlane &plane); + INLINE const LPlane &get_plane() const; INLINE void flip(); @@ -75,7 +75,7 @@ protected: virtual void fill_viz_geom(); private: - Planef _plane; + LPlane _plane; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/collide/collisionPolygon.I b/panda/src/collide/collisionPolygon.I index eae703299a..12410bafb0 100644 --- a/panda/src/collide/collisionPolygon.I +++ b/panda/src/collide/collisionPolygon.I @@ -19,9 +19,9 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPolygon:: -CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c) { - LPoint3f array[3]; +CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c) { + LPoint3 array[3]; array[0] = a; array[1] = b; array[2] = c; @@ -34,9 +34,9 @@ CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPolygon:: -CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c, const LVecBase3f &d) { - LPoint3f array[4]; +CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c, const LVecBase3 &d) { + LPoint3 array[4]; array[0] = a; array[1] = b; array[2] = c; @@ -51,7 +51,7 @@ CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPolygon:: -CollisionPolygon(const LPoint3f *begin, const LPoint3f *end) { +CollisionPolygon(const LPoint3 *begin, const LPoint3 *end) { setup_points(begin, end); } @@ -82,10 +82,10 @@ get_num_points() const { // Description: Returns the nth vertex of the CollisionPolygon, // expressed in 3-D space. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f CollisionPolygon:: +INLINE LPoint3 CollisionPolygon:: get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3f::zero()); - LMatrix4f to_3d_mat; + nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); return to_3d(_points[n]._p, to_3d_mat); } @@ -98,9 +98,9 @@ get_point(int n) const { // non-collinear points, with no points repeated. //////////////////////////////////////////////////////////////////// INLINE bool CollisionPolygon:: -verify_points(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c) { - LPoint3f array[3]; +verify_points(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c) { + LPoint3 array[3]; array[0] = a; array[1] = b; array[2] = c; @@ -115,9 +115,9 @@ verify_points(const LPoint3f &a, const LPoint3f &b, // non-collinear points, with no points repeated. //////////////////////////////////////////////////////////////////// INLINE bool CollisionPolygon:: -verify_points(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d) { - LPoint3f array[4]; +verify_points(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d) { + LPoint3 array[4]; array[0] = a; array[1] = b; array[2] = c; @@ -142,7 +142,7 @@ flush_level() { // Description: Returns true if the 2-d v1 is to the right of v2. //////////////////////////////////////////////////////////////////// INLINE bool CollisionPolygon:: -is_right(const LVector2f &v1, const LVector2f &v2) { +is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 1.0e-6f; } @@ -154,10 +154,10 @@ is_right(const LVector2f &v1, const LVector2f &v2) { // result is negative if p is left of the line, positive // if it is right of the line. //////////////////////////////////////////////////////////////////// -INLINE float CollisionPolygon:: -dist_to_line(const LPoint2f &p, - const LPoint2f &f, const LVector2f &v) { - LVector2f v1 = (p - f); +INLINE PN_stdfloat CollisionPolygon:: +dist_to_line(const LPoint2 &p, + const LPoint2 &f, const LVector2 &v) { + LVector2 v1 = (p - f); return (v1[0] * v[1] - v1[1] * v[0]); } @@ -168,10 +168,10 @@ dist_to_line(const LPoint2f &p, // the polygon's plane, returns the corresponding point // in the polygon's 2-d definition space. //////////////////////////////////////////////////////////////////// -INLINE LPoint2f CollisionPolygon:: -to_2d(const LVecBase3f &point3d) const { - LPoint3f point = LPoint3f(point3d) * _to_2d_mat; - return LPoint2f(point[0], point[2]); +INLINE LPoint2 CollisionPolygon:: +to_2d(const LVecBase3 &point3d) const { + LPoint3 point = LPoint3(point3d) * _to_2d_mat; + return LPoint2(point[0], point[2]); } //////////////////////////////////////////////////////////////////// @@ -182,7 +182,7 @@ to_2d(const LVecBase3f &point3d) const { // into the 3-d (X, 0, Z) plane. //////////////////////////////////////////////////////////////////// INLINE void CollisionPolygon:: -calc_to_3d_mat(LMatrix4f &to_3d_mat) const { +calc_to_3d_mat(LMatrix4 &to_3d_mat) const { // We have to be explicit about the coordinate system--we // specifically mean CS_zup_right, because that points the forward // vector down the Y axis and moves the coords in (X, 0, Z). We @@ -192,7 +192,7 @@ calc_to_3d_mat(LMatrix4f &to_3d_mat) const { // The up vector, on the other hand, is completely arbitrary. look_at(to_3d_mat, -get_plane().get_normal(), - LVector3f(0.0f, 0.0f, 1.0f), CS_zup_right); + LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); to_3d_mat.set_row(3, get_plane().get_point()); } @@ -211,7 +211,7 @@ calc_to_3d_mat(LMatrix4f &to_3d_mat) const { // numerical precision. //////////////////////////////////////////////////////////////////// INLINE void CollisionPolygon:: -rederive_to_3d_mat(LMatrix4f &to_3d_mat) const { +rederive_to_3d_mat(LMatrix4 &to_3d_mat) const { to_3d_mat.invert_from(_to_2d_mat); } @@ -221,9 +221,9 @@ rederive_to_3d_mat(LMatrix4f &to_3d_mat) const { // Description: Extrude the indicated point in the polygon's 2-d // definition space back into 3-d coordinates. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f CollisionPolygon:: -to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat) { - return LPoint3f(point2d[0], 0.0f, point2d[1]) * to_3d_mat; +INLINE LPoint3 CollisionPolygon:: +to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat) { + return LPoint3(point2d[0], 0.0f, point2d[1]) * to_3d_mat; } //////////////////////////////////////////////////////////////////// @@ -232,7 +232,7 @@ to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat) { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPolygon::PointDef:: -PointDef(const LPoint2f &p, const LVector2f &v) : _p(p), _v(v) { +PointDef(const LPoint2 &p, const LVector2 &v) : _p(p), _v(v) { } //////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ PointDef(const LPoint2f &p, const LVector2f &v) : _p(p), _v(v) { // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionPolygon::PointDef:: -PointDef(float x, float y) : _p(x, y), _v(0.0f, 0.0f) { +PointDef(PN_stdfloat x, PN_stdfloat y) : _p(x, y), _v(0.0f, 0.0f) { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index ce7506d7b7..c28abfbea7 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -80,7 +80,7 @@ make_copy() { // is easier. //////////////////////////////////////////////////////////////////// bool CollisionPolygon:: -verify_points(const LPoint3f *begin, const LPoint3f *end) { +verify_points(const LPoint3 *begin, const LPoint3 *end) { int num_points = end - begin; if (num_points < 3) { return false; @@ -89,13 +89,13 @@ verify_points(const LPoint3f *begin, const LPoint3f *end) { bool all_ok = true; // First, check for repeated or invalid points. - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end && all_ok; ++pi) { if ((*pi).is_nan()) { all_ok = false; } else { // Make sure no points are repeated. - const LPoint3f *pj; + const LPoint3 *pj; for (pj = begin; pj != pi && all_ok; ++pj) { if ((*pj) == (*pi)) { all_ok = false; @@ -110,9 +110,9 @@ verify_points(const LPoint3f *begin, const LPoint3f *end) { // case the first three points happen to be collinear). bool got_normal = false; for (int i = 2; i < num_points && !got_normal; i++) { - Planef plane(begin[0], begin[1], begin[i]); - LVector3f normal = plane.get_normal(); - float normal_length = normal.length(); + LPlane plane(begin[0], begin[1], begin[i]); + LVector3 normal = plane.get_normal(); + PN_stdfloat normal_length = normal.length(); got_normal = IS_THRESHOLD_EQUAL(normal_length, 1.0f, 0.001f); } @@ -149,15 +149,15 @@ is_concave() const { return true; } - LPoint2f p0 = _points[0]._p; - LPoint2f p1 = _points[1]._p; - float dx1 = p1[0] - p0[0]; - float dy1 = p1[1] - p0[1]; + LPoint2 p0 = _points[0]._p; + LPoint2 p1 = _points[1]._p; + PN_stdfloat dx1 = p1[0] - p0[0]; + PN_stdfloat dy1 = p1[1] - p0[1]; p0 = p1; p1 = _points[2]._p; - float dx2 = p1[0] - p0[0]; - float dy2 = p1[1] - p0[1]; + PN_stdfloat dx2 = p1[0] - p0[0]; + PN_stdfloat dy2 = p1[1] - p0[1]; int asum = ((dx1 * dy2 - dx2 * dy1 >= 0.0f) ? 1 : 0); for (size_t i = 0; i < _points.size() - 1; i++) { @@ -186,7 +186,7 @@ is_concave() const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionPolygon:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { // We need to convert all the vertices to 3-d for this operation, // and then convert them back. Hopefully we won't lose too much // precision during all of this. @@ -202,18 +202,18 @@ xform(const LMatrix4f &mat) { } if (!_points.empty()) { - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); - pvector verts; + pvector verts; verts.reserve(_points.size()); Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { verts.push_back(to_3d((*pi)._p, to_3d_mat) * mat); } - const LPoint3f *verts_begin = &verts[0]; - const LPoint3f *verts_end = verts_begin + verts.size(); + const LPoint3 *verts_begin = &verts[0]; + const LPoint3 *verts_end = verts_begin + verts.size(); setup_points(verts_begin, verts_end); } @@ -228,12 +228,12 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionPolygon:: +LPoint3 CollisionPolygon:: get_collision_origin() const { - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); - LPoint2f median = _points[0]._p; + LPoint2 median = _points[0]._p; for (int n = 1; n < (int)_points.size(); n++) { median += _points[n]._p; } @@ -343,11 +343,11 @@ write(ostream &out, int indent_level) const { indent(out, indent_level + 2) << (*pi)._p << "\n"; } - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); out << "In 3-d space:\n"; for (pi = _points.begin(); pi != _points.end(); ++pi) { - Vertexf vert = to_3d((*pi)._p, to_3d_mat); + LVertex vert = to_3d((*pi)._p, to_3d_mat); indent(out, indent_level + 2) << vert << "\n"; } } @@ -363,14 +363,14 @@ compute_internal_bounds() const { return new BoundingBox; } - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); Points::const_iterator pi = _points.begin(); - LPoint3f p = to_3d((*pi)._p, to_3d_mat); + LPoint3 p = to_3d((*pi)._p, to_3d_mat); - LPoint3f x = p; - LPoint3f n = p; + LPoint3 x = p; + LPoint3 n = p; for (++pi; pi != _points.end(); ++pi) { p = to_3d((*pi)._p, to_3d_mat); @@ -405,31 +405,31 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); + const LMatrix4 &wrt_mat = wrt_space->get_mat(); - LPoint3f orig_center = sphere->get_center() * wrt_mat; - LPoint3f from_center = orig_center; + LPoint3 orig_center = sphere->get_center() * wrt_mat; + LPoint3 from_center = orig_center; bool moved_from_center = false; - float t = 1.0f; - LPoint3f contact_point(from_center); - float actual_t = 1.0f; + PN_stdfloat t = 1.0f; + LPoint3 contact_point(from_center); + PN_stdfloat actual_t = 1.0f; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius_2 = from_radius_v.length_squared(); - float from_radius = csqrt(from_radius_2); + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius_2 = from_radius_v.length_squared(); + PN_stdfloat from_radius = csqrt(from_radius_2); if (wrt_prev_space != wrt_space) { // If we have a delta between the previous position and the // current position, we use that to determine some more properties // of the collision. - LPoint3f b = from_center; - LPoint3f a = sphere->get_center() * wrt_prev_space->get_mat(); - LVector3f delta = b - a; + LPoint3 b = from_center; + LPoint3 a = sphere->get_center() * wrt_prev_space->get_mat(); + LVector3 delta = b - a; // First, there is no collision if the "from" object is definitely // moving in the same direction as the plane's normal. - float dot = delta.dot(get_normal()); + PN_stdfloat dot = delta.dot(get_normal()); if (dot > 0.1f) { return NULL; } @@ -447,13 +447,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // direction of the plane normal // t = ratio of (distance from start pos to plane) to (distance // from start pos to end pos), along axis of plane normal - float dist_to_p = dist_to_plane(a); + PN_stdfloat dist_to_p = dist_to_plane(a); t = (dist_to_p / -dot); // also compute the actual contact point and time of contact // for handlers that need it actual_t = ((dist_to_p - from_radius) / -dot); - actual_t = min(1.0f, max(0.0f, actual_t)); + actual_t = min((PN_stdfloat)1.0, max((PN_stdfloat)0.0, actual_t)); contact_point = a + (actual_t * delta); if (t >= 1.0f) { @@ -470,7 +470,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } } - LVector3f normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); #ifndef NDEBUG if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001), NULL) { collide_cat.info() @@ -483,7 +483,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // The nearest point within the plane to our center is the // intersection of the line (center, center - normal) with the plane. - float dist; + PN_stdfloat dist; if (!get_plane().intersects_line(dist, from_center, -get_normal())) { // No intersection with plane? This means the plane's effective // normal was within the plane itself. A useless polygon. @@ -495,8 +495,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return NULL; } - LPoint2f p = to_2d(from_center - dist * get_normal()); - float edge_dist = 0.0f; + LPoint2 p = to_2d(from_center - dist * get_normal()); + PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -536,9 +536,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // remain from the plane, based on its distance from the nearest // edge. - float max_dist = from_radius; + PN_stdfloat max_dist = from_radius; if (edge_dist >= 0.0f) { - float max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, 0.0f); + PN_stdfloat max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, (PN_stdfloat)0.0); max_dist = csqrt(max_dist_2); } @@ -554,12 +554,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - float into_depth = max_dist - dist; + PN_stdfloat into_depth = max_dist - dist; if (moved_from_center) { // We have to base the depth of intersection on the sphere's final // resting point, not the point from which we tested the // intersection. - float orig_dist; + PN_stdfloat orig_dist; get_plane().intersects_line(orig_dist, orig_center, -normal); into_depth = max_dist - orig_dist; } @@ -590,19 +590,19 @@ test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = line->get_origin() * wrt_mat; - LVector3f from_direction = line->get_direction() * wrt_mat; + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; - float t; + PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. return NULL; } - LPoint3f plane_point = from_origin + t * from_direction; - LPoint2f p = to_2d(plane_point); + LPoint3 plane_point = from_origin + t * from_direction; + LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -637,7 +637,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = (has_effective_normal() && line->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && line->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); new_entry->set_surface_point(plane_point); @@ -661,12 +661,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; - float t; + PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. return NULL; @@ -677,8 +677,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return NULL; } - LPoint3f plane_point = from_origin + t * from_direction; - LPoint2f p = to_2d(plane_point); + LPoint3 plane_point = from_origin + t * from_direction; + LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -713,7 +713,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); new_entry->set_surface_point(plane_point); @@ -737,13 +737,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_a = segment->get_point_a() * wrt_mat; - LPoint3f from_b = segment->get_point_b() * wrt_mat; - LPoint3f from_direction = from_b - from_a; + LPoint3 from_a = segment->get_point_a() * wrt_mat; + LPoint3 from_b = segment->get_point_b() * wrt_mat; + LPoint3 from_direction = from_b - from_a; - float t; + PN_stdfloat t; if (!get_plane().intersects_line(t, from_a, from_direction)) { // No intersection. return NULL; @@ -755,8 +755,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return NULL; } - LPoint3f plane_point = from_a + t * from_direction; - LPoint2f p = to_2d(plane_point); + LPoint3 plane_point = from_a + t * from_direction; + LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -791,7 +791,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = (has_effective_normal() && segment->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && segment->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); new_entry->set_surface_point(plane_point); @@ -815,19 +815,19 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; DCAST_INTO_R(parabola, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); // Convert the parabola into local coordinate space. - Parabolaf local_p(parabola->get_parabola()); + LParabola local_p(parabola->get_parabola()); local_p.xform(wrt_mat); - float t1, t2; + PN_stdfloat t1, t2; if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. return NULL; } - float t; + PN_stdfloat t; if (t1 >= parabola->get_t1() && t1 <= parabola->get_t2()) { if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { // Both intersection points are within our segment of the @@ -847,8 +847,8 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { return NULL; } - LPoint3f plane_point = local_p.calc_point(t); - LPoint2f p = to_2d(plane_point); + LPoint3 plane_point = local_p.calc_point(t); + LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); if (cpa != (ClipPlaneAttrib *)NULL) { @@ -883,7 +883,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3f normal = (has_effective_normal() && parabola->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && parabola->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); new_entry->set_surface_point(plane_point); @@ -919,18 +919,18 @@ fill_viz_geom() { // would be for a straight distance-to-line test). If // the result is negative, we don't bother. //////////////////////////////////////////////////////////////////// -float CollisionPolygon:: -dist_to_line_segment(const LPoint2f &p, - const LPoint2f &f, const LPoint2f &t, - const LVector2f &v) { - LVector2f v1 = (p - f); - float d = (v1[0] * v[1] - v1[1] * v[0]); +PN_stdfloat CollisionPolygon:: +dist_to_line_segment(const LPoint2 &p, + const LPoint2 &f, const LPoint2 &t, + const LVector2 &v) { + LVector2 v1 = (p - f); + PN_stdfloat d = (v1[0] * v[1] - v1[1] * v[0]); if (d < 0.0f) { return d; } // Compute the nearest point on the line. - LPoint2f q = p + LVector2f(-v[1], v[0]) * d; + LPoint2 q = p + LVector2(-v[1], v[0]) * d; // Now constrain that point to the line segment. if (v[0] > 0.0f) { @@ -1061,7 +1061,7 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, return; } - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); PT(GeomVertexData) vdata = new GeomVertexData @@ -1071,7 +1071,7 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, Points::const_iterator pi; for (pi = points.begin(); pi != points.end(); ++pi) { - vertex.add_data3f(to_3d((*pi)._p, to_3d_mat)); + vertex.add_data3(to_3d((*pi)._p, to_3d_mat)); } PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); @@ -1104,7 +1104,7 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, // polygon's 2-d space, false otherwise. //////////////////////////////////////////////////////////////////// bool CollisionPolygon:: -point_is_inside(const LPoint2f &p, const CollisionPolygon::Points &points) const { +point_is_inside(const LPoint2 &p, const CollisionPolygon::Points &points) const { // We insist that the polygon be convex. This makes things a bit simpler. // In the case of a convex polygon, defined with points in counterclockwise @@ -1131,8 +1131,8 @@ point_is_inside(const LPoint2f &p, const CollisionPolygon::Points &points) const // vector. The result is negative if the point is // within the polygon. //////////////////////////////////////////////////////////////////// -float CollisionPolygon:: -dist_to_polygon(const LPoint2f &p, const CollisionPolygon::Points &points) const { +PN_stdfloat CollisionPolygon:: +dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const { // We know that that the polygon is convex and is defined with the // points in counterclockwise order. Therefore, we simply compare @@ -1143,11 +1143,11 @@ dist_to_polygon(const LPoint2f &p, const CollisionPolygon::Points &points) const // therefore return an arbitrary negative result. bool got_dist = false; - float best_dist = -1.0f; + PN_stdfloat best_dist = -1.0f; size_t num_points = points.size(); for (size_t i = 0; i < num_points - 1; ++i) { - float d = dist_to_line_segment(p, points[i]._p, points[i + 1]._p, + PN_stdfloat d = dist_to_line_segment(p, points[i]._p, points[i + 1]._p, points[i]._v); if (d >= 0.0f) { if (!got_dist || d < best_dist) { @@ -1157,7 +1157,7 @@ dist_to_polygon(const LPoint2f &p, const CollisionPolygon::Points &points) const } } - float d = dist_to_line_segment(p, points[num_points - 1]._p, points[0]._p, + PN_stdfloat d = dist_to_line_segment(p, points[num_points - 1]._p, points[0]._p, points[num_points - 1]._v); if (d >= 0.0f) { if (!got_dist || d < best_dist) { @@ -1175,7 +1175,7 @@ dist_to_polygon(const LPoint2f &p, const CollisionPolygon::Points &points) const // Description: //////////////////////////////////////////////////////////////////// void CollisionPolygon:: -setup_points(const LPoint3f *begin, const LPoint3f *end) { +setup_points(const LPoint3 *begin, const LPoint3 *end) { int num_points = end - begin; nassertv(num_points >= 3); @@ -1183,7 +1183,7 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { // Tell the base CollisionPlane class what its plane will be. To do // this, we must first compute the polygon normal. - LVector3f normal = Normalf::zero(); + LVector3 normal = LVector3::zero(); // Project the polygon into each of the three major planes and // calculate the area of each 2-d projection. This becomes the @@ -1191,8 +1191,8 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { // different areas corresponds to the angle at which the polygon is // tilted toward each plane. for (int i = 0; i < num_points; i++) { - const LPoint3f &p0 = begin[i]; - const LPoint3f &p1 = begin[(i + 1) % num_points]; + const LPoint3 &p0 = begin[i]; + const LPoint3 &p1 = begin[(i + 1) % num_points]; normal[0] += p0[1] * p1[2] - p0[2] * p1[1]; normal[1] += p0[2] * p1[0] - p0[0] * p1[2]; normal[2] += p0[0] * p1[1] - p0[1] * p1[0]; @@ -1208,7 +1208,7 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { { if (!verify_points(begin, end)) { collide_cat.error() << "Invalid points in CollisionPolygon:\n"; - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { collide_cat.error(false) << " " << (*pi) << "\n"; } @@ -1222,18 +1222,18 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { if (collide_cat.is_spam()) { collide_cat.spam() << "CollisionPolygon defined with " << num_points << " vertices:\n"; - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { collide_cat.spam(false) << " " << (*pi) << "\n"; } } #endif - set_plane(Planef(normal, begin[0])); + set_plane(LPlane(normal, begin[0])); // Construct a matrix that rotates the points from the (X,0,Z) plane // into the 3-d plane. - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; calc_to_3d_mat(to_3d_mat); // And the inverse matrix rotates points from 3-d space into the 2-d @@ -1242,9 +1242,9 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { // Now project all of the points onto the 2-d plane. - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { - LPoint3f point = (*pi) * _to_2d_mat; + LPoint3 point = (*pi) * _to_2d_mat; _points.push_back(PointDef(point[0], point[2])); } @@ -1255,7 +1255,7 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { // Now make sure the points define a convex polygon. if (is_concave()) { collide_cat.error() << "Invalid concave CollisionPolygon defined:\n"; - const LPoint3f *pi; + const LPoint3 *pi; for (pi = begin; pi != end; ++pi) { collide_cat.error(false) << " " << (*pi) << "\n"; } @@ -1276,31 +1276,31 @@ setup_points(const LPoint3f *begin, const LPoint3f *end) { // to the way CollisionPolygons used to be stored in bam // files prior to 4.9. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionPolygon:: -legacy_to_3d(const LVecBase2f &point2d, int axis) const { - nassertr(!point2d.is_nan(), LPoint3f(0.0f, 0.0f, 0.0f)); +LPoint3 CollisionPolygon:: +legacy_to_3d(const LVecBase2 &point2d, int axis) const { + nassertr(!point2d.is_nan(), LPoint3(0.0f, 0.0f, 0.0f)); - LVector3f normal = get_normal(); - float D = get_plane()[3]; + LVector3 normal = get_normal(); + PN_stdfloat D = get_plane()[3]; - nassertr(!normal.is_nan(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!cnan(D), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!normal.is_nan(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!cnan(D), LPoint3(0.0f, 0.0f, 0.0f)); switch (axis) { case 0: // AT_x: - return LPoint3f(-(normal[1]*point2d[0] + normal[2]*point2d[1] + D)/normal[0], point2d[0], point2d[1]); + return LPoint3(-(normal[1]*point2d[0] + normal[2]*point2d[1] + D)/normal[0], point2d[0], point2d[1]); case 1: // AT_y: - return LPoint3f(point2d[0], + return LPoint3(point2d[0], -(normal[0]*point2d[0] + normal[2]*point2d[1] + D)/normal[1], point2d[1]); case 2: // AT_z: - return LPoint3f(point2d[0], point2d[1], + return LPoint3(point2d[0], point2d[1], -(normal[0]*point2d[0] + normal[1]*point2d[1] + D)/normal[2]); } - nassertr(false, LPoint3f(0.0f, 0.0f, 0.0f)); - return LPoint3f(0.0f, 0.0f, 0.0f); + nassertr(false, LPoint3(0.0f, 0.0f, 0.0f)); + return LPoint3(0.0f, 0.0f, 0.0f); } //////////////////////////////////////////////////////////////////// @@ -1318,14 +1318,14 @@ legacy_to_3d(const LVecBase2f &point2d, int axis) const { bool CollisionPolygon:: clip_polygon(CollisionPolygon::Points &new_points, const CollisionPolygon::Points &source_points, - const Planef &plane) const { + const LPlane &plane) const { new_points.clear(); if (source_points.empty()) { return true; } - LPoint3f from3d; - LVector3f delta3d; + LPoint3 from3d; + LVector3 delta3d; if (!plane.intersects_plane(from3d, delta3d, get_plane())) { // The clipping plane is parallel to the polygon. The polygon is // either all in or all out. @@ -1340,12 +1340,12 @@ clip_polygon(CollisionPolygon::Points &new_points, // Project the line of intersection into the 2-d plane. Now we have // a 2-d clipping line. - LPoint2f from2d = to_2d(from3d); - LVector2f delta2d = to_2d(delta3d); + LPoint2 from2d = to_2d(from3d); + LVector2 delta2d = to_2d(delta3d); - float a = -delta2d[1]; - float b = delta2d[0]; - float c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; + PN_stdfloat a = -delta2d[1]; + PN_stdfloat b = delta2d[0]; + PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; // Now walk through the points. Any point on the left of our line // gets removed, and the line segment clipped at the point of @@ -1356,12 +1356,12 @@ clip_polygon(CollisionPolygon::Points &new_points, // number of vertices, or keep them the same number.) new_points.reserve(source_points.size() + 1); - LPoint2f last_point = source_points.back()._p; + LPoint2 last_point = source_points.back()._p; bool last_is_in = !is_right(last_point - from2d, delta2d); bool all_in = last_is_in; Points::const_iterator pi; for (pi = source_points.begin(); pi != source_points.end(); ++pi) { - const LPoint2f &this_point = (*pi)._p; + const LPoint2 &this_point = (*pi)._p; bool this_is_in = !is_right(this_point - from2d, delta2d); // There appears to be a compiler bug in gcc 4.0: we need to @@ -1370,11 +1370,11 @@ clip_polygon(CollisionPolygon::Points &new_points, if (crossed_over) { // We have just crossed over the clipping line. Find the point // of intersection. - LVector2f d = this_point - last_point; - float denom = (a * d[0] + b * d[1]); + LVector2 d = this_point - last_point; + PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { - float t = -(a * last_point[0] + b * last_point[1] + c) / denom; - LPoint2f p = last_point + t * d; + PN_stdfloat t = -(a * last_point[0] + b * last_point[1] + c) / denom; + LPoint2 p = last_point + t * d; new_points.push_back(PointDef(p[0], p[1])); last_is_in = this_is_in; @@ -1421,7 +1421,7 @@ apply_clip_plane(CollisionPolygon::Points &new_points, CPT(TransformState) new_transform = net_transform->invert_compose(plane_path.get_net_transform()); - Planef plane = plane_node->get_plane() * new_transform->get_mat(); + LPlane plane = plane_node->get_plane() * new_transform->get_mat(); if (first_plane) { first_plane = false; if (!clip_polygon(new_points, _points, plane)) { @@ -1475,8 +1475,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { size_t size = scan.get_uint16(); for (size_t i = 0; i < size; i++) { - LPoint2f p; - LVector2f v; + LPoint2 p; + LVector2 v; p.read_datagram(scan); v.read_datagram(scan); _points.push_back(PointDef(p, v)); @@ -1488,18 +1488,18 @@ fillin(DatagramIterator &scan, BamReader *manager) { // CollisionPolygon vertices clockwise, instead of // counter-clockwise. Correct that by re-projecting. if (_points.size() >= 3) { - LMatrix4f to_3d_mat; + LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); - pvector verts; + pvector verts; verts.reserve(_points.size()); Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { verts.push_back(to_3d((*pi)._p, to_3d_mat)); } - const LPoint3f *verts_begin = &verts[0]; - const LPoint3f *verts_end = verts_begin + verts.size(); + const LPoint3 *verts_begin = &verts[0]; + const LPoint3 *verts_end = verts_begin + verts.size(); setup_points(verts_begin, verts_end); } } diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 78409d68e8..b1cf44ac95 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -20,8 +20,7 @@ #include "collisionPlane.h" #include "clipPlaneAttrib.h" #include "look_at.h" - -#include "vector_LPoint2f.h" +#include "pvector.h" class GeomNode; @@ -31,11 +30,11 @@ class GeomNode; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionPolygon : public CollisionPlane { PUBLISHED: - INLINE CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c); - INLINE CollisionPolygon(const LVecBase3f &a, const LVecBase3f &b, - const LVecBase3f &c, const LVecBase3f &d); - INLINE CollisionPolygon(const LPoint3f *begin, const LPoint3f *end); + INLINE CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c); + INLINE CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, + const LVecBase3 &c, const LVecBase3 &d); + INLINE CollisionPolygon(const LPoint3 *begin, const LPoint3 *end); private: INLINE CollisionPolygon(); @@ -46,23 +45,23 @@ public: virtual CollisionSolid *make_copy(); PUBLISHED: - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; INLINE int get_num_points() const; - INLINE LPoint3f get_point(int n) const; + INLINE LPoint3 get_point(int n) const; MAKE_SEQ(get_points, get_num_points, get_point); - INLINE static bool verify_points(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c); - INLINE static bool verify_points(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d); - static bool verify_points(const LPoint3f *begin, const LPoint3f *end); + INLINE static bool verify_points(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c); + INLINE static bool verify_points(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d); + static bool verify_points(const LPoint3 *begin, const LPoint3 *end); bool is_valid() const; bool is_concave() const; public: - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PT(PandaNode) get_viz(const CullTraverser *trav, const CullTraverserData &data, @@ -93,23 +92,23 @@ protected: virtual void fill_viz_geom(); private: - INLINE static bool is_right(const LVector2f &v1, const LVector2f &v2); - INLINE static float dist_to_line(const LPoint2f &p, - const LPoint2f &f, const LVector2f &v); - static float dist_to_line_segment(const LPoint2f &p, - const LPoint2f &f, const LPoint2f &t, - const LVector2f &v); + INLINE static bool is_right(const LVector2 &v1, const LVector2 &v2); + INLINE static PN_stdfloat dist_to_line(const LPoint2 &p, + const LPoint2 &f, const LVector2 &v); + static PN_stdfloat dist_to_line_segment(const LPoint2 &p, + const LPoint2 &f, const LPoint2 &t, + const LVector2 &v); private: class PointDef { public: - INLINE PointDef(const LPoint2f &p, const LVector2f &v); - INLINE PointDef(float x, float y); + INLINE PointDef(const LPoint2 &p, const LVector2 &v); + INLINE PointDef(PN_stdfloat x, PN_stdfloat y); INLINE PointDef(const PointDef ©); INLINE void operator = (const PointDef ©); - LPoint2f _p; // the point in 2-d space - LVector2f _v; // the normalized vector to the next point + LPoint2 _p; // the point in 2-d space + LVector2 _v; // the normalized vector to the next point }; typedef pvector Points; @@ -117,24 +116,24 @@ private: void draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, const Points &points) const; - bool point_is_inside(const LPoint2f &p, const Points &points) const; - float dist_to_polygon(const LPoint2f &p, const Points &points) const; + bool point_is_inside(const LPoint2 &p, const Points &points) const; + PN_stdfloat dist_to_polygon(const LPoint2 &p, const Points &points) const; - void setup_points(const LPoint3f *begin, const LPoint3f *end); - INLINE LPoint2f to_2d(const LVecBase3f &point3d) const; - INLINE void calc_to_3d_mat(LMatrix4f &to_3d_mat) const; - INLINE void rederive_to_3d_mat(LMatrix4f &to_3d_mat) const; - INLINE static LPoint3f to_3d(const LVecBase2f &point2d, const LMatrix4f &to_3d_mat); - LPoint3f legacy_to_3d(const LVecBase2f &point2d, int axis) const; + void setup_points(const LPoint3 *begin, const LPoint3 *end); + INLINE LPoint2 to_2d(const LVecBase3 &point3d) const; + INLINE void calc_to_3d_mat(LMatrix4 &to_3d_mat) const; + INLINE void rederive_to_3d_mat(LMatrix4 &to_3d_mat) const; + INLINE static LPoint3 to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat); + LPoint3 legacy_to_3d(const LVecBase2 &point2d, int axis) const; bool clip_polygon(Points &new_points, const Points &source_points, - const Planef &plane) const; + const LPlane &plane) const; bool apply_clip_plane(Points &new_points, const ClipPlaneAttrib *cpa, const TransformState *net_transform) const; private: Points _points; - LMatrix4f _to_2d_mat; + LMatrix4 _to_2d_mat; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/collide/collisionRay.I b/panda/src/collide/collisionRay.I index fd5eea54d8..2cefe9855c 100644 --- a/panda/src/collide/collisionRay.I +++ b/panda/src/collide/collisionRay.I @@ -23,8 +23,8 @@ //////////////////////////////////////////////////////////////////// INLINE CollisionRay:: CollisionRay() : - _origin(LPoint3f(0.0, 0.0, 0.0)), - _direction(LVector3f(0.0, 0.0, 0.0)) + _origin(LPoint3(0.0, 0.0, 0.0)), + _direction(LVector3(0.0, 0.0, 0.0)) { } @@ -34,10 +34,10 @@ CollisionRay() : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionRay:: -CollisionRay(const LPoint3f &origin, const LVector3f &direction) : +CollisionRay(const LPoint3 &origin, const LVector3 &direction) : _origin(origin), _direction(direction) { - nassertv(_direction != LPoint3f::zero()); + nassertv(_direction != LPoint3::zero()); } //////////////////////////////////////////////////////////////////// @@ -46,11 +46,11 @@ CollisionRay(const LPoint3f &origin, const LVector3f &direction) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionRay:: -CollisionRay(float ox, float oy, float oz, - float dx, float dy, float dz) : +CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, + PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz) : _origin(ox, oy, oz), _direction(dx, dy, dz) { - nassertv(_direction != LPoint3f::zero()); + nassertv(_direction != LPoint3::zero()); } //////////////////////////////////////////////////////////////////// @@ -72,7 +72,7 @@ CollisionRay(const CollisionRay ©) : // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionRay:: -set_origin(const LPoint3f &origin) { +set_origin(const LPoint3 &origin) { _origin = origin; mark_internal_bounds_stale(); mark_viz_stale(); @@ -84,8 +84,8 @@ set_origin(const LPoint3f &origin) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionRay:: -set_origin(float x, float y, float z) { - set_origin(LPoint3f(x, y, z)); +set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_origin(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -93,7 +93,7 @@ set_origin(float x, float y, float z) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionRay:: +INLINE const LPoint3 &CollisionRay:: get_origin() const { return _origin; } @@ -104,11 +104,11 @@ get_origin() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionRay:: -set_direction(const LVector3f &direction) { +set_direction(const LVector3 &direction) { _direction = direction; mark_internal_bounds_stale(); mark_viz_stale(); - nassertv(_direction != LPoint3f::zero()); + nassertv(_direction != LPoint3::zero()); } //////////////////////////////////////////////////////////////////// @@ -117,8 +117,8 @@ set_direction(const LVector3f &direction) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionRay:: -set_direction(float x, float y, float z) { - set_direction(LVector3f(x, y, z)); +set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_direction(LVector3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -126,7 +126,7 @@ set_direction(float x, float y, float z) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &CollisionRay:: +INLINE const LVector3 &CollisionRay:: get_direction() const { return _direction; } @@ -141,6 +141,6 @@ get_direction() const { // the screen given a camera and a mouse location. //////////////////////////////////////////////////////////////////// INLINE bool CollisionRay:: -set_from_lens(LensNode *camera, float px, float py) { - return set_from_lens(camera, LPoint2f(px, py)); +set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) { + return set_from_lens(camera, LPoint2(px, py)); } diff --git a/panda/src/collide/collisionRay.cxx b/panda/src/collide/collisionRay.cxx index ba14becdac..9d5c229331 100644 --- a/panda/src/collide/collisionRay.cxx +++ b/panda/src/collide/collisionRay.cxx @@ -58,7 +58,7 @@ test_intersection(const CollisionEntry &entry) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionRay:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _origin = _origin * mat; _direction = _direction * mat; @@ -73,7 +73,7 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionRay:: +LPoint3 CollisionRay:: get_collision_origin() const { return get_origin(); } @@ -101,14 +101,14 @@ output(ostream &out) const { // otherwise. //////////////////////////////////////////////////////////////////// bool CollisionRay:: -set_from_lens(LensNode *camera, const LPoint2f &point) { +set_from_lens(LensNode *camera, const LPoint2 &point) { Lens *lens = camera->get_lens(); bool success = true; - LPoint3f near_point, far_point; + LPoint3 near_point, far_point; if (!lens->extrude(point, near_point, far_point)) { - _origin = LPoint3f::origin(); - _direction = LVector3f::forward(); + _origin = LPoint3::origin(); + _direction = LVector3::forward(); success = false; } else { _origin = near_point; @@ -155,10 +155,10 @@ fill_viz_geom() { for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points); - vertex.add_data3f(get_origin() + t * scale * get_direction()); + vertex.add_data3(get_origin() + t * scale * get_direction()); - color.add_data4f(Colorf(1.0f, 1.0f, 1.0f, 1.0f) + - t * Colorf(0.0f, 0.0f, 0.0f, -1.0f)); + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 1.0f) + + t * LColor(0.0f, 0.0f, 0.0f, -1.0f)); } PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); diff --git a/panda/src/collide/collisionRay.h b/panda/src/collide/collisionRay.h index 800796ba1b..27eb84720d 100644 --- a/panda/src/collide/collisionRay.h +++ b/panda/src/collide/collisionRay.h @@ -32,11 +32,11 @@ class LensNode; class EXPCL_PANDA_COLLIDE CollisionRay : public CollisionSolid { PUBLISHED: INLINE CollisionRay(); - INLINE CollisionRay(const LPoint3f &origin, const LVector3f &direction); - INLINE CollisionRay(float ox, float oy, float oz, - float dx, float dy, float dz); + INLINE CollisionRay(const LPoint3 &origin, const LVector3 &direction); + INLINE CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, + PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; public: INLINE CollisionRay(const CollisionRay ©); @@ -45,21 +45,21 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: - INLINE void set_origin(const LPoint3f &origin); - INLINE void set_origin(float x, float y, float z); - INLINE const LPoint3f &get_origin() const; + INLINE void set_origin(const LPoint3 &origin); + INLINE void set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_origin() const; - INLINE void set_direction(const LVector3f &direction); - INLINE void set_direction(float x, float y, float z); - INLINE const LVector3f &get_direction() const; + INLINE void set_direction(const LVector3 &direction); + INLINE void set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LVector3 &get_direction() const; - bool set_from_lens(LensNode *camera, const LPoint2f &point); - INLINE bool set_from_lens(LensNode *camera, float px, float py); + bool set_from_lens(LensNode *camera, const LPoint2 &point); + INLINE bool set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py); protected: virtual PT(BoundingVolume) compute_internal_bounds() const; @@ -68,8 +68,8 @@ protected: virtual void fill_viz_geom(); private: - LPoint3f _origin; - LVector3f _direction; + LPoint3 _origin; + LVector3 _direction; public: static void register_with_read_factory(); diff --git a/panda/src/collide/collisionSegment.I b/panda/src/collide/collisionSegment.I index e619148678..cdb1e0d983 100644 --- a/panda/src/collide/collisionSegment.I +++ b/panda/src/collide/collisionSegment.I @@ -23,8 +23,8 @@ //////////////////////////////////////////////////////////////////// INLINE CollisionSegment:: CollisionSegment() : - _a(LPoint3f(0.0, 0.0, 0.0)), - _b(LPoint3f(0.0, 0.0, 0.0)) + _a(LPoint3(0.0, 0.0, 0.0)), + _b(LPoint3(0.0, 0.0, 0.0)) { } @@ -34,7 +34,7 @@ CollisionSegment() : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionSegment:: -CollisionSegment(const LPoint3f &a, const LPoint3f &b) : +CollisionSegment(const LPoint3 &a, const LPoint3 &b) : _a(a), _b(b) { nassertv(_a != _b); @@ -46,8 +46,8 @@ CollisionSegment(const LPoint3f &a, const LPoint3f &b) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionSegment:: -CollisionSegment(float ax, float ay, float az, - float bx, float by, float bz) : +CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, + PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz) : _a(ax, ay, az), _b(bx, by, bz) { nassertv(_a != _b); @@ -72,7 +72,7 @@ CollisionSegment(const CollisionSegment ©) : // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSegment:: -set_point_a(const LPoint3f &a) { +set_point_a(const LPoint3 &a) { _a = a; mark_internal_bounds_stale(); mark_viz_stale(); @@ -87,8 +87,8 @@ set_point_a(const LPoint3f &a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSegment:: -set_point_a(float x, float y, float z) { - set_point_a(LPoint3f(x, y, z)); +set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_point_a(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -96,7 +96,7 @@ set_point_a(float x, float y, float z) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionSegment:: +INLINE const LPoint3 &CollisionSegment:: get_point_a() const { return _a; } @@ -107,7 +107,7 @@ get_point_a() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSegment:: -set_point_b(const LPoint3f &b) { +set_point_b(const LPoint3 &b) { _b = b; mark_internal_bounds_stale(); mark_viz_stale(); @@ -120,8 +120,8 @@ set_point_b(const LPoint3f &b) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSegment:: -set_point_b(float x, float y, float z) { - set_point_b(LPoint3f(x, y, z)); +set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_point_b(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -129,7 +129,7 @@ set_point_b(float x, float y, float z) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionSegment:: +INLINE const LPoint3 &CollisionSegment:: get_point_b() const { return _b; } @@ -144,6 +144,6 @@ get_point_b() const { // from the screen given a camera and a mouse location. //////////////////////////////////////////////////////////////////// INLINE bool CollisionSegment:: -set_from_lens(LensNode *camera, float px, float py) { - return set_from_lens(camera, LPoint2f(px, py)); +set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) { + return set_from_lens(camera, LPoint2(px, py)); } diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index 78c97d8031..6014ca288b 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -60,7 +60,7 @@ test_intersection(const CollisionEntry &entry) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionSegment:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _a = _a * mat; _b = _b * mat; @@ -75,7 +75,7 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionSegment:: +LPoint3 CollisionSegment:: get_collision_origin() const { return get_point_a(); } @@ -103,13 +103,13 @@ output(ostream &out) const { // otherwise. //////////////////////////////////////////////////////////////////// bool CollisionSegment:: -set_from_lens(LensNode *camera, const LPoint2f &point) { +set_from_lens(LensNode *camera, const LPoint2 &point) { Lens *proj = camera->get_lens(); bool success = true; if (!proj->extrude(point, _a, _b)) { - _a = LPoint3f::origin(); - _b = _a + LVector3f::forward(); + _a = LPoint3::origin(); + _b = _a + LVector3::forward(); success = false; } @@ -127,26 +127,26 @@ set_from_lens(LensNode *camera, const LPoint2f &point) { PT(BoundingVolume) CollisionSegment:: compute_internal_bounds() const { - LVector3f pdelta = _b - _a; + LVector3 pdelta = _b - _a; // If p1 and p2 are sufficiently close, just put a sphere around // them. - float d2 = pdelta.length_squared(); + PN_stdfloat d2 = pdelta.length_squared(); if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) { - LPoint3f pmid = (_a + _b) * 0.5f; + LPoint3 pmid = (_a + _b) * 0.5f; return new BoundingSphere(pmid, csqrt(d2) * 0.5f); } - LMatrix4f from_segment; - look_at(from_segment, pdelta, LPoint3f(0,0,1), CS_zup_right); + LMatrix4 from_segment; + look_at(from_segment, pdelta, LPoint3(0,0,1), CS_zup_right); from_segment.set_row(3, _a); - float max_y = sqrt(d2) + 0.01; + PN_stdfloat max_y = sqrt(d2) + 0.01; PT(BoundingHexahedron) volume = - new BoundingHexahedron(LPoint3f(-0.01, max_y, -0.01), LPoint3f(0.01, max_y, -0.01), - LPoint3f(0.01, max_y, 0.01), LPoint3f(-0.01, max_y, 0.01), - LPoint3f(-0.01, -0.01, -0.01), LPoint3f(0.01, 0.01, -0.01), - LPoint3f(0.01, -0.01, 0.01), LPoint3f(-0.01, -0.01, 0.01)); + new BoundingHexahedron(LPoint3(-0.01, max_y, -0.01), LPoint3(0.01, max_y, -0.01), + LPoint3(0.01, max_y, 0.01), LPoint3(-0.01, max_y, 0.01), + LPoint3(-0.01, -0.01, -0.01), LPoint3(0.01, 0.01, -0.01), + LPoint3(0.01, -0.01, 0.01), LPoint3(-0.01, -0.01, 0.01)); volume->xform(from_segment); return volume.p(); @@ -170,8 +170,8 @@ fill_viz_geom() { Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(_a); - vertex.add_data3f(_b); + vertex.add_data3(_a); + vertex.add_data3(_b); PT(GeomLines) line = new GeomLines(Geom::UH_static); line->add_next_vertices(2); diff --git a/panda/src/collide/collisionSegment.h b/panda/src/collide/collisionSegment.h index 5794ed8d1c..a45ac4ff6b 100644 --- a/panda/src/collide/collisionSegment.h +++ b/panda/src/collide/collisionSegment.h @@ -35,11 +35,11 @@ class LensNode; class EXPCL_PANDA_COLLIDE CollisionSegment : public CollisionSolid { PUBLISHED: INLINE CollisionSegment(); - INLINE CollisionSegment(const LPoint3f &a, const LPoint3f &db); - INLINE CollisionSegment(float ax, float ay, float az, - float bx, float by, float bz); + INLINE CollisionSegment(const LPoint3 &a, const LPoint3 &db); + INLINE CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, + PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; public: INLINE CollisionSegment(const CollisionSegment ©); @@ -48,21 +48,21 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: - INLINE void set_point_a(const LPoint3f &a); - INLINE void set_point_a(float x, float y, float z); - INLINE const LPoint3f &get_point_a() const; + INLINE void set_point_a(const LPoint3 &a); + INLINE void set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_point_a() const; - INLINE void set_point_b(const LPoint3f &b); - INLINE void set_point_b(float x, float y, float z); - INLINE const LPoint3f &get_point_b() const; + INLINE void set_point_b(const LPoint3 &b); + INLINE void set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_point_b() const; - bool set_from_lens(LensNode *camera, const LPoint2f &point); - INLINE bool set_from_lens(LensNode *camera, float px, float py); + bool set_from_lens(LensNode *camera, const LPoint2 &point); + INLINE bool set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py); protected: virtual PT(BoundingVolume) compute_internal_bounds() const; @@ -71,7 +71,7 @@ protected: virtual void fill_viz_geom(); private: - LPoint3f _a, _b; + LPoint3 _a, _b; public: static void register_with_read_factory(); diff --git a/panda/src/collide/collisionSolid.I b/panda/src/collide/collisionSolid.I index dd25056d14..3242b86d77 100644 --- a/panda/src/collide/collisionSolid.I +++ b/panda/src/collide/collisionSolid.I @@ -62,7 +62,7 @@ is_tangible() const { // slide down it. //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: -set_effective_normal(const LVector3f &effective_normal) { +set_effective_normal(const LVector3 &effective_normal) { LightMutexHolder holder(_lock); _effective_normal = effective_normal; _flags |= F_effective_normal; @@ -99,10 +99,10 @@ has_effective_normal() const { // set_effective_normal(). It is an error to call this // unless has_effective_normal() returns true. //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &CollisionSolid:: +INLINE const LVector3 &CollisionSolid:: get_effective_normal() const { LightMutexHolder holder(_lock); - nassertr(do_has_effective_normal(), LVector3f::zero()); + nassertr(do_has_effective_normal(), LVector3::zero()); return _effective_normal; } diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index 9c64741e8c..6c3d38d858 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -132,7 +132,7 @@ test_intersection(const CollisionEntry &) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionSolid:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightMutexHolder holder(_lock); if ((_flags & F_effective_normal) != 0) { _effective_normal = _effective_normal * mat; @@ -226,20 +226,6 @@ compute_internal_bounds() const { return new BoundingSphere; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_ds_solid -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a DSSolid. -//////////////////////////////////////////////////////////////////// -PT(CollisionEntry) CollisionSolid:: -test_intersection_from_ds_solid(const CollisionEntry &) const { - report_undefined_intersection_test(CollisionSphere::get_class_type(), - get_type()); - return NULL; -} - //////////////////////////////////////////////////////////////////// // Function: CollisionSolid::test_intersection_from_sphere // Access: Protected, Virtual @@ -470,7 +456,7 @@ get_solid_viz_state() { static CPT(RenderState) intangible_state = (const RenderState *)NULL; if (intangible_state == (const RenderState *)NULL) { intangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(1.0f, 0.3f, 0.5f, 0.5f))); + (ColorAttrib::make_flat(LColor(1.0f, 0.3, 0.5f, 0.5f))); } return intangible_state; @@ -478,7 +464,7 @@ get_solid_viz_state() { static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; if (fakenormal_state == (const RenderState *)NULL) { fakenormal_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(0.5f, 0.5f, 1.0f, 0.5f))); + (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.5f))); } return fakenormal_state; @@ -486,7 +472,7 @@ get_solid_viz_state() { static CPT(RenderState) tangible_state = (const RenderState *)NULL; if (tangible_state == (const RenderState *)NULL) { tangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 1.0f, 0.5f))); + (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 0.5f))); } return tangible_state; } @@ -519,7 +505,7 @@ get_wireframe_viz_state() { static CPT(RenderState) intangible_state = (const RenderState *)NULL; if (intangible_state == (const RenderState *)NULL) { intangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.0f, 1.0f))); + (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.0f, 1.0f))); } return intangible_state; @@ -527,7 +513,7 @@ get_wireframe_viz_state() { static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; if (fakenormal_state == (const RenderState *)NULL) { fakenormal_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(0.0f, 0.0f, 1.0f, 1.0f))); + (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } return fakenormal_state; @@ -535,7 +521,7 @@ get_wireframe_viz_state() { static CPT(RenderState) tangible_state = (const RenderState *)NULL; if (tangible_state == (const RenderState *)NULL) { tangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(0.0f, 0.0f, 1.0f, 1.0f))); + (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } return tangible_state; } @@ -594,7 +580,7 @@ get_solid_bounds_viz_state() { static CPT(RenderState) intangible_state = (const RenderState *)NULL; if (intangible_state == (const RenderState *)NULL) { intangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.5f, 0.3f))); + (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } return intangible_state; @@ -602,7 +588,7 @@ get_solid_bounds_viz_state() { static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; if (fakenormal_state == (const RenderState *)NULL) { fakenormal_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(0.5f, 0.5f, 1.0f, 0.3f))); + (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.3))); } return fakenormal_state; @@ -610,7 +596,7 @@ get_solid_bounds_viz_state() { static CPT(RenderState) tangible_state = (const RenderState *)NULL; if (tangible_state == (const RenderState *)NULL) { tangible_state = base_state->add_attrib - (ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.5f, 0.3f))); + (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } return tangible_state; } @@ -637,7 +623,7 @@ get_wireframe_bounds_viz_state() { (CullFaceAttrib::make(CullFaceAttrib::M_cull_none), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), TransparencyAttrib::make(TransparencyAttrib::M_none), - ColorAttrib::make_flat(Colorf(1.0f, 0.0f, 0.0f, 1.0f))); + ColorAttrib::make_flat(LColor(1.0f, 0.0f, 0.0f, 1.0f))); } return base_state; diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index 7fc45759af..3cf1634224 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -58,15 +58,15 @@ protected: virtual PT(CopyOnWriteObject) make_cow_copy(); PUBLISHED: - virtual LPoint3f get_collision_origin() const=0; + virtual LPoint3 get_collision_origin() const=0; INLINE void set_tangible(bool tangible); INLINE bool is_tangible() const; - INLINE void set_effective_normal(const LVector3f &effective_normal); + INLINE void set_effective_normal(const LVector3 &effective_normal); INLINE void clear_effective_normal(); INLINE bool has_effective_normal() const; - INLINE const LVector3f &get_effective_normal() const; + INLINE const LVector3 &get_effective_normal() const; INLINE void set_respect_effective_normal(bool respect_effective_normal); INLINE bool get_respect_effective_normal() const; @@ -78,7 +78,7 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PT(PandaNode) get_viz(const CullTraverser *trav, const CullTraverserData &data, @@ -98,8 +98,6 @@ protected: INLINE void mark_internal_bounds_stale(); virtual PT(BoundingVolume) compute_internal_bounds() const; - virtual PT(CollisionEntry) - test_intersection_from_ds_solid(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const; virtual PT(CollisionEntry) @@ -131,7 +129,7 @@ protected: PT(GeomNode) _bounds_viz_geom; private: - LVector3f _effective_normal; + LVector3 _effective_normal; PT(BoundingVolume) _internal_bounds; // Be careful reordering these bits, since they are written to a bam @@ -173,7 +171,6 @@ public: private: static TypeHandle _type_handle; - friend class CollisionDSSolid; friend class CollisionSphere; friend class CollisionLine; friend class CollisionRay; diff --git a/panda/src/collide/collisionSphere.I b/panda/src/collide/collisionSphere.I index ae4451251c..a53e319bc9 100644 --- a/panda/src/collide/collisionSphere.I +++ b/panda/src/collide/collisionSphere.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionSphere:: -CollisionSphere(const LPoint3f ¢er, float radius) : +CollisionSphere(const LPoint3 ¢er, PN_stdfloat radius) : _center(center), _radius(radius) { nassertv(_radius >= 0.0f); @@ -31,7 +31,7 @@ CollisionSphere(const LPoint3f ¢er, float radius) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionSphere:: -CollisionSphere(float cx, float cy, float cz, float radius) : +CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) : _center(cx, cy, cz), _radius(radius) { nassertv(_radius >= 0.0f); @@ -77,7 +77,7 @@ flush_level() { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSphere:: -set_center(const LPoint3f ¢er) { +set_center(const LPoint3 ¢er) { _center = center; mark_internal_bounds_stale(); mark_viz_stale(); @@ -89,8 +89,8 @@ set_center(const LPoint3f ¢er) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSphere:: -set_center(float x, float y, float z) { - set_center(LPoint3f(x, y, z)); +set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_center(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -98,7 +98,7 @@ set_center(float x, float y, float z) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionSphere:: +INLINE const LPoint3 &CollisionSphere:: get_center() const { return _center; } @@ -109,7 +109,7 @@ get_center() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionSphere:: -set_radius(float radius) { +set_radius(PN_stdfloat radius) { nassertv(radius >= 0.0f); _radius = radius; mark_internal_bounds_stale(); @@ -121,7 +121,7 @@ set_radius(float radius) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float CollisionSphere:: +INLINE PN_stdfloat CollisionSphere:: get_radius() const { return _radius; } diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index ed77219981..773b11c104 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -13,7 +13,6 @@ //////////////////////////////////////////////////////////////////// -#include "collisionDSSolid.h" #include "collisionSphere.h" #include "collisionLine.h" #include "collisionRay.h" @@ -65,12 +64,12 @@ test_intersection(const CollisionEntry &entry) const { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionSphere:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _center = _center * mat; // This is a little cheesy and fails miserably in the presence of a // non-uniform scale. - LVector3f radius_v = LVector3f(_radius, 0.0f, 0.0f) * mat; + LVector3 radius_v = LVector3(_radius, 0.0f, 0.0f) * mat; _radius = length(radius_v); mark_viz_stale(); mark_internal_bounds_stale(); @@ -84,7 +83,7 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionSphere:: +LPoint3 CollisionSphere:: get_collision_origin() const { return get_center(); } @@ -132,174 +131,6 @@ PT(BoundingVolume) CollisionSphere:: compute_internal_bounds() const { return new BoundingSphere(_center, _radius); } -#define USE_DS_SOLID_PLANES 1 -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_ds_solid -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -PT(CollisionEntry) CollisionSphere:: -test_intersection_from_ds_solid(const CollisionEntry &entry) const { - const CollisionDSSolid *ds_solid; - DCAST_INTO_R(ds_solid, entry.get_from(), 0); - cerr<<"CollisionSphere::test_intersection_from_ds_solid\n"; - - CPT(TransformState) wrt_space = entry.get_wrt_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); - - LPoint3f into_center = get_center(); - float into_radius = get_radius(); - - LPoint3f sa_center = ds_solid->get_center_a() * wrt_mat; - float sa_radius = length( - LVector3f(ds_solid->get_radius_a(), 0.0f, 0.0f) * wrt_mat); - LVector3f sa_vec = sa_center - into_center; - float sa_distance_squared = dot(sa_vec, sa_vec); - float sa_and_into_radii_squared = ( - sa_radius + into_radius) * (sa_radius + into_radius); - if (sa_distance_squared > sa_and_into_radii_squared) { - // No intersection. - return NULL; - } - - LPoint3f sb_center = ds_solid->get_center_b() * wrt_mat; - float sb_radius = length( - LVector3f(ds_solid->get_radius_b(), 0.0f, 0.0f) * wrt_mat); - LVector3f sb_vec = sb_center - into_center; - float sb_distance_squared = dot(sb_vec, sb_vec); - float sb_and_into_radii_squared = ( - sb_radius + into_radius) * (sb_radius + into_radius); - if (sb_distance_squared > sb_and_into_radii_squared) { - // No intersection. - return NULL; - } - - #if USE_DS_SOLID_PLANES - CPT(TransformState) inv_wrt_space = entry.get_inv_wrt_space(); - const LMatrix4f &inv_wrt_mat = inv_wrt_space->get_mat(); - - LPoint3f inv_into_center = get_center() * inv_wrt_mat; - float inv_into_radius = length( - LVector3f(get_radius(), 0.0f, 0.0f) * inv_wrt_mat); - - float pa_distance = - ds_solid->dist_to_plane_a(inv_into_center) - inv_into_radius; - if (pa_distance > 0.0f) { - // No intersection. - return NULL; - } - - float pb_distance = - ds_solid->dist_to_plane_b(inv_into_center) - inv_into_radius; - if (pb_distance > 0.0f) { - // No intersection. - return NULL; - } - #endif - - LVector3f lens_center = ds_solid->get_collision_origin() * wrt_mat; - float lens_radius = length( - LVector3f(ds_solid->get_lens_radius(), 0.0f, 0.0f) * wrt_mat); - LVector3f lens_vec = lens_center - into_center; - // float lens_distance_squared = dot(lens_vec, lens_vec); - - LVector3f surface_normal; // into - //LPoint3f surface_point; // into - LPoint3f interior_point; // from - float sa_distance = sqrtf(sa_distance_squared) - sa_radius; - float sb_distance = sqrtf(sb_distance_squared) - sb_radius; - pa_distance = ds_solid->dist_to_plane_a(inv_into_center); - pb_distance = ds_solid->dist_to_plane_b(inv_into_center); - #if USE_DS_SOLID_PLANES - cerr - <<" sa_distance:"< pa_distance && sa_distance > pb_distance) || - (sb_distance > pa_distance && sb_distance > pb_distance)) { - #else - cerr - <<" sa_distance:"< sb_distance) { - // sphere_a is the furthest - cerr<<"sphere_a is the furthest\n"; - primary_vec = &sa_vec; - primary_center = &sa_center; - primary_radius = sa_radius; - secondary_center = &sb_center; - secondary_radius = sb_radius; - } else { - // sphere_b is the furthest - cerr<<"sphere_b is the furthest\n"; - primary_vec = &sb_vec; - primary_center = &sb_center; - primary_radius = sb_radius; - secondary_center = &sa_center; - secondary_radius = sa_radius; - } - - float vec_length = primary_vec->length(); - if (IS_NEARLY_ZERO(vec_length)) { - // The centers are coincident, use an arbitrary normal. - surface_normal.set(1.0, 0.0, 0.0); - } else { - // Lens face - surface_normal = *primary_vec / vec_length; - } - interior_point = *primary_center - surface_normal * primary_radius; - - float temp_length_squared = - (interior_point - *secondary_center).length_squared(); - if (temp_length_squared > (secondary_radius * secondary_radius)) { - cerr<<"foo\n"; - LVector3f a = (*primary_center - lens_center).normalize(); - LVector3f b = - cross(cross(a, (into_center - lens_center).normalize()), a).normalize(); - interior_point = lens_center + b * lens_radius; - surface_normal = (interior_point - into_center).normalize(); - } - #if USE_DS_SOLID_PLANES - } else { - if (pa_distance > pb_distance) { - // plane_a is the furthest - cerr<<"plane_a is the furthest\n"; - surface_normal = -(ds_solid->get_plane_a().get_normal() * wrt_mat); - float d = length( - LVector3f(pa_distance, 0.0f, 0.0f) * wrt_mat); - interior_point = into_center + surface_normal * d; - } else { - // plane_b is the furthest - cerr<<"plane_b is the furthest\n"; - //surface_normal = -(ds_solid->get_plane_b().get_normal() * wrt_mat); - surface_normal = -ds_solid->get_plane_b().get_normal(); - surface_normal = surface_normal * wrt_mat; - float d = length( - LVector3f(pb_distance, 0.0f, 0.0f) * wrt_mat); - interior_point = into_center + surface_normal * d; - } - } - #endif - - if (collide_cat.is_debug()) { - collide_cat.debug() - << "intersection detected from " << entry.get_from_node_path() - << " into " << entry.get_into_node_path() << "\n"; - } - - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - new_entry->set_surface_normal(surface_normal); - new_entry->set_surface_point(into_center + surface_normal * into_radius); - new_entry->set_interior_point(interior_point); - return new_entry; -} //////////////////////////////////////////////////////////////////// // Function: CollisionSphere::test_intersection_from_sphere @@ -313,32 +144,32 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { CPT(TransformState) wrt_space = entry.get_wrt_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); + const LMatrix4 &wrt_mat = wrt_space->get_mat(); - LPoint3f from_b = sphere->get_center() * wrt_mat; + LPoint3 from_b = sphere->get_center() * wrt_mat; - LPoint3f into_center(get_center()); - float into_radius(get_radius()); + LPoint3 into_center(get_center()); + PN_stdfloat into_radius(get_radius()); - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius = length(from_radius_v); + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); - LPoint3f into_intersection_point(from_b); + LPoint3 into_intersection_point(from_b); double t1, t2; - LPoint3f contact_point(into_intersection_point); - float actual_t = 0.0f; + LPoint3 contact_point(into_intersection_point); + PN_stdfloat actual_t = 0.0f; - LVector3f vec = from_b - into_center; - float dist2 = dot(vec, vec); + LVector3 vec = from_b - into_center; + PN_stdfloat dist2 = dot(vec, vec); if (dist2 > (into_radius + from_radius) * (into_radius + from_radius)) { // No intersection with the current position. Check the delta // from the previous frame. CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); - LPoint3f from_a = sphere->get_center() * wrt_prev_space->get_mat(); + LPoint3 from_a = sphere->get_center() * wrt_prev_space->get_mat(); if (!from_a.almost_equal(from_b)) { - LVector3f from_direction = from_b - from_a; + LVector3 from_direction = from_b - from_a; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. return NULL; @@ -376,11 +207,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f from_center = sphere->get_center() * wrt_mat; + LPoint3 from_center = sphere->get_center() * wrt_mat; - LVector3f surface_normal; - LVector3f v(into_intersection_point - into_center); - float vec_length = v.length(); + LVector3 surface_normal; + LVector3 v(into_intersection_point - into_center); + PN_stdfloat vec_length = v.length(); if (IS_NEARLY_ZERO(vec_length)) { // If we don't have a collision normal (e.g. the centers are // exactly coincident), then make up an arbitrary normal--any one @@ -390,11 +221,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { surface_normal = v / vec_length; } - LVector3f eff_normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : surface_normal; + LVector3 eff_normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : surface_normal; - LVector3f contact_normal; - LVector3f v2 = contact_point - into_center; - float v2_len = v2.length(); + LVector3 contact_normal; + LVector3 v2 = contact_point - into_center; + PN_stdfloat v2_len = v2.length(); if (IS_NEARLY_ZERO(v2_len)) { // If we don't have a collision normal (e.g. the centers are // exactly coincident), then make up an arbitrary normal--any one @@ -424,10 +255,10 @@ test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = line->get_origin() * wrt_mat; - LVector3f from_direction = line->get_direction() * wrt_mat; + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -442,13 +273,13 @@ test_intersection_from_line(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t1 * from_direction; + LPoint3 into_intersection_point = from_origin + t1 * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && line->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(normal); } @@ -469,27 +300,27 @@ test_intersection_from_box(const CollisionEntry &entry) const { CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); + const LMatrix4 &wrt_mat = wrt_space->get_mat(); CollisionBox local_b( *box ); local_b.xform( wrt_mat ); - LPoint3f from_center = local_b.get_center(); + LPoint3 from_center = local_b.get_center(); - LPoint3f orig_center = get_center(); - LPoint3f to_center = orig_center; - LPoint3f contact_point(from_center); - float actual_t = 1.0f; + LPoint3 orig_center = get_center(); + LPoint3 to_center = orig_center; + LPoint3 contact_point(from_center); + PN_stdfloat actual_t = 1.0f; - float to_radius = get_radius(); - float to_radius_2 = to_radius * to_radius; + PN_stdfloat to_radius = get_radius(); + PN_stdfloat to_radius_2 = to_radius * to_radius; int ip; - float max_dist = 0.0f; - float dist = 0.0f; // initial assignment to squelch silly compiler warning + PN_stdfloat max_dist = 0.0f; + PN_stdfloat dist = 0.0f; // initial assignment to squelch silly compiler warning bool intersect; - Planef plane; - LVector3f normal; + LPlane plane; + LVector3 normal; for (ip = 0, intersect=false; ip < 6 && !intersect; ip++) { plane = local_b.get_plane( ip ); @@ -524,8 +355,8 @@ test_intersection_from_box(const CollisionEntry &entry) const { continue; } - LPoint2f p = local_b.to_2d(to_center - dist * plane.get_normal(), ip); - float edge_dist = 0.0f; + LPoint2 p = local_b.to_2d(to_center - dist * plane.get_normal(), ip); + PN_stdfloat edge_dist = 0.0f; edge_dist = local_b.dist_to_polygon(p, local_b.get_plane_points(ip)); @@ -548,7 +379,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { max_dist = to_radius; if (edge_dist >= 0.0f) { - float max_dist_2 = max(to_radius_2 - edge_dist * edge_dist, 0.0f); + PN_stdfloat max_dist_2 = max(to_radius_2 - edge_dist * edge_dist, (PN_stdfloat)0.0); max_dist = csqrt(max_dist_2); } @@ -569,7 +400,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { PT(CollisionEntry) new_entry = new CollisionEntry(entry); - float into_depth = max_dist - dist; + PN_stdfloat into_depth = max_dist - dist; new_entry->set_surface_normal(normal); new_entry->set_surface_point(to_center - normal * dist); @@ -591,10 +422,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -616,13 +447,13 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t1 * from_direction; + LPoint3 into_intersection_point = from_origin + t1 * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && ray->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(normal); } @@ -640,11 +471,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_a = segment->get_point_a() * wrt_mat; - LPoint3f from_b = segment->get_point_b() * wrt_mat; - LVector3f from_direction = from_b - from_a; + LPoint3 from_a = segment->get_point_a() * wrt_mat; + LPoint3 from_b = segment->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { @@ -667,13 +498,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_a + t1 * from_direction; + LPoint3 into_intersection_point = from_a + t1 * from_direction; new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && segment->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(normal); } @@ -691,10 +522,10 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; DCAST_INTO_R(parabola, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); // Convert the parabola into local coordinate space. - Parabolaf local_p(parabola->get_parabola()); + LParabola local_p(parabola->get_parabola()); local_p.xform(wrt_mat); double t; @@ -712,13 +543,13 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = local_p.calc_point(t); + LPoint3 into_intersection_point = local_p.calc_point(t); new_entry->set_surface_point(into_intersection_point); if (has_effective_normal() && parabola->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point - get_center(); + LVector3 normal = into_intersection_point - get_center(); normal.normalize(); new_entry->set_surface_normal(normal); } @@ -749,15 +580,15 @@ fill_viz_geom() { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); for (int sl = 0; sl < num_slices; ++sl) { - float longitude0 = (float)sl / (float)num_slices; - float longitude1 = (float)(sl + 1) / (float)num_slices; - vertex.add_data3f(compute_point(0.0, longitude0)); + PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; + PN_stdfloat longitude1 = (PN_stdfloat)(sl + 1) / (PN_stdfloat)num_slices; + vertex.add_data3(compute_point(0.0, longitude0)); for (int st = 1; st < num_stacks; ++st) { - float latitude = (float)st / (float)num_stacks; - vertex.add_data3f(compute_point(latitude, longitude0)); - vertex.add_data3f(compute_point(latitude, longitude1)); + PN_stdfloat latitude = (PN_stdfloat)st / (PN_stdfloat)num_stacks; + vertex.add_data3(compute_point(latitude, longitude0)); + vertex.add_data3(compute_point(latitude, longitude1)); } - vertex.add_data3f(compute_point(1.0, longitude0)); + vertex.add_data3(compute_point(1.0, longitude0)); strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); @@ -785,8 +616,8 @@ fill_viz_geom() { //////////////////////////////////////////////////////////////////// bool CollisionSphere:: intersects_line(double &t1, double &t2, - const LPoint3f &from, const LVector3f &delta, - float inflate_radius) const { + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_radius) const { // Solve the equation for the intersection of a line with a sphere // using the quadratic equation. @@ -821,7 +652,7 @@ intersects_line(double &t1, double &t2, nassertr(A != 0.0, false); - LVector3f fc = from - get_center(); + LVector3 fc = from - get_center(); double B = 2.0f* dot(delta, fc); double fc_d2 = dot(fc, fc); double radius = get_radius() + inflate_radius; @@ -861,9 +692,9 @@ intersects_line(double &t1, double &t2, // is returned. //////////////////////////////////////////////////////////////////// bool CollisionSphere:: -intersects_parabola(double &t, const Parabolaf ¶bola, +intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, - const LPoint3f &p1, const LPoint3f &p2) const { + const LPoint3 &p1, const LPoint3 &p2) const { if (t1 == t2) { // Special case: a single point. if ((p1 - _center).length_squared() > _radius * _radius) { @@ -888,8 +719,8 @@ intersects_parabola(double &t, const Parabolaf ¶bola, // point. double tmid = (t1 + t2) * 0.5; if (tmid != t1 && tmid != t2) { - LPoint3f pmid = parabola.calc_point(tmid); - LPoint3f pmid2 = (p1 + p2) * 0.5f; + LPoint3 pmid = parabola.calc_point(tmid); + LPoint3 pmid2 = (p1 + p2) * 0.5f; if ((pmid - pmid2).length_squared() > 0.001f) { // Subdivide. @@ -922,15 +753,15 @@ intersects_parabola(double &t, const Parabolaf ¶bola, // is used by fill_viz_geom() to create a visible // representation of the sphere. //////////////////////////////////////////////////////////////////// -Vertexf CollisionSphere:: -compute_point(float latitude, float longitude) const { - float s1, c1; - csincos(latitude * MathNumbers::pi_f, &s1, &c1); +LVertex CollisionSphere:: +compute_point(PN_stdfloat latitude, PN_stdfloat longitude) const { + PN_stdfloat s1, c1; + csincos(latitude * MathNumbers::pi, &s1, &c1); - float s2, c2; - csincos(longitude * 2.0f * MathNumbers::pi_f, &s2, &c2); + PN_stdfloat s2, c2; + csincos(longitude * 2.0f * MathNumbers::pi, &s2, &c2); - Vertexf p(s1 * c2, s1 * s2, c1); + LVertex p(s1 * c2, s1 * s2, c1); return p * get_radius() + get_center(); } @@ -954,7 +785,7 @@ void CollisionSphere:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSolid::write_datagram(manager, me); _center.write_datagram(me); - me.add_float32(_radius); + me.add_stdfloat(_radius); } //////////////////////////////////////////////////////////////////// @@ -985,5 +816,5 @@ void CollisionSphere:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSolid::fillin(scan, manager); _center.read_datagram(scan); - _radius = scan.get_float32(); + _radius = scan.get_stdfloat(); } diff --git a/panda/src/collide/collisionSphere.h b/panda/src/collide/collisionSphere.h index 9045cfa9ce..d6ebef3c21 100644 --- a/panda/src/collide/collisionSphere.h +++ b/panda/src/collide/collisionSphere.h @@ -26,10 +26,10 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionSphere : public CollisionSolid { PUBLISHED: - INLINE CollisionSphere(const LPoint3f ¢er, float radius); - INLINE CollisionSphere(float cx, float cy, float cz, float radius); + INLINE CollisionSphere(const LPoint3 ¢er, PN_stdfloat radius); + INLINE CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; protected: INLINE CollisionSphere(); @@ -41,7 +41,7 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); @@ -51,18 +51,16 @@ public: INLINE static void flush_level(); PUBLISHED: - INLINE void set_center(const LPoint3f ¢er); - INLINE void set_center(float x, float y, float z); - INLINE const LPoint3f &get_center() const; + INLINE void set_center(const LPoint3 ¢er); + INLINE void set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_center() const; - INLINE void set_radius(float radius); - INLINE float get_radius() const; + INLINE void set_radius(PN_stdfloat radius); + INLINE PN_stdfloat get_radius() const; protected: virtual PT(BoundingVolume) compute_internal_bounds() const; - virtual PT(CollisionEntry) - test_intersection_from_ds_solid(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const; virtual PT(CollisionEntry) @@ -80,16 +78,16 @@ protected: protected: bool intersects_line(double &t1, double &t2, - const LPoint3f &from, const LVector3f &delta, - float inflate_radius) const; - bool intersects_parabola(double &t, const Parabolaf ¶bola, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_radius) const; + bool intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, - const LPoint3f &p1, const LPoint3f &p2) const; - Vertexf compute_point(float latitude, float longitude) const; + const LPoint3 &p1, const LPoint3 &p2) const; + LVertex compute_point(PN_stdfloat latitude, PN_stdfloat longitude) const; private: - LPoint3f _center; - float _radius; + LPoint3 _center; + PN_stdfloat _radius; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 5f93457297..9ac8bb521b 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -1328,14 +1328,14 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, // Indexed case. GeomVertexReader index(tris->get_vertices(), 0); while (!index.is_at_end()) { - Vertexf v[3]; + LVertex v[3]; vertex.set_row_unsafe(index.get_data1i()); - v[0] = vertex.get_data3f(); + v[0] = vertex.get_data3(); vertex.set_row_unsafe(index.get_data1i()); - v[1] = vertex.get_data3f(); + v[1] = vertex.get_data3(); vertex.set_row_unsafe(index.get_data1i()); - v[2] = vertex.get_data3f(); + v[2] = vertex.get_data3(); // Generate a temporary CollisionGeom on the fly for each // triangle in the Geom. @@ -1361,11 +1361,11 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, vertex.set_row_unsafe(primitive->get_first_vertex()); int num_vertices = primitive->get_num_vertices(); for (int i = 0; i < num_vertices; i += 3) { - Vertexf v[3]; + LVertex v[3]; - v[0] = vertex.get_data3f(); - v[1] = vertex.get_data3f(); - v[2] = vertex.get_data3f(); + v[0] = vertex.get_data3(); + v[1] = vertex.get_data3(); + v[2] = vertex.get_data3(); // Generate a temporary CollisionGeom on the fly for each // triangle in the Geom. diff --git a/panda/src/collide/collisionTube.I b/panda/src/collide/collisionTube.I index 74ecff65fe..0af8961111 100644 --- a/panda/src/collide/collisionTube.I +++ b/panda/src/collide/collisionTube.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionTube:: -CollisionTube(const LPoint3f &a, const LPoint3f &b, float radius) : +CollisionTube(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : _a(a), _b(b), _radius(radius) { recalc_internals(); @@ -32,9 +32,9 @@ CollisionTube(const LPoint3f &a, const LPoint3f &b, float radius) : // Description: //////////////////////////////////////////////////////////////////// INLINE CollisionTube:: -CollisionTube(float ax, float ay, float az, - float bx, float by, float bz, - float radius) : +CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, + PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, + PN_stdfloat radius) : _a(ax, ay, az), _b(bx, by, bz), _radius(radius) { recalc_internals(); @@ -83,7 +83,7 @@ flush_level() { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionTube:: -set_point_a(const LPoint3f &a) { +set_point_a(const LPoint3 &a) { _a = a; recalc_internals(); } @@ -94,8 +94,8 @@ set_point_a(const LPoint3f &a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionTube:: -set_point_a(float x, float y, float z) { - set_point_a(LPoint3f(x, y, z)); +set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_point_a(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -103,7 +103,7 @@ set_point_a(float x, float y, float z) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionTube:: +INLINE const LPoint3 &CollisionTube:: get_point_a() const { return _a; } @@ -114,7 +114,7 @@ get_point_a() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionTube:: -set_point_b(const LPoint3f &b) { +set_point_b(const LPoint3 &b) { _b = b; recalc_internals(); } @@ -125,8 +125,8 @@ set_point_b(const LPoint3f &b) { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionTube:: -set_point_b(float x, float y, float z) { - set_point_b(LPoint3f(x, y, z)); +set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_point_b(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ set_point_b(float x, float y, float z) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &CollisionTube:: +INLINE const LPoint3 &CollisionTube:: get_point_b() const { return _b; } @@ -145,7 +145,7 @@ get_point_b() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void CollisionTube:: -set_radius(float radius) { +set_radius(PN_stdfloat radius) { nassertv(radius >= 0.0f); _radius = radius; @@ -160,7 +160,7 @@ set_radius(float radius) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float CollisionTube:: +INLINE PN_stdfloat CollisionTube:: get_radius() const { return _radius; } diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index c3cadbe4bc..c9df64ae5e 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -55,13 +55,13 @@ make_copy() { // Description: Transforms the solid by the indicated matrix. //////////////////////////////////////////////////////////////////// void CollisionTube:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _a = _a * mat; _b = _b * mat; // This is a little cheesy and fails miserably in the presence of a // non-uniform scale. - LVector3f radius_v = LVector3f(_radius, 0.0f, 0.0f) * mat; + LVector3 radius_v = LVector3(_radius, 0.0f, 0.0f) * mat; _radius = length(radius_v); recalc_internals(); @@ -76,7 +76,7 @@ xform(const LMatrix4f &mat) { // intersection point to this origin point is considered // to be the most significant. //////////////////////////////////////////////////////////////////// -LPoint3f CollisionTube:: +LPoint3 CollisionTube:: get_collision_origin() const { return get_point_a(); } @@ -128,11 +128,11 @@ compute_internal_bounds() const { GeometricBoundingVolume *gbound; DCAST_INTO_R(gbound, bound, bound); - LVector3f vec = (_b - _a); + LVector3 vec = (_b - _a); if (vec.normalize()) { // The bounding volume includes both endpoints, plus a little // bit more to include the radius in both directions. - LPoint3f points[2]; + LPoint3 points[2]; points[0] = _a - vec * _radius; points[1] = _b + vec * _radius; @@ -162,13 +162,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); - const LMatrix4f &wrt_mat = wrt_space->get_mat(); + const LMatrix4 &wrt_mat = wrt_space->get_mat(); - LPoint3f from_a = sphere->get_center() * wrt_mat; - LPoint3f from_b = from_a; + LPoint3 from_a = sphere->get_center() * wrt_mat; + LPoint3 from_b = from_a; - LPoint3f contact_point; - float actual_t = 0.0f; + LPoint3 contact_point; + PN_stdfloat actual_t = 0.0f; if (wrt_prev_space != wrt_space) { // If the sphere is moving relative to the tube, it becomes a tube @@ -176,11 +176,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { from_a = sphere->get_center() * wrt_prev_space->get_mat(); } - LVector3f from_direction = from_b - from_a; + LVector3 from_direction = from_b - from_a; - LVector3f from_radius_v = - LVector3f(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; - float from_radius = length(from_radius_v); + LVector3 from_radius_v = + LVector3(sphere->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { @@ -205,7 +205,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point; + LPoint3 into_intersection_point; if (t2 > 1.0) { // Point b is within the tube. The first intersection point is // point b itself. @@ -217,8 +217,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } set_intersection_point(new_entry, into_intersection_point, from_radius); - LPoint3f fake_contact_point; - LVector3f contact_normal; + LPoint3 fake_contact_point; + LVector3 contact_normal; calculate_surface_point_and_normal(contact_point, from_radius, fake_contact_point, @@ -240,10 +240,10 @@ test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = line->get_origin() * wrt_mat; - LVector3f from_direction = line->get_direction() * wrt_mat; + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -258,14 +258,14 @@ test_intersection_from_line(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = from_origin + t1 * from_direction; + LPoint3 into_intersection_point = from_origin + t1 * from_direction; set_intersection_point(new_entry, into_intersection_point, 0.0); if (has_effective_normal() && line->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point * _inv_mat; + LVector3 normal = into_intersection_point * _inv_mat; if (normal[1] > _length) { // The point is within the top endcap. normal[1] -= _length; @@ -290,10 +290,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_origin = ray->get_origin() * wrt_mat; - LVector3f from_direction = ray->get_direction() * wrt_mat; + LPoint3 from_origin = ray->get_origin() * wrt_mat; + LVector3 from_direction = ray->get_direction() * wrt_mat; double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { @@ -313,7 +313,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point; + LPoint3 into_intersection_point; if (t1 < 0.0) { // Point a is within the tube. The first intersection point is // point a itself. @@ -329,7 +329,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point * _inv_mat; + LVector3 normal = into_intersection_point * _inv_mat; if (normal[1] > _length) { // The point is within the top endcap. normal[1] -= _length; @@ -354,11 +354,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3f from_a = segment->get_point_a() * wrt_mat; - LPoint3f from_b = segment->get_point_b() * wrt_mat; - LVector3f from_direction = from_b - from_a; + LPoint3 from_a = segment->get_point_a() * wrt_mat; + LPoint3 from_b = segment->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { @@ -379,7 +379,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point; + LPoint3 into_intersection_point; if (t1 < 0.0) { // Point a is within the tube. The first intersection point is // point a itself. @@ -395,7 +395,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point * _inv_mat; + LVector3 normal = into_intersection_point * _inv_mat; if (normal[1] > _length) { // The point is within the top endcap. normal[1] -= _length; @@ -420,10 +420,10 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; DCAST_INTO_R(parabola, entry.get_from(), 0); - const LMatrix4f &wrt_mat = entry.get_wrt_mat(); + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); // Convert the parabola into local coordinate space. - Parabolaf local_p(parabola->get_parabola()); + LParabola local_p(parabola->get_parabola()); local_p.xform(wrt_mat); double t; @@ -441,14 +441,14 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3f into_intersection_point = local_p.calc_point(t); + LPoint3 into_intersection_point = local_p.calc_point(t); set_intersection_point(new_entry, into_intersection_point, 0.0); if (has_effective_normal() && parabola->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { - LVector3f normal = into_intersection_point * _inv_mat; + LVector3 normal = into_intersection_point * _inv_mat; if (normal[1] > _length) { // The point is within the top endcap. normal[1] -= _length; @@ -479,8 +479,8 @@ fill_viz_geom() { // Generate the vertices such that we draw a tube with one endpoint // at (0, 0, 0), and another at (0, length, 0). Then we'll rotate // and translate it into place with the appropriate look_at matrix. - LVector3f direction = (_b - _a); - float length = direction.length(); + LVector3 direction = (_b - _a); + PN_stdfloat length = direction.length(); PT(GeomVertexData) vdata = new GeomVertexData ("collision", GeomVertexFormat::get_v3(), @@ -494,8 +494,8 @@ fill_viz_geom() { int ri, si; for (ri = 0; ri < num_rings; ri++) { for (si = 0; si <= num_slices; si++) { - vertex.add_data3f(calc_sphere1_vertex(ri, si, num_rings, num_slices)); - vertex.add_data3f(calc_sphere1_vertex(ri + 1, si, num_rings, num_slices)); + vertex.add_data3(calc_sphere1_vertex(ri, si, num_rings, num_slices)); + vertex.add_data3(calc_sphere1_vertex(ri + 1, si, num_rings, num_slices)); } strip->add_next_vertices((num_slices + 1) * 2); strip->close_primitive(); @@ -503,8 +503,8 @@ fill_viz_geom() { // Now the cylinder sides. for (si = 0; si <= num_slices; si++) { - vertex.add_data3f(calc_sphere1_vertex(num_rings, si, num_rings, num_slices)); - vertex.add_data3f(calc_sphere2_vertex(num_rings, si, num_rings, num_slices, + vertex.add_data3(calc_sphere1_vertex(num_rings, si, num_rings, num_slices)); + vertex.add_data3(calc_sphere2_vertex(num_rings, si, num_rings, num_slices, length)); } strip->add_next_vertices((num_slices + 1) * 2); @@ -513,8 +513,8 @@ fill_viz_geom() { // And the second endcap. for (ri = num_rings - 1; ri >= 0; ri--) { for (si = 0; si <= num_slices; si++) { - vertex.add_data3f(calc_sphere2_vertex(ri + 1, si, num_rings, num_slices, length)); - vertex.add_data3f(calc_sphere2_vertex(ri, si, num_rings, num_slices, length)); + vertex.add_data3(calc_sphere2_vertex(ri + 1, si, num_rings, num_slices, length)); + vertex.add_data3(calc_sphere2_vertex(ri, si, num_rings, num_slices, length)); } strip->add_next_vertices((num_slices + 1) * 2); strip->close_primitive(); @@ -524,8 +524,8 @@ fill_viz_geom() { geom->add_primitive(strip); // Now transform the vertices to their actual location. - LMatrix4f mat; - look_at(mat, direction, LVector3f(0.0f, 0.0f, 1.0f), CS_zup_right); + LMatrix4 mat; + look_at(mat, direction, LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); mat.set_row(3, _a); geom->transform_vertices(mat); @@ -542,10 +542,10 @@ fill_viz_geom() { //////////////////////////////////////////////////////////////////// void CollisionTube:: recalc_internals() { - LVector3f direction = (_b - _a); + LVector3 direction = (_b - _a); _length = direction.length(); - look_at(_mat, direction, LVector3f(0.0f, 0.0f, 1.0f), CS_zup_right); + look_at(_mat, direction, LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); _mat.set_row(3, _a); _inv_mat.invert_from(_mat); @@ -560,25 +560,25 @@ recalc_internals() { // first endcap hemisphere, for use in generating the // viz geometry. //////////////////////////////////////////////////////////////////// -Vertexf CollisionTube:: +LVertex CollisionTube:: calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { - float r = (float)ri / (float)num_rings; - float s = (float)si / (float)num_slices; + PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; // Find the point on the rim, based on the slice. - float theta = s * 2.0f * MathNumbers::pi_f; - float x_rim = ccos(theta); - float z_rim = csin(theta); + PN_stdfloat theta = s * 2.0f * MathNumbers::pi; + PN_stdfloat x_rim = ccos(theta); + PN_stdfloat z_rim = csin(theta); // Now pull that point in towards the pole, based on the ring. - float phi = r * 0.5f * MathNumbers::pi_f; - float to_pole = csin(phi); + PN_stdfloat phi = r * 0.5f * MathNumbers::pi; + PN_stdfloat to_pole = csin(phi); - float x = _radius * x_rim * to_pole; - float y = -_radius * ccos(phi); - float z = _radius * z_rim * to_pole; + PN_stdfloat x = _radius * x_rim * to_pole; + PN_stdfloat y = -_radius * ccos(phi); + PN_stdfloat z = _radius * z_rim * to_pole; - return Vertexf(x, y, z); + return LVertex(x, y, z); } //////////////////////////////////////////////////////////////////// @@ -588,26 +588,26 @@ calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { // second endcap hemisphere, for use in generating the // viz geometry. //////////////////////////////////////////////////////////////////// -Vertexf CollisionTube:: +LVertex CollisionTube:: calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, - float length) { - float r = (float)ri / (float)num_rings; - float s = (float)si / (float)num_slices; + PN_stdfloat length) { + PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; // Find the point on the rim, based on the slice. - float theta = s * 2.0f * MathNumbers::pi_f; - float x_rim = ccos(theta); - float z_rim = csin(theta); + PN_stdfloat theta = s * 2.0f * MathNumbers::pi; + PN_stdfloat x_rim = ccos(theta); + PN_stdfloat z_rim = csin(theta); // Now pull that point in towards the pole, based on the ring. - float phi = r * 0.5f * MathNumbers::pi_f; - float to_pole = csin(phi); + PN_stdfloat phi = r * 0.5f * MathNumbers::pi; + PN_stdfloat to_pole = csin(phi); - float x = _radius * x_rim * to_pole; - float y = length + _radius * ccos(phi); - float z = _radius * z_rim * to_pole; + PN_stdfloat x = _radius * x_rim * to_pole; + PN_stdfloat y = length + _radius * ccos(phi); + PN_stdfloat z = _radius * z_rim * to_pole; - return Vertexf(x, y, z); + return LVertex(x, y, z); } //////////////////////////////////////////////////////////////////// @@ -625,13 +625,13 @@ calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, //////////////////////////////////////////////////////////////////// bool CollisionTube:: intersects_line(double &t1, double &t2, - LPoint3f from, LVector3f delta, float inflate_radius) const { + LPoint3 from, LVector3 delta, PN_stdfloat inflate_radius) const { // Convert the line into our canonical coordinate space: the tube is // aligned with the y axis. from = from * _inv_mat; delta = delta * _inv_mat; - float radius = _radius + inflate_radius; + PN_stdfloat radius = _radius + inflate_radius; // Now project the line into the X-Z plane to test for intersection // with a 2-d circle around the origin. The equation for this is @@ -639,8 +639,8 @@ intersects_line(double &t1, double &t2, // sphere; see CollisionSphere::intersects_line() for the complete // derivation. It's a little bit simpler because the circle is // centered on the origin. - LVector2f from2(from[0], from[2]); - LVector2f delta2(delta[0], delta[2]); + LVector2 from2(from[0], from[2]); + LVector2 delta2(delta[0], delta[2]); double A = dot(delta2, delta2); @@ -715,8 +715,8 @@ intersects_line(double &t1, double &t2, // Now we need to verify that the intersection points fall within // the length of the cylinder. - float t1_y = from[1] + t1 * delta[1]; - float t2_y = from[1] + t2 * delta[1]; + PN_stdfloat t1_y = from[1] + t1 * delta[1]; + PN_stdfloat t2_y = from[1] + t2 * delta[1]; if (t1_y < -radius && t2_y < -radius) { // Both points are way off the bottom of the tube; no @@ -785,18 +785,18 @@ intersects_line(double &t1, double &t2, // sphere (and hence the particular endcap. //////////////////////////////////////////////////////////////////// bool CollisionTube:: -sphere_intersects_line(double &t1, double &t2, float center_y, - const LPoint3f &from, const LVector3f &delta, - float inflate_radius) const { +sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_radius) const { // See CollisionSphere::intersects_line() for a derivation of the // formula here. - float radius = _radius + inflate_radius; + PN_stdfloat radius = _radius + inflate_radius; double A = dot(delta, delta); nassertr(A != 0.0, false); - LVector3f fc = from; + LVector3 fc = from; fc[1] -= center_y; double B = 2.0f* dot(delta, fc); double fc_d2 = dot(fc, fc); @@ -836,9 +836,9 @@ sphere_intersects_line(double &t1, double &t2, float center_y, // is returned. //////////////////////////////////////////////////////////////////// bool CollisionTube:: -intersects_parabola(double &t, const Parabolaf ¶bola, +intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, - const LPoint3f &p1, const LPoint3f &p2) const { + const LPoint3 &p1, const LPoint3 &p2) const { // I don't even want to think about the math to do this calculation // directly--it's even worse than sphere-parabola. So I'll use the // recursive subdivision solution again, just like I did for @@ -851,8 +851,8 @@ intersects_parabola(double &t, const Parabolaf ¶bola, double tmid = (t1 + t2) * 0.5; if (tmid != t1 && tmid != t2) { - LPoint3f pmid = parabola.calc_point(tmid); - LPoint3f pmid2 = (p1 + p2) * 0.5f; + LPoint3 pmid = parabola.calc_point(tmid); + LPoint3 pmid2 = (p1 + p2) * 0.5f; if ((pmid - pmid2).length_squared() > 0.001f) { // Subdivide. @@ -886,13 +886,13 @@ intersects_parabola(double &t, const Parabolaf ¶bola, // tube. //////////////////////////////////////////////////////////////////// void CollisionTube:: -calculate_surface_point_and_normal(const LPoint3f &surface_point, +calculate_surface_point_and_normal(const LPoint3 &surface_point, double extra_radius, - LPoint3f &result_point, - LVector3f &result_normal) const { + LPoint3 &result_point, + LVector3 &result_normal) const { // Convert the point into our canonical space for analysis. - LPoint3f point = surface_point * _inv_mat; - LVector3f normal; + LPoint3 point = surface_point * _inv_mat; + LVector3 normal; if (point[1] <= 0.0) { // The point is on the first endcap. @@ -936,10 +936,10 @@ calculate_surface_point_and_normal(const LPoint3f &surface_point, //////////////////////////////////////////////////////////////////// void CollisionTube:: set_intersection_point(CollisionEntry *new_entry, - const LPoint3f &into_intersection_point, + const LPoint3 &into_intersection_point, double extra_radius) const { - LPoint3f point; - LVector3f normal; + LPoint3 point; + LVector3 normal; calculate_surface_point_and_normal(into_intersection_point, extra_radius, @@ -980,7 +980,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { CollisionSolid::write_datagram(manager, dg); _a.write_datagram(dg); _b.write_datagram(dg); - dg.add_float32(_radius); + dg.add_stdfloat(_radius); } //////////////////////////////////////////////////////////////////// @@ -1015,6 +1015,6 @@ fillin(DatagramIterator &scan, BamReader *manager) { CollisionSolid::fillin(scan, manager); _a.read_datagram(scan); _b.read_datagram(scan); - _radius = scan.get_float32(); + _radius = scan.get_stdfloat(); recalc_internals(); } diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 7c57baa4fc..bb1f74955e 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -29,13 +29,13 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_COLLIDE CollisionTube : public CollisionSolid { PUBLISHED: - INLINE CollisionTube(const LPoint3f &a, const LPoint3f &db, - float radius); - INLINE CollisionTube(float ax, float ay, float az, - float bx, float by, float bz, - float radius); + INLINE CollisionTube(const LPoint3 &a, const LPoint3 &db, + PN_stdfloat radius); + INLINE CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, + PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, + PN_stdfloat radius); - virtual LPoint3f get_collision_origin() const; + virtual LPoint3 get_collision_origin() const; private: INLINE CollisionTube(); @@ -44,7 +44,7 @@ public: INLINE CollisionTube(const CollisionTube ©); virtual CollisionSolid *make_copy(); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); @@ -54,16 +54,16 @@ public: INLINE static void flush_level(); PUBLISHED: - INLINE void set_point_a(const LPoint3f &a); - INLINE void set_point_a(float x, float y, float z); - INLINE const LPoint3f &get_point_a() const; + INLINE void set_point_a(const LPoint3 &a); + INLINE void set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_point_a() const; - INLINE void set_point_b(const LPoint3f &b); - INLINE void set_point_b(float x, float y, float z); - INLINE const LPoint3f &get_point_b() const; + INLINE void set_point_b(const LPoint3 &b); + INLINE void set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE const LPoint3 &get_point_b() const; - INLINE void set_radius(float radius); - INLINE float get_radius() const; + INLINE void set_radius(PN_stdfloat radius); + INLINE PN_stdfloat get_radius() const; protected: virtual PT(BoundingVolume) compute_internal_bounds() const; @@ -85,35 +85,35 @@ protected: private: void recalc_internals(); - Vertexf calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices); - Vertexf calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, - float length); + LVertex calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices); + LVertex calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, + PN_stdfloat length); bool intersects_line(double &t1, double &t2, - LPoint3f from, LVector3f delta, - float inflate_radius) const; - bool sphere_intersects_line(double &t1, double &t2, float center_y, - const LPoint3f &from, const LVector3f &delta, - float inflate_radius) const; - bool intersects_parabola(double &t, const Parabolaf ¶bola, + LPoint3 from, LVector3 delta, + PN_stdfloat inflate_radius) const; + bool sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_radius) const; + bool intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, - const LPoint3f &p1, const LPoint3f &p2) const; - void calculate_surface_point_and_normal(const LPoint3f &surface_point, + const LPoint3 &p1, const LPoint3 &p2) const; + void calculate_surface_point_and_normal(const LPoint3 &surface_point, double extra_radius, - LPoint3f &result_point, - LVector3f &result_normal) const; + LPoint3 &result_point, + LVector3 &result_normal) const; void set_intersection_point(CollisionEntry *new_entry, - const LPoint3f &into_intersection_point, + const LPoint3 &into_intersection_point, double extra_radius) const; private: - LPoint3f _a, _b; - float _radius; + LPoint3 _a, _b; + PN_stdfloat _radius; // These are derived from the above. - LMatrix4f _mat; - LMatrix4f _inv_mat; - float _length; + LMatrix4 _mat; + LMatrix4 _inv_mat; + PN_stdfloat _length; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/collide/collisionVisualizer.I b/panda/src/collide/collisionVisualizer.I index b25e6531ec..915c4843f9 100644 --- a/panda/src/collide/collisionVisualizer.I +++ b/panda/src/collide/collisionVisualizer.I @@ -38,7 +38,7 @@ SolidInfo() { // objects in a smaller window. //////////////////////////////////////////////////////////////////// INLINE void CollisionVisualizer:: -set_point_scale(float point_scale) { +set_point_scale(PN_stdfloat point_scale) { _point_scale = point_scale; } @@ -47,7 +47,7 @@ set_point_scale(float point_scale) { // Access: Published // Description: Returns the value last set by set_point_scale(). //////////////////////////////////////////////////////////////////// -INLINE float CollisionVisualizer:: +INLINE PN_stdfloat CollisionVisualizer:: get_point_scale() const { return _point_scale; } @@ -64,7 +64,7 @@ get_point_scale() const { // observe these normals from farther away. //////////////////////////////////////////////////////////////////// INLINE void CollisionVisualizer:: -set_normal_scale(float normal_scale) { +set_normal_scale(PN_stdfloat normal_scale) { _normal_scale = normal_scale; } @@ -73,7 +73,7 @@ set_normal_scale(float normal_scale) { // Access: Published // Description: Returns the value last set by set_normal_scale(). //////////////////////////////////////////////////////////////////// -INLINE float CollisionVisualizer:: +INLINE PN_stdfloat CollisionVisualizer:: get_normal_scale() const { return _normal_scale; } diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 9633b768d5..ddb13d59d7 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -163,11 +163,11 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PT(GeomVertexArrayFormat) point_array_format = new GeomVertexArrayFormat(InternalName::get_vertex(), 3, - Geom::NT_float32, Geom::C_point, + Geom::NT_stdfloat, Geom::C_point, InternalName::get_color(), 1, Geom::NT_packed_dabc, Geom::C_color, InternalName::get_size(), 1, - Geom::NT_float32, Geom::C_other); + Geom::NT_stdfloat, Geom::C_other); CPT(GeomVertexFormat) point_format = GeomVertexFormat::register_format(point_array_format); @@ -187,15 +187,15 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { GeomVertexWriter color(point_vdata, InternalName::get_color()); GeomVertexWriter size(point_vdata, InternalName::get_size()); - vertex.add_data3f(point._surface_point); - color.add_data4f(1.0f, 0.0f, 0.0f, 1.0f); + vertex.add_data3(point._surface_point); + color.add_data4(1.0f, 0.0f, 0.0f, 1.0f); size.add_data1f(16.0f * _point_scale); points->add_next_vertices(1); points->close_primitive(); if (point._interior_point != point._surface_point) { - vertex.add_data3f(point._interior_point); - color.add_data4f(1.0f, 1.0f, 1.0f, 1.0f); + vertex.add_data3(point._interior_point); + color.add_data4(1.0f, 1.0f, 1.0f, 1.0f); size.add_data1f(8.0f * _point_scale); points->add_next_vertices(1); points->close_primitive(); @@ -214,7 +214,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } // Draw the normal vector at the surface point. - if (!point._surface_normal.almost_equal(LVector3f::zero())) { + if (!point._surface_normal.almost_equal(LVector3::zero())) { PT(GeomVertexData) line_vdata = new GeomVertexData("viz", GeomVertexFormat::get_v3cp(), Geom::UH_stream); @@ -224,11 +224,11 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { GeomVertexWriter vertex(line_vdata, InternalName::get_vertex()); GeomVertexWriter color(line_vdata, InternalName::get_color()); - vertex.add_data3f(point._surface_point); - vertex.add_data3f(point._surface_point + + vertex.add_data3(point._surface_point); + vertex.add_data3(point._surface_point + point._surface_normal * _normal_scale); - color.add_data4f(1.0f, 0.0f, 0.0f, 1.0f); - color.add_data4f(1.0f, 1.0f, 1.0f, 1.0f); + color.add_data4(1.0f, 0.0f, 0.0f, 1.0f); + color.add_data4(1.0f, 1.0f, 1.0f, 1.0f); lines->add_next_vertices(2); lines->close_primitive(); diff --git a/panda/src/collide/collisionVisualizer.h b/panda/src/collide/collisionVisualizer.h index 72ba144aea..1578bdce9f 100644 --- a/panda/src/collide/collisionVisualizer.h +++ b/panda/src/collide/collisionVisualizer.h @@ -39,11 +39,11 @@ PUBLISHED: CollisionVisualizer(const string &name); virtual ~CollisionVisualizer(); - INLINE void set_point_scale(float point_scale); - INLINE float get_point_scale() const; + INLINE void set_point_scale(PN_stdfloat point_scale); + INLINE PN_stdfloat get_point_scale() const; - INLINE void set_normal_scale(float normal_scale); - INLINE float get_normal_scale() const; + INLINE void set_normal_scale(PN_stdfloat normal_scale); + INLINE PN_stdfloat get_normal_scale() const; void clear(); @@ -76,9 +76,9 @@ private: class CollisionPoint { public: - LPoint3f _surface_point; - LVector3f _surface_normal; - LPoint3f _interior_point; + LPoint3 _surface_point; + LVector3 _surface_normal; + LPoint3 _interior_point; }; typedef pvector Points; @@ -91,8 +91,8 @@ private: typedef pmap Data; Data _data; - float _point_scale; - float _normal_scale; + PN_stdfloat _point_scale; + PN_stdfloat _normal_scale; public: static TypeHandle get_class_type() { diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index a35a421a46..34580e7bc7 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -24,7 +24,6 @@ #include "collisionHandlerPusher.h" #include "collisionHandlerFluidPusher.h" #include "collisionHandlerQueue.h" -#include "collisionDSSolid.h" #include "collisionInvSphere.h" #include "collisionLine.h" #include "collisionLevelStateBase.h" @@ -130,7 +129,6 @@ init_libcollide() { CollisionHandlerPusher::init_type(); CollisionHandlerFluidPusher::init_type(); CollisionHandlerQueue::init_type(); - CollisionDSSolid::init_type(); CollisionInvSphere::init_type(); CollisionLine::init_type(); CollisionLevelStateBase::init_type(); @@ -153,7 +151,6 @@ init_libcollide() { #endif CollisionBox::register_with_read_factory(); - CollisionDSSolid::register_with_read_factory(); CollisionInvSphere::register_with_read_factory(); CollisionLine::register_with_read_factory(); CollisionNode::register_with_read_factory(); diff --git a/panda/src/cull/cullBinBackToFront.I b/panda/src/cull/cullBinBackToFront.I index 7d33863d8f..45641e8b4c 100644 --- a/panda/src/cull/cullBinBackToFront.I +++ b/panda/src/cull/cullBinBackToFront.I @@ -31,7 +31,7 @@ CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg, // Description: //////////////////////////////////////////////////////////////////// INLINE CullBinBackToFront::ObjectData:: -ObjectData(CullableObject *object, float dist) : +ObjectData(CullableObject *object, PN_stdfloat dist) : _object(object), _dist(dist) { diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index 4761ddc5a2..d90fb4968d 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -67,11 +67,11 @@ add_object(CullableObject *object, Thread *current_thread) { const GeometricBoundingVolume *gbv; DCAST_INTO_V(gbv, volume); - LPoint3f center = gbv->get_approx_center(); + LPoint3 center = gbv->get_approx_center(); nassertv(object->_modelview_transform != (const TransformState *)NULL); center = center * object->_modelview_transform->get_mat(); - float distance = _gsg->compute_distance_to(center); + PN_stdfloat distance = _gsg->compute_distance_to(center); _objects.push_back(ObjectData(object, distance)); } diff --git a/panda/src/cull/cullBinBackToFront.h b/panda/src/cull/cullBinBackToFront.h index 8a161f2420..93544cc69d 100644 --- a/panda/src/cull/cullBinBackToFront.h +++ b/panda/src/cull/cullBinBackToFront.h @@ -53,11 +53,11 @@ protected: private: class ObjectData { public: - INLINE ObjectData(CullableObject *object, float dist); + INLINE ObjectData(CullableObject *object, PN_stdfloat dist); INLINE bool operator < (const ObjectData &other) const; CullableObject *_object; - float _dist; + PN_stdfloat _dist; }; typedef pvector Objects; diff --git a/panda/src/cull/cullBinFrontToBack.I b/panda/src/cull/cullBinFrontToBack.I index 5558d8003c..d1d4bae261 100644 --- a/panda/src/cull/cullBinFrontToBack.I +++ b/panda/src/cull/cullBinFrontToBack.I @@ -31,7 +31,7 @@ CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg, // Description: //////////////////////////////////////////////////////////////////// INLINE CullBinFrontToBack::ObjectData:: -ObjectData(CullableObject *object, float dist) : +ObjectData(CullableObject *object, PN_stdfloat dist) : _object(object), _dist(dist) { diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 3eb82192f1..ab1a23b777 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -67,11 +67,11 @@ add_object(CullableObject *object, Thread *current_thread) { const GeometricBoundingVolume *gbv; DCAST_INTO_V(gbv, volume); - LPoint3f center = gbv->get_approx_center(); + LPoint3 center = gbv->get_approx_center(); nassertv(object->_modelview_transform != (const TransformState *)NULL); center = center * object->_modelview_transform->get_mat(); - float distance = _gsg->compute_distance_to(center); + PN_stdfloat distance = _gsg->compute_distance_to(center); _objects.push_back(ObjectData(object, distance)); } diff --git a/panda/src/cull/cullBinFrontToBack.h b/panda/src/cull/cullBinFrontToBack.h index 549f8cf754..a23cb8e551 100644 --- a/panda/src/cull/cullBinFrontToBack.h +++ b/panda/src/cull/cullBinFrontToBack.h @@ -53,11 +53,11 @@ protected: private: class ObjectData { public: - INLINE ObjectData(CullableObject *object, float dist); + INLINE ObjectData(CullableObject *object, PN_stdfloat dist); INLINE bool operator < (const ObjectData &other) const; CullableObject *_object; - float _dist; + PN_stdfloat _dist; }; typedef pvector Objects; diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index 5531c26578..1bea47ceb2 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -30,7 +30,7 @@ AnalogNode(ClientBase *client, const string &device_name) : DataNode(device_name) { _xy_output = define_output("xy", EventStoreVec2::get_class_type()); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); nassertv(client != (ClientBase *)NULL); PT(ClientDevice) device = @@ -99,7 +99,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, if (is_valid()) { _analog->poll(); - LPoint2f out(0.0f, 0.0f); + LPoint2 out(0.0f, 0.0f); _analog->acquire(); for (int i = 0; i < max_outputs; i++) { diff --git a/panda/src/device/mouseAndKeyboard.cxx b/panda/src/device/mouseAndKeyboard.cxx index 7cff1319e4..205386b0e3 100644 --- a/panda/src/device/mouseAndKeyboard.cxx +++ b/panda/src/device/mouseAndKeyboard.cxx @@ -38,9 +38,9 @@ MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); _pointer_events_output = define_output("pointer_events", PointerEventList::get_class_type()); - _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _pixel_size = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _pixel_size = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); _button_events = new ButtonEventList; } @@ -113,7 +113,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, int w = properties.get_x_size(); int h = properties.get_y_size(); - _pixel_size->set_value(LPoint2f(w, h)); + _pixel_size->set_value(LPoint2(w, h)); output.set_data(_pixel_size_output, EventParameter(_pixel_size)); if (_window->has_pointer(_device)) { @@ -121,14 +121,14 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, if (mdata._in_window) { // Get mouse motion in pixels. - _pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos)); + _pixel_xy->set_value(LPoint2(mdata._xpos, mdata._ypos)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); // Normalize pixel motion to range [-1,1]. - float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f; - float yf = 1.0f - (float)(2 * mdata._ypos) / (float)h; + PN_stdfloat xf = (PN_stdfloat)(2 * mdata._xpos) / (PN_stdfloat)w - 1.0f; + PN_stdfloat yf = 1.0f - (PN_stdfloat)(2 * mdata._ypos) / (PN_stdfloat)h; - _xy->set_value(LPoint2f(xf, yf)); + _xy->set_value(LPoint2(xf, yf)); output.set_data(_xy_output, EventParameter(_xy)); } } diff --git a/panda/src/device/trackerData.I b/panda/src/device/trackerData.I index a09e051930..f190e41778 100644 --- a/panda/src/device/trackerData.I +++ b/panda/src/device/trackerData.I @@ -91,7 +91,7 @@ get_time() const { // defined by the tracker. //////////////////////////////////////////////////////////////////// INLINE void TrackerData:: -set_pos(const LPoint3f &pos) { +set_pos(const LPoint3 &pos) { _pos = pos; _flags |= F_has_pos; } @@ -114,12 +114,12 @@ has_pos() const { // legal to call this if has_pos() returns false; in // this case, the position will always be (0, 0, 0). //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &TrackerData:: +INLINE const LPoint3 &TrackerData:: get_pos() const { if (has_pos()) { return _pos; } else { - static LPoint3f zero(0.0, 0.0, 0.0); + static LPoint3 zero(0.0, 0.0, 0.0); return zero; } } @@ -134,7 +134,7 @@ get_pos() const { // set_pos(). //////////////////////////////////////////////////////////////////// INLINE void TrackerData:: -set_orient(const LOrientationf &orient) { +set_orient(const LOrientation &orient) { _orient = orient; _flags |= F_has_orient; } @@ -158,12 +158,12 @@ has_orient() const { // in this case, the result is always the identity // orientation. //////////////////////////////////////////////////////////////////// -INLINE const LOrientationf &TrackerData:: +INLINE const LOrientation &TrackerData:: get_orient() const { if (has_orient()) { return _orient; } else { - static LOrientationf ident = LOrientationf::ident_quat(); + static LOrientation ident = LOrientation::ident_quat(); return ident; } } diff --git a/panda/src/device/trackerData.h b/panda/src/device/trackerData.h index c4b8713611..6642b04486 100644 --- a/panda/src/device/trackerData.h +++ b/panda/src/device/trackerData.h @@ -34,13 +34,13 @@ public: INLINE bool has_time() const; INLINE double get_time() const; - INLINE void set_pos(const LPoint3f &pos); + INLINE void set_pos(const LPoint3 &pos); INLINE bool has_pos() const; - INLINE const LPoint3f &get_pos() const; + INLINE const LPoint3 &get_pos() const; - INLINE void set_orient(const LOrientationf &orient); + INLINE void set_orient(const LOrientation &orient); INLINE bool has_orient() const; - INLINE const LOrientationf &get_orient() const; + INLINE const LOrientation &get_orient() const; INLINE void set_dt(double dt); INLINE bool has_dt() const; @@ -57,8 +57,8 @@ private: int _flags; double _time; - LPoint3f _pos; - LOrientationf _orient; + LPoint3 _pos; + LOrientation _orient; double _dt; }; diff --git a/panda/src/device/trackerNode.I b/panda/src/device/trackerNode.I index d9109a8fa4..5f872c7ea3 100644 --- a/panda/src/device/trackerNode.I +++ b/panda/src/device/trackerNode.I @@ -30,7 +30,7 @@ is_valid() const { // Description: Returns the current position of the tracker, if it is // available. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &TrackerNode:: +INLINE const LPoint3 &TrackerNode:: get_pos() const { return _data.get_pos(); } @@ -41,7 +41,7 @@ get_pos() const { // Description: Returns the current orientation of the tracker, if it // is available. //////////////////////////////////////////////////////////////////// -INLINE const LOrientationf &TrackerNode:: +INLINE const LOrientation &TrackerNode:: get_orient() const { return _data.get_orient(); } @@ -72,7 +72,7 @@ has_time() const { // Description: Returns the current position and orientation of the // tracker, as a combined matrix. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &TrackerNode:: +INLINE const LMatrix4 &TrackerNode:: get_transform() const { return _mat; } diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index 750ed1f880..d5706912b0 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -91,7 +91,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, _data.get_orient().extract_to_matrix(_mat); if (_tracker_cs != _graph_cs) { // Convert the rotation for passing down the data graph. - _mat = _mat * LMatrix4f::convert_mat(_tracker_cs, _graph_cs); + _mat = _mat * LMatrix4::convert_mat(_tracker_cs, _graph_cs); } _mat.set_row(3, _data.get_pos()); diff --git a/panda/src/device/trackerNode.h b/panda/src/device/trackerNode.h index e584c7359e..aa9548971a 100644 --- a/panda/src/device/trackerNode.h +++ b/panda/src/device/trackerNode.h @@ -40,9 +40,9 @@ PUBLISHED: INLINE bool is_valid() const; - INLINE const LPoint3f &get_pos() const; - INLINE const LOrientationf &get_orient() const; - INLINE const LMatrix4f &get_transform() const; + INLINE const LPoint3 &get_pos() const; + INLINE const LOrientation &get_orient() const; + INLINE const LMatrix4 &get_transform() const; INLINE double get_time() const; INLINE bool has_time() const; @@ -67,7 +67,7 @@ private: private: PT(ClientTrackerDevice) _tracker; TrackerData _data; - LMatrix4f _mat; + LMatrix4 _mat; CoordinateSystem _tracker_cs, _graph_cs; public: diff --git a/panda/src/device/virtualMouse.cxx b/panda/src/device/virtualMouse.cxx index 6d91bd343d..8eec32b47c 100644 --- a/panda/src/device/virtualMouse.cxx +++ b/panda/src/device/virtualMouse.cxx @@ -31,9 +31,9 @@ VirtualMouse(const string &name) : _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); - _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _pixel_size = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _pixel_size = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); _button_events = new ButtonEventList; _next_button_events = new ButtonEventList; @@ -130,18 +130,18 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, _next_button_events->clear(); output.set_data(_button_events_output, EventParameter(_button_events)); - _pixel_size->set_value(LPoint2f(_win_width, _win_height)); + _pixel_size->set_value(LPoint2(_win_width, _win_height)); output.set_data(_pixel_size_output, EventParameter(_pixel_size)); if (_mouse_on) { // The mouse is within the window. - _pixel_xy->set_value(LPoint2f(_mouse_x, _mouse_y)); + _pixel_xy->set_value(LPoint2(_mouse_x, _mouse_y)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); // Normalize pixel motion to range [-1,1]. - float xf = (2.0f * (float)_mouse_x) / (float)_win_width - 1.0f; - float yf = 1.0f - (2.0f * (float)_mouse_y) / (float)_win_height; - _xy->set_value(LPoint2f(xf, yf)); + PN_stdfloat xf = (2.0f * (PN_stdfloat)_mouse_x) / (PN_stdfloat)_win_width - 1.0f; + PN_stdfloat yf = 1.0f - (2.0f * (PN_stdfloat)_mouse_y) / (PN_stdfloat)_win_height; + _xy->set_value(LPoint2(xf, yf)); output.set_data(_xy_output, EventParameter(_xy)); } } diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index fd8aa34a23..7e6e554fd5 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -46,7 +46,7 @@ get_lens_index() const { // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// INLINE void DisplayRegion:: -get_dimensions(float &l, float &r, float &b, float &t) const { +get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { CDReader cdata(_cycler); l = cdata->_dimensions[0]; r = cdata->_dimensions[1]; @@ -61,7 +61,7 @@ get_dimensions(float &l, float &r, float &b, float &t) const { // rectangle within its GraphicsOutput. These numbers // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f DisplayRegion:: +INLINE LVecBase4 DisplayRegion:: get_dimensions() const { CDReader cdata(_cycler); return cdata->_dimensions; @@ -74,7 +74,7 @@ get_dimensions() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegion:: +INLINE PN_stdfloat DisplayRegion:: get_left() const { CDReader cdata(_cycler); return cdata->_dimensions[0]; @@ -87,7 +87,7 @@ get_left() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegion:: +INLINE PN_stdfloat DisplayRegion:: get_right() const { CDReader cdata(_cycler); return cdata->_dimensions[1]; @@ -100,7 +100,7 @@ get_right() const { // the rectangle within its GraphicsOutput. This // number will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegion:: +INLINE PN_stdfloat DisplayRegion:: get_bottom() const { CDReader cdata(_cycler); return cdata->_dimensions[2]; @@ -113,7 +113,7 @@ get_bottom() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegion:: +INLINE PN_stdfloat DisplayRegion:: get_top() const { CDReader cdata(_cycler); return cdata->_dimensions[3]; @@ -129,8 +129,8 @@ get_top() const { // whole screen. //////////////////////////////////////////////////////////////////// INLINE void DisplayRegion:: -set_dimensions(float l, float r, float b, float t) { - set_dimensions(LVecBase4f(l, r, b, t)); +set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { + set_dimensions(LVecBase4(l, r, b, t)); } //////////////////////////////////////////////////////////////////// @@ -631,7 +631,7 @@ is_any_clear_active() const { // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// INLINE void DisplayRegionPipelineReader:: -get_dimensions(float &l, float &r, float &b, float &t) const { +get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { l = _cdata->_dimensions[0]; r = _cdata->_dimensions[1]; b = _cdata->_dimensions[2]; @@ -645,7 +645,7 @@ get_dimensions(float &l, float &r, float &b, float &t) const { // rectangle within its GraphicsOutput. These numbers // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &DisplayRegionPipelineReader:: +INLINE const LVecBase4 &DisplayRegionPipelineReader:: get_dimensions() const { return _cdata->_dimensions; } @@ -657,7 +657,7 @@ get_dimensions() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegionPipelineReader:: +INLINE PN_stdfloat DisplayRegionPipelineReader:: get_left() const { return _cdata->_dimensions[0]; } @@ -669,7 +669,7 @@ get_left() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegionPipelineReader:: +INLINE PN_stdfloat DisplayRegionPipelineReader:: get_right() const { return _cdata->_dimensions[1]; } @@ -681,7 +681,7 @@ get_right() const { // the rectangle within its GraphicsOutput. This // number will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegionPipelineReader:: +INLINE PN_stdfloat DisplayRegionPipelineReader:: get_bottom() const { return _cdata->_dimensions[2]; } @@ -693,7 +693,7 @@ get_bottom() const { // rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// -INLINE float DisplayRegionPipelineReader:: +INLINE PN_stdfloat DisplayRegionPipelineReader:: get_top() const { return _cdata->_dimensions[3]; } diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 5c4dee1184..836d65aa29 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -32,7 +32,7 @@ TypeHandle DisplayRegionPipelineReader::_type_handle; // Description: //////////////////////////////////////////////////////////////////// DisplayRegion:: -DisplayRegion(GraphicsOutput *window, const LVecBase4f &dimensions) : +DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions) : _window(window), _incomplete_render(true), _texture_reload_priority(0), @@ -124,7 +124,7 @@ set_lens_index(int index) { // whole screen. //////////////////////////////////////////////////////////////////// void DisplayRegion:: -set_dimensions(const LVecBase4f &dimensions) { +set_dimensions(const LVecBase4 &dimensions) { int pipeline_stage = Thread::get_current_pipeline_stage(); nassertv(pipeline_stage == 0); CDWriter cdata(_cycler); diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index e78deef608..c921118770 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -59,7 +59,7 @@ class CullTraverser; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_DISPLAY DisplayRegion : public DisplayRegionBase, public DrawableRegion { protected: - DisplayRegion(GraphicsOutput *window, const LVecBase4f &dimensions); + DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions); private: DisplayRegion(const DisplayRegion ©); @@ -72,14 +72,14 @@ public: INLINE bool operator < (const DisplayRegion &other) const; PUBLISHED: - INLINE void get_dimensions(float &l, float &r, float &b, float &t) const; - INLINE LVecBase4f get_dimensions() const; - INLINE float get_left() const; - INLINE float get_right() const; - INLINE float get_bottom() const; - INLINE float get_top() const; - INLINE void set_dimensions(float l, float r, float b, float t); - virtual void set_dimensions(const LVecBase4f &dimensions); + INLINE void get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const; + INLINE LVecBase4 get_dimensions() const; + INLINE PN_stdfloat get_left() const; + INLINE PN_stdfloat get_right() const; + INLINE PN_stdfloat get_bottom() const; + INLINE PN_stdfloat get_top() const; + INLINE void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t); + virtual void set_dimensions(const LVecBase4 &dimensions); INLINE GraphicsOutput *get_window() const; GraphicsPipe *get_pipe() const; @@ -189,7 +189,7 @@ private: return DisplayRegion::get_class_type(); } - LVecBase4f _dimensions; // left, right, bottom, top + LVecBase4 _dimensions; // left, right, bottom, top int _pl; int _pr; @@ -286,12 +286,12 @@ public: INLINE bool is_any_clear_active() const; - INLINE void get_dimensions(float &l, float &r, float &b, float &t) const; - INLINE const LVecBase4f &get_dimensions() const; - INLINE float get_left() const; - INLINE float get_right() const; - INLINE float get_bottom() const; - INLINE float get_top() const; + INLINE void get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const; + INLINE const LVecBase4 &get_dimensions() const; + INLINE PN_stdfloat get_left() const; + INLINE PN_stdfloat get_right() const; + INLINE PN_stdfloat get_bottom() const; + INLINE PN_stdfloat get_top() const; INLINE GraphicsOutput *get_window() const; GraphicsPipe *get_pipe() const; diff --git a/panda/src/display/drawableRegion.I b/panda/src/display/drawableRegion.I index cab362fa1f..269c02c1a1 100644 --- a/panda/src/display/drawableRegion.I +++ b/panda/src/display/drawableRegion.I @@ -25,9 +25,9 @@ DrawableRegion() : { for (int i=0; i= 0) && (n < RTP_COUNT)); _clear_value[n] = clear_value; } @@ -63,9 +63,9 @@ set_clear_value(int n, const Colorf &clear_value) { // Access: Published, Virtual // Description: Returns the clear value for any bitplane. //////////////////////////////////////////////////////////////////// -const Colorf &DrawableRegion:: +const LColor &DrawableRegion:: get_clear_value(int n) const { - static Colorf blank(0.5,0.5,0.5,0.0); + static LColor blank(0.5,0.5,0.5,0.0); nassertr((n >= 0) && (n < RTP_COUNT), blank); return _clear_value[n]; } @@ -129,7 +129,7 @@ is_any_clear_active() const { // it. //////////////////////////////////////////////////////////////////// void DrawableRegion:: -set_pixel_zoom(float pixel_zoom) { +set_pixel_zoom(PN_stdfloat pixel_zoom) { _pixel_zoom = pixel_zoom; update_pixel_factor(); } diff --git a/panda/src/display/drawableRegion.h b/panda/src/display/drawableRegion.h index 29bc2ae508..83929fe502 100644 --- a/panda/src/display/drawableRegion.h +++ b/panda/src/display/drawableRegion.h @@ -72,11 +72,11 @@ PUBLISHED: INLINE void set_clear_stencil_active(bool clear_stencil_active); INLINE bool get_clear_stencil_active() const; - INLINE void set_clear_color(const Colorf &color); - INLINE const Colorf &get_clear_color() const; + INLINE void set_clear_color(const LColor &color); + INLINE const LColor &get_clear_color() const; - INLINE void set_clear_depth(float depth); - INLINE float get_clear_depth() const; + INLINE void set_clear_depth(PN_stdfloat depth); + INLINE PN_stdfloat get_clear_depth() const; INLINE void set_clear_stencil(unsigned int stencil); INLINE unsigned int get_clear_stencil() const; @@ -84,15 +84,15 @@ PUBLISHED: virtual void set_clear_active(int n, bool clear_aux_active); virtual bool get_clear_active(int n) const; - virtual void set_clear_value(int n, const Colorf &clear_value); - virtual const Colorf &get_clear_value(int n) const; + virtual void set_clear_value(int n, const LColor &clear_value); + virtual const LColor &get_clear_value(int n) const; virtual void disable_clears(); virtual bool is_any_clear_active() const; - virtual void set_pixel_zoom(float pixel_zoom); - INLINE float get_pixel_zoom() const; - INLINE float get_pixel_factor() const; + virtual void set_pixel_zoom(PN_stdfloat pixel_zoom); + INLINE PN_stdfloat get_pixel_zoom() const; + INLINE PN_stdfloat get_pixel_factor() const; virtual bool supports_pixel_zoom() const; static int get_renderbuffer_type(int plane); @@ -111,10 +111,10 @@ protected: private: bool _clear_active[RTP_COUNT]; - Colorf _clear_value[RTP_COUNT]; + LColor _clear_value[RTP_COUNT]; - float _pixel_zoom; - float _pixel_factor; + PN_stdfloat _pixel_zoom; + PN_stdfloat _pixel_factor; }; diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 84c09d0a54..5a07ca2519 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -225,7 +225,7 @@ get_fb_y_size() const { //////////////////////////////////////////////////////////////////// INLINE int GraphicsOutput:: get_sbs_left_x_size() const { - float left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; + PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; return max(int(_x_size * left_w), 1); } @@ -240,7 +240,7 @@ get_sbs_left_x_size() const { //////////////////////////////////////////////////////////////////// INLINE int GraphicsOutput:: get_sbs_left_y_size() const { - float left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; + PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; return max(int(_y_size * left_h), 1); } @@ -255,7 +255,7 @@ get_sbs_left_y_size() const { //////////////////////////////////////////////////////////////////// INLINE int GraphicsOutput:: get_sbs_right_x_size() const { - float right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; + PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; return max(int(_x_size * right_w), 1); } @@ -270,7 +270,7 @@ get_sbs_right_x_size() const { //////////////////////////////////////////////////////////////////// INLINE int GraphicsOutput:: get_sbs_right_y_size() const { - float right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; + PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; return max(int(_y_size * right_h), 1); } @@ -399,7 +399,7 @@ get_side_by_side_stereo() const { // mode is in effect for the window. See // set_side_by_side_stereo(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &GraphicsOutput:: +INLINE const LVecBase4 &GraphicsOutput:: get_sbs_left_dimensions() const { return _sbs_left_dimensions; } @@ -412,7 +412,7 @@ get_sbs_left_dimensions() const { // mode is in effect for the window. See // set_side_by_side_stereo(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &GraphicsOutput:: +INLINE const LVecBase4 &GraphicsOutput:: get_sbs_right_dimensions() const { return _sbs_right_dimensions; } @@ -562,8 +562,8 @@ make_display_region() { // one or the other. //////////////////////////////////////////////////////////////////// DisplayRegion *GraphicsOutput:: -make_display_region(float l, float r, float b, float t) { - return make_display_region(LVecBase4f(l, r, b, t)); +make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { + return make_display_region(LVecBase4(l, r, b, t)); } //////////////////////////////////////////////////////////////////// @@ -598,8 +598,8 @@ make_mono_display_region() { // necessary to draw even mono DisplayRegions twice). //////////////////////////////////////////////////////////////////// INLINE DisplayRegion *GraphicsOutput:: -make_mono_display_region(float l, float r, float b, float t) { - return make_mono_display_region(LVecBase4f(l, r, b, t)); +make_mono_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { + return make_mono_display_region(LVecBase4(l, r, b, t)); } //////////////////////////////////////////////////////////////////// @@ -626,8 +626,8 @@ make_stereo_display_region() { // is_stereo() is false. //////////////////////////////////////////////////////////////////// INLINE StereoDisplayRegion *GraphicsOutput:: -make_stereo_display_region(float l, float r, float b, float t) { - return make_stereo_display_region(LVecBase4f(l, r, b, t)); +make_stereo_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { + return make_stereo_display_region(LVecBase4(l, r, b, t)); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index ff47ec31ca..8a86cc47f2 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -43,21 +43,21 @@ PStatCollector GraphicsOutput::_cull_pcollector("Cull"); PStatCollector GraphicsOutput::_draw_pcollector("Draw"); struct CubeFaceDef { - CubeFaceDef(const char *name, const LPoint3f &look_at, const LVector3f &up) : + CubeFaceDef(const char *name, const LPoint3 &look_at, const LVector3 &up) : _name(name), _look_at(look_at), _up(up) { } const char *_name; - LPoint3f _look_at; - LVector3f _up; + LPoint3 _look_at; + LVector3 _up; }; static CubeFaceDef cube_faces[6] = { - CubeFaceDef("positive_x", LPoint3f(1, 0, 0), LVector3f(0, -1, 0)), - CubeFaceDef("negative_x", LPoint3f(-1, 0, 0), LVector3f(0, -1, 0)), - CubeFaceDef("positive_y", LPoint3f(0, 1, 0), LVector3f(0, 0, 1)), - CubeFaceDef("negative_y", LPoint3f(0, -1, 0), LVector3f(0, 0, -1)), - CubeFaceDef("positive_z", LPoint3f(0, 0, 1), LVector3f(0, -1, 0)), - CubeFaceDef("negative_z", LPoint3f(0, 0, -1), LVector3f(0, -1, 0)) + CubeFaceDef("positive_x", LPoint3(1, 0, 0), LVector3(0, -1, 0)), + CubeFaceDef("negative_x", LPoint3(-1, 0, 0), LVector3(0, -1, 0)), + CubeFaceDef("positive_y", LPoint3(0, 1, 0), LVector3(0, 0, 1)), + CubeFaceDef("negative_y", LPoint3(0, -1, 0), LVector3(0, 0, -1)), + CubeFaceDef("positive_z", LPoint3(0, 0, 1), LVector3(0, -1, 0)), + CubeFaceDef("negative_z", LPoint3(0, 0, -1), LVector3(0, -1, 0)) }; //////////////////////////////////////////////////////////////////// @@ -158,19 +158,19 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, switch (background_color.get_num_words()) { case 1: - set_clear_color(Colorf(background_color[0], background_color[0], background_color[0], 0.0f)); + set_clear_color(LColor(background_color[0], background_color[0], background_color[0], 0.0f)); break; case 2: - set_clear_color(Colorf(background_color[0], background_color[0], background_color[0], background_color[1])); + set_clear_color(LColor(background_color[0], background_color[0], background_color[0], background_color[1])); break; case 3: - set_clear_color(Colorf(background_color[0], background_color[1], background_color[2], 0.0f)); + set_clear_color(LColor(background_color[0], background_color[1], background_color[2], 0.0f)); break; case 4: - set_clear_color(Colorf(background_color[0], background_color[1], background_color[2], background_color[3])); + set_clear_color(LColor(background_color[0], background_color[1], background_color[2], background_color[3])); break; default: @@ -554,7 +554,7 @@ set_inverted(bool inverted) { //////////////////////////////////////////////////////////////////// void GraphicsOutput:: set_side_by_side_stereo(bool side_by_side_stereo) { - LVecBase4f left, right; + LVecBase4 left, right; left.set(sbs_left_dimensions[0], sbs_left_dimensions[1], sbs_left_dimensions[2], sbs_left_dimensions[3]); right.set(sbs_right_dimensions[0], sbs_right_dimensions[1], @@ -581,8 +581,8 @@ set_side_by_side_stereo(bool side_by_side_stereo) { //////////////////////////////////////////////////////////////////// void GraphicsOutput:: set_side_by_side_stereo(bool side_by_side_stereo, - const LVecBase4f &sbs_left_dimensions, - const LVecBase4f &sbs_right_dimensions) { + const LVecBase4 &sbs_left_dimensions, + const LVecBase4 &sbs_right_dimensions) { _side_by_side_stereo = side_by_side_stereo; if (_side_by_side_stereo) { _sbs_left_dimensions = sbs_left_dimensions; @@ -645,7 +645,7 @@ set_sort(int sort) { // one or the other. //////////////////////////////////////////////////////////////////// DisplayRegion *GraphicsOutput:: -make_display_region(const LVecBase4f &dimensions) { +make_display_region(const LVecBase4 &dimensions) { if (is_stereo() && default_stereo_camera) { return make_stereo_display_region(dimensions); } else { @@ -668,7 +668,7 @@ make_display_region(const LVecBase4f &dimensions) { // necessary to draw even mono DisplayRegions twice). //////////////////////////////////////////////////////////////////// DisplayRegion *GraphicsOutput:: -make_mono_display_region(const LVecBase4f &dimensions) { +make_mono_display_region(const LVecBase4 &dimensions) { if (_side_by_side_stereo) { StereoDisplayRegion *dr = make_stereo_display_region(dimensions); dr->get_left_eye()->set_stereo_channel(Lens::SC_mono); @@ -690,27 +690,27 @@ make_mono_display_region(const LVecBase4f &dimensions) { // is_stereo() is false. //////////////////////////////////////////////////////////////////// StereoDisplayRegion *GraphicsOutput:: -make_stereo_display_region(const LVecBase4f &dimensions) { +make_stereo_display_region(const LVecBase4 &dimensions) { PT(DisplayRegion) left, right; if (_side_by_side_stereo) { // On a side-by-side stereo window, each eye gets the // corresponding dimensions of its own sub-region. - float left_l = _sbs_left_dimensions[0]; - float left_b = _sbs_left_dimensions[2]; - float left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; - float left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; - LVecBase4f left_dimensions(dimensions[0] * left_w + left_l, + PN_stdfloat left_l = _sbs_left_dimensions[0]; + PN_stdfloat left_b = _sbs_left_dimensions[2]; + PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; + PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; + LVecBase4 left_dimensions(dimensions[0] * left_w + left_l, dimensions[1] * left_w + left_l, dimensions[2] * left_h + left_b, dimensions[3] * left_h + left_b); left = new DisplayRegion(this, left_dimensions); - float right_l = _sbs_right_dimensions[0]; - float right_b = _sbs_right_dimensions[2]; - float right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; - float right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; - LVecBase4f right_dimensions(dimensions[0] * right_w + right_l, + PN_stdfloat right_l = _sbs_right_dimensions[0]; + PN_stdfloat right_b = _sbs_right_dimensions[2]; + PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; + PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; + LVecBase4 right_dimensions(dimensions[0] * right_w + right_l, dimensions[1] * right_w + right_l, dimensions[2] * right_h + right_b, dimensions[3] * right_h + right_b); @@ -1557,8 +1557,8 @@ copy_to_textures() { //////////////////////////////////////////////////////////////////// PT(GeomVertexData) GraphicsOutput:: create_texture_card_vdata(int x, int y) { - float xhi = 1.0; - float yhi = 1.0; + PN_stdfloat xhi = 1.0; + PN_stdfloat yhi = 1.0; if (Texture::get_textures_power_2() != ATS_none) { int xru = Texture::up_to_power_2(x); @@ -1576,20 +1576,20 @@ create_texture_card_vdata(int x, int y) { GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); GeomVertexWriter normal(vdata, InternalName::get_normal()); - vertex.add_data3f(Vertexf::rfu(-1.0f, 0.0f, 1.0f)); - vertex.add_data3f(Vertexf::rfu(-1.0f, 0.0f, -1.0f)); - vertex.add_data3f(Vertexf::rfu( 1.0f, 0.0f, 1.0f)); - vertex.add_data3f(Vertexf::rfu( 1.0f, 0.0f, -1.0f)); + vertex.add_data3(LVertex::rfu(-1.0f, 0.0f, 1.0f)); + vertex.add_data3(LVertex::rfu(-1.0f, 0.0f, -1.0f)); + vertex.add_data3(LVertex::rfu( 1.0f, 0.0f, 1.0f)); + vertex.add_data3(LVertex::rfu( 1.0f, 0.0f, -1.0f)); - texcoord.add_data2f( 0.0f, yhi); - texcoord.add_data2f( 0.0f, 0.0f); - texcoord.add_data2f( xhi, yhi); - texcoord.add_data2f( xhi, 0.0f); + texcoord.add_data2( 0.0f, yhi); + texcoord.add_data2( 0.0f, 0.0f); + texcoord.add_data2( xhi, yhi); + texcoord.add_data2( xhi, 0.0f); - normal.add_data3f(LVector3f::back()); - normal.add_data3f(LVector3f::back()); - normal.add_data3f(LVector3f::back()); - normal.add_data3f(LVector3f::back()); + normal.add_data3(LVector3::back()); + normal.add_data3(LVector3::back()); + normal.add_data3(LVector3::back()); + normal.add_data3(LVector3::back()); return vdata; } diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index ddb8f35782..524bc19af0 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -142,11 +142,11 @@ PUBLISHED: void set_side_by_side_stereo(bool side_by_side_stereo); void set_side_by_side_stereo(bool side_by_side_stereo, - const LVecBase4f &sbs_left_dimensions, - const LVecBase4f &sbs_right_dimensions); + const LVecBase4 &sbs_left_dimensions, + const LVecBase4 &sbs_right_dimensions); INLINE bool get_side_by_side_stereo() const; - INLINE const LVecBase4f &get_sbs_left_dimensions() const; - INLINE const LVecBase4f &get_sbs_right_dimensions() const; + INLINE const LVecBase4 &get_sbs_left_dimensions() const; + INLINE const LVecBase4 &get_sbs_right_dimensions() const; INLINE const FrameBufferProperties &get_fb_properties() const; INLINE bool is_stereo() const; @@ -164,14 +164,14 @@ PUBLISHED: INLINE void trigger_copy(); INLINE DisplayRegion *make_display_region(); - INLINE DisplayRegion *make_display_region(float l, float r, float b, float t); - DisplayRegion *make_display_region(const LVecBase4f &dimensions); + INLINE DisplayRegion *make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t); + DisplayRegion *make_display_region(const LVecBase4 &dimensions); INLINE DisplayRegion *make_mono_display_region(); - INLINE DisplayRegion *make_mono_display_region(float l, float r, float b, float t); - DisplayRegion *make_mono_display_region(const LVecBase4f &dimensions); + INLINE DisplayRegion *make_mono_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t); + DisplayRegion *make_mono_display_region(const LVecBase4 &dimensions); INLINE StereoDisplayRegion *make_stereo_display_region(); - INLINE StereoDisplayRegion *make_stereo_display_region(float l, float r, float b, float t); - StereoDisplayRegion *make_stereo_display_region(const LVecBase4f &dimensions); + INLINE StereoDisplayRegion *make_stereo_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t); + StereoDisplayRegion *make_stereo_display_region(const LVecBase4 &dimensions); bool remove_display_region(DisplayRegion *display_region); void remove_all_display_regions(); @@ -308,8 +308,8 @@ protected: unsigned int _left_eye_color_mask; unsigned int _right_eye_color_mask; bool _side_by_side_stereo; - LVecBase4f _sbs_left_dimensions; - LVecBase4f _sbs_right_dimensions; + LVecBase4 _sbs_left_dimensions; + LVecBase4 _sbs_right_dimensions; bool _delete_flag; // These weak pointers are used to keep track of whether the diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index c2a2c28df9..96ccd7a188 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1,5 +1,5 @@ // Filename: graphicsStateGuardian.cxx -// Created by: drose (02Feb99) +// Created by: drose (02eb99) // Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter, // _max_2d_texture_array_layers, _supports_2d_texture_array, // get_supports_cg_profile) @@ -356,11 +356,11 @@ set_coordinate_system(CoordinateSystem cs) { } else { _cs_transform = TransformState::make_mat - (LMatrix4f::convert_mat(_coordinate_system, + (LMatrix4::convert_mat(_coordinate_system, _internal_coordinate_system)); _inv_cs_transform = TransformState::make_mat - (LMatrix4f::convert_mat(_internal_coordinate_system, + (LMatrix4::convert_mat(_internal_coordinate_system, _coordinate_system)); } } @@ -401,7 +401,7 @@ get_prepared_objects() { // Description: Set gamma. Returns true on success. //////////////////////////////////////////////////////////////////// bool GraphicsStateGuardian:: -set_gamma(float gamma) { +set_gamma(PN_stdfloat gamma) { _gamma = gamma; return false; @@ -412,8 +412,8 @@ set_gamma(float gamma) { // Access: Published // Description: Get the current gamma setting. //////////////////////////////////////////////////////////////////// -float GraphicsStateGuardian:: -get_gamma(float gamma) { +PN_stdfloat GraphicsStateGuardian:: +get_gamma(PN_stdfloat gamma) { return _gamma; } @@ -856,8 +856,8 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { // indicated point, assumed to be in eye coordinates, // from the camera plane. //////////////////////////////////////////////////////////////////// -float GraphicsStateGuardian:: -compute_distance_to(const LPoint3f &point) const { +PN_stdfloat GraphicsStateGuardian:: +compute_distance_to(const LPoint3 &point) const { switch (_coordinate_system) { case CS_zup_right: return point[1]; @@ -912,18 +912,18 @@ compute_distance_to(const LPoint3f &point) const { // This may allow data to be cached and not reevaluated. // //////////////////////////////////////////////////////////////////// -const LMatrix4f *GraphicsStateGuardian:: +const LMatrix4 *GraphicsStateGuardian:: fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { - LVecBase3f v; + LVecBase3 v; if (altered & spec._dep[0]) { - const LMatrix4f *t = fetch_specified_part(spec._part[0], spec._arg[0], spec._cache[0]); + const LMatrix4 *t = fetch_specified_part(spec._part[0], spec._arg[0], spec._cache[0]); if (t != &spec._cache[0]) { spec._cache[0] = *t; } } if (altered & spec._dep[1]) { - const LMatrix4f *t = fetch_specified_part(spec._part[1], spec._arg[1], spec._cache[1]); + const LMatrix4 *t = fetch_specified_part(spec._part[1], spec._arg[1], spec._cache[1]); if (t != &spec._cache[1]) { spec._cache[1] = *t; } @@ -957,7 +957,7 @@ fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { return &spec._cache[0]; default: // should never get here - spec._value = LMatrix4f::ident_mat(); + spec._value = LMatrix4::ident_mat(); return &spec._value; } } @@ -967,59 +967,59 @@ fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { // Access: Public // Description: See fetch_specified_value //////////////////////////////////////////////////////////////////// -const LMatrix4f *GraphicsStateGuardian:: -fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f &t) { +const LMatrix4 *GraphicsStateGuardian:: +fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 &t) { switch(part) { case Shader::SMO_identity: { - return &LMatrix4f::ident_mat(); + return &LMatrix4::ident_mat(); } case Shader::SMO_window_size: { - t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(), + t = LMatrix4::translate_mat(_current_display_region->get_pixel_width(), _current_display_region->get_pixel_height(), 0.0); return &t; } case Shader::SMO_pixel_size: { - t = LMatrix4f::translate_mat(_current_display_region->get_pixel_width(), + t = LMatrix4::translate_mat(_current_display_region->get_pixel_width(), _current_display_region->get_pixel_height(), 0.0); return &t; } case Shader::SMO_texpad_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4f::zeros_mat()); + nassertr(tex != 0, &LMatrix4::zeros_mat()); int sx = tex->get_x_size() - tex->get_pad_x_size(); int sy = tex->get_y_size() - tex->get_pad_y_size(); int sz = tex->get_z_size() - tex->get_pad_z_size(); double cx = (sx * 0.5) / tex->get_x_size(); double cy = (sy * 0.5) / tex->get_y_size(); double cz = (sz * 0.5) / tex->get_z_size(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,cx,cy,cz,0); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,cx,cy,cz,0); return &t; } case Shader::SMO_texpix_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4f::zeros_mat()); + nassertr(tex != 0, &LMatrix4::zeros_mat()); double px = 1.0 / tex->get_x_size(); double py = 1.0 / tex->get_y_size(); double pz = 1.0 / tex->get_z_size(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,px,py,pz,0); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,px,py,pz,0); return &t; } case Shader::SMO_attr_material: { const MaterialAttrib *target_material = DCAST(MaterialAttrib, _target_rs->get_attrib_def(MaterialAttrib::get_class_slot())); // Material matrix contains AMBIENT, DIFFUSE, EMISSION, SPECULAR+SHININESS if (target_material->is_off()) { - t = LMatrix4f(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0); + t = LMatrix4(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0); return &t; } Material *m = target_material->get_material(); - LVecBase4f const &amb = m->get_ambient(); - LVecBase4f const &dif = m->get_diffuse(); - LVecBase4f const &emm = m->get_emission(); - LVecBase4f spc = m->get_specular(); + LVecBase4 const &amb = m->get_ambient(); + LVecBase4 const &dif = m->get_diffuse(); + LVecBase4 const &emm = m->get_emission(); + LVecBase4 spc = m->get_specular(); spc[3] = m->get_shininess(); - t = LMatrix4f(amb[0],amb[1],amb[2],amb[3], + t = LMatrix4(amb[0],amb[1],amb[2],amb[3], dif[0],dif[1],dif[2],dif[3], emm[0],emm[1],emm[2],emm[3], spc[0],spc[1],spc[2],spc[3]); @@ -1028,109 +1028,109 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f case Shader::SMO_attr_color: { const ColorAttrib *target_color = DCAST(ColorAttrib, _target_rs->get_attrib_def(ColorAttrib::get_class_slot())); if (target_color->get_color_type() != ColorAttrib::T_flat) { - return &LMatrix4f::ones_mat(); + return &LMatrix4::ones_mat(); } - LVecBase4f c = target_color->get_color(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + LVecBase4 c = target_color->get_color(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); return &t; } case Shader::SMO_attr_colorscale: { const ColorScaleAttrib *target_color = DCAST(ColorScaleAttrib, _target_rs->get_attrib_def(ColorScaleAttrib::get_class_slot())); if (target_color->is_identity()) { - return &LMatrix4f::ones_mat(); + return &LMatrix4::ones_mat(); } - LVecBase4f cs = target_color->get_scale(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,cs[0],cs[1],cs[2],cs[3]); + LVecBase4 cs = target_color->get_scale(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,cs[0],cs[1],cs[2],cs[3]); return &t; } case Shader::SMO_attr_fog: { const FogAttrib *target_fog = DCAST(FogAttrib, _target_rs->get_attrib_def(FogAttrib::get_class_slot())); Fog *fog = target_fog->get_fog(); if (fog == (Fog*) NULL) { - return &LMatrix4f::ones_mat(); + return &LMatrix4::ones_mat(); } - float start, end; + PN_stdfloat start, end; fog->get_linear_range(start, end); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,fog->get_exp_density(),start,end,1.0f/(end-start)); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,fog->get_exp_density(),start,end,1.0f/(end-start)); return &t; } case Shader::SMO_attr_fogcolor: { const FogAttrib *target_fog = DCAST(FogAttrib, _target_rs->get_attrib_def(FogAttrib::get_class_slot())); Fog *fog = target_fog->get_fog(); if (fog == (Fog*) NULL) { - return &LMatrix4f::ones_mat(); + return &LMatrix4::ones_mat(); } - LVecBase4f c = fog->get_color(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + LVecBase4 c = fog->get_color(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); return &t; } case Shader::SMO_alight_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::zeros_mat()); + nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); AmbientLight *lt; - DCAST_INTO_R(lt, np.node(), &LMatrix4f::zeros_mat()); - Colorf const &c = lt->get_color(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); + LColor const &c = lt->get_color(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); return &t; } case Shader::SMO_satten_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ones_mat()); + nassertr(!np.is_empty(), &LMatrix4::ones_mat()); Spotlight *lt; - DCAST_INTO_R(lt, np.node(), &LMatrix4f::ones_mat()); - LVecBase3f const &a = lt->get_attenuation(); - float x = lt->get_exponent(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,a[0],a[1],a[2],x); + DCAST_INTO_R(lt, np.node(), &LMatrix4::ones_mat()); + LVecBase3 const &a = lt->get_attenuation(); + PN_stdfloat x = lt->get_exponent(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,a[0],a[1],a[2],x); return &t; } case Shader::SMO_dlight_x: { // The dlight matrix contains COLOR, SPECULAR, DIRECTION, PSEUDOHALFANGLE const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::zeros_mat()); + nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); DirectionalLight *lt; - DCAST_INTO_R(lt, np.node(), &LMatrix4f::zeros_mat()); - Colorf const &c = lt->get_color(); - Colorf const &s = lt->get_specular_color(); + DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); + LColor const &c = lt->get_color(); + LColor const &s = lt->get_specular_color(); t = np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); - LVecBase3f d = -(t.xform_vec(lt->get_direction())); + LVecBase3 d = -(t.xform_vec(lt->get_direction())); d.normalize(); - LVecBase3f h = d + LVecBase3f(0,-1,0); + LVecBase3 h = d + LVecBase3(0,-1,0); h.normalize(); - t = LMatrix4f(c[0],c[1],c[2],c[3],s[0],s[1],s[2],c[3],d[0],d[1],d[2],0,h[0],h[1],h[2],0); + t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],c[3],d[0],d[1],d[2],0,h[0],h[1],h[2],0); return &t; } case Shader::SMO_plight_x: { // The plight matrix contains COLOR, SPECULAR, POINT, ATTENUATION const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ones_mat()); + nassertr(!np.is_empty(), &LMatrix4::ones_mat()); PointLight *lt; - DCAST_INTO_R(lt, np.node(), &LMatrix4f::zeros_mat()); - Colorf const &c = lt->get_color(); - Colorf const &s = lt->get_specular_color(); + DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); + LColor const &c = lt->get_color(); + LColor const &s = lt->get_specular_color(); t = np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); - LVecBase3f p = (t.xform_point(lt->get_point())); - LVecBase3f a = lt->get_attenuation(); - t = LMatrix4f(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],0,a[0],a[1],a[2],0); + LVecBase3 p = (t.xform_point(lt->get_point())); + LVecBase3 a = lt->get_attenuation(); + t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],0,a[0],a[1],a[2],0); return &t; } case Shader::SMO_slight_x: { // The slight matrix contains COLOR, SPECULAR, POINT, DIRECTION const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::zeros_mat()); + nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); Spotlight *lt; - DCAST_INTO_R(lt, np.node(), &LMatrix4f::zeros_mat()); + DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); Lens *lens = lt->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4f::zeros_mat()); - Colorf const &c = lt->get_color(); - Colorf const &s = lt->get_specular_color(); - float cutoff = cos(deg_2_rad(lens->get_hfov() * 0.5f)); + nassertr(lens != (Lens *)NULL, &LMatrix4::zeros_mat()); + LColor const &c = lt->get_color(); + LColor const &s = lt->get_specular_color(); + PN_stdfloat cutoff = ccos(deg_2_rad(lens->get_hfov() * 0.5f)); t = np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); - LVecBase3f p = t.xform_point(lens->get_nodal_point()); - LVecBase3f d = -(t.xform_vec(lens->get_view_vector())); - t = LMatrix4f(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],0,d[0],d[1],d[2],cutoff); + LVecBase3 p = t.xform_point(lens->get_nodal_point()); + LVecBase3 d = -(t.xform_vec(lens->get_view_vector())); + t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],0,d[0],d[1],d[2],cutoff); return &t; } case Shader::SMO_texmat_x: { @@ -1138,44 +1138,44 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f const TextureAttrib *ta = DCAST(TextureAttrib, _target_rs->get_attrib_def(TextureAttrib::get_class_slot())); int stagenr = atoi(name->get_name().c_str()); if (stagenr >= ta->get_num_on_stages()) { - return &LMatrix4f::ident_mat(); + return &LMatrix4::ident_mat(); } return &tma->get_mat(ta->get_on_stage(stagenr)); } case Shader::SMO_plane_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::zeros_mat()); - nassertr(np.node()->is_of_type(PlaneNode::get_class_type()), &LMatrix4f::zeros_mat()); - Planef p = DCAST(PlaneNode, np.node())->get_plane(); - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); + nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); + nassertr(np.node()->is_of_type(PlaneNode::get_class_type()), &LMatrix4::zeros_mat()); + LPlane p = DCAST(PlaneNode, np.node())->get_plane(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); return &t; } case Shader::SMO_clipplane_x: { const ClipPlaneAttrib *cpa = DCAST(ClipPlaneAttrib, _target_rs->get_attrib_def(ClipPlaneAttrib::get_class_slot())); int planenr = atoi(name->get_name().c_str()); if (planenr >= cpa->get_num_on_planes()) { - return &LMatrix4f::zeros_mat(); + return &LMatrix4::zeros_mat(); } const NodePath &np = cpa->get_on_plane(planenr); - nassertr(!np.is_empty(), &LMatrix4f::zeros_mat()); - nassertr(np.node()->is_of_type(PlaneNode::get_class_type()), &LMatrix4f::zeros_mat()); - Planef p (DCAST(PlaneNode, np.node())->get_plane()); + nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); + nassertr(np.node()->is_of_type(PlaneNode::get_class_type()), &LMatrix4::zeros_mat()); + LPlane p (DCAST(PlaneNode, np.node())->get_plane()); p.xform(np.get_net_transform()->get_mat()); // World-space - t = LMatrix4f(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); return &t; } case Shader::SMO_mat_constant_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); return &(np.node()->get_transform()->get_mat()); } case Shader::SMO_vec_constant_x: { - const LVector4f &input = _target_shader->get_shader_input_vector(name); - const float *data = input.get_data(); - t = LMatrix4f(data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3]); + const LVecBase4 &input = _target_shader->get_shader_input_vector(name); + const PN_stdfloat *data = input.get_data(); + t = LMatrix4(data[0],data[1],data[2],data[3], + data[0],data[1],data[2],data[3], + data[0],data[1],data[2],data[3], + data[0],data[1],data[2],data[3]); return &t; } case Shader::SMO_world_to_view: { @@ -1204,7 +1204,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f return &(_current_lens->get_projection_mat_inv(_current_stereo_channel)); } else { t = _current_lens->get_projection_mat_inv(_current_stereo_channel) * - LMatrix4f::convert_mat(_current_lens->get_coordinate_system(), _coordinate_system); + LMatrix4::convert_mat(_current_lens->get_coordinate_system(), _coordinate_system); return &t; } } @@ -1212,7 +1212,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f if (_current_lens->get_coordinate_system() == _coordinate_system) { return &(_current_lens->get_projection_mat(_current_stereo_channel)); } else { - t = LMatrix4f::convert_mat(_coordinate_system, _current_lens->get_coordinate_system()) * + t = LMatrix4::convert_mat(_coordinate_system, _current_lens->get_coordinate_system()) * _current_lens->get_projection_mat(_current_stereo_channel); return &t; } @@ -1227,67 +1227,67 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4f } case Shader::SMO_view_x_to_view: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); t = np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); return &t; } case Shader::SMO_view_to_view_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); t = get_scene()->get_camera_transform()->get_mat() * invert(np.get_net_transform()->get_mat()); return &t; } case Shader::SMO_apiview_x_to_view: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); - t = LMatrix4f::convert_mat(_internal_coordinate_system, _coordinate_system) * + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); + t = LMatrix4::convert_mat(_internal_coordinate_system, _coordinate_system) * np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); return &t; } case Shader::SMO_view_to_apiview_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); t = (get_scene()->get_camera_transform()->get_mat() * invert(np.get_net_transform()->get_mat()) * - LMatrix4f::convert_mat(_coordinate_system, _internal_coordinate_system)); + LMatrix4::convert_mat(_coordinate_system, _internal_coordinate_system)); return &t; } case Shader::SMO_clip_x_to_view: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); - nassertr(np.node()->is_of_type(LensNode::get_class_type()), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); + nassertr(np.node()->is_of_type(LensNode::get_class_type()), &LMatrix4::ident_mat()); Lens *lens = DCAST(LensNode, np.node())->get_lens(); t = lens->get_projection_mat_inv(_current_stereo_channel) * - LMatrix4f::convert_mat(lens->get_coordinate_system(), _coordinate_system) * + LMatrix4::convert_mat(lens->get_coordinate_system(), _coordinate_system) * np.get_net_transform()->get_mat() * get_scene()->get_world_transform()->get_mat(); return &t; } case Shader::SMO_view_to_clip_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); - nassertr(!np.is_empty(), &LMatrix4f::ident_mat()); - nassertr(np.node()->is_of_type(LensNode::get_class_type()), &LMatrix4f::ident_mat()); + nassertr(!np.is_empty(), &LMatrix4::ident_mat()); + nassertr(np.node()->is_of_type(LensNode::get_class_type()), &LMatrix4::ident_mat()); Lens *lens = DCAST(LensNode, np.node())->get_lens(); t = get_scene()->get_camera_transform()->get_mat() * invert(np.get_net_transform()->get_mat()) * - LMatrix4f::convert_mat(_coordinate_system, lens->get_coordinate_system()) * + LMatrix4::convert_mat(_coordinate_system, lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); return &t; } case Shader::SMO_apiclip_x_to_view: { // NOT IMPLEMENTED - return &LMatrix4f::ident_mat(); + return &LMatrix4::ident_mat(); } case Shader::SMO_view_to_apiclip_x: { // NOT IMPLEMENTED - return &LMatrix4f::ident_mat(); + return &LMatrix4::ident_mat(); } default: // should never get here - return &LMatrix4f::ident_mat(); + return &LMatrix4::ident_mat(); } } @@ -2027,7 +2027,7 @@ void GraphicsStateGuardian:: do_issue_light() { // Initialize the current ambient light total and newly enabled // light list - Colorf cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); + LColor cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); int i; int num_enabled = 0; @@ -2063,7 +2063,7 @@ do_issue_light() { cur_ambient_light += light_obj->get_color(); } else { - const Colorf &color = light_obj->get_color(); + const LColor &color = light_obj->get_color(); // Don't bother binding the light if it has no color to contribute. if (color[0] != 0.0 || color[1] != 0.0 || color[2] != 0.0) { enable_light(num_enabled, true); @@ -2085,14 +2085,14 @@ do_issue_light() { // If no lights were set, disable lighting if (num_on_lights == 0) { - if (_color_scale_via_lighting && (_has_material_force_color || _light_color_scale != LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f))) { + if (_color_scale_via_lighting && (_has_material_force_color || _light_color_scale != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f))) { // Unless we need lighting anyway to apply a color or color // scale. if (!_lighting_enabled) { enable_lighting(true); _lighting_enabled = true; } - set_ambient_light(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_ambient_light(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } else { if (_lighting_enabled) { @@ -2216,7 +2216,7 @@ init_frame_pstats() { // Description: Create a gamma table. //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: -create_gamma_table (float gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; if (gamma <= 0.0) { @@ -2227,7 +2227,7 @@ create_gamma_table (float gamma, unsigned short *red_table, unsigned short *gree for (i = 0; i < 256; i++) { double g; double x; - float gamma_correction; + PN_stdfloat gamma_correction; x = ((double) i / 255.0); gamma_correction = 1.0 / gamma; @@ -2276,7 +2276,7 @@ enable_lighting(bool enable) { // all other lights have been enabled or disabled. //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: -set_ambient_light(const Colorf &color) { +set_ambient_light(const LColor &color) { } //////////////////////////////////////////////////////////////////// @@ -2407,7 +2407,7 @@ determine_target_texture() { _target_texture = DCAST(TextureAttrib, _target_texture->add_on_stage(stage, texture)); _target_tex_gen = DCAST(TexGenAttrib, _target_tex_gen->add_stage - (stage, TexGenAttrib::M_constant, TexCoord3f(_current_color_scale[3], 0.0f, 0.0f))); + (stage, TexGenAttrib::M_constant, LTexCoord3(_current_color_scale[3], 0.0f, 0.0f))); } nassertv(_target_texture->get_num_on_stages() <= max_texture_stages); @@ -2647,7 +2647,7 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) { // Set the wrap mode to BORDER_COLOR tex->set_wrap_u(Texture::WM_border_color); tex->set_wrap_v(Texture::WM_border_color); - tex->set_border_color(LVecBase4f(1, 1, 1, 1)); + tex->set_border_color(LVecBase4(1, 1, 1, 1)); if (get_supports_shadow_filter()) { // If we have the ARB_shadow extension, enable shadow filtering. diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 918b4c6664..94c392e127 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -1,5 +1,5 @@ // Filename: graphicsStateGuardian.h -// Created by: drose (02Feb99) +// Created by: drose (02eb99) // Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter, // _max_2d_texture_array_layers on z axis, get_supports_cg_profile) // @@ -171,8 +171,8 @@ PUBLISHED: virtual PreparedGraphicsObjects *get_prepared_objects(); - virtual bool set_gamma(float gamma); - float get_gamma(float gamma); + virtual bool set_gamma(PN_stdfloat gamma); + PN_stdfloat get_gamma(PN_stdfloat gamma); virtual void restore_gamma(); INLINE void set_texture_quality_override(Texture::QualityLevel quality_level); @@ -224,12 +224,12 @@ public: virtual void set_state_and_transform(const RenderState *state, const TransformState *transform); - virtual float compute_distance_to(const LPoint3f &point) const; + virtual PN_stdfloat compute_distance_to(const LPoint3 &point) const; virtual void clear(DrawableRegion *clearable); - const LMatrix4f *fetch_specified_value(Shader::ShaderMatSpec &spec, int altered); - const LMatrix4f *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, LMatrix4f &t); + const LMatrix4 *fetch_specified_value(Shader::ShaderMatSpec &spec, int altered); + const LMatrix4 *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, LMatrix4 &t); const Shader::ShaderPtrData *fetch_ptr_parameter(const Shader::ShaderPtrSpec& spec); virtual void prepare_display_region(DisplayRegionPipelineReader *dr); @@ -308,7 +308,7 @@ public: virtual void bind_light(Spotlight *light_obj, const NodePath &light, int light_id); - static void create_gamma_table (float gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table); + static void create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table); virtual PT(Texture) make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host); @@ -320,7 +320,7 @@ protected: virtual void reissue_transforms(); virtual void enable_lighting(bool enable); - virtual void set_ambient_light(const Colorf &color); + virtual void set_ambient_light(const LColor &color); virtual void enable_light(int light_id, bool enable); virtual void begin_bind_lights(); virtual void end_bind_lights(); @@ -404,7 +404,7 @@ protected: CPT(TransformState) _cs_transform; CPT(TransformState) _inv_cs_transform; - Colorf _scene_graph_color; + LColor _scene_graph_color; bool _has_scene_graph_color; bool _transform_stale; bool _color_blend_involves_color_scale; @@ -413,11 +413,11 @@ protected: bool _lighting_enabled; bool _clip_planes_enabled; bool _color_scale_enabled; - LVecBase4f _current_color_scale; + LVecBase4 _current_color_scale; bool _has_material_force_color; - Colorf _material_force_color; - LVecBase4f _light_color_scale; + LColor _material_force_color; + LVecBase4 _light_color_scale; bool _has_texture_alpha_scale; bool _tex_gen_modifies_mat; @@ -501,7 +501,7 @@ protected: Shader::ShaderCaps _shader_caps; - float _gamma; + PN_stdfloat _gamma; Texture::QualityLevel _texture_quality_override; ShaderGenerator* _shader_generator; diff --git a/panda/src/display/lru.cxx b/panda/src/display/lru.cxx index dbd850126c..f9361ceaac 100644 --- a/panda/src/display/lru.cxx +++ b/panda/src/display/lru.cxx @@ -521,12 +521,12 @@ void Lru::access_page (LruPage *lru_page) // Description: //////////////////////////////////////////////////////////////////// void Lru::set_maximum_frame_bandwidth_utilization - (float maximum_frame_bandwidth_utilization) + (PN_stdfloat maximum_frame_bandwidth_utilization) { this->_m.maximum_frame_bandwidth_utilization = maximum_frame_bandwidth_utilization; - this->_m.frame_bandwidth_factor = (float) LPP_TotalPriorities + this->_m.frame_bandwidth_factor = (PN_stdfloat) LPP_TotalPriorities / this->_m.maximum_frame_bandwidth_utilization; } @@ -615,18 +615,18 @@ void Lru::update_lru_page (LruPage *lru_page) if(lru_page->_m.update_frame_identifier) { int target_priority; int integer_update_frames; - float update_frames; - float one_over_update_frames; - float update_average_frame_utilization; + PN_stdfloat update_frames; + PN_stdfloat one_over_update_frames; + PN_stdfloat update_average_frame_utilization; integer_update_frames = (this->_m.current_frame_identifier - lru_page->_m.update_frame_identifier); if(integer_update_frames > 0) { - update_frames = ( float ) integer_update_frames; + update_frames = ( PN_stdfloat ) integer_update_frames; one_over_update_frames = 1.0f / update_frames; update_average_frame_utilization = - (float) (lru_page->_m.update_total_usage)* one_over_update_frames; + (PN_stdfloat) (lru_page->_m.update_total_usage)* one_over_update_frames; lru_page->_m.average_frame_utilization = calculate_exponential_moving_average( @@ -639,7 +639,7 @@ void Lru::update_lru_page (LruPage *lru_page) integer_average_frame_utilization = (int) ((lru_page->_m.average_frame_utilization - 1.0f) * - (float) HIGH_PRIORITY_SCALE); + (PN_stdfloat) HIGH_PRIORITY_SCALE); if(integer_average_frame_utilization >= LPP_New) { integer_average_frame_utilization = LPP_New; } @@ -652,7 +652,7 @@ void Lru::update_lru_page (LruPage *lru_page) integer_average_frame_utilization = (int) (lru_page->_m.average_frame_utilization * - (float) LOW_PRIORITY_RANGE); + (PN_stdfloat) LOW_PRIORITY_RANGE); integer_average_frame_utilization = LOW_PRIORITY_RANGE - integer_average_frame_utilization; target_priority = LPP_New + integer_average_frame_utilization; @@ -1030,8 +1030,8 @@ void Lru::calculate_lru_statistics (void) // Access: Public // Description: //////////////////////////////////////////////////////////////////// -float calculate_exponential_moving_average(float value, - float weight, float average) +PN_stdfloat calculate_exponential_moving_average(PN_stdfloat value, + PN_stdfloat weight, PN_stdfloat average) { return ((value - average) * weight) + average; } @@ -1082,15 +1082,15 @@ bool default_page_out_function(LruPage *lru_page) void test_ema(void) { int index; - float usage; - float weight; - float average; + PN_stdfloat usage; + PN_stdfloat weight; + PN_stdfloat average; - weight = 0.2f; + weight = 0.2; average = 1.0f; for(index = 0; index < 50; index++) { if(index < 25) { - usage = (float) (index & 0x01); + usage = (PN_stdfloat) (index & 0x01); } else { usage = 0.0f; diff --git a/panda/src/display/lru.h b/panda/src/display/lru.h index e08aeff0aa..45c8f8c2c2 100644 --- a/panda/src/display/lru.h +++ b/panda/src/display/lru.h @@ -112,7 +112,7 @@ public: int identifier; - float average_frame_utilization; + PN_stdfloat average_frame_utilization; LruPage *previous; LruPage *next; @@ -171,7 +171,7 @@ public: void access_page (LruPage *lru_page); - void set_maximum_frame_bandwidth_utilization (float maximum_frame_bandwidth_utilization); + void set_maximum_frame_bandwidth_utilization (PN_stdfloat maximum_frame_bandwidth_utilization); void begin_frame ( ); @@ -226,10 +226,10 @@ public: int identifier; // the number of pages created during the lifetime of the LRU - float weight; // used for exponential moving average - float maximum_frame_bandwidth_utilization; + PN_stdfloat weight; // used for exponential moving average + PN_stdfloat maximum_frame_bandwidth_utilization; - float frame_bandwidth_factor; + PN_stdfloat frame_bandwidth_factor; LruPageTypeFunction page_in_function_array [MAXIMUM_LRU_PAGE_TYPES]; LruPageTypeFunction page_out_function_array [MAXIMUM_LRU_PAGE_TYPES]; @@ -259,7 +259,7 @@ public: friend class LruPage; }; -float calculate_exponential_moving_average (float value, float weight, float average); +PN_stdfloat calculate_exponential_moving_average (PN_stdfloat value, PN_stdfloat weight, PN_stdfloat average); bool default_page_in_function (LruPage *lru_page); bool default_page_out_function (LruPage *lru_page); diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index d9b14708ae..ab00378536 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -59,7 +59,7 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, _color = color_attrib->get_color(); if (color_scale_attrib != (ColorScaleAttrib *)NULL && color_scale_attrib->has_scale()) { - const LVecBase4f &cs = color_scale_attrib->get_scale(); + const LVecBase4 &cs = color_scale_attrib->get_scale(); _color.set(_color[0] * cs[0], _color[1] * cs[1], _color[2] * cs[2], diff --git a/panda/src/display/standardMunger.h b/panda/src/display/standardMunger.h index 4c5c1a5943..9b432da718 100644 --- a/panda/src/display/standardMunger.h +++ b/panda/src/display/standardMunger.h @@ -58,8 +58,8 @@ private: bool _munge_color; bool _munge_color_scale; - Colorf _color; - LVecBase4f _color_scale; + LColor _color; + LVecBase4 _color_scale; public: static TypeHandle get_class_type() { diff --git a/panda/src/display/stereoDisplayRegion.cxx b/panda/src/display/stereoDisplayRegion.cxx index 76e768f75b..7284358c4f 100644 --- a/panda/src/display/stereoDisplayRegion.cxx +++ b/panda/src/display/stereoDisplayRegion.cxx @@ -24,7 +24,7 @@ TypeHandle StereoDisplayRegion::_type_handle; //////////////////////////////////////////////////////////////////// StereoDisplayRegion:: StereoDisplayRegion(GraphicsOutput *window, - const LVecBase4f &dimensions, + const LVecBase4 &dimensions, DisplayRegion *left, DisplayRegion *right) : DisplayRegion(window, dimensions), _left_eye(left), @@ -77,7 +77,7 @@ set_clear_active(int n, bool clear_active) { // Description: Sets the clear value for any bitplane. //////////////////////////////////////////////////////////////////// void StereoDisplayRegion:: -set_clear_value(int n, const Colorf &clear_value) { +set_clear_value(int n, const LColor &clear_value) { DisplayRegion::set_clear_value(n, clear_value); _left_eye->set_clear_value(n, clear_value); _right_eye->set_clear_value(n, clear_value); @@ -102,7 +102,7 @@ disable_clears() { // Description: Sets the pixel_zoom for left and right eyes. //////////////////////////////////////////////////////////////////// void StereoDisplayRegion:: -set_pixel_zoom(float pixel_zoom) { +set_pixel_zoom(PN_stdfloat pixel_zoom) { DisplayRegion::set_pixel_zoom(pixel_zoom); _left_eye->set_pixel_zoom(pixel_zoom); _right_eye->set_pixel_zoom(pixel_zoom); @@ -115,7 +115,7 @@ set_pixel_zoom(float pixel_zoom) { // indicated dimensions. //////////////////////////////////////////////////////////////////// void StereoDisplayRegion:: -set_dimensions(const LVecBase4f &dimensions) { +set_dimensions(const LVecBase4 &dimensions) { DisplayRegion::set_dimensions(dimensions); _left_eye->set_dimensions(dimensions); _right_eye->set_dimensions(dimensions); diff --git a/panda/src/display/stereoDisplayRegion.h b/panda/src/display/stereoDisplayRegion.h index 25d865a5ed..18e574c315 100644 --- a/panda/src/display/stereoDisplayRegion.h +++ b/panda/src/display/stereoDisplayRegion.h @@ -37,7 +37,7 @@ class EXPCL_PANDA_DISPLAY StereoDisplayRegion : public DisplayRegion { protected: StereoDisplayRegion(GraphicsOutput *window, - const LVecBase4f &dimensions, + const LVecBase4 &dimensions, DisplayRegion *left, DisplayRegion *right); public: @@ -46,12 +46,12 @@ public: PUBLISHED: // Inherited from DrawableRegion virtual void set_clear_active(int n, bool clear_aux_active); - virtual void set_clear_value(int n, const Colorf &clear_value); + virtual void set_clear_value(int n, const LColor &clear_value); virtual void disable_clears(); - virtual void set_pixel_zoom(float pixel_zoom); + virtual void set_pixel_zoom(PN_stdfloat pixel_zoom); // Inherited from DisplayRegion - virtual void set_dimensions(const LVecBase4f &dimensions); + virtual void set_dimensions(const LVecBase4 &dimensions); virtual bool is_stereo() const; virtual void set_camera(const NodePath &camera); virtual void set_active(bool active); diff --git a/panda/src/distort/cylindricalLens.cxx b/panda/src/distort/cylindricalLens.cxx index adf4558b59..bc87ff6e02 100644 --- a/panda/src/distort/cylindricalLens.cxx +++ b/panda/src/distort/cylindricalLens.cxx @@ -19,7 +19,7 @@ TypeHandle CylindricalLens::_type_handle; // This is the focal-length constant for fisheye lenses. See // fisheyeLens.cxx. -static const float cylindrical_k = 60.0f; +static const PN_stdfloat cylindrical_k = 60.0f; // focal_length = film_size * cylindrical_k / fov; @@ -51,23 +51,23 @@ make_copy() const { // otherwise. //////////////////////////////////////////////////////////////////// bool CylindricalLens:: -extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { +extrude_impl(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { // Undo the shifting from film offsets, etc. This puts the point // into the range [-film_size/2, film_size/2] in x and y. - LPoint3f f = point2d * get_film_mat_inv(); + LPoint3 f = point2d * get_film_mat_inv(); - float focal_length = get_focal_length(); - float angle = f[0] * cylindrical_k / focal_length; - float sinAngle, cosAngle; + PN_stdfloat focal_length = get_focal_length(); + PN_stdfloat angle = f[0] * cylindrical_k / focal_length; + PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); // Define a unit vector (well, a unit vector in the XY plane, at // least) that represents the vector corresponding to this point. - LPoint3f v(sinAngle, cosAngle, f[1] / focal_length); + LPoint3 v(sinAngle, cosAngle, f[1] / focal_length); // And we'll need to account for the lens's rotations, etc. at the // end of the day. - const LMatrix4f &lens_mat = get_lens_mat(); + const LMatrix4 &lens_mat = get_lens_mat(); near_point = (v * get_near()) * lens_mat; far_point = (v * get_far()) * lens_mat; @@ -95,17 +95,17 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // otherwise. //////////////////////////////////////////////////////////////////// bool CylindricalLens:: -extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { +extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const { // Undo the shifting from film offsets, etc. This puts the point // into the range [-film_size/2, film_size/2] in x and y. - LPoint3f f = point2d * get_film_mat_inv(); + LPoint3 f = point2d * get_film_mat_inv(); - float focal_length = get_focal_length(); - float angle = f[0] * cylindrical_k / focal_length; - float sinAngle, cosAngle; + PN_stdfloat focal_length = get_focal_length(); + PN_stdfloat angle = f[0] * cylindrical_k / focal_length; + PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); - vec = LVector3f(sinAngle, cosAngle, 0.0f) * get_lens_mat(); + vec = LVector3(sinAngle, cosAngle, 0.0f) * get_lens_mat(); return true; } @@ -128,24 +128,24 @@ extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { // is filled in), or false otherwise. //////////////////////////////////////////////////////////////////// bool CylindricalLens:: -project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { +project_impl(const LPoint3 &point3d, LPoint3 &point2d) const { // First, account for any rotations, etc. on the lens. - LPoint3f p = point3d * get_lens_mat_inv(); + LPoint3 p = point3d * get_lens_mat_inv(); // To compute the x position on the frame, we only need to consider // the angle of the vector about the Z axis. Project the vector // into the XY plane to do this. - LVector2f xy(p[0], p[1]); + LVector2 xy(p[0], p[1]); // The perspective distance is the length of this vector in the XY // plane. - float pdist = xy.length(); + PN_stdfloat pdist = xy.length(); if (pdist == 0.0f) { point2d.set(0.0f, 0.0f, 0.0f); return false; } - float focal_length = get_focal_length(); + PN_stdfloat focal_length = get_focal_length(); point2d.set ( @@ -176,8 +176,8 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float CylindricalLens:: -fov_to_film(float fov, float focal_length, bool horiz) const { +PN_stdfloat CylindricalLens:: +fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const { if (horiz) { return focal_length * fov / cylindrical_k; } else { @@ -194,8 +194,8 @@ fov_to_film(float fov, float focal_length, bool horiz) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float CylindricalLens:: -fov_to_focal_length(float fov, float film_size, bool horiz) const { +PN_stdfloat CylindricalLens:: +fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const { if (horiz) { return film_size * cylindrical_k / fov; } else { @@ -212,8 +212,8 @@ fov_to_focal_length(float fov, float film_size, bool horiz) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float CylindricalLens:: -film_to_fov(float film_size, float focal_length, bool horiz) const { +PN_stdfloat CylindricalLens:: +film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const { if (horiz) { return film_size * cylindrical_k / focal_length; } else { diff --git a/panda/src/distort/cylindricalLens.h b/panda/src/distort/cylindricalLens.h index 096bd8aae6..f104f9954c 100644 --- a/panda/src/distort/cylindricalLens.h +++ b/panda/src/distort/cylindricalLens.h @@ -49,14 +49,14 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool extrude_impl(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - virtual bool extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const; - virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const; + virtual bool extrude_impl(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + virtual bool extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const; + virtual bool project_impl(const LPoint3 &point3d, LPoint3 &point2d) const; - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; public: virtual TypeHandle get_type() const { diff --git a/panda/src/distort/fisheyeLens.cxx b/panda/src/distort/fisheyeLens.cxx index 0768ea691b..603a51c947 100644 --- a/panda/src/distort/fisheyeLens.cxx +++ b/panda/src/distort/fisheyeLens.cxx @@ -32,7 +32,7 @@ TypeHandle FisheyeLens::_type_handle; // know how well this extends to other lenses and other negative // sizes. -static const float fisheye_k = 60.0f; +static const PN_stdfloat fisheye_k = 60.0f; // focal_length = film_size * fisheye_k / fov; @@ -64,18 +64,18 @@ make_copy() const { // otherwise. //////////////////////////////////////////////////////////////////// bool FisheyeLens:: -extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { +extrude_impl(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { // Undo the shifting from film offsets, etc. This puts the point // into the range [-film_size/2, film_size/2] in x and y. - LPoint3f f = point2d * get_film_mat_inv(); + LPoint3 f = point2d * get_film_mat_inv(); // First, get the vector from the center of the film to the point, // and normalize it. - LVector2f v2(f[0], f[1]); + LVector2 v2(f[0], f[1]); - LPoint3f v; + LPoint3 v; - float r = v2.length(); + PN_stdfloat r = v2.length(); if (r == 0.0f) { // Special case: directly forward. v.set(0.0f, 1.0f, 0.0f); @@ -84,12 +84,12 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) v2 /= r; // Now get the point r units around the circle in the YZ plane. - float focal_length = get_focal_length(); - float angle = r * fisheye_k / focal_length; - float sinAngle, cosAngle; + PN_stdfloat focal_length = get_focal_length(); + PN_stdfloat angle = r * fisheye_k / focal_length; + PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); - LVector3f p(0.0, cosAngle, sinAngle); + LVector3 p(0.0, cosAngle, sinAngle); // And rotate this point around the Y axis. v.set(p[0]*v2[1] + p[2]*v2[0], @@ -99,7 +99,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // And we'll need to account for the lens's rotations, etc. at the // end of the day. - const LMatrix4f &lens_mat = get_lens_mat(); + const LMatrix4 &lens_mat = get_lens_mat(); near_point = (v * get_near()) * lens_mat; far_point = (v * get_far()) * lens_mat; @@ -127,8 +127,8 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // otherwise. //////////////////////////////////////////////////////////////////// bool FisheyeLens:: -extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { - LPoint3f near_point, far_point; +extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const { + LPoint3 near_point, far_point; if (!extrude_impl(point2d, near_point, far_point)) { return false; } @@ -156,9 +156,9 @@ extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { // is filled in), or false otherwise. //////////////////////////////////////////////////////////////////// bool FisheyeLens:: -project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { +project_impl(const LPoint3 &point3d, LPoint3 &point2d) const { // First, account for any rotations, etc. on the lens. - LVector3f v2 = point3d * get_lens_mat_inv(); + LVector3 v2 = point3d * get_lens_mat_inv(); // A fisheye lens projection has the property that the distance from // the center point to any other point on the projection is @@ -168,16 +168,16 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // First, get the straight-line distance from the lens, and use it // to normalize the vector. - float dist = v2.length(); + PN_stdfloat dist = v2.length(); v2 /= dist; // Now, project the point into the XZ plane and measure its angle // to the Z axis. This is the same angle it will have to the // vertical axis on the film. - LVector2f y(v2[0], v2[2]); + LVector2 y(v2[0], v2[2]); y.normalize(); - if (y == LVector2f(0.0f, 0.0f)) { + if (y == LVector2(0.0f, 0.0f)) { // Special case. This point is either directly ahead or directly // behind. point2d.set(0.0f, 0.0f, @@ -187,14 +187,14 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // Now bring the vector into the YZ plane by rotating about the Y // axis. - LVector2f x(v2[1], v2[0]*y[0]+v2[2]*y[1]); + LVector2 x(v2[1], v2[0]*y[0]+v2[2]*y[1]); // Now the angle of x to the forward vector represents the distance // along the great circle to the point. - float r = 90.0f - rad_2_deg(catan2(x[0], x[1])); + PN_stdfloat r = 90.0f - rad_2_deg(catan2(x[0], x[1])); - float focal_length = get_focal_length(); - float factor = r * focal_length / fisheye_k; + PN_stdfloat focal_length = get_focal_length(); + PN_stdfloat factor = r * focal_length / fisheye_k; point2d.set (y[0] * factor, @@ -221,8 +221,8 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float FisheyeLens:: -fov_to_film(float fov, float focal_length, bool) const { +PN_stdfloat FisheyeLens:: +fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / fisheye_k; } @@ -235,8 +235,8 @@ fov_to_film(float fov, float focal_length, bool) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float FisheyeLens:: -fov_to_focal_length(float fov, float film_size, bool) const { +PN_stdfloat FisheyeLens:: +fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * fisheye_k / fov; } @@ -249,8 +249,8 @@ fov_to_focal_length(float fov, float film_size, bool) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float FisheyeLens:: -film_to_fov(float film_size, float focal_length, bool) const { +PN_stdfloat FisheyeLens:: +film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * fisheye_k / focal_length; } diff --git a/panda/src/distort/fisheyeLens.h b/panda/src/distort/fisheyeLens.h index 4db33a8ab9..6ae27b5ee4 100644 --- a/panda/src/distort/fisheyeLens.h +++ b/panda/src/distort/fisheyeLens.h @@ -39,14 +39,14 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool extrude_impl(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - virtual bool extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const; - virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const; + virtual bool extrude_impl(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + virtual bool extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const; + virtual bool project_impl(const LPoint3 &point3d, LPoint3 &point2d) const; - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; public: virtual TypeHandle get_type() const { diff --git a/panda/src/distort/oSphereLens.cxx b/panda/src/distort/oSphereLens.cxx index f006881849..fd084e09f2 100755 --- a/panda/src/distort/oSphereLens.cxx +++ b/panda/src/distort/oSphereLens.cxx @@ -19,7 +19,7 @@ TypeHandle OSphereLens::_type_handle; // This is the focal-length constant for fisheye lenses. See // fisheyeLens.cxx. -static const float ospherical_k = 60.0f; +static const PN_stdfloat ospherical_k = 60.0f; // focal_length = film_size * ospherical_k / fov; @@ -51,19 +51,19 @@ make_copy() const { // otherwise. //////////////////////////////////////////////////////////////////// bool OSphereLens:: -extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { +extrude_impl(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { // Undo the shifting from film offsets, etc. This puts the point // into the range [-film_size/2, film_size/2] in x and y. - LPoint3f f = point2d * get_film_mat_inv(); + LPoint3 f = point2d * get_film_mat_inv(); - float focal_length = get_focal_length(); - float angle = f[0] * cylindrical_k / focal_length; - float sinAngle, cosAngle; + PN_stdfloat focal_length = get_focal_length(); + PN_stdfloat angle = f[0] * cylindrical_k / focal_length; + PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); // Define a unit vector that represents the vector corresponding to // this point. - LPoint3f v(sinAngle, cosAngle, 0.0f); + LPoint3 v(sinAngle, cosAngle, 0.0f); near_point = (v * get_near()); far_point = (v * get_far()); @@ -72,7 +72,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // And we'll need to account for the lens's rotations, etc. at the // end of the day. - const LMatrix4f &lens_mat = get_lens_mat(); + const LMatrix4 &lens_mat = get_lens_mat(); near_point = near_point * lens_mat; far_point = far_point * lens_mat; @@ -97,23 +97,23 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // is filled in), or false otherwise. //////////////////////////////////////////////////////////////////// bool OSphereLens:: -project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { +project_impl(const LPoint3 &point3d, LPoint3 &point2d) const { // First, account for any rotations, etc. on the lens. - LPoint3f p = point3d * get_lens_mat_inv(); - float dist = p.length(); + LPoint3 p = point3d * get_lens_mat_inv(); + PN_stdfloat dist = p.length(); if (dist == 0.0f) { point2d.set(0.0f, 0.0f, 0.0f); return false; } - LPoint3f v3 = p / dist; + LPoint3 v3 = p / dist; - float focal_length = get_focal_length(); + PN_stdfloat focal_length = get_focal_length(); // To compute the x position on the frame, we only need to consider // the angle of the vector about the Z axis. Project the vector // into the XY plane to do this. - LVector2f xy(v3[0], v3[1]); + LVector2 xy(v3[0], v3[1]); point2d.set ( @@ -144,8 +144,8 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float OSphereLens:: -fov_to_film(float fov, float focal_length, bool) const { +PN_stdfloat OSphereLens:: +fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / ospherical_k; } @@ -158,8 +158,8 @@ fov_to_film(float fov, float focal_length, bool) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float OSphereLens:: -fov_to_focal_length(float fov, float film_size, bool) const { +PN_stdfloat OSphereLens:: +fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * ospherical_k / fov; } @@ -172,7 +172,7 @@ fov_to_focal_length(float fov, float film_size, bool) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float OSphereLens:: -film_to_fov(float film_size, float focal_length, bool) const { +PN_stdfloat OSphereLens:: +film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * ospherical_k / focal_length; } diff --git a/panda/src/distort/oSphereLens.h b/panda/src/distort/oSphereLens.h index f3537a1f19..ee400f9267 100755 --- a/panda/src/distort/oSphereLens.h +++ b/panda/src/distort/oSphereLens.h @@ -43,13 +43,13 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool extrude_impl(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const; + virtual bool extrude_impl(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + virtual bool project_impl(const LPoint3 &point3d, LPoint3 &point2d) const; - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; public: virtual TypeHandle get_type() const { diff --git a/panda/src/distort/pSphereLens.cxx b/panda/src/distort/pSphereLens.cxx index de229de62c..d159abb7fe 100644 --- a/panda/src/distort/pSphereLens.cxx +++ b/panda/src/distort/pSphereLens.cxx @@ -19,7 +19,7 @@ TypeHandle PSphereLens::_type_handle; // This is the focal-length constant for fisheye lenses. See // fisheyeLens.cxx. -static const float pspherical_k = 60.0f; +static const PN_stdfloat pspherical_k = 60.0f; //////////////////////////////////////////////////////////////////// @@ -50,22 +50,22 @@ make_copy() const { // otherwise. //////////////////////////////////////////////////////////////////// bool PSphereLens:: -extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { +extrude_impl(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { // Undo the shifting from film offsets, etc. This puts the point // into the range [-film_size/2, film_size/2] in x and y. - LPoint3f f = point2d * get_film_mat_inv(); + LPoint3 f = point2d * get_film_mat_inv(); - float focal_length = get_focal_length(); + PN_stdfloat focal_length = get_focal_length(); // Rotate the forward vector through the rotation angles // corresponding to this point. - LPoint3f v = LPoint3f(0.0f, 1.0f, 0.0f) * - LMatrix3f::rotate_mat(f[1] * pspherical_k / focal_length, LVector3f(1.0f, 0.0f, 0.0f)) * - LMatrix3f::rotate_mat(f[0] * pspherical_k / focal_length, LVector3f(0.0f, 0.0f, -1.0f)); + LPoint3 v = LPoint3(0.0f, 1.0f, 0.0f) * + LMatrix3::rotate_mat(f[1] * pspherical_k / focal_length, LVector3(1.0f, 0.0f, 0.0f)) * + LMatrix3::rotate_mat(f[0] * pspherical_k / focal_length, LVector3(0.0f, 0.0f, -1.0f)); // And we'll need to account for the lens's rotations, etc. at the // end of the day. - const LMatrix4f &lens_mat = get_lens_mat(); + const LMatrix4 &lens_mat = get_lens_mat(); near_point = (v * get_near()) * lens_mat; far_point = (v * get_far()) * lens_mat; @@ -90,10 +90,10 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // is filled in), or false otherwise. //////////////////////////////////////////////////////////////////// bool PSphereLens:: -project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { +project_impl(const LPoint3 &point3d, LPoint3 &point2d) const { // First, account for any rotations, etc. on the lens. - LVector3f v3 = point3d * get_lens_mat_inv(); - float dist = v3.length(); + LVector3 v3 = point3d * get_lens_mat_inv(); + PN_stdfloat dist = v3.length(); if (dist == 0.0f) { point2d.set(0.0f, 0.0f, 0.0f); return false; @@ -101,12 +101,12 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { v3 /= dist; - float focal_length = get_focal_length(); + PN_stdfloat focal_length = get_focal_length(); // To compute the x position on the frame, we only need to consider // the angle of the vector about the Z axis. Project the vector // into the XY plane to do this. - LVector2f xy(v3[0], v3[1]); + LVector2 xy(v3[0], v3[1]); // Unroll the Z angle, and the y position is the angle about the X // axis. @@ -141,8 +141,8 @@ project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PSphereLens:: -fov_to_film(float fov, float focal_length, bool) const { +PN_stdfloat PSphereLens:: +fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / pspherical_k; } @@ -155,8 +155,8 @@ fov_to_film(float fov, float focal_length, bool) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PSphereLens:: -fov_to_focal_length(float fov, float film_size, bool) const { +PN_stdfloat PSphereLens:: +fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * pspherical_k / fov; } @@ -169,7 +169,7 @@ fov_to_focal_length(float fov, float film_size, bool) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PSphereLens:: -film_to_fov(float film_size, float focal_length, bool) const { +PN_stdfloat PSphereLens:: +film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * pspherical_k / focal_length; } diff --git a/panda/src/distort/pSphereLens.h b/panda/src/distort/pSphereLens.h index b27dbf7843..1ef91fee20 100644 --- a/panda/src/distort/pSphereLens.h +++ b/panda/src/distort/pSphereLens.h @@ -47,13 +47,13 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool extrude_impl(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const; + virtual bool extrude_impl(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + virtual bool project_impl(const LPoint3 &point3d, LPoint3 &point2d) const; - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; public: virtual TypeHandle get_type() const { diff --git a/panda/src/distort/projectionScreen.I b/panda/src/distort/projectionScreen.I index ca6deb13c6..d354a4e97d 100644 --- a/panda/src/distort/projectionScreen.I +++ b/panda/src/distort/projectionScreen.I @@ -128,7 +128,7 @@ get_vignette_on() const { // set_vignette_on(). //////////////////////////////////////////////////////////////////// INLINE void ProjectionScreen:: -set_vignette_color(const Colorf &vignette_color) { +set_vignette_color(const LColor &vignette_color) { _vignette_color = vignette_color; _stale = true; } @@ -140,7 +140,7 @@ set_vignette_color(const Colorf &vignette_color) { // portions outside of the lens' frustum. See // set_vignette_color(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &ProjectionScreen:: +INLINE const LColor &ProjectionScreen:: get_vignette_color() const { return _vignette_color; } @@ -155,7 +155,7 @@ get_vignette_color() const { // set_vignette_on(). //////////////////////////////////////////////////////////////////// INLINE void ProjectionScreen:: -set_frame_color(const Colorf &frame_color) { +set_frame_color(const LColor &frame_color) { _frame_color = frame_color; _stale = true; } @@ -167,7 +167,7 @@ set_frame_color(const Colorf &frame_color) { // portions outside of the lens' frustum. See // set_frame_color(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &ProjectionScreen:: +INLINE const LColor &ProjectionScreen:: get_frame_color() const { return _frame_color; } diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 6a0bb250dc..09f3100574 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -175,8 +175,8 @@ set_projector(const NodePath &projector) { //////////////////////////////////////////////////////////////////// PT(GeomNode) ProjectionScreen:: generate_screen(const NodePath &projector, const string &screen_name, - int num_x_verts, int num_y_verts, float distance, - float fill_ratio) { + int num_x_verts, int num_y_verts, PN_stdfloat distance, + PN_stdfloat fill_ratio) { nassertr(!projector.is_empty() && projector.node()->is_of_type(LensNode::get_class_type()), NULL); @@ -184,7 +184,7 @@ generate_screen(const NodePath &projector, const string &screen_name, nassertr(projector_node->get_lens() != NULL, NULL); // First, get the relative coordinate space of the projector. - LMatrix4f rel_mat; + LMatrix4 rel_mat; NodePath this_np(this); rel_mat = projector.get_transform(this_np)->get_mat(); @@ -195,10 +195,10 @@ generate_screen(const NodePath &projector, const string &screen_name, // in order from left to right and bottom to top. int num_verts = num_x_verts * num_y_verts; Lens *lens = projector_node->get_lens(); - float t = (distance - lens->get_near()) / (lens->get_far() - lens->get_near()); + PN_stdfloat t = (distance - lens->get_near()) / (lens->get_far() - lens->get_near()); - float x_scale = 2.0f / (num_x_verts - 1); - float y_scale = 2.0f / (num_y_verts - 1); + PN_stdfloat x_scale = 2.0f / (num_x_verts - 1); + PN_stdfloat y_scale = 2.0f / (num_y_verts - 1); PT(GeomVertexData) vdata = new GeomVertexData ("projectionScreen", GeomVertexFormat::get_v3n3(), @@ -208,23 +208,23 @@ generate_screen(const NodePath &projector, const string &screen_name, for (int yi = 0; yi < num_y_verts; yi++) { for (int xi = 0; xi < num_x_verts; xi++) { - LPoint2f film = LPoint2f((float)xi * x_scale - 1.0f, - (float)yi * y_scale - 1.0f); + LPoint2 film = LPoint2((PN_stdfloat)xi * x_scale - 1.0f, + (PN_stdfloat)yi * y_scale - 1.0f); // Reduce the image by the fill ratio. film *= fill_ratio; - LPoint3f near_point, far_point; + LPoint3 near_point, far_point; lens->extrude(film, near_point, far_point); - LPoint3f point = near_point + t * (far_point - near_point); + LPoint3 point = near_point + t * (far_point - near_point); // Normals aren't often needed on projection screens, but you // never know. - LVector3f norm; + LVector3 norm; lens->extrude_vec(film, norm); - vertex.add_data3f(point * rel_mat); - normal.add_data3f(-normalize(norm * rel_mat)); + vertex.add_data3(point * rel_mat); + normal.add_data3(-normalize(norm * rel_mat)); } } nassertr(vdata->get_num_rows() == num_verts, NULL); @@ -264,8 +264,8 @@ generate_screen(const NodePath &projector, const string &screen_name, //////////////////////////////////////////////////////////////////// void ProjectionScreen:: regenerate_screen(const NodePath &projector, const string &screen_name, - int num_x_verts, int num_y_verts, float distance, - float fill_ratio) { + int num_x_verts, int num_y_verts, PN_stdfloat distance, + PN_stdfloat fill_ratio) { // First, remove all existing children. remove_all_children(); @@ -309,7 +309,7 @@ make_flat_mesh(const NodePath &this_np, const NodePath &camera) { PT(PandaNode) top = new PandaNode(get_name()); - LMatrix4f rel_mat; + LMatrix4 rel_mat; bool computed_rel_mat = false; make_mesh_children(top, this_np, camera, rel_mat, computed_rel_mat); @@ -356,7 +356,7 @@ recompute_if_stale(const NodePath &this_np) { } else { // Get the relative transform to ensure it hasn't changed. CPT(TransformState) transform = this_np.get_transform(_projector); - const LMatrix4f &top_mat = transform->get_mat(); + const LMatrix4 &top_mat = transform->get_mat(); if (!_rel_top_mat.almost_equal(top_mat)) { _rel_top_mat = top_mat; _computed_rel_top_mat = true; @@ -394,7 +394,7 @@ do_recompute(const NodePath &this_np) { // encountered, a new relative matrix is computed. //////////////////////////////////////////////////////////////////// void ProjectionScreen:: -recompute_node(const WorkingNodePath &np, LMatrix4f &rel_mat, +recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { PandaNode *node = np.node(); if (node->is_geom_node()) { @@ -430,7 +430,7 @@ recompute_node(const WorkingNodePath &np, LMatrix4f &rel_mat, // of a given node. //////////////////////////////////////////////////////////////////// void ProjectionScreen:: -recompute_child(const WorkingNodePath &np, LMatrix4f &rel_mat, +recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { PandaNode *child = np.node(); @@ -438,7 +438,7 @@ recompute_child(const WorkingNodePath &np, LMatrix4f &rel_mat, if (!transform->is_identity()) { // This child node has a transform; therefore, we must recompute // the relative matrix from this point. - LMatrix4f new_rel_mat; + LMatrix4 new_rel_mat; bool computed_new_rel_mat = false; if (distort_cat.is_spam()) { @@ -461,7 +461,7 @@ recompute_child(const WorkingNodePath &np, LMatrix4f &rel_mat, // Description: Recomputes the UV's just for the indicated GeomNode. //////////////////////////////////////////////////////////////////// void ProjectionScreen:: -recompute_geom_node(const WorkingNodePath &np, LMatrix4f &rel_mat, +recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { GeomNode *node = DCAST(GeomNode, np.node()); if (!computed_rel_mat) { @@ -496,14 +496,14 @@ recompute_geom_node(const WorkingNodePath &np, LMatrix4f &rel_mat, // Description: Recomputes the UV's just for the indicated Geom. //////////////////////////////////////////////////////////////////// void ProjectionScreen:: -recompute_geom(Geom *geom, const LMatrix4f &rel_mat) { - static const LMatrix4f lens_to_uv +recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { + static const LMatrix4 lens_to_uv (0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f); - static const LMatrix4f lens_to_uv_inverted + static const LMatrix4 lens_to_uv_inverted (0.5f, 0.0f, 0.0f, 0.0f, 0.0f,-0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, @@ -514,7 +514,7 @@ recompute_geom(Geom *geom, const LMatrix4f &rel_mat) { Lens *lens = _projector_node->get_lens(); nassertv(lens != (Lens *)NULL); - const LMatrix4f &to_uv = _invert_uvs ? lens_to_uv_inverted : lens_to_uv; + const LMatrix4 &to_uv = _invert_uvs ? lens_to_uv_inverted : lens_to_uv; // Iterate through all the vertices in the Geom. @@ -522,7 +522,7 @@ recompute_geom(Geom *geom, const LMatrix4f &rel_mat) { if (!vdata->has_column(_texcoord_name)) { // We need to add a new column for the new texcoords. vdata = vdata->replace_column - (_texcoord_name, 3, Geom::NT_float32, Geom::C_texcoord); + (_texcoord_name, 3, Geom::NT_stdfloat, Geom::C_texcoord); geom->set_vertex_data(vdata); } if (_vignette_on && !vdata->has_column(InternalName::get_color())) { @@ -549,23 +549,23 @@ recompute_geom(Geom *geom, const LMatrix4f &rel_mat) { } while (!vertex.is_at_end()) { - Vertexf vert = vertex.get_data3f(); + LVertex vert = vertex.get_data3(); // For each vertex, project to the film plane. - LPoint3f film(0.0f, 0.0f, 0.0f); + LPoint3 film(0.0f, 0.0f, 0.0f); bool good = lens->project(vert * rel_mat, film); // Now the lens gives us coordinates in the range [-1, 1]. // Rescale these to [0, 1]. - texcoord.set_data3f(film * to_uv); + texcoord.set_data3(film * to_uv); // If we have vignette color in effect, color the vertex according // to whether it fell in front of the lens or not. if (_vignette_on) { if (good) { - color.set_data4f(_frame_color); + color.set_data4(_frame_color); } else { - color.set_data4f(_vignette_color); + color.set_data4(_vignette_color); } } } @@ -583,7 +583,7 @@ recompute_geom(Geom *geom, const LMatrix4f &rel_mat) { PandaNode *ProjectionScreen:: make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, bool &computed_rel_mat) { + LMatrix4 &rel_mat, bool &computed_rel_mat) { PandaNode *node = np.node(); if (!node->safe_to_flatten()) { // If we can't safely flatten this node, ignore it (and all of its @@ -613,7 +613,7 @@ make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, void ProjectionScreen:: make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, bool &computed_rel_mat) { + LMatrix4 &rel_mat, bool &computed_rel_mat) { PandaNode *node = np.node(); int num_children = node->get_num_children(); for (int i = 0; i < num_children; i++) { @@ -624,7 +624,7 @@ make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, if (!transform->is_identity()) { // This child node has a transform; therefore, we must recompute // the relative matrix from this point. - LMatrix4f new_rel_mat; + LMatrix4 new_rel_mat; bool computed_new_rel_mat = false; new_child = make_mesh_node(new_node, WorkingNodePath(np, child), camera, new_rel_mat, computed_new_rel_mat); @@ -651,7 +651,7 @@ make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, //////////////////////////////////////////////////////////////////// PT(GeomNode) ProjectionScreen:: make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, bool &computed_rel_mat) { + LMatrix4 &rel_mat, bool &computed_rel_mat) { GeomNode *node = DCAST(GeomNode, np.node()); PT(GeomNode) new_node = new GeomNode(node->get_name()); LensNode *lens_node = DCAST(LensNode, camera.node()); @@ -685,20 +685,20 @@ make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, // that involves an unprojectable vertex is eliminated. //////////////////////////////////////////////////////////////////// PT(Geom) ProjectionScreen:: -make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4f &rel_mat) { +make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat) { PT(Geom) new_geom = geom->make_copy(); GeomVertexRewriter vertex(new_geom->modify_vertex_data(), InternalName::get_vertex()); while (!vertex.is_at_end()) { - Vertexf vert = vertex.get_data3f(); + LVertex vert = vertex.get_data3(); // Project each vertex into the film plane, but use three // dimensions so the Z coordinate remains meaningful. - LPoint3f film(0.0f, 0.0f, 0.0f); + LPoint3 film(0.0f, 0.0f, 0.0f); lens->project(vert * rel_mat, film); - vertex.set_data3f(film); + vertex.set_data3(film); } return new_geom; diff --git a/panda/src/distort/projectionScreen.h b/panda/src/distort/projectionScreen.h index f8910ba4b1..18d8be1c52 100644 --- a/panda/src/distort/projectionScreen.h +++ b/panda/src/distort/projectionScreen.h @@ -70,10 +70,10 @@ PUBLISHED: PT(GeomNode) generate_screen(const NodePath &projector, const string &screen_name, int num_x_verts, int num_y_verts, - float distance, float fill_ratio); + PN_stdfloat distance, PN_stdfloat fill_ratio); void regenerate_screen(const NodePath &projector, const string &screen_name, - int num_x_verts, int num_y_verts, float distance, - float fill_ratio); + int num_x_verts, int num_y_verts, PN_stdfloat distance, + PN_stdfloat fill_ratio); PT(PandaNode) make_flat_mesh(const NodePath &this_np, const NodePath &camera); INLINE void set_texcoord_name(const string &texcoord_name); @@ -85,10 +85,10 @@ PUBLISHED: INLINE void set_vignette_on(bool vignette_on); INLINE bool get_vignette_on() const; - INLINE void set_vignette_color(const Colorf &vignette_color); - INLINE const Colorf &get_vignette_color() const; - INLINE void set_frame_color(const Colorf &frame_color); - INLINE const Colorf &get_frame_color() const; + INLINE void set_vignette_color(const LColor &vignette_color); + INLINE const LColor &get_vignette_color() const; + INLINE void set_frame_color(const LColor &frame_color); + INLINE const LColor &get_frame_color() const; void recompute(); @@ -98,23 +98,23 @@ public: private: void do_recompute(const NodePath &this_np); - void recompute_node(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat); - void recompute_child(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat); - void recompute_geom_node(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat); - void recompute_geom(Geom *geom, const LMatrix4f &rel_mat); + void recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat); + void recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat); + void recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat); + void recompute_geom(Geom *geom, const LMatrix4 &rel_mat); PandaNode * make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, bool &computed_rel_mat); + LMatrix4 &rel_mat, bool &computed_rel_mat); void make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, bool &computed_rel_mat); + LMatrix4 &rel_mat, bool &computed_rel_mat); PT(GeomNode) make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, - LMatrix4f &rel_mat, + LMatrix4 &rel_mat, bool &computed_rel_mat); - PT(Geom) make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4f &rel_mat); + PT(Geom) make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat); NodePath _projector; @@ -122,10 +122,10 @@ private: PT(InternalName) _texcoord_name; bool _invert_uvs; bool _vignette_on; - Colorf _vignette_color; - Colorf _frame_color; + LColor _vignette_color; + LColor _frame_color; - LMatrix4f _rel_top_mat; + LMatrix4 _rel_top_mat; bool _computed_rel_top_mat; bool _stale; UpdateSeq _projector_lens_change; diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index 4df8aaafe2..7f8739f55b 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -244,7 +244,7 @@ decompress(Ramfile &source_and_dest_file) { // Description: Returns the ratio through the decompression step // in the background. //////////////////////////////////////////////////////////////////// -float Decompressor:: +PN_stdfloat Decompressor:: get_progress() const { if (_decompress == (istream *)NULL) { // Hmm, we were already done. @@ -256,7 +256,7 @@ get_progress() const { // We stop the scale at 0.99 because there may be a little bit more // to do even after the decompressor has read all of the source. - return (0.99f * (float)source_pos / (float)_source_length); + return (0.99f * (PN_stdfloat)source_pos / (PN_stdfloat)_source_length); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/downloader/decompressor.h b/panda/src/downloader/decompressor.h index a80641ee8d..e84c1c561d 100644 --- a/panda/src/downloader/decompressor.h +++ b/panda/src/downloader/decompressor.h @@ -41,7 +41,7 @@ PUBLISHED: bool decompress(const Filename &source_file); bool decompress(Ramfile &source_and_dest_file); - float get_progress() const; + PN_stdfloat get_progress() const; private: void cleanup(); diff --git a/panda/src/downloader/downloadDb.h b/panda/src/downloader/downloadDb.h index ff36191e0f..37fbcbfca4 100644 --- a/panda/src/downloader/downloadDb.h +++ b/panda/src/downloader/downloadDb.h @@ -29,7 +29,7 @@ class StreamReader; class StreamWriter; -typedef float Phase; +typedef PN_stdfloat Phase; class Ramfile; /* diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 1de3bdb64e..210e7fca48 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -266,7 +266,7 @@ step() { // Description: Returns the fraction of the Multifile extracted so // far. //////////////////////////////////////////////////////////////////// -float Extractor:: +PN_stdfloat Extractor:: get_progress() const { if (!_initiated) { return 0.0f; @@ -275,7 +275,7 @@ get_progress() const { return 1.0f; } - return (float)_total_bytes_extracted / (float)_requests_total_length; + return (PN_stdfloat)_total_bytes_extracted / (PN_stdfloat)_requests_total_length; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/downloader/extractor.h b/panda/src/downloader/extractor.h index 59856282e1..c25185ad54 100644 --- a/panda/src/downloader/extractor.h +++ b/panda/src/downloader/extractor.h @@ -50,7 +50,7 @@ PUBLISHED: int request_all_subfiles(); int step(); - float get_progress() const; + PN_stdfloat get_progress() const; bool run(); diff --git a/panda/src/downloader/patcher.I b/panda/src/downloader/patcher.I index 632fec7065..494375e3c2 100644 --- a/panda/src/downloader/patcher.I +++ b/panda/src/downloader/patcher.I @@ -17,7 +17,7 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE float Patcher:: +INLINE PN_stdfloat Patcher:: get_progress() const { if(_patchfile) { return _patchfile->get_progress(); diff --git a/panda/src/downloader/patcher.h b/panda/src/downloader/patcher.h index ae9a1d21fe..6404a17545 100644 --- a/panda/src/downloader/patcher.h +++ b/panda/src/downloader/patcher.h @@ -36,7 +36,7 @@ PUBLISHED: int initiate(Filename &patch, Filename &infile); int run(); - INLINE float get_progress() const; + INLINE PN_stdfloat get_progress() const; private: void init(PT(Buffer) buffer); diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I index 08204e2ba9..c0c8401076 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I @@ -14,13 +14,13 @@ //////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian8::Colorf_to_D3DCOLOR +// Function: DXGraphicsStateGuardian8::LColor_to_D3DCOLOR // Access: Public, Static -// Description: Converts Panda's floating-point Colorf structure to +// Description: Converts Panda's floating-point LColor structure to // DirectX's D3DCOLOR packed structure. //////////////////////////////////////////////////////////////////// INLINE DWORD DXGraphicsStateGuardian8:: -Colorf_to_D3DCOLOR(const Colorf &cColorf) { +LColor_to_D3DCOLOR(const LColor &cLColor) { // MS VC defines _M_IX86 for x86. gcc should define _X86_ #if defined(_M_IX86) || defined(_X86_) DWORD d3dcolor, tempcolorval=255; @@ -31,7 +31,7 @@ Colorf_to_D3DCOLOR(const Colorf &cColorf) { __asm { push ebx ; want to save this in case this fn is inlined push ecx - mov ecx, cColorf + mov ecx, cLColor fild tempcolorval fld DWORD PTR [ecx] fmul ST(0), ST(1) @@ -68,7 +68,7 @@ Colorf_to_D3DCOLOR(const Colorf &cColorf) { // dxgsg8_cat.debug() << (void*)d3dcolor << endl; return d3dcolor; #else //!_X86_ - return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]); + return MY_D3DRGBA(cLColor[0], cLColor[1], cLColor[2], cLColor[3]); #endif //!_X86_ } diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index b34eda4bf0..cf4b8afb94 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -72,7 +72,7 @@ D3DMATRIX DXGraphicsStateGuardian8::_d3d_ident_mat; unsigned char *DXGraphicsStateGuardian8::_temp_buffer = NULL; unsigned char *DXGraphicsStateGuardian8::_safe_buffer_start = NULL; -#define __D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX)) //for some reason this is missing in dx8 hdrs +#define __D3DLIGHT_RANGE_MAX ((PN_stdfloat)sqrt(FLT_MAX)) //for some reason this is missing in dx8 hdrs #define MY_D3DRGBA(r, g, b, a) ((D3DCOLOR) D3DCOLOR_COLORVALUE(r, g, b, a)) @@ -202,7 +202,7 @@ apply_texture(int i, TextureContext *tc) { _d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSW, get_texture_wrap_mode(wrap_w)); _d3d_device->SetTextureStageState(i, D3DTSS_BORDERCOLOR, - Colorf_to_D3DCOLOR(tex->get_border_color())); + LColor_to_D3DCOLOR(tex->get_border_color())); uint aniso_degree = tex->get_effective_anisotropic_degree(); Texture::FilterType ft = tex->get_effective_magfilter(); @@ -575,8 +575,8 @@ clear(DrawableRegion *clearable) { DWORD main_flags = 0; DWORD aux_flags = 0; - D3DCOLOR color_clear_value = Colorf_to_D3DCOLOR(clearable->get_clear_color()); - float depth_clear_value = clearable->get_clear_depth(); + D3DCOLOR color_clear_value = LColor_to_D3DCOLOR(clearable->get_clear_color()); + PN_stdfloat depth_clear_value = clearable->get_clear_depth(); DWORD stencil_clear_value = (DWORD)(clearable->get_clear_stencil()); //set appropriate flags @@ -689,21 +689,21 @@ calc_projection_mat(const Lens *lens) { // DirectX also uses a Z range of 0 to 1, whereas the Panda // convention is for the projection matrix to produce a Z range of // -1 to 1. We have to rescale to compensate. - static const LMatrix4f rescale_mat + static const LMatrix4 rescale_mat (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1); - LMatrix4f result = - LMatrix4f::convert_mat(CS_yup_left, _current_lens->get_coordinate_system()) * + LMatrix4 result = + LMatrix4::convert_mat(CS_yup_left, _current_lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel) * rescale_mat; if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the // projection matrix. - result *= LMatrix4f::scale_mat(1.0f, -1.0f, 1.0f); + result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); @@ -929,7 +929,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, const TransformTable *table = data_reader->get_transform_table(); if (table != (TransformTable *)NULL) { for (int i = 0; i < table->get_num_transforms(); i++) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); const D3DMATRIX *d3d_mat = (const D3DMATRIX *)mat.get_data(); _d3d_device->SetTransform(D3DTS_WORLDMATRIX(i), d3d_mat); @@ -966,7 +966,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // we want: that also prevents lighting calculations and user clip // planes. _d3d_device->SetTransform(D3DTS_WORLD, &_d3d_ident_mat); - static const LMatrix4f rescale_mat + static const LMatrix4 rescale_mat (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, @@ -2090,7 +2090,7 @@ apply_fog(Fog *fog) { _d3d_device->SetRenderState((D3DRENDERSTATETYPE)_do_fog_type, d3dfogmode); - const Colorf &fog_colr = fog->get_color(); + const LColor &fog_colr = fog->get_color(); _d3d_device->SetRenderState(D3DRS_FOGCOLOR, MY_D3DRGBA(fog_colr[0], fog_colr[1], fog_colr[2], 0.0f)); // Alpha bits are not used @@ -2100,7 +2100,7 @@ apply_fog(Fog *fog) { switch (panda_fogmode) { case Fog::M_linear: { - float onset, opaque; + PN_stdfloat onset, opaque; fog->get_linear_range(onset, opaque); _d3d_device->SetRenderState(D3DRS_FOGSTART, @@ -2113,7 +2113,7 @@ apply_fog(Fog *fog) { case Fog::M_exponential_squared: { // Exponential fog is always camera-relative. - float fog_density = fog->get_exp_density(); + PN_stdfloat fog_density = fog->get_exp_density(); _d3d_device->SetRenderState(D3DRS_FOGDENSITY, *((LPDWORD) (&fog_density))); } @@ -2195,18 +2195,18 @@ do_issue_render_mode() { } // This might also specify the point size. - float point_size = target_render_mode->get_thickness(); + PN_stdfloat point_size = target_render_mode->get_thickness(); _d3d_device->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&point_size)); if (target_render_mode->get_perspective()) { _d3d_device->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE); - LVector3f height(0.0f, point_size, 1.0f); + LVector3 height(0.0f, point_size, 1.0f); height = height * _projection_mat->get_mat(); - float s = height[1] / point_size; + PN_stdfloat s = height[1] / point_size; - float zero = 0.0f; - float one_over_s2 = 1.0f / (s * s); + PN_stdfloat zero = 0.0f; + PN_stdfloat one_over_s2 = 1.0f / (s * s); _d3d_device->SetRenderState(D3DRS_POINTSCALE_A, *((DWORD*)&zero)); _d3d_device->SetRenderState(D3DRS_POINTSCALE_B, *((DWORD*)&zero)); _d3d_device->SetRenderState(D3DRS_POINTSCALE_C, *((DWORD*)&one_over_s2)); @@ -2586,9 +2586,9 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LPoint3f pos = light_obj->get_point() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LPoint3 pos = light_obj->get_point() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -2605,7 +2605,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { alight.Range = __D3DLIGHT_RANGE_MAX; alight.Falloff = 1.0f; - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0]; alight.Attenuation1 = att[1]; alight.Attenuation2 = att[2]; @@ -2638,9 +2638,9 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LVector3f dir = light_obj->get_direction() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LVector3 dir = light_obj->get_direction() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -2691,10 +2691,10 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LPoint3f pos = lens->get_nodal_point() * rel_mat; - LVector3f dir = lens->get_view_vector() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LPoint3 pos = lens->get_nodal_point() * rel_mat; + LVector3 dir = lens->get_view_vector() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -2716,13 +2716,13 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // I determined this formular empirically. It seems to mostly // approximate the OpenGL spotlight equation, for a reasonable range // of values for FOV. - float fov = lens->get_hfov(); + PN_stdfloat fov = lens->get_hfov(); alight.Falloff = light_obj->get_exponent() * (fov * fov * fov) / 1620000.0f; alight.Theta = 0.0f; alight.Phi = deg_2_rad(fov); - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0]; alight.Attenuation1 = att[1]; alight.Attenuation2 = att[2]; @@ -2878,8 +2878,8 @@ do_issue_texture() { // computed by D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, // approximates the effect produced by OpenGL's GL_SPHERE_MAP. static CPT(TransformState) sphere_map = - TransformState::make_mat(LMatrix4f(0.33f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.33f, 0.0f, 0.0f, + TransformState::make_mat(LMatrix4(0.33, 0.0f, 0.0f, 0.0f, + 0.0f, 0.33, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f)); tex_mat = tex_mat->compose(sphere_map); @@ -2897,7 +2897,7 @@ do_issue_texture() { texcoord_index | D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); texcoord_dimensions = 3; CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3f::zero())); + tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3::zero())); } break; @@ -2918,7 +2918,7 @@ do_issue_texture() { texcoord_index | D3DTSS_TCI_CAMERASPACENORMAL); texcoord_dimensions = 3; CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3f::zero())); + tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3::zero())); } break; @@ -2970,10 +2970,10 @@ do_issue_texture() { texcoord_index | D3DTSS_TCI_CAMERASPACEPOSITION); texcoord_dimensions = 3; - const TexCoord3f &v = _target_tex_gen->get_constant_value(stage); + const TexCoord3 &v = _target_tex_gen->get_constant_value(stage); CPT(TransformState) squash = - TransformState::make_pos_hpr_scale(v, LVecBase3f::zero(), - LVecBase3f::zero()); + TransformState::make_pos_hpr_scale(v, LVecBase3::zero(), + LVecBase3::zero()); tex_mat = tex_mat->compose(squash); } break; @@ -2984,7 +2984,7 @@ do_issue_texture() { if (!tex_mat->is_identity()) { if (/*tex_mat->is_2d() &&*/ texcoord_dimensions <= 2) { // For 2-d texture coordinates, we have to reorder the matrix. - LMatrix4f m = tex_mat->get_mat(); + LMatrix4 m = tex_mat->get_mat(); m.set(m(0, 0), m(0, 1), m(0, 3), 0.0f, m(1, 0), m(1, 1), m(1, 3), 0.0f, m(3, 0), m(3, 1), m(3, 3), 0.0f, @@ -2993,10 +2993,10 @@ do_issue_texture() { _d3d_device->SetTextureStageState(si, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); } else { - LMatrix4f m = tex_mat->get_mat(); + LMatrix4 m = tex_mat->get_mat(); _d3d_device->SetTransform(get_tex_mat_sym(si), (D3DMATRIX *)m.get_data()); DWORD transform_flags = texcoord_dimensions; - if (m.get_col(3) != LVecBase4f(0.0f, 0.0f, 0.0f, 1.0f)) { + if (m.get_col(3) != LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)) { // If we have a projected texture matrix, we also need to // set D3DTTFF_COUNT4. transform_flags = D3DTTFF_COUNT4 | D3DTTFF_PROJECTED; @@ -3060,14 +3060,14 @@ enable_lighting(bool enable) { // all other lights have been enabled or disabled. //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian8:: -set_ambient_light(const Colorf &color) { - Colorf c = color; +set_ambient_light(const LColor &color) { + LColor c = color; c.set(c[0] * _light_color_scale[0], c[1] * _light_color_scale[1], c[2] * _light_color_scale[2], c[3] * _light_color_scale[3]); - _d3d_device->SetRenderState(D3DRS_AMBIENT, Colorf_to_D3DCOLOR(c)); + _d3d_device->SetRenderState(D3DRS_AMBIENT, LColor_to_D3DCOLOR(c)); } //////////////////////////////////////////////////////////////////// @@ -3120,11 +3120,11 @@ bind_clip_plane(const NodePath &plane, int plane_id) { // coordinates). This means the plane in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = plane.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &plane_mat = transform->get_mat(); - LMatrix4f rel_mat = plane_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); + const LMatrix4 &plane_mat = transform->get_mat(); + LMatrix4 rel_mat = plane_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); const PlaneNode *plane_node; DCAST_INTO_V(plane_node, plane.node()); - Planef world_plane = plane_node->get_plane() * rel_mat; + LPlane world_plane = plane_node->get_plane() * rel_mat; HRESULT hr = _d3d_device->SetClipPlane(plane_id, world_plane.get_data()); if (FAILED(hr)) { @@ -3358,7 +3358,7 @@ do_auto_rescale_normal() { //////////////////////////////////////////////////////////////////// const D3DCOLORVALUE &DXGraphicsStateGuardian8:: get_light_color(Light *light) const { - static Colorf c; + static LColor c; c = light->get_color(); c.set(c[0] * _light_color_scale[0], c[1] * _light_color_scale[1], @@ -3704,15 +3704,15 @@ set_texture_blend_mode(int i, const TextureStage *stage) { D3DCOLOR texture_factor; if (stage->involves_color_scale() && _color_scale_enabled) { - Colorf color = stage->get_color(); + LColor color = stage->get_color(); color.set(color[0] * _current_color_scale[0], color[1] * _current_color_scale[1], color[2] * _current_color_scale[2], color[3] * _current_color_scale[3]); _texture_involves_color_scale = true; - texture_factor = Colorf_to_D3DCOLOR(color); + texture_factor = LColor_to_D3DCOLOR(color); } else { - texture_factor = Colorf_to_D3DCOLOR(stage->get_color()); + texture_factor = LColor_to_D3DCOLOR(stage->get_color()); } _d3d_device->SetRenderState(D3DRS_TEXTUREFACTOR, texture_factor); } @@ -4461,7 +4461,7 @@ get_d3d_device() { void DXGraphicsStateGuardian8:: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); - const LVecBase4f &frame = target_scissor->get_frame(); + const LVecBase4 &frame = target_scissor->get_frame(); set_scissor(frame[0], frame[1], frame[2], frame[3]); } @@ -4472,7 +4472,7 @@ do_issue_scissor() { // relative to the current viewport. //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian8:: -set_scissor(float left, float right, float bottom, float top) { +set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { // DirectX8 doesn't have an explicit scissor control, independent of // the viewport, so we have to do it by hand, by moving the viewport // smaller but adjusting the projection matrix to compensate. @@ -4510,16 +4510,16 @@ set_scissor(float left, float right, float bottom, float top) { // Now, compute _scissor_mat, which we use to compensate the // projection matrix. - float xsize = right - left; - float ysize = top - bottom; - float xcenter = (left + right) - 1.0f; - float ycenter = (bottom + top) - 1.0f; + PN_stdfloat xsize = right - left; + PN_stdfloat ysize = top - bottom; + PN_stdfloat xcenter = (left + right) - 1.0f; + PN_stdfloat ycenter = (bottom + top) - 1.0f; if (xsize == 0.0f || ysize == 0.0f) { // If the scissor region is zero, nothing will be drawn anyway, so // don't worry about it. _scissor_mat = TransformState::make_identity(); } else { - _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f))); + _scissor_mat = TransformState::make_scale(LVecBase3(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3(-xcenter, -ycenter, 0.0f))); } prepare_lens(); } @@ -4581,7 +4581,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) { static bool _gamma_table_initialized = false; static unsigned short _orignial_gamma_table [256 * 3]; -void _create_gamma_table (float gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; double gamma_correction; @@ -4664,7 +4664,7 @@ get_gamma_table(void) { // for atexit. //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian8:: -static_set_gamma(bool restore, float gamma) { +static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; HDC hdc = GetDC(NULL); @@ -4696,7 +4696,7 @@ static_set_gamma(bool restore, float gamma) { // on success. //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian8:: -set_gamma(float gamma) { +set_gamma(PN_stdfloat gamma) { bool set; set = static_set_gamma(false, gamma); diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h index d8dde0d5c5..765bfd23ad 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.h +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.h @@ -117,15 +117,15 @@ public: int light_id); static D3DFORMAT get_index_type(Geom::NumericType numeric_type); - INLINE static DWORD Colorf_to_D3DCOLOR(const Colorf &cColorf); + INLINE static DWORD LColor_to_D3DCOLOR(const LColor &cLColor); virtual void set_state_and_transform(const RenderState *state, const TransformState *transform); LPDIRECT3DDEVICE8 get_d3d_device(); static bool get_gamma_table(void); - static bool static_set_gamma(bool restore, float gamma); - bool set_gamma(float gamma); + static bool static_set_gamma(bool restore, PN_stdfloat gamma); + bool set_gamma(PN_stdfloat gamma); void restore_gamma(); static void atexit_function(void); @@ -148,12 +148,12 @@ protected: void do_issue_stencil(); void do_issue_scissor(); - void set_scissor(float left, float right, float bottom, float top); + void set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); virtual void reissue_transforms(); virtual void enable_lighting(bool enable); - virtual void set_ambient_light(const Colorf &color); + virtual void set_ambient_light(const LColor &color); virtual void enable_light(int light_id, bool enable); virtual void enable_clip_plane(int plane_id, bool enable); @@ -229,11 +229,11 @@ protected: RenderBuffer::Type _cur_read_pixel_buffer; // source for copy_pixel_buffer operation bool _auto_rescale_normal; - float _material_ambient; - float _material_diffuse; - float _material_specular; - float _material_shininess; - float _material_emission; + PN_stdfloat _material_ambient; + PN_stdfloat _material_diffuse; + PN_stdfloat _material_specular; + PN_stdfloat _material_shininess; + PN_stdfloat _material_emission; enum DxgsgFogType { None, diff --git a/panda/src/dxgsg8/wdxGraphicsPipe8.cxx b/panda/src/dxgsg8/wdxGraphicsPipe8.cxx index cfb9666847..3e0707cb05 100644 --- a/panda/src/dxgsg8/wdxGraphicsPipe8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsPipe8.cxx @@ -666,7 +666,7 @@ search_for_valid_displaymode(DXScreenData &scrn, } bool bIs16bppRenderTgt = IS_16BPP_DISPLAY_FORMAT(dispmode.Format); - float RendTgtMinMemReqmt = 0.0f; + PN_stdfloat RendTgtMinMemReqmt = 0.0f; // if we have a valid memavail value, try to determine if we have // enough space @@ -680,12 +680,12 @@ search_for_valid_displaymode(DXScreenData &scrn, #define REQD_TEXMEM 1800000 - float bytes_per_pixel = (bIs16bppRenderTgt ? 2 : 4); + PN_stdfloat bytes_per_pixel = (bIs16bppRenderTgt ? 2 : 4); // *2 for double buffer RendTgtMinMemReqmt = - ((float)RequestedX_Size) * ((float)RequestedY_Size) * + ((PN_stdfloat)RequestedX_Size) * ((PN_stdfloat)RequestedY_Size) * bytes_per_pixel * 2 + REQD_TEXMEM; if (bVerboseMode || wdxdisplay8_cat.is_spam()) @@ -714,12 +714,12 @@ search_for_valid_displaymode(DXScreenData &scrn, continue; } - float MinMemReqmt = 0.0f; + PN_stdfloat MinMemReqmt = 0.0f; if (bDoMemBasedChecks) { // test memory again, this time including zbuf size - float zbytes_per_pixel = (IS_16BPP_ZBUFFER(zformat) ? 2 : 4); - float MinMemReqmt = RendTgtMinMemReqmt + ((float)RequestedX_Size)*((float)RequestedY_Size)*zbytes_per_pixel; + PN_stdfloat zbytes_per_pixel = (IS_16BPP_ZBUFFER(zformat) ? 2 : 4); + PN_stdfloat MinMemReqmt = RendTgtMinMemReqmt + ((PN_stdfloat)RequestedX_Size)*((PN_stdfloat)RequestedY_Size)*zbytes_per_pixel; if (bVerboseMode || wdxdisplay8_cat.is_spam()) wdxdisplay8_cat.info() diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I index a6ba352cfc..9edbc0104c 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I @@ -14,13 +14,13 @@ //////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::Colorf_to_D3DCOLOR +// Function: DXGraphicsStateGuardian9::LColor_to_D3DCOLOR // Access: Public, Static -// Description: Converts Panda's floating-point Colorf structure to +// Description: Converts Panda's floating-point LColor structure to // DirectX's D3DCOLOR packed structure. //////////////////////////////////////////////////////////////////// INLINE DWORD DXGraphicsStateGuardian9:: -Colorf_to_D3DCOLOR(const Colorf &cColorf) { +LColor_to_D3DCOLOR(const LColor &cLColor) { // MS VC defines _M_IX86 for x86. gcc should define _X86_ #if defined(_M_IX86) || defined(_X86_) DWORD d3dcolor, tempcolorval=255; @@ -31,7 +31,7 @@ Colorf_to_D3DCOLOR(const Colorf &cColorf) { __asm { push ebx ; want to save this in case this fn is inlined push ecx - mov ecx, cColorf + mov ecx, cLColor fild tempcolorval fld DWORD PTR [ecx] fmul ST(0), ST(1) @@ -68,7 +68,7 @@ Colorf_to_D3DCOLOR(const Colorf &cColorf) { // dxgsg9_cat.debug() << (void*)d3dcolor << endl; return d3dcolor; #else //!_X86_ - return D3DCOLOR_COLORVALUE(cColorf[0], cColorf[1], cColorf[2], cColorf[3]); + return D3DCOLOR_COLORVALUE(cLColor[0], cLColor[1], cLColor[2], cLColor[3]); #endif //!_X86_ } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 6a1ecc4180..00e730509e 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -86,7 +86,7 @@ unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = NULL; LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = NULL; -#define __D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX)) //for some reason this is missing in dx9 hdrs +#define __D3DLIGHT_RANGE_MAX ((PN_stdfloat)sqrt(FLT_MAX)) //for some reason this is missing in dx9 hdrs #define MY_D3DRGBA(r, g, b, a) ((D3DCOLOR) D3DCOLOR_COLORVALUE(r, g, b, a)) @@ -242,7 +242,7 @@ apply_texture(int i, TextureContext *tc) { set_sampler_state(i, D3DSAMP_ADDRESSW, address_w); DWORD border_color; - border_color = Colorf_to_D3DCOLOR(tex->get_border_color()); + border_color = LColor_to_D3DCOLOR(tex->get_border_color()); set_sampler_state(i, D3DSAMP_BORDERCOLOR, border_color); @@ -819,8 +819,8 @@ clear(DrawableRegion *clearable) { set_state_and_transform(RenderState::make_empty(), _internal_transform); - D3DCOLOR color_clear_value = Colorf_to_D3DCOLOR(clearable->get_clear_color()); - float depth_clear_value = clearable->get_clear_depth(); + D3DCOLOR color_clear_value = LColor_to_D3DCOLOR(clearable->get_clear_color()); + PN_stdfloat depth_clear_value = clearable->get_clear_depth(); DWORD stencil_clear_value = (DWORD)(clearable->get_clear_stencil()); //set appropriate flags @@ -954,21 +954,21 @@ calc_projection_mat(const Lens *lens) { // DirectX also uses a Z range of 0 to 1, whereas the Panda // convention is for the projection matrix to produce a Z range of // -1 to 1. We have to rescale to compensate. - static const LMatrix4f rescale_mat + static const LMatrix4 rescale_mat (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1); - LMatrix4f result = - LMatrix4f::convert_mat(CS_yup_left, _current_lens->get_coordinate_system()) * + LMatrix4 result = + LMatrix4::convert_mat(CS_yup_left, _current_lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel) * rescale_mat; if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the // projection matrix. - result *= LMatrix4f::scale_mat(1.0f, -1.0f, 1.0f); + result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); @@ -1243,7 +1243,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, const TransformTable *table = data_reader->get_transform_table(); if (table != (TransformTable *)NULL) { for (int i = 0; i < table->get_num_transforms(); i++) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); const D3DMATRIX *d3d_mat = (const D3DMATRIX *)mat.get_data(); _d3d_device->SetTransform(D3DTS_WORLDMATRIX(i), d3d_mat); @@ -1280,7 +1280,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // we want: that also prevents lighting calculations and user clip // planes. _d3d_device->SetTransform(D3DTS_WORLD, &_d3d_ident_mat); - static const LMatrix4f rescale_mat + static const LMatrix4 rescale_mat (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, @@ -2654,10 +2654,10 @@ reset() { if (SUCCEEDED(hr)){ _screen->_supports_rgba16f_texture_format = true; } - _screen->_supports_rgba32f_texture_format = false; + _screen->_supports_rgba32_texture_format = false; hr = _screen->_d3d9->CheckDeviceFormat(_screen->_card_id, D3DDEVTYPE_HAL, _screen->_display_mode.Format, 0x0, D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F); if (SUCCEEDED(hr)){ - _screen->_supports_rgba32f_texture_format = true; + _screen->_supports_rgba32_texture_format = true; } // s3 virge drivers sometimes give crap values for these @@ -2766,7 +2766,7 @@ apply_fog(Fog *fog) { set_render_state((D3DRENDERSTATETYPE)_do_fog_type, d3dfogmode); - const Colorf &fog_colr = fog->get_color(); + const LColor &fog_colr = fog->get_color(); set_render_state(D3DRS_FOGCOLOR, MY_D3DRGBA(fog_colr[0], fog_colr[1], fog_colr[2], 0.0f)); // Alpha bits are not used @@ -2776,7 +2776,7 @@ apply_fog(Fog *fog) { switch (panda_fogmode) { case Fog::M_linear: { - float onset, opaque; + PN_stdfloat onset, opaque; fog->get_linear_range(onset, opaque); set_render_state(D3DRS_FOGSTART, @@ -2789,7 +2789,7 @@ apply_fog(Fog *fog) { case Fog::M_exponential_squared: { // Exponential fog is always camera-relative. - float fog_density = fog->get_exp_density(); + PN_stdfloat fog_density = fog->get_exp_density(); set_render_state(D3DRS_FOGDENSITY, *((LPDWORD) (&fog_density))); } @@ -2826,7 +2826,7 @@ do_issue_transform() { // DEBUG PRINT /* - const float *data; + const PN_stdfloat *data; data = &d3d_mat -> _11; dxgsg9_cat.debug ( ) << "do_issue_transform\n" << data[ 0] << " " << data[ 1] << " " << data[ 2] << " " << data[ 3] << "\n" << @@ -2945,18 +2945,18 @@ do_issue_render_mode() { } // This might also specify the point size. - float point_size = target_render_mode->get_thickness(); + PN_stdfloat point_size = target_render_mode->get_thickness(); set_render_state(D3DRS_POINTSIZE, *((DWORD*)&point_size)); if (target_render_mode->get_perspective()) { set_render_state(D3DRS_POINTSCALEENABLE, TRUE); - LVector3f height(0.0f, point_size, 1.0f); + LVector3 height(0.0f, point_size, 1.0f); height = height * _projection_mat->get_mat(); - float s = height[1] / point_size; + PN_stdfloat s = height[1] / point_size; - float zero = 0.0f; - float one_over_s2 = 1.0f / (s * s); + PN_stdfloat zero = 0.0f; + PN_stdfloat one_over_s2 = 1.0f / (s * s); set_render_state(D3DRS_POINTSCALE_A, *((DWORD*)&zero)); set_render_state(D3DRS_POINTSCALE_B, *((DWORD*)&zero)); set_render_state(D3DRS_POINTSCALE_C, *((DWORD*)&one_over_s2)); @@ -3106,7 +3106,7 @@ do_issue_depth_offset() { // DirectX depth bias isn't directly supported by the driver. // Cheese a depth bias effect by sliding the viewport backward a // bit. - static const float bias_scale = dx_depth_bias_scale; + static const PN_stdfloat bias_scale = dx_depth_bias_scale; D3DVIEWPORT9 vp = _current_viewport; vp.MinZ -= bias_scale * offset; vp.MaxZ -= bias_scale * offset; @@ -3382,9 +3382,9 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LPoint3f pos = light_obj->get_point() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LPoint3 pos = light_obj->get_point() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -3401,7 +3401,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { alight.Range = __D3DLIGHT_RANGE_MAX; alight.Falloff = 1.0f; - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0]; alight.Attenuation1 = att[1]; alight.Attenuation2 = att[2]; @@ -3434,9 +3434,9 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LVector3f dir = light_obj->get_direction() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LVector3 dir = light_obj->get_direction() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -3487,10 +3487,10 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // coordinates). This means the light in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &light_mat = transform->get_mat(); - LMatrix4f rel_mat = light_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); - LPoint3f pos = lens->get_nodal_point() * rel_mat; - LVector3f dir = lens->get_view_vector() * rel_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); + LPoint3 pos = lens->get_nodal_point() * rel_mat; + LVector3 dir = lens->get_view_vector() * rel_mat; D3DCOLORVALUE black; black.r = black.g = black.b = black.a = 0.0f; @@ -3512,13 +3512,13 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // I determined this formular empirically. It seems to mostly // approximate the OpenGL spotlight equation, for a reasonable range // of values for FOV. - float fov = lens->get_hfov(); + PN_stdfloat fov = lens->get_hfov(); alight.Falloff = light_obj->get_exponent() * (fov * fov * fov) / 1620000.0f; alight.Theta = 0.0f; alight.Phi = deg_2_rad(fov); - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); alight.Attenuation0 = att[0]; alight.Attenuation1 = att[1]; alight.Attenuation2 = att[2]; @@ -3734,8 +3734,8 @@ update_standard_texture_bindings() { // computed by D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, // approximates the effect produced by OpenGL's GL_SPHERE_MAP. static CPT(TransformState) sphere_map = - TransformState::make_mat(LMatrix4f(0.33f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.33f, 0.0f, 0.0f, + TransformState::make_mat(LMatrix4(0.33, 0.0f, 0.0f, 0.0f, + 0.0f, 0.33, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f)); tex_mat = tex_mat->compose(sphere_map); @@ -3753,7 +3753,7 @@ update_standard_texture_bindings() { texcoord_index | D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); texcoord_dimensions = 3; CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3f::zero())); + tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3::zero())); } break; @@ -3774,7 +3774,7 @@ update_standard_texture_bindings() { texcoord_index | D3DTSS_TCI_CAMERASPACENORMAL); texcoord_dimensions = 3; CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3f::zero())); + tex_mat = tex_mat->compose(camera_transform->set_pos(LVecBase3::zero())); } break; @@ -3826,10 +3826,10 @@ update_standard_texture_bindings() { texcoord_index | D3DTSS_TCI_CAMERASPACEPOSITION); texcoord_dimensions = 3; - const TexCoord3f &v = _target_tex_gen->get_constant_value(stage); + const TexCoord3 &v = _target_tex_gen->get_constant_value(stage); CPT(TransformState) squash = - TransformState::make_pos_hpr_scale(v, LVecBase3f::zero(), - LVecBase3f::zero()); + TransformState::make_pos_hpr_scale(v, LVecBase3::zero(), + LVecBase3::zero()); tex_mat = tex_mat->compose(squash); } break; @@ -3840,7 +3840,7 @@ update_standard_texture_bindings() { if (!tex_mat->is_identity()) { if (/*tex_mat->is_2d() &&*/ texcoord_dimensions <= 2) { // For 2-d texture coordinates, we have to reorder the matrix. - LMatrix4f m = tex_mat->get_mat(); + LMatrix4 m = tex_mat->get_mat(); m.set(m(0, 0), m(0, 1), m(0, 3), 0.0f, m(1, 0), m(1, 1), m(1, 3), 0.0f, m(3, 0), m(3, 1), m(3, 3), 0.0f, @@ -3849,10 +3849,10 @@ update_standard_texture_bindings() { set_texture_stage_state(si, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); } else { - LMatrix4f m = tex_mat->get_mat(); + LMatrix4 m = tex_mat->get_mat(); _d3d_device->SetTransform(get_tex_mat_sym(si), (D3DMATRIX *)m.get_data()); DWORD transform_flags = texcoord_dimensions; - if (m.get_col(3) != LVecBase4f(0.0f, 0.0f, 0.0f, 1.0f)) { + if (m.get_col(3) != LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)) { // If we have a projected texture matrix, we also need to // set D3DTTFF_COUNT4. transform_flags = D3DTTFF_COUNT4 | D3DTTFF_PROJECTED; @@ -4019,14 +4019,14 @@ enable_lighting(bool enable) { // all other lights have been enabled or disabled. //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian9:: -set_ambient_light(const Colorf &color) { - Colorf c = color; +set_ambient_light(const LColor &color) { + LColor c = color; c.set(c[0] * _light_color_scale[0], c[1] * _light_color_scale[1], c[2] * _light_color_scale[2], c[3] * _light_color_scale[3]); - set_render_state(D3DRS_AMBIENT, Colorf_to_D3DCOLOR(c)); + set_render_state(D3DRS_AMBIENT, LColor_to_D3DCOLOR(c)); } //////////////////////////////////////////////////////////////////// @@ -4079,11 +4079,11 @@ bind_clip_plane(const NodePath &plane, int plane_id) { // coordinates). This means the plane in the coordinate space of // the camera, converted to DX's coordinate system. CPT(TransformState) transform = plane.get_transform(_scene_setup->get_camera_path()); - const LMatrix4f &plane_mat = transform->get_mat(); - LMatrix4f rel_mat = plane_mat * LMatrix4f::convert_mat(CS_yup_left, CS_default); + const LMatrix4 &plane_mat = transform->get_mat(); + LMatrix4 rel_mat = plane_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); const PlaneNode *plane_node; DCAST_INTO_V(plane_node, plane.node()); - Planef world_plane = plane_node->get_plane() * rel_mat; + LPlane world_plane = plane_node->get_plane() * rel_mat; HRESULT hr = _d3d_device->SetClipPlane(plane_id, world_plane.get_data()); if (FAILED(hr)) { @@ -4229,7 +4229,7 @@ do_auto_rescale_normal() { //////////////////////////////////////////////////////////////////// const D3DCOLORVALUE &DXGraphicsStateGuardian9:: get_light_color(Light *light) const { - static Colorf c; + static LColor c; c = light->get_color(); c.set(c[0] * _light_color_scale[0], c[1] * _light_color_scale[1], @@ -4583,15 +4583,15 @@ set_texture_blend_mode(int i, const TextureStage *stage) { D3DCOLOR constant_color; if (stage->involves_color_scale() && _color_scale_enabled) { - Colorf color = stage->get_color(); + LColor color = stage->get_color(); color.set(color[0] * _current_color_scale[0], color[1] * _current_color_scale[1], color[2] * _current_color_scale[2], color[3] * _current_color_scale[3]); _texture_involves_color_scale = true; - constant_color = Colorf_to_D3DCOLOR(color); + constant_color = LColor_to_D3DCOLOR(color); } else { - constant_color = Colorf_to_D3DCOLOR(stage->get_color()); + constant_color = LColor_to_D3DCOLOR(stage->get_color()); } if (_supports_texture_constant_color) { set_texture_stage_state(i, D3DTSS_CONSTANT, constant_color); @@ -5422,7 +5422,7 @@ do_issue_stencil() { void DXGraphicsStateGuardian9:: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); - const LVecBase4f &frame = target_scissor->get_frame(); + const LVecBase4 &frame = target_scissor->get_frame(); RECT r; r.left = _current_viewport.X + _current_viewport.Width * frame[0]; @@ -5496,7 +5496,7 @@ calc_fb_properties(DWORD cformat, DWORD dformat, static bool _gamma_table_initialized = false; static unsigned short _orignial_gamma_table [256 * 3]; -void _create_gamma_table (float gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; double gamma_correction; @@ -5579,7 +5579,7 @@ get_gamma_table(void) { // for atexit. //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian9:: -static_set_gamma(bool restore, float gamma) { +static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; HDC hdc = GetDC(NULL); @@ -5611,7 +5611,7 @@ static_set_gamma(bool restore, float gamma) { // on success. //////////////////////////////////////////////////////////////////// bool DXGraphicsStateGuardian9:: -set_gamma(float gamma) { +set_gamma(PN_stdfloat gamma) { bool set; set = static_set_gamma(false, gamma); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index 0286938a0a..2c1dfc5ece 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -146,7 +146,7 @@ public: int light_id); static D3DFORMAT get_index_type(Geom::NumericType numeric_type); - INLINE static DWORD Colorf_to_D3DCOLOR(const Colorf &cColorf); + INLINE static DWORD LColor_to_D3DCOLOR(const LColor &cLColor); virtual void set_state_and_transform(const RenderState *state, const TransformState *transform); @@ -158,8 +158,8 @@ public: INLINE HRESULT set_sampler_state (DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value); static bool get_gamma_table(void); - static bool static_set_gamma(bool restore, float gamma); - bool set_gamma(float gamma); + static bool static_set_gamma(bool restore, PN_stdfloat gamma); + bool set_gamma(PN_stdfloat gamma); void restore_gamma(); static void atexit_function(void); @@ -190,7 +190,7 @@ protected: virtual void reissue_transforms(); virtual void enable_lighting(bool enable); - virtual void set_ambient_light(const Colorf &color); + virtual void set_ambient_light(const LColor &color); virtual void enable_light(int light_id, bool enable); virtual void enable_clip_plane(int plane_id, bool enable); @@ -273,11 +273,11 @@ protected: RenderBuffer::Type _cur_read_pixel_buffer; // source for copy_pixel_buffer operation bool _auto_rescale_normal; - float _material_ambient; - float _material_diffuse; - float _material_specular; - float _material_shininess; - float _material_emission; + PN_stdfloat _material_ambient; + PN_stdfloat _material_diffuse; + PN_stdfloat _material_specular; + PN_stdfloat _material_shininess; + PN_stdfloat _material_emission; enum DxgsgFogType { None, diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 1140589fc4..14f7cacd61 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -332,7 +332,7 @@ unbind(GSG *gsg) { //////////////////////////////////////////////////////////////////// #if DEBUG_SHADER -float *global_data = 0; +PN_stdfloat *global_data = 0; ShaderContext::ShaderMatSpec *global_shader_mat_spec = 0; InternalName *global_internal_name_0 = 0; InternalName *global_internal_name_1 = 0; @@ -361,7 +361,7 @@ issue_parameters(GSG *gsg, int altered) switch(_ptr_data->_type) { case Shader::SPT_float: - cgD3D9SetUniform(p, (float*)_ptr_data->_ptr); + cgD3D9SetUniform(p, (PN_stdfloat*)_ptr_data->_ptr); break; default: @@ -380,21 +380,21 @@ issue_parameters(GSG *gsg, int altered) if (p == NULL) { continue; } - const LMatrix4f *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered); + const LMatrix4 *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered); if (val) { HRESULT hr; - float v [4]; - LMatrix4f temp_matrix; + PN_stdfloat v [4]; + LMatrix4 temp_matrix; hr = D3D_OK; - const float *data; + const PN_stdfloat *data; data = val -> get_data ( ); #if DEBUG_SHADER // DEBUG - global_data = (float *) data; + global_data = (PN_stdfloat *) data; global_shader_mat_spec = &_shader->_mat_spec[i]; global_internal_name_0 = global_shader_mat_spec -> _arg [0]; global_internal_name_1 = global_shader_mat_spec -> _arg [1]; diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 8efdc0b998..6bd533082f 100755 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -426,7 +426,7 @@ create_texture(DXScreenData &scrn) { case 128: // check if format is supported - if (scrn._supports_rgba32f_texture_format) { + if (scrn._supports_rgba32_texture_format) { target_pixel_format = D3DFMT_A32B32G32R32F; } else { @@ -827,7 +827,7 @@ create_texture(DXScreenData &scrn) { } } - float bytes_per_texel; + PN_stdfloat bytes_per_texel; bytes_per_texel = this -> d3d_format_to_bytes_per_pixel (target_pixel_format); if (bytes_per_texel == 0.0f) { @@ -839,9 +839,9 @@ create_texture(DXScreenData &scrn) { data_size = target_width * target_height * target_depth; if (_has_mipmaps) { - data_size = (int) ((float) data_size * 1.3333333f); + data_size = (int) ((PN_stdfloat) data_size * 1.3333333); } - data_size = (int) ((float) data_size * bytes_per_texel); + data_size = (int) ((PN_stdfloat) data_size * bytes_per_texel); if (tex->get_texture_type() == Texture::TT_cube_map) { data_size *= 6; } @@ -2170,10 +2170,10 @@ get_bits_per_pixel(Texture::Format format, int *alphbits) { // Access: Private // Description: Determines bytes per pixel from D3DFORMAT. //////////////////////////////////////////////////////////////////// -float DXTextureContext9:: +PN_stdfloat DXTextureContext9:: d3d_format_to_bytes_per_pixel (D3DFORMAT format) { - float bytes_per_pixel; + PN_stdfloat bytes_per_pixel; bytes_per_pixel = 0.0f; switch (format) diff --git a/panda/src/dxgsg9/dxTextureContext9.h b/panda/src/dxgsg9/dxTextureContext9.h index 8c38ad363f..3d8549b3e4 100755 --- a/panda/src/dxgsg9/dxTextureContext9.h +++ b/panda/src/dxgsg9/dxTextureContext9.h @@ -54,7 +54,7 @@ private: HRESULT fill_d3d_volume_texture_pixels(DXScreenData &scrn); static int down_to_power_2(int value); unsigned int get_bits_per_pixel(Texture::Format format, int *alphbits); - float d3d_format_to_bytes_per_pixel (D3DFORMAT format); + PN_stdfloat d3d_format_to_bytes_per_pixel (D3DFORMAT format); private: D3DFORMAT _d3d_format; // the 'D3DFORMAT' the Panda TextureBuffer fmt corresponds to diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 1f360f6241..a31730b47e 100755 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -209,7 +209,7 @@ struct DXScreenData { UINT _supported_screen_depths_mask; UINT _supported_tex_formats_mask; bool _supports_rgba16f_texture_format; - bool _supports_rgba32f_texture_format; + bool _supports_rgba32_texture_format; D3DCAPS9 _d3dcaps; D3DDISPLAYMODE _display_mode; D3DPRESENT_PARAMETERS _presentation_params; // not redundant with _display_mode since width/height must be 0 for windowed mode diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 75ae08b1e1..30231326d7 100755 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -691,7 +691,7 @@ search_for_valid_displaymode(DXScreenData &scrn, } bool bIs16bppRenderTgt = IS_16BPP_DISPLAY_FORMAT(dispmode.Format); - float RendTgtMinMemReqmt = 0.0f; + PN_stdfloat RendTgtMinMemReqmt = 0.0f; // if we have a valid memavail value, try to determine if we have // enough space @@ -705,12 +705,12 @@ search_for_valid_displaymode(DXScreenData &scrn, #define REQD_TEXMEM 1800000 - float bytes_per_pixel = (bIs16bppRenderTgt ? 2 : 4); + PN_stdfloat bytes_per_pixel = (bIs16bppRenderTgt ? 2 : 4); // *2 for double buffer RendTgtMinMemReqmt = - ((float)RequestedX_Size) * ((float)RequestedY_Size) * + ((PN_stdfloat)RequestedX_Size) * ((PN_stdfloat)RequestedY_Size) * bytes_per_pixel * 2 + REQD_TEXMEM; if (bVerboseMode) @@ -739,12 +739,12 @@ search_for_valid_displaymode(DXScreenData &scrn, continue; } - float MinMemReqmt = 0.0f; + PN_stdfloat MinMemReqmt = 0.0f; if (bDoMemBasedChecks) { // test memory again, this time including zbuf size - float zbytes_per_pixel = (IS_16BPP_ZBUFFER(zformat) ? 2 : 4); - float MinMemReqmt = RendTgtMinMemReqmt + ((float)RequestedX_Size)*((float)RequestedY_Size)*zbytes_per_pixel; + PN_stdfloat zbytes_per_pixel = (IS_16BPP_ZBUFFER(zformat) ? 2 : 4); + PN_stdfloat MinMemReqmt = RendTgtMinMemReqmt + ((PN_stdfloat)RequestedX_Size)*((PN_stdfloat)RequestedY_Size)*zbytes_per_pixel; if (bVerboseMode) wdxdisplay9_cat.info() diff --git a/panda/src/effects/Sources.pp b/panda/src/effects/Sources.pp deleted file mode 100644 index 3c6d2c5a52..0000000000 --- a/panda/src/effects/Sources.pp +++ /dev/null @@ -1,27 +0,0 @@ -#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ - dtoolutil:c dtoolbase:c dtool:m prc:c -#define USE_PACKAGES cg -#begin lib_target - #define TARGET effects - #define LOCAL_LIBS \ - display gobj putil gsgbase linmath \ - mathutil - - #define COMBINED_SOURCES $[TARGET]_composite1.cxx - - #define SOURCES \ - config_effects.h \ - lensFlareNode.I lensFlareNode.h - - #define INCLUDED_SOURCES \ - config_effects.cxx \ - lensFlareNode.cxx - - #define INSTALL_HEADERS \ - config_effects.h \ - lensFlareNode.I lensFlareNode.h - - #define IGATESCAN all - -#end lib_target - diff --git a/panda/src/effects/config_effects.cxx b/panda/src/effects/config_effects.cxx deleted file mode 100644 index dc9ecd6620..0000000000 --- a/panda/src/effects/config_effects.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// Filename: config_effects.cxx -// Created by: jason (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// 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 "config_effects.h" -#include "lensFlareNode.h" -#include "pandaSystem.h" -#include "dconfig.h" - -Configure(config_effects); -NotifyCategoryDef(effects, ""); - -ConfigureFn(config_effects) { - init_libeffects(); -} - -//////////////////////////////////////////////////////////////////// -// Function: init_libeffects -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// -void -init_libeffects() { -#if 0 // temporarily disabled until we can port to new scene graph. - LensFlareNode::init_type(); - LensFlareNode::register_with_read_factory(); -#endif // temporarily disabled until we can port to new scene graph. -} diff --git a/panda/src/effects/effects_composite.cxx b/panda/src/effects/effects_composite.cxx deleted file mode 100644 index 0d2f43cdf1..0000000000 --- a/panda/src/effects/effects_composite.cxx +++ /dev/null @@ -1 +0,0 @@ -#include "effects_composite1.cxx" diff --git a/panda/src/effects/effects_composite1.cxx b/panda/src/effects/effects_composite1.cxx deleted file mode 100644 index 7683817be3..0000000000 --- a/panda/src/effects/effects_composite1.cxx +++ /dev/null @@ -1,4 +0,0 @@ - -#include "config_effects.cxx" -#include "lensFlareNode.cxx" - diff --git a/panda/src/effects/lensFlareNode.I b/panda/src/effects/lensFlareNode.I deleted file mode 100644 index 403c6f855b..0000000000 --- a/panda/src/effects/lensFlareNode.I +++ /dev/null @@ -1,80 +0,0 @@ -// Filename: lensFlareNode.I -// Created by: jason (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// 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: LensFlareNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE LensFlareNode:: -LensFlareNode() : - _global_scale(1), _texel_scale(0.1), _blind_fall_off(45), _flare_fall_off(5) -{ - _blind = (Texture *)NULL; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_texel_scale -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void LensFlareNode:: -set_texel_scale(float texel_to_world) -{ - _texel_scale = texel_to_world; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_global_scale -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void LensFlareNode:: -set_global_scale(float scale) -{ - _global_scale = scale; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_blind_falloff -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void LensFlareNode:: -set_blind_falloff(float fall_off) -{ - _blind_fall_off = cos(deg_2_rad(fall_off)) - 1; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_flare_falloff -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void LensFlareNode:: -set_flare_falloff(float fall_off) -{ - _flare_fall_off = cos(deg_2_rad(fall_off)) - 1; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_light -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void LensFlareNode:: -set_light_source(PT_Node light) -{ - _light_node = light; -} diff --git a/panda/src/effects/lensFlareNode.cxx b/panda/src/effects/lensFlareNode.cxx deleted file mode 100644 index 8ee4669529..0000000000 --- a/panda/src/effects/lensFlareNode.cxx +++ /dev/null @@ -1,734 +0,0 @@ -// Filename: lensFlareNode.cxx -// Created by: jason (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// - -#if 0 // temporarily disabled until we can port to new scene graph. - -#include "lensFlareNode.h" -#include "config_effects.h" - -#include "sequenceNode.h" -#include "geomNode.h" -#include "geomSprite.h" -#include "textureTransition.h" -#include "transformTransition.h" -#include "billboardTransition.h" -#include "transformTransition.h" -#include "transparencyTransition.h" -#include "renderTraverser.h" -#include "lens.h" -#include "get_rel_pos.h" -#include "clockObject.h" -#include "allTransitionsWrapper.h" -#include "allTransitionsWrapper.h" -#include "graphicsStateGuardian.h" -#include "datagram.h" -#include "datagramIterator.h" -#include "bamReader.h" -#include "bamWriter.h" -#include "ioPtaDatagramFloat.h" -#include "ioPtaDatagramLinMath.h" - -//////////////////////////////////////////////////////////////////// -// Static variables -//////////////////////////////////////////////////////////////////// -TypeHandle LensFlareNode::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::add_bloom -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -add_flare(PT(Texture) flare, PTA_float scales, PTA_float offsets, - PTA_float angle_scales, PTA_Colorf colors) -{ - nassertv(scales.size() == offsets.size()); - nassertv(colors.size() == offsets.size()); - nassertv(angle_scales.size() == offsets.size()); - - _flare_scales.push_back(scales); - _flare_offsets.push_back(offsets); - _flare_colors.push_back(colors); - _flare_angle_scales.push_back(angle_scales); - _flares.push_back(flare); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::add_blind -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -add_blind(PT(Texture) blind) -{ - _blind = blind; - GeomSprite *sprite = new GeomSprite(); - GeomNode *node = new GeomNode(); - - //We don't want to set any geometry right now, as that will be - //taken care of later (and on each subsequent render), but - //Geoms requires a certain amount of info or else they crash, - //so simply give it the minimum it needs not to crash - - //The lengths and number of prims will never change, so give - //it valid values for those, but pass it an empty array of - //vertices - PTA_Vertexf coords=PTA_Vertexf::empty_array(0); - PTA_float tex_scales=PTA_float::empty_array(0); - - tex_scales.push_back(_texel_scale); - - sprite->set_coords(coords); - sprite->set_num_prims(1); - sprite->set_texture(_blind); - - node->add_geom(sprite); - - _blind_arc = new RenderRelation(this, node); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_geometry -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -set_geometry(GeomSprite *sprite, const PTA_float &geom_scales, - const PTA_float &geom_offsets, const PTA_float &geom_angle_scales, - const PTA_Colorf &geom_colors, const LVector3f &delta, - const LPoint3f &light, const float &angle) -{ - - PTA_Vertexf coords=PTA_Vertexf::empty_array(0); - PTA_float tex_scales=PTA_float::empty_array(0); - PTA_Colorf colors=PTA_Colorf::empty_array(0); - - //Sanity check - nassertv(geom_scales.size() == geom_offsets.size()); - nassertv(geom_colors.size() == geom_offsets.size()); - - float world_scale = _texel_scale * _global_scale; - for(int i = 0; i < (int)geom_scales.size(); i++) - { - LVector3f position = (delta * geom_offsets[i]) + light; - float view_scale; - //If this is true then we are supposed to invert the meaning of - //the scale. I.E. As the angle between the viewing direction and - //the light direction increases we want the size of the thing to - //get smaller and as it increases we want it to get bigger. This - //will actually be the normal use of angle scales - if (geom_angle_scales[i] < 0) - { - view_scale = (1.0f-pow(angle, 15.0f)) * -geom_angle_scales[i]; - } - else - { - view_scale = pow(angle, 15.0f) * geom_angle_scales[i]; - } - float offset = (angle - 1.0f) / _flare_fall_off; - offset = (offset < 0.0f) ? 0.0f : ((offset > 1.0f) ? 1.0f : offset); - float r = geom_colors[i][0] - offset; - float g = geom_colors[i][1] - offset; - float b = geom_colors[i][2] - offset; - r = (r < 0.0f) ? 0.0f : r; - g = (g < 0.0f) ? 0.0f : g; - b = (b < 0.0f) ? 0.0f : b; - - coords.push_back(position); tex_scales.push_back(geom_scales[i] * (world_scale + view_scale)); - colors.push_back(Colorf(r, g, b, 1)); - } - - sprite->set_coords(coords); - sprite->set_x_texel_ratio(tex_scales, G_PER_PRIM); - sprite->set_y_texel_ratio(tex_scales, G_PER_PRIM); - sprite->set_colors(colors, G_PER_PRIM); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::prepare_flares -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -prepare_flares(const LVector3f &delta, const LPoint3f &light, const float &angle) -{ - if (_flares.size() > 0) - { - if (_flares.size() > _flare_arcs.size()) - { - for(int i = _flare_arcs.size(); i < (int)_flares.size(); i++) - { - //Sanity check - nassertv(_flare_offsets[i].size() == _flare_scales[i].size()); - - GeomSprite *sprite = new GeomSprite(); - GeomNode *node = new GeomNode(); - - //We don't want to set any geometry right now, as that will be - //taken care of later (and on each subsequent render), but - //Geoms requires a certain amount of info or else they crash, - //so simply give it the minimum it needs not to crash - - //The lengths and number of prims will never change, so give - //it valid values for those, but pass it an empty array of - //vertices - PTA_Vertexf coords=PTA_Vertexf::empty_array(0); - - sprite->set_coords(coords); - sprite->set_num_prims(_flare_offsets[i].size()); - - node->add_geom(sprite); - - RenderRelation *arc = new RenderRelation(this, node); - //arc->set_transition(new TransparencyTransition(TransparencyProperty::M_alpha)); - _flare_arcs.push_back(arc); - } - } - - for(int i = 0; i < (int)_flares.size(); i++) - { - GeomNode *node = DCAST(GeomNode, _flare_arcs[i]->get_child()); - GeomSprite *sprite = DCAST(GeomSprite, node->get_geom(0)); - - set_geometry(sprite, _flare_scales[i], _flare_offsets[i], - _flare_angle_scales[i], _flare_colors[i], - delta, light, angle); - sprite->set_texture(_flares[i]); - - //Tell them to recompute their bounding volumes - sprite->mark_bound_stale(); - node->mark_bound_stale(); - } - } -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::prepare_blind -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -prepare_blind(const float &angle, const float &tnear) -{ - if (_blind != (Texture*) NULL) - { - GeomNode *node = DCAST(GeomNode, _blind_arc->get_child()); - GeomSprite *sprite = DCAST(GeomSprite, node->get_geom(0)); - - float offset = (angle - 1.0f) / _blind_fall_off; - //Make sure that it always blends some - offset = (offset < 0.3f) ? 0.3f : ((offset > 1.0f) ? 1.0f : offset); - - PTA_Vertexf coords=PTA_Vertexf::empty_array(0); - PTA_Colorf colors=PTA_Colorf::empty_array(0); - PTA_float x_tex_scales=PTA_float::empty_array(0); - PTA_float y_tex_scales=PTA_float::empty_array(0); - - //The height and the width are set to two as sprites are always - //drawn in a frustum of size 2. - float width = sprite->get_frustum_right() - sprite->get_frustum_left(); - float height = sprite->get_frustum_top() - sprite->get_frustum_bottom(); - float x_offset_scale = width / _blind->_pbuffer->get_xsize(); - float y_offset_scale = height / _blind->_pbuffer->get_ysize(); - - float inten = 1.0f - offset; - - coords.push_back(Vertexf(0.0f, 0.0f, -tnear )); - colors.push_back(Colorf(inten,inten,inten,1.0f)); - x_tex_scales.push_back(x_offset_scale); y_tex_scales.push_back(y_offset_scale); - - sprite->set_x_texel_ratio(x_tex_scales, G_PER_PRIM); - sprite->set_y_texel_ratio(y_tex_scales, G_PER_PRIM); - sprite->set_coords(coords); - sprite->set_colors(colors, G_PER_PRIM); - - //Tell it to recompute it's bounding volume - sprite->mark_bound_stale(); - node->mark_bound_stale(); - } -} -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::render_child -// Access: Pribate -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -render_child(RenderRelation *arc, const AllTransitionsWrapper &trans, - GraphicsStateGuardian *gsg) -{ - - AllTransitionsWrapper new_trans(trans); - new_trans.clear_transition(TransformTransition::get_class_type()); - - AllTransitionsWrapper arc_trans; - arc_trans.extract_from(arc); - - new_trans.compose_in_place(arc_trans); - - // Now render everything from this node and below. - gsg->render_subgraph(gsg->get_render_traverser(), - arc->get_child(), new_trans); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::render_children -// Access: Pribate -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -render_children(const vector_relation &arcs, - const AllTransitionsWrapper &trans, - GraphicsStateGuardian *gsg) -{ - for(int i = 0; i < (int)arcs.size(); i++) - { - render_child(arcs[i], trans, gsg); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::sub_render -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -bool LensFlareNode:: -sub_render(const AllTransitionsWrapper &input_trans, - AllTransitionsWrapper &, RenderTraverser *trav) { - GraphicsStateGuardian *gsg = trav->get_gsg(); - - nassertr(_light_node != (Node*) NULL, false); - - //First we need the light position - LensNode *camera_node = gsg->get_current_camera(); - Lens *lens = camera_node->get_lens(); - - LPoint3f light_pos = get_rel_pos(_light_node, camera_node); - - LMatrix4f light_mat; - get_rel_mat(_light_node, camera_node, light_mat); - - LMatrix4f modelview_mat; - - const TransformTransition *ta; - if (!get_transition_into(ta, input_trans)) - modelview_mat = LMatrix4f::ident_mat(); - else - modelview_mat = ta->get_matrix(); - - LMatrix4f inv_light_mat = invert(light_mat); - light_pos = light_pos * inv_light_mat * modelview_mat; - - //Now figure out where the center of the screen is. Since we are - //doing everything in camera space, this should merely be the - //distance between the camera and the near clipping plane projected - //along Y into the screen - LPoint3f center = LPoint3f::origin() + LPoint3f::rfu(0,lens->get_near(),0); - center = center * inv_light_mat * modelview_mat; - - //Now lets get the vector from the light to the center. - LPoint3f delta = center - light_pos; - delta.set_z(light_pos.get_z()); - - //Now perform the angle caclulationss for increasing the brightness - //as we look at the light dead on - LPoint3f origin = LPoint3f::origin() * inv_light_mat * modelview_mat; - LVector3f light_dir = light_pos - origin; - light_dir.normalize(); - LVector3f view_dir = center - origin; - - float dot = view_dir.dot(light_dir); - dot = (dot < 0.0f) ? -dot : dot; - - prepare_flares(delta, light_pos, dot); - prepare_blind(dot, lens->get_near()); - - render_children(_flare_arcs, input_trans, gsg); - render_child(_blind_arc, input_trans, gsg); - - //Short circuit the rendering - return false; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::has_sub_render -// Access: Public, Virtual -// Description: Should be redefined to return true if the function -// sub_render(), above, expects to be called during -// traversal. -//////////////////////////////////////////////////////////////////// -bool LensFlareNode:: -has_sub_render() const -{ - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::write_object -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -write_datagram(BamWriter *manager, Datagram &me) { - int i; - - Node::write_datagram(manager, me); - - me.add_uint16(_flares.size()); - for(i = 0; i < (int)_flares.size(); i++) - { - manager->write_pointer(me, _flares[i]); - } - manager->write_pointer(me, _blind); - - me.add_uint16(_flare_arcs.size()); - for(i = 0; i < (int)_flare_arcs.size(); i++) - { - manager->write_pointer(me, _flare_arcs[i]); - } - - me.add_uint16(_flare_scales.size()); - for(i = 0; i < (int)_flare_scales.size(); i++) - { - WRITE_PTA(manager, me, IPD_float::write_datagram, _flare_scales[i]) - } - - me.add_uint16(_flare_angle_scales.size()); - for(i = 0; i < (int)_flare_angle_scales.size(); i++) - { - WRITE_PTA(manager, me, IPD_float::write_datagram, _flare_angle_scales[i]) - } - - me.add_uint16(_flare_offsets.size()); - for(i = 0; i < (int)_flare_offsets.size(); i++) - { - WRITE_PTA(manager, me, IPD_float::write_datagram, _flare_offsets[i]) - } - - me.add_uint16(_flare_colors.size()); - for(i = 0; i < (int)_flare_colors.size(); i++) - { - WRITE_PTA(manager, me, IPD_Colorf::write_datagram, _flare_colors[i]) - } - - me.add_float32(_global_scale); - me.add_float32(_texel_scale); - me.add_float32(_blind_fall_off); - me.add_float32(_flare_fall_off); - - manager->write_pointer(me, _light_node); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::fillin -// Access: Protected -// Description: This internal function is called by make_LensFlareNode to -// read in all of the relevant data from the BamFile for -// the new LensFlareNode. -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -fillin(DatagramIterator &scan, BamReader *manager) -{ - int i, size; - Node::fillin(scan, manager); - - Node::fillin(scan, manager); - - _num_flares = scan.get_uint16(); - for(i = 0; i < _num_flares; i++) - { - manager->read_pointer(scan); - } - manager->read_pointer(scan); - - _num_arcs = scan.get_uint16(); - for(i = 0; i < _num_arcs; i++) - { - manager->read_pointer(scan); - } - - size = scan.get_uint16(); - for(i = 0; i < size; i++) - { - PTA_float temp=PTA_float::empty_array(0); - READ_PTA(manager, scan, IPD_float::read_datagram, temp) - _flare_scales.push_back(temp); - } - - size = scan.get_uint16(); - for(i = 0; i < size; i++) - { - PTA_float temp=PTA_float::empty_array(0); - READ_PTA(manager, scan, IPD_float::read_datagram, temp) - _flare_angle_scales.push_back(temp); - } - - size = scan.get_uint16(); - for(i = 0; i < size; i++) - { - PTA_float temp=PTA_float::empty_array(0); - READ_PTA(manager, scan, IPD_float::read_datagram, temp) - _flare_offsets.push_back(temp); - } - - size = scan.get_uint16(); - for(i = 0; i < size; i++) - { - PTA_Colorf temp=PTA_Colorf::empty_array(0); - READ_PTA(manager, scan, IPD_Colorf::read_datagram, temp) - _flare_colors.push_back(temp); - } - - _global_scale = scan.get_float32(); - _texel_scale = scan.get_float32(); - _blind_fall_off = scan.get_float32(); - _flare_fall_off = scan.get_float32(); - - manager->read_pointer(scan); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::complete_pointers -// Access: Public -// Description: Takes in a vector of pointes to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// -int LensFlareNode:: -complete_pointers(TypedWritable **p_list, BamReader *manager) -{ - int i; - int start = Node::complete_pointers(p_list, manager); - int end = _num_flares + start; - - for(i = start; i < end; i++) - { - _flares.push_back(DCAST(Texture, p_list[i])); - } - - _blind = DCAST(Texture, p_list[end]); - - end += 1 + _num_arcs; - for(; i < end; i++) - { - _flare_arcs.push_back(DCAST(RenderRelation, p_list[i])); - } - - _light_node = DCAST(Node, p_list[end]); - - return end+1; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::make_LensFlareNode -// Access: Protected -// Description: This function is called by the BamReader's factory -// when a new object of type LensFlareNode is encountered in -// the Bam file. It should create the LensFlareNode and -// extract its information from the file. -//////////////////////////////////////////////////////////////////// -TypedWritable *LensFlareNode:: -make_LensFlareNode(const FactoryParams ¶ms) { - LensFlareNode *me = new LensFlareNode; - DatagramIterator scan; - BamReader *manager; - - parse_params(params, scan, manager); - me->fillin(scan, manager); - return me; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LensFlareNode. -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -register_with_read_factory() { - BamReader::get_factory()->register_factory(get_class_type(), make_LensFlareNode); -} - - -/*************** - OLD SPARKLE CODE - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -LensFlareNode:: -LensFlareNode() : - _global_scale(1), _next_switch(-1), _sparkle_fps(0.2), - _texel_scale(0.1), _inv_sparkle_fps(5), _exp_scale(15) -{ - _global_clock = ClockObject::get_global_clock(); - _next_switch = _global_clock->get_real_time() + _sparkle_fps; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_sparkle_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -set_sparkle_fps(float fps) -{ - nassertv(fps > 0); - _next_switch = _next_switch - _sparkle_fps + fps; - _sparkle_fps = fps; - _inv_sparkle_fps = 1. / _sparkle_fps; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::compute_current -// Access: Private -// Description: Determines the current sparkle index -//////////////////////////////////////////////////////////////////// -int LensFlareNode:: -compute_current(int ¤t_sparkle, vector_texture sparkles) -{ - double current_time = _global_clock->get_real_time(); - unsigned int increment = (unsigned int) ((current_time - _next_switch) * _inv_sparkle_fps); - - _next_switch += _sparkle_fps * increment; - current_sparkle = (current_sparkle + increment) % sparkles.size(); - - return current_sparkle; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::add_sparkle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -add_sparkle(PT_Node source, PT(Texture) sparkle) -{ - set_light(source); - _sparkles.push_back(sparkle); -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_sparkles_attributes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -set_sparkles_attributes(PT_Node source, vector_float scales, - vector_float offsets, vector_Colorf colors) -{ - nassertv(scales.size() == offsets.size()); - - set_light(source); - - _sparkle_scales = scales; - _sparkle_offsets = offsets; - _sparkle_colors = colors; -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::set_light -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -set_light(PT_Node light) -{ - _lights.insert(light); - if (_current_sparkles.find(light) == _current_sparkles.end()) - { - _current_sparkles[light] = 0; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: LensFlareNode::prepare_sparkles -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void LensFlareNode:: -prepare_sparkles(vector_relation &arcs, const vector_texture &sparkles, - const vector_float &scales, const vector_float &offsets, - const vector_Colorf &colors, const LVector3f &delta, - const LPoint3f &light, const BoundingVolume &bound, int &old_sparkle) -{ - //Sanity check - nassertv(scales.size() == offsets.size()); - - if (scales.size() > 0) - { - if (arcs.size() == 0) - { - for(int i = 0; i < scales.size(); i++) - { - GeomSprite *sprite = new GeomSprite(); - GeomNode *node = new GeomNode(); - - //We don't want to set any geometry right now, as that will be - //taken care of later (and on each subsequent render), but - //Geoms requires a certain amount of info or else they crash, - //so simply give it the minimum it needs not to crash - - //The lengths and number of prims will never change, so give - //it valid values for those, but pass it an empty array of - //vertices - PTA_Vertexf coords(0); - - sprite->set_coords(coords); - sprite->set_num_prims(1); - - node->add_geom(sprite); - - arcs.push_back(new RenderRelation(this, node)); - } - } - - //Unfortunately, we can't use set_geometry here because only a - //certain number of sparkles are active at once, and set_geometry - //knows nothing about switching between them - - for(int i = 0; i < scales.size(); i++) - { - int index = (compute_current(old_sparkle, sparkles)+i) % sparkles.size(); - LVector3f position = (delta * offsets[i]) + light; - - GeomNode *node = DCAST(GeomNode, arcs[i]->get_child()); - GeomSprite *sprite = DCAST(GeomSprite, node->get_geom(0)); - - PTA_Vertexf coords(0); - PTA_float tex_scales(0); - PTA_Colorf sprite_colors(0); - - coords.push_back(position); tex_scales.push_back(scales[i] * _texel_scale * _global_scale); - - sprite_colors.push_back(colors[i]); - - sprite->set_coords(coords); - sprite->set_x_texel_ratio(tex_scales, G_PER_PRIM); - sprite->set_y_texel_ratio(tex_scales, G_PER_PRIM); - sprite->set_colors(sprite_colors, G_PER_PRIM); - sprite->set_texture(sparkles[index]); - - //Tell them to recompute their bounding volumes - sprite->set_bound(bound); - sprite->mark_bound_stale(); - node->mark_bound_stale(); - } - } -} - -****************/ - -#endif // temporarily disabled until we can port to new scene graph. diff --git a/panda/src/effects/lensFlareNode.h b/panda/src/effects/lensFlareNode.h deleted file mode 100644 index 2b7846675c..0000000000 --- a/panda/src/effects/lensFlareNode.h +++ /dev/null @@ -1,178 +0,0 @@ -// Filename: lensFlareNode.h -// Created by: jason (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// - -#if 0 // temporarily disabled until we can port to new scene graph. - -#ifndef LENSFLARENODE_H -#define LENSFLARENODE_H - -#include "pandabase.h" - -#include "namedNode.h" -#include "texture.h" -#include "luse.h" -#include "pta_Colorf.h" -#include "pta_float.h" -#include "renderRelation.h" -#include "pmap.h" - -class GraphicsStateGuardian; -class ClockObject; - -class EXPCL_PANDAFX LensFlareNode : public Node -{ -PUBLISHED: - INLINE LensFlareNode(); - - void add_flare(PT(Texture) flare, PTA_float scales, PTA_float offsets, - PTA_float angle_scales, PTA_Colorf colors); - void add_blind(PT(Texture) blind); - - INLINE void set_texel_scale(float texel_to_world); - INLINE void set_global_scale(float scale); - - INLINE void set_blind_falloff(float fall_off); - INLINE void set_flare_falloff(float fall_off); - - INLINE void set_light_source(PT_Node source); - -public: - virtual bool sub_render(const AllTransitionsWrapper &input_trans, - AllTransitionsWrapper &modify_trans, - RenderTraverser *trav); - virtual bool has_sub_render() const; - -private: - typedef pvector vector_Vfloat; - typedef pvector vector_Vcolorf; - typedef pvector< PT(RenderRelation) > vector_relation; - typedef pvector< PT(Texture) > vector_texture; - - vector_texture _flares; - PT(Texture) _blind; - - vector_relation _flare_arcs; - PT(RenderRelation) _blind_arc; - - vector_Vfloat _flare_scales; - vector_Vfloat _flare_angle_scales; - vector_Vfloat _flare_offsets; - vector_Vcolorf _flare_colors; - - float _global_scale; - float _texel_scale; - - float _blind_fall_off; - float _flare_fall_off; - - PT_Node _light_node; - - /****Internal functions*****/ - - //Sub-routines that are defined only for code cleanliness - void prepare_flares(const LVector3f &delta, const LPoint3f &light, const float &angle); - void prepare_blind(const float &angle, const float &tnear); - - //All of the geometry for halos and blooms is created the same way. - //Sparkle geometry is created differently because we cycle through - //the set of Sparkle textures to create an animation - - void set_geometry(GeomSprite *sprite, const PTA_float &geom_scales, - const PTA_float &geom_offsets, const PTA_float &geom_angle_scales, - const PTA_Colorf &geom_colors, const LVector3f &delta, - const LPoint3f &light, const float &angle); - - - void render_child(RenderRelation *arc, - const AllTransitionsWrapper &trans, - GraphicsStateGuardian *gsg); - void render_children(const vector_relation &arcs, - const AllTransitionsWrapper &trans, - GraphicsStateGuardian *gsg); - -public: - static void register_with_read_factory(); - virtual void write_datagram(BamWriter *manager, Datagram &me); - virtual int complete_pointers(TypedWritable **plist, - BamReader *manager); - - static TypedWritable *make_LensFlareNode(const FactoryParams ¶ms); - -protected: - void fillin(DatagramIterator &scan, BamReader *manager); - -private: - int _num_flares, _num_arcs; - -public: - static TypeHandle get_class_type( void ) { - return _type_handle; - } - static void init_type( void ) { - NamedNode::init_type(); - register_type( _type_handle, "LensFlareNode", - NamedNode::get_class_type() ); - } - virtual TypeHandle get_type( void ) const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "lensFlareNode.I" - -#endif - -/***********OLD SPARKLE CODE. LEFT IN CASE -public: - void add_sparkle(PT_Node source, PT(Texture) sparkle); - void set_sparkles_attributes(PT_Node source, float angle_scale, vector_float scales, - vector_float offsets, vector_Colorf colors); - void set_sparkle_fps(float fps); - -private: - //Sparkle animation variables - ClockObject* _global_clock; - float _next_switch; - float _sparkle_fps; - float _inv_sparkle_fps; - - typedef pmap Sparkle_Scales; - typedef pmap Sparkle_Offsets; - typedef pmap Sparkle_Colors; - - Textures _sparkles; - Relations _sparkle_arcs; - - Sparkle_Scales _sparkle_scales; - Sparkle_Offsets _sparkle_offsets; - Sparkle_Colors _sparkle_colors; - - int _num_sparkles_on; - pmap _current_sparkles; - - void prepare_sparkles(vector_relation &arcs, const vector_texture &sparkles, - const vector_float &scales, const vector_float &offsets, - const vector_Colorf &colors, const LVector3f &delta, - const LPoint3f &light, const BoundingVolume &bound, int &old_sparkle); - - //Timing function to control sparkle animation - int compute_current(int ¤t_sparkle, vector_texture sparkles); - -******************/ - -#endif // temporarily disabled until we can port to new scene graph. diff --git a/panda/src/egg/eggAttributes.I b/panda/src/egg/eggAttributes.I index 1956b1d474..29f0bea697 100644 --- a/panda/src/egg/eggAttributes.I +++ b/panda/src/egg/eggAttributes.I @@ -106,12 +106,12 @@ has_color() const { // Description: Returns the color set on this particular attribute. // If there is no color set, returns white. //////////////////////////////////////////////////////////////////// -INLINE Colorf EggAttributes:: +INLINE LColor EggAttributes:: get_color() const { if (has_color()) { return _color; } else { - return Colorf(1.0, 1.0, 1.0, 1.0); + return LColor(1.0, 1.0, 1.0, 1.0); } } @@ -121,7 +121,7 @@ get_color() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggAttributes:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; _flags |= F_has_color; } diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index 27ac628bf0..9aaa994242 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -49,8 +49,8 @@ PUBLISHED: INLINE void copy_normal(const EggAttributes &other); INLINE bool has_color() const; - INLINE Colorf get_color() const; - INLINE void set_color(const Colorf &Color); + INLINE LColor get_color() const; + INLINE void set_color(const LColor &Color); INLINE void clear_color(); INLINE bool matches_color(const EggAttributes &other) const; INLINE void copy_color(const EggAttributes &other); @@ -72,7 +72,7 @@ private: int _flags; Normald _normal; - Colorf _color; + LColor _color; public: diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index dbd99ff297..8234b2b31c 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -177,7 +177,7 @@ unify_attributes(EggPrimitive::Shading shading) { // Not having a color is implicitly white. if (!has_color()) { - set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } iterator pi; @@ -230,7 +230,7 @@ unify_attributes(EggPrimitive::Shading shading) { // Not having a color is implicitly white. if (!has_color()) { - set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } Components::iterator ci; @@ -293,7 +293,7 @@ unify_attributes(EggPrimitive::Shading shading) { // Not having a color is implicitly white. if (!has_color()) { - set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } } break; diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index 43281cad94..df0b4b746f 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -785,7 +785,7 @@ get_blend_operand_b() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: -set_blend_color(const Colorf &blend_color) { +set_blend_color(const LColor &blend_color) { _blend_color = blend_color; _flags2 |= F2_has_blend_color; } @@ -797,7 +797,7 @@ set_blend_color(const Colorf &blend_color) { //////////////////////////////////////////////////////////////////// INLINE void EggGroup:: clear_blend_color() { - _blend_color = Colorf::zero(); + _blend_color = LColor::zero(); _flags2 &= ~F2_has_blend_color; } @@ -818,7 +818,7 @@ has_blend_color() const { // Description: Returns the blend color if one has been specified, or // (0, 0, 0, 0) if one has not. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &EggGroup:: +INLINE const LColor &EggGroup:: get_blend_color() const { return _blend_color; } diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 1f4c9e822e..0234733aed 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -39,7 +39,7 @@ EggGroup(const string &name) : EggGroupNode(name) { _blend_mode = BM_unspecified; _blend_operand_a = BO_unspecified; _blend_operand_b = BO_unspecified; - _blend_color = Colorf::zero(); + _blend_color = LColor::zero(); _u_speed = 0; _v_speed = 0; _r_speed = 0; @@ -289,7 +289,7 @@ write(ostream &out, int indent_level) const { } if (has_blend_color()) { - const Colorf &c = get_blend_color(); + const LColor &c = get_blend_color(); indent(out, indent_level + 2) << " blendr { " << c[0] << " }\n"; indent(out, indent_level + 2) diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 16e7121537..c71345e3cf 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -254,10 +254,10 @@ PUBLISHED: INLINE BlendOperand get_blend_operand_a() const; INLINE void set_blend_operand_b(BlendOperand blend_operand_b); INLINE BlendOperand get_blend_operand_b() const; - INLINE void set_blend_color(const Colorf &blend_color); + INLINE void set_blend_color(const LColor &blend_color); INLINE void clear_blend_color(); INLINE bool has_blend_color() const; - INLINE const Colorf &get_blend_color() const; + INLINE const LColor &get_blend_color() const; INLINE void set_lod(const EggSwitchCondition &lod); INLINE void clear_lod(); @@ -374,7 +374,7 @@ private: BlendMode _blend_mode; BlendOperand _blend_operand_a; BlendOperand _blend_operand_b; - Colorf _blend_color; + LColor _blend_color; LPoint3d _billboard_center; vector_string _object_types; string _collision_name; diff --git a/panda/src/egg/eggMaterial.I b/panda/src/egg/eggMaterial.I index a75ca19780..7aff647b4b 100644 --- a/panda/src/egg/eggMaterial.I +++ b/panda/src/egg/eggMaterial.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE void EggMaterial:: -set_diff(const Colorf &diff) { +set_diff(const LColor &diff) { _diff = diff; _flags |= F_diff; } @@ -51,12 +51,12 @@ has_diff() const { // false. If so, it simply returns the default diff // color. //////////////////////////////////////////////////////////////////// -INLINE Colorf EggMaterial:: +INLINE LColor EggMaterial:: get_diff() const { if (has_diff()) { return _diff; } else { - return Colorf(1.0, 1.0, 1.0, 1.0); + return LColor(1.0, 1.0, 1.0, 1.0); } } @@ -66,7 +66,7 @@ get_diff() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggMaterial:: -set_amb(const Colorf &amb) { +set_amb(const LColor &amb) { _amb = amb; _flags |= F_amb; } @@ -98,12 +98,12 @@ has_amb() const { // false. If so, it simply returns the default amb // color. //////////////////////////////////////////////////////////////////// -INLINE Colorf EggMaterial:: +INLINE LColor EggMaterial:: get_amb() const { if (has_amb()) { return _amb; } else { - return Colorf(1.0, 1.0, 1.0, 1.0); + return LColor(1.0, 1.0, 1.0, 1.0); } } @@ -113,7 +113,7 @@ get_amb() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggMaterial:: -set_emit(const Colorf &emit) { +set_emit(const LColor &emit) { _emit = emit; _flags |= F_emit; } @@ -145,12 +145,12 @@ has_emit() const { // false. If so, it simply returns the default emit // color. //////////////////////////////////////////////////////////////////// -INLINE Colorf EggMaterial:: +INLINE LColor EggMaterial:: get_emit() const { if (has_emit()) { return _emit; } else { - return Colorf(0.0, 0.0, 0.0, 1.0); + return LColor(0.0, 0.0, 0.0, 1.0); } } @@ -160,7 +160,7 @@ get_emit() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggMaterial:: -set_spec(const Colorf &spec) { +set_spec(const LColor &spec) { _spec = spec; _flags |= F_spec; } @@ -192,12 +192,12 @@ has_spec() const { // false. If so, it simply returns the default spec // color. //////////////////////////////////////////////////////////////////// -INLINE Colorf EggMaterial:: +INLINE LColor EggMaterial:: get_spec() const { if (has_spec()) { return _spec; } else { - return Colorf(0.0, 0.0, 0.0, 1.0); + return LColor(0.0, 0.0, 0.0, 1.0); } } diff --git a/panda/src/egg/eggMaterial.h b/panda/src/egg/eggMaterial.h index 9d500d89e6..5f2813345f 100644 --- a/panda/src/egg/eggMaterial.h +++ b/panda/src/egg/eggMaterial.h @@ -40,25 +40,25 @@ PUBLISHED: bool is_equivalent_to(const EggMaterial &other, int eq) const; bool sorts_less_than(const EggMaterial &other, int eq) const; - INLINE void set_diff(const Colorf &diff); + INLINE void set_diff(const LColor &diff); INLINE void clear_diff(); INLINE bool has_diff() const; - INLINE Colorf get_diff() const; + INLINE LColor get_diff() const; - INLINE void set_amb(const Colorf &amb); + INLINE void set_amb(const LColor &amb); INLINE void clear_amb(); INLINE bool has_amb() const; - INLINE Colorf get_amb() const; + INLINE LColor get_amb() const; - INLINE void set_emit(const Colorf &emit); + INLINE void set_emit(const LColor &emit); INLINE void clear_emit(); INLINE bool has_emit() const; - INLINE Colorf get_emit() const; + INLINE LColor get_emit() const; - INLINE void set_spec(const Colorf &spec); + INLINE void set_spec(const LColor &spec); INLINE void clear_spec(); INLINE bool has_spec() const; - INLINE Colorf get_spec() const; + INLINE LColor get_spec() const; INLINE void set_shininess(double shininess); INLINE void clear_shininess(); @@ -80,10 +80,10 @@ private: F_local = 0x020 }; - Colorf _diff; - Colorf _amb; - Colorf _emit; - Colorf _spec; + LColor _diff; + LColor _amb; + LColor _emit; + LColor _spec; double _shininess; bool _local; int _flags; diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index 8a67748baa..d81a5efc71 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -341,7 +341,7 @@ get_prim(EggMesherStrip &strip) { // If we have egg_show_tstrips on, it means we need to color every // primitive according to which, if any, tristrip it is in. - Colorf color1, color2; + LColor color1, color2; if (egg_prim->is_of_type(EggTriangleStrip::get_class_type()) || egg_prim->is_of_type(EggTriangleFan::get_class_type())) { @@ -380,7 +380,7 @@ get_prim(EggMesherStrip &strip) { // because the entire primitive gets the same color. // Is this a quadsheet? - Colorf color1; + LColor color1; if (strip._row_id < 0) { // Yep! Assign a new color, if it doesn't already have one. ColorSheetMap::iterator ci = _color_sheets.find(strip._row_id); @@ -422,13 +422,13 @@ get_prim(EggMesherStrip &strip) { // green: fans and retesselated fan polygons. // We need a handful of entries. - Colorf white(0.85, 0.85, 0.85, 1.0); - Colorf dark_blue(0.0, 0.0, 0.75, 1.0); - Colorf light_blue(0.4, 0.4, 0.8, 1.0); - Colorf very_light_blue(0.6, 0.6, 1.0, 1.0); - Colorf green(0.2, 0.8, 0.2, 1.0); + LColor white(0.85, 0.85, 0.85, 1.0); + LColor dark_blue(0.0, 0.0, 0.75, 1.0); + LColor light_blue(0.4, 0.4, 0.8, 1.0); + LColor very_light_blue(0.6, 0.6, 1.0, 1.0); + LColor green(0.2, 0.8, 0.2, 1.0); - Colorf color1; + LColor color1; if (strip._origin == EggMesherStrip::MO_user) { color1 = white; } else if (strip._origin == EggMesherStrip::MO_firstquad) { @@ -449,7 +449,7 @@ get_prim(EggMesherStrip &strip) { make_random_color(color1); // Make it a shade of red. if (color1[0] < color1[1]) { - float t = color1[0]; + PN_stdfloat t = color1[0]; color1[0] = color1[1]; color1[1] = t; } @@ -460,7 +460,7 @@ get_prim(EggMesherStrip &strip) { make_random_color(color1); // Make it a shade of green. if (color1[0] > color1[1]) { - float t = color1[0]; + PN_stdfloat t = color1[0]; color1[0] = color1[1]; color1[1] = t; } @@ -844,9 +844,9 @@ mesh_list(Strips &strips) { // Description: Chooses a reasonable random color. //////////////////////////////////////////////////////////////////// void EggMesher:: -make_random_color(Colorf &color) { - LVector3f rgb; - float len; +make_random_color(LColor &color) { + LVector3 rgb; + PN_stdfloat len; do { for (int i = 0; i < 3; i++) { rgb[i] = (double)rand() / (double)RAND_MAX; diff --git a/panda/src/egg/eggMesher.h b/panda/src/egg/eggMesher.h index bc9a3f836b..05bbef48b3 100644 --- a/panda/src/egg/eggMesher.h +++ b/panda/src/egg/eggMesher.h @@ -58,7 +58,7 @@ private: typedef pmap Verts; // This is used for show-qsheets. - typedef pmap ColorSheetMap; + typedef pmap ColorSheetMap; int count_vert_edges(const EdgePtrs &edges) const; plist &choose_strip_list(const EggMesherStrip &strip); @@ -67,7 +67,7 @@ private: void find_fans(); void make_quads(); void mesh_list(Strips &strips); - static void make_random_color(Colorf &color); + static void make_random_color(LColor &color); bool _flat_shaded; Strips _tris, _quads, _strips; diff --git a/panda/src/egg/eggMesherStrip.I b/panda/src/egg/eggMesherStrip.I index b4df1fb691..a38b1ed4bb 100644 --- a/panda/src/egg/eggMesherStrip.I +++ b/panda/src/egg/eggMesherStrip.I @@ -42,7 +42,7 @@ EggMesherStrip(const EggMesherStrip ©) : // coplanarity(). //////////////////////////////////////////////////////////////////// INLINE bool EggMesherStrip:: -is_coplanar_with(const EggMesherStrip &other, float threshold) const { +is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const { return (coplanarity(other) <= threshold); } @@ -55,7 +55,7 @@ is_coplanar_with(const EggMesherStrip &other, float threshold) const { // at right angles; 2.0 is exactly backfacing. If // either strip is not itself planar, 3.0 is returned. //////////////////////////////////////////////////////////////////// -INLINE float EggMesherStrip:: +INLINE PN_stdfloat EggMesherStrip:: coplanarity(const EggMesherStrip &other) const { if (_planar && other._planar) { return 1.0 - dot(_plane_normal, other._plane_normal); diff --git a/panda/src/egg/eggMesherStrip.h b/panda/src/egg/eggMesherStrip.h index 34947c0c27..9c20b0d514 100644 --- a/panda/src/egg/eggMesherStrip.h +++ b/panda/src/egg/eggMesherStrip.h @@ -81,8 +81,8 @@ public: int count_neighbors() const; void output_neighbors(ostream &out) const; - INLINE bool is_coplanar_with(const EggMesherStrip &other, float threshold) const; - INLINE float coplanarity(const EggMesherStrip &other) const; + INLINE bool is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const; + INLINE PN_stdfloat coplanarity(const EggMesherStrip &other) const; INLINE int type_category() const; int find_uncommon_vertex(const EggMesherEdge *edge) const; @@ -141,7 +141,7 @@ public: bool _planar; Normald _plane_normal; - float _plane_offset; + PN_stdfloat _plane_offset; int _row_id, _row_distance; MesherOrigin _origin; bool _flat_shaded; diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index af0564ae64..4bf5cb37b8 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -50,12 +50,12 @@ private: }; EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); typedef EggMorph EggMorphVertex; typedef EggMorph EggMorphNormal; typedef EggMorph EggMorphTexCoord; -typedef EggMorph EggMorphColor; +typedef EggMorph EggMorphColor; #include "eggMorph.I" diff --git a/panda/src/egg/eggMorphList.cxx b/panda/src/egg/eggMorphList.cxx index e48800c1ec..626721ee74 100644 --- a/panda/src/egg/eggMorphList.cxx +++ b/panda/src/egg/eggMorphList.cxx @@ -30,6 +30,6 @@ #define EXPCL EXPCL_PANDAEGG #define EXPTP EXPTP_PANDAEGG -#define TYPE LVector4f -#define NAME vector_LVector4f +#define TYPE LVector4 +#define NAME vector_LVector4 #include "vector_src.cxx" diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index e6fa8610ee..8cc6dfde9c 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -81,8 +81,8 @@ private: #define EXPCL EXPCL_PANDAEGG #define EXPTP EXPTP_PANDAEGG -#define TYPE LVector4f -#define NAME vector_LVector4f +#define TYPE LVector4 +#define NAME vector_LVector4 #include "vector_src.h" typedef EggMorphList EggMorphVertexList; diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index 4b1227d637..788395612c 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -51,7 +51,7 @@ public: // The per-component difference below which two vertices are deemed // to have the same color. - float _color_threshold; + PN_stdfloat _color_threshold; // The per-component difference below which two anim table values // are deemed to be equivalent. diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index be1ca432cf..045f11ff54 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -400,7 +400,7 @@ unify_attributes(EggPrimitive::Shading shading) { } if (!has_color()) { // If we still don't have a color, the implicit color is white. - set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } } @@ -465,7 +465,7 @@ unify_attributes(EggPrimitive::Shading shading) { } if (!has_color() && shading == S_overall) { - set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } } @@ -1257,10 +1257,10 @@ r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, // Make a special case for not having an overall color: that's // implicitly white. if (!neighbor->has_color() && has_color() && _drgbas.empty() && - get_color() == Colorf(1.0f, 1.0f, 1.0f, 1.0f)) { + get_color() == LColor(1.0f, 1.0f, 1.0f, 1.0f)) { matches_color = true; } else if (!has_color() && neighbor->has_color() && neighbor->_drgbas.empty() && - neighbor->get_color() == Colorf(1.0f, 1.0f, 1.0f, 1.0f)) { + neighbor->get_color() == LColor(1.0f, 1.0f, 1.0f, 1.0f)) { matches_color = true; } } diff --git a/panda/src/egg/eggTexture.I b/panda/src/egg/eggTexture.I index dba194729a..25f1bcfab4 100644 --- a/panda/src/egg/eggTexture.I +++ b/panda/src/egg/eggTexture.I @@ -567,7 +567,7 @@ get_priority() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggTexture:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; _flags |= F_has_color; } @@ -600,7 +600,7 @@ has_color() const { // Description: Returns the blend color if one has been // specified, or (0, 0, 0, 1) otherwise. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &EggTexture:: +INLINE const LColor &EggTexture:: get_color() const { return _color; } @@ -611,7 +611,7 @@ get_color() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void EggTexture:: -set_border_color(const Colorf &border_color) { +set_border_color(const LColor &border_color) { _border_color = border_color; _flags |= F_has_border_color; } @@ -644,7 +644,7 @@ has_border_color() const { // Description: Returns the border color if one has been // specified, or (0, 0, 0, 1) otherwise. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &EggTexture:: +INLINE const LColor &EggTexture:: get_border_color() const { return _border_color; } diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 1b7e5b9ac8..0ed06d4708 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -231,15 +231,15 @@ PUBLISHED: INLINE bool has_priority() const; INLINE int get_priority() const; - INLINE void set_color(const Colorf &color); + INLINE void set_color(const LColor &color); INLINE void clear_color(); INLINE bool has_color() const; - INLINE const Colorf &get_color() const; + INLINE const LColor &get_color() const; - INLINE void set_border_color(const Colorf &border_color); + INLINE void set_border_color(const LColor &border_color); INLINE void clear_border_color(); INLINE bool has_border_color() const; - INLINE const Colorf &get_border_color() const; + INLINE const LColor &get_border_color() const; INLINE void set_uv_name(const string &uv_name); INLINE void clear_uv_name(); @@ -335,8 +335,8 @@ private: QualityLevel _quality_level; string _stage_name; int _priority; - Colorf _color; - Colorf _border_color; + LColor _color; + LColor _border_color; string _uv_name; int _rgb_scale; int _alpha_scale; diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index 0d513c6b5c..500fc278fb 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -262,7 +262,7 @@ has_nonwhite_colors() const { for (ivi = _index_vertices.begin(); ivi != _index_vertices.end(); ++ivi) { EggVertex *vertex = (*ivi).second; if (vertex->has_color() && - (vertex->get_color() != Colorf(1.0, 1.0, 1.0, 1.0) || + (vertex->get_color() != LColor(1.0, 1.0, 1.0, 1.0) || !vertex->_drgbas.empty())) { return true; } @@ -283,7 +283,7 @@ has_nonwhite_colors() const { // different colors, sets has_overall_color to false. //////////////////////////////////////////////////////////////////// void EggVertexPool:: -check_overall_color(bool &has_overall_color, Colorf &overall_color) const { +check_overall_color(bool &has_overall_color, LColor &overall_color) const { if (empty()) { has_overall_color = true; overall_color.set(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index 16781ce53b..42bea2eff0 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -94,7 +94,7 @@ PUBLISHED: bool has_normals() const; bool has_colors() const; bool has_nonwhite_colors() const; - void check_overall_color(bool &has_overall_color, Colorf &overall_color) const; + void check_overall_color(bool &has_overall_color, LColor &overall_color) const; bool has_uvs() const; void get_uv_names(vector_string &uv_names, vector_string &uvw_names, vector_string &tbn_names) const; diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 5d980ccfeb..9808543101 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -584,42 +584,42 @@ texture_body: } } else if (cmp_nocase_uh(name, "blendr") == 0) { - Colorf color = texture->get_color(); + LColor color = texture->get_color(); color[0] = value; texture->set_color(color); } else if (cmp_nocase_uh(name, "blendg") == 0) { - Colorf color = texture->get_color(); + LColor color = texture->get_color(); color[1] = value; texture->set_color(color); } else if (cmp_nocase_uh(name, "blendb") == 0) { - Colorf color = texture->get_color(); + LColor color = texture->get_color(); color[2] = value; texture->set_color(color); } else if (cmp_nocase_uh(name, "blenda") == 0) { - Colorf color = texture->get_color(); + LColor color = texture->get_color(); color[3] = value; texture->set_color(color); } else if (cmp_nocase_uh(name, "borderr") == 0) { - Colorf border_color = texture->get_border_color(); + LColor border_color = texture->get_border_color(); border_color[0] = value; texture->set_border_color(border_color); } else if (cmp_nocase_uh(name, "borderg") == 0) { - Colorf border_color = texture->get_border_color(); + LColor border_color = texture->get_border_color(); border_color[1] = value; texture->set_border_color(border_color); } else if (cmp_nocase_uh(name, "borderb") == 0) { - Colorf border_color = texture->get_border_color(); + LColor border_color = texture->get_border_color(); border_color[2] = value; texture->set_border_color(border_color); } else if (cmp_nocase_uh(name, "bordera") == 0) { - Colorf border_color = texture->get_border_color(); + LColor border_color = texture->get_border_color(); border_color[3] = value; texture->set_border_color(border_color); @@ -745,70 +745,70 @@ material_body: double value = $<_number>5; if (cmp_nocase_uh(name, "diffr") == 0) { - Colorf diff = material->get_diff(); + LColor diff = material->get_diff(); diff[0] = value; material->set_diff(diff); } else if (cmp_nocase_uh(name, "diffg") == 0) { - Colorf diff = material->get_diff(); + LColor diff = material->get_diff(); diff[1] = value; material->set_diff(diff); } else if (cmp_nocase_uh(name, "diffb") == 0) { - Colorf diff = material->get_diff(); + LColor diff = material->get_diff(); diff[2] = value; material->set_diff(diff); } else if (cmp_nocase_uh(name, "diffa") == 0) { - Colorf diff = material->get_diff(); + LColor diff = material->get_diff(); diff[3] = value; material->set_diff(diff); } else if (cmp_nocase_uh(name, "ambr") == 0) { - Colorf amb = material->get_amb(); + LColor amb = material->get_amb(); amb[0] = value; material->set_amb(amb); } else if (cmp_nocase_uh(name, "ambg") == 0) { - Colorf amb = material->get_amb(); + LColor amb = material->get_amb(); amb[1] = value; material->set_amb(amb); } else if (cmp_nocase_uh(name, "ambb") == 0) { - Colorf amb = material->get_amb(); + LColor amb = material->get_amb(); amb[2] = value; material->set_amb(amb); } else if (cmp_nocase_uh(name, "amba") == 0) { - Colorf amb = material->get_amb(); + LColor amb = material->get_amb(); amb[3] = value; material->set_amb(amb); } else if (cmp_nocase_uh(name, "emitr") == 0) { - Colorf emit = material->get_emit(); + LColor emit = material->get_emit(); emit[0] = value; material->set_emit(emit); } else if (cmp_nocase_uh(name, "emitg") == 0) { - Colorf emit = material->get_emit(); + LColor emit = material->get_emit(); emit[1] = value; material->set_emit(emit); } else if (cmp_nocase_uh(name, "emitb") == 0) { - Colorf emit = material->get_emit(); + LColor emit = material->get_emit(); emit[2] = value; material->set_emit(emit); } else if (cmp_nocase_uh(name, "emita") == 0) { - Colorf emit = material->get_emit(); + LColor emit = material->get_emit(); emit[3] = value; material->set_emit(emit); } else if (cmp_nocase_uh(name, "specr") == 0) { - Colorf spec = material->get_spec(); + LColor spec = material->get_spec(); spec[0] = value; material->set_spec(spec); } else if (cmp_nocase_uh(name, "specg") == 0) { - Colorf spec = material->get_spec(); + LColor spec = material->get_spec(); spec[1] = value; material->set_spec(spec); } else if (cmp_nocase_uh(name, "specb") == 0) { - Colorf spec = material->get_spec(); + LColor spec = material->get_spec(); spec[2] = value; material->set_spec(spec); } else if (cmp_nocase_uh(name, "speca") == 0) { - Colorf spec = material->get_spec(); + LColor spec = material->get_spec(); spec[3] = value; material->set_spec(spec); @@ -1127,12 +1127,12 @@ vertex_normal_body: vertex_color_body: real real real real { - DCAST(EggVertex, egg_stack.back())->set_color(Colorf($1, $2, $3, $4)); + DCAST(EggVertex, egg_stack.back())->set_color(LColor($1, $2, $3, $4)); } | vertex_color_body DRGBA string '{' real real real real '}' { bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. - insert(EggMorphColor($3, LVector4f($5, $6, $7, $8))).second; + insert(EggMorphColor($3, LVector4($5, $6, $7, $8))).second; if (!inserted) { eggyywarning("Ignoring repeated morph name " + $3); } @@ -1140,7 +1140,7 @@ vertex_color_body: | vertex_color_body DRGBA '{' string real real real real '}' { bool inserted = DCAST(EggVertex, egg_stack.back())->_drgbas. - insert(EggMorphColor($4, LVector4f($5, $6, $7, $8))).second; + insert(EggMorphColor($4, LVector4($5, $6, $7, $8))).second; if (!inserted) { eggyywarning("Ignoring repeated morph name " + $4); } @@ -1349,22 +1349,22 @@ group_body: } } else if (cmp_nocase_uh(name, "blendr") == 0) { - Colorf color = group->get_blend_color(); + LColor color = group->get_blend_color(); color[0] = value; group->set_blend_color(color); } else if (cmp_nocase_uh(name, "blendg") == 0) { - Colorf color = group->get_blend_color(); + LColor color = group->get_blend_color(); color[1] = value; group->set_blend_color(color); } else if (cmp_nocase_uh(name, "blendb") == 0) { - Colorf color = group->get_blend_color(); + LColor color = group->get_blend_color(); color[2] = value; group->set_blend_color(color); } else if (cmp_nocase_uh(name, "blenda") == 0) { - Colorf color = group->get_blend_color(); + LColor color = group->get_blend_color(); color[3] = value; group->set_blend_color(color); @@ -2329,12 +2329,12 @@ primitive_normal_body: primitive_color_body: real real real real { - DCAST(EggPrimitive, egg_stack.back())->set_color(Colorf($1, $2, $3, $4)); + DCAST(EggPrimitive, egg_stack.back())->set_color(LColor($1, $2, $3, $4)); } | primitive_color_body DRGBA string '{' real real real real '}' { bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. - insert(EggMorphColor($3, LVector4f($5, $6, $7, $8))).second; + insert(EggMorphColor($3, LVector4($5, $6, $7, $8))).second; if (!inserted) { eggyywarning("Ignoring repeated morph name " + $3); } @@ -2342,7 +2342,7 @@ primitive_color_body: | primitive_color_body DRGBA '{' string real real real real '}' { bool inserted = DCAST(EggPrimitive, egg_stack.back())->_drgbas. - insert(EggMorphColor($4, LVector4f($5, $6, $7, $8))).second; + insert(EggMorphColor($4, LVector4($5, $6, $7, $8))).second; if (!inserted) { eggyywarning("Ignoring repeated morph name " + $4); } diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index d87cc7a969..b1244ca27f 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -109,7 +109,7 @@ inspect_tree(EggNode *egg_node) { _fps = egg_anim->get_fps(); } else if (_fps != egg_anim->get_fps()) { // Whoops! This table differs in opinion from the other tables. - _fps = min(_fps, (float)egg_anim->get_fps()); + _fps = min(_fps, (PN_stdfloat)egg_anim->get_fps()); _ok_fps = false; } } @@ -123,7 +123,7 @@ inspect_tree(EggNode *egg_node) { _fps = egg_anim->get_fps(); } else if (_fps != egg_anim->get_fps()) { // Whoops! This table differs in opinion from the other tables. - _fps = min(_fps, (float)egg_anim->get_fps()); + _fps = min(_fps, (PN_stdfloat)egg_anim->get_fps()); _ok_fps = false; } } @@ -235,11 +235,11 @@ create_s_channel(EggSAnimData *egg_anim, const string &name, = new AnimChannelScalarTable(parent, name); // First we have to copy the table data from PTA_double to - // PTA_float. - PTA_float new_data = PTA_float::empty_array(egg_anim->get_num_rows(), - table->get_class_type()); + // PTA_stdfloat. + PTA_stdfloat new_data = PTA_stdfloat::empty_array(egg_anim->get_num_rows(), + table->get_class_type()); for (int i = 0; i < egg_anim->get_num_rows(); i++) { - new_data[i] = (float)egg_anim->get_value(i); + new_data[i] = (PN_stdfloat)egg_anim->get_value(i); } // Now we can assign the table. @@ -321,11 +321,11 @@ create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, } else { // Now we have to copy the table data from PTA_double to - // PTA_float. - PTA_float new_data=PTA_float::empty_array(child->get_num_rows(), + // PTA_stdfloat. + PTA_stdfloat new_data=PTA_stdfloat::empty_array(child->get_num_rows(), table->get_class_type()); for (int i = 0; i < child->get_num_rows(); i++) { - new_data[i] = (float)child->get_value(i); + new_data[i] = (PN_stdfloat)child->get_value(i); } // Now we can assign the table. diff --git a/panda/src/egg2pg/animBundleMaker.h b/panda/src/egg2pg/animBundleMaker.h index 8d7dbe6b01..0fa0d0d9b8 100644 --- a/panda/src/egg2pg/animBundleMaker.h +++ b/panda/src/egg2pg/animBundleMaker.h @@ -56,7 +56,7 @@ private: create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, AnimGroup *parent); - float _fps; + PN_stdfloat _fps; int _num_frames; bool _ok_fps; bool _ok_num_frames; diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 0df6c93b03..d9e0a63db6 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -292,7 +292,7 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { matd = LMatrix4d::ident_mat(); } - LMatrix4f matf = LCAST(float, matd); + LMatrix4 matf = LCAST(PN_stdfloat, matd); CharacterJoint *joint = new CharacterJoint(_character_node, _character_node->get_bundle(0), @@ -305,7 +305,7 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { // entry. if (egg_group->get_default_pose().has_transform()) { matd = egg_group->get_default_pose().get_transform3d(); - matf = LCAST(float, matd); + matf = LCAST(PN_stdfloat, matd); joint->_default_value = matf; joint->_value = matf; } diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index 1789159da2..fdc06814f0 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -56,16 +56,6 @@ ConfigVariableDouble egg_flatten_radius "the user to specify what should be considered \"small\". Set " "it to 0.0 to disable this feature.")); -ConfigVariableBool egg_float64_vertices -("egg-float64-vertices", false, - PRC_DESC("When this is true, the egg loader will store the vertices " - "for all geometry in a 64-bit double-precision float, instead " - "of the standard 32-bit single-precision float. You almost never " - "want to set this true, since current hardware does not support " - "double-precision vertices, and setting this will just require the " - "driver to downsample the vertices at load time, making everything " - "slower.")); - ConfigVariableBool egg_unify ("egg-unify", true, PRC_DESC("When this is true, then in addition to flattening the scene graph " diff --git a/panda/src/egg2pg/config_egg2pg.h b/panda/src/egg2pg/config_egg2pg.h index 5bad7a8aa8..c5096b4e02 100644 --- a/panda/src/egg2pg/config_egg2pg.h +++ b/panda/src/egg2pg/config_egg2pg.h @@ -38,7 +38,6 @@ extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_clamp; extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_decals; extern EXPCL_PANDAEGG ConfigVariableBool egg_flatten; extern EXPCL_PANDAEGG ConfigVariableDouble egg_flatten_radius; -extern EXPCL_PANDAEGG ConfigVariableBool egg_float64_vertices; extern EXPCL_PANDAEGG ConfigVariableBool egg_unify; extern EXPCL_PANDAEGG ConfigVariableBool egg_combine_geoms; extern EXPCL_PANDAEGG ConfigVariableBool egg_rigid_geometry; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 12639c6a14..838ccdacdd 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -370,7 +370,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, // vertex_pool->write(cerr, 0); bool has_overall_color; - Colorf overall_color; + LColor overall_color; vertex_pool->check_overall_color(has_overall_color, overall_color); if (!egg_flat_colors) { // If flat colors aren't allowed, then we don't care whether @@ -447,7 +447,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, CPT(RenderState) geom_state = render_state->_state; if (has_overall_color) { - if (!overall_color.almost_equal(Colorf(1.0f, 1.0f, 1.0f, 1.0f))) { + if (!overall_color.almost_equal(LColor(1.0f, 1.0f, 1.0f, 1.0f))) { geom_state = geom_state->add_attrib(ColorAttrib::make_flat(overall_color), -1); } } else { @@ -484,85 +484,85 @@ make_transform(const EggTransform *egg_transform) { switch (egg_transform->get_component_type(i)) { case EggTransform::CT_translate2d: { - LVecBase2f trans2d(LCAST(float, egg_transform->get_component_vec2(i))); - LVecBase3f trans3d(trans2d[0], trans2d[1], 0.0f); + LVecBase2 trans2d(LCAST(PN_stdfloat, egg_transform->get_component_vec2(i))); + LVecBase3 trans3d(trans2d[0], trans2d[1], 0.0f); ts = TransformState::make_pos(trans3d)->compose(ts); } break; case EggTransform::CT_translate3d: { - LVecBase3f trans3d(LCAST(float, egg_transform->get_component_vec3(i))); + LVecBase3 trans3d(LCAST(PN_stdfloat, egg_transform->get_component_vec3(i))); ts = TransformState::make_pos(trans3d)->compose(ts); } break; case EggTransform::CT_rotate2d: { - LRotationf rot(LVector3f(0.0f, 0.0f, 1.0f), - (float)egg_transform->get_component_number(i)); + LRotation rot(LVector3(0.0f, 0.0f, 1.0f), + (PN_stdfloat)egg_transform->get_component_number(i)); ts = TransformState::make_quat(rot)->compose(ts); } break; case EggTransform::CT_rotx: { - LRotationf rot(LVector3f(1.0f, 0.0f, 0.0f), - (float)egg_transform->get_component_number(i)); + LRotation rot(LVector3(1.0f, 0.0f, 0.0f), + (PN_stdfloat)egg_transform->get_component_number(i)); ts = TransformState::make_quat(rot)->compose(ts); } break; case EggTransform::CT_roty: { - LRotationf rot(LVector3f(0.0f, 1.0f, 0.0f), - (float)egg_transform->get_component_number(i)); + LRotation rot(LVector3(0.0f, 1.0f, 0.0f), + (PN_stdfloat)egg_transform->get_component_number(i)); ts = TransformState::make_quat(rot)->compose(ts); } break; case EggTransform::CT_rotz: { - LRotationf rot(LVector3f(0.0f, 0.0f, 1.0f), - (float)egg_transform->get_component_number(i)); + LRotation rot(LVector3(0.0f, 0.0f, 1.0f), + (PN_stdfloat)egg_transform->get_component_number(i)); ts = TransformState::make_quat(rot)->compose(ts); } break; case EggTransform::CT_rotate3d: { - LRotationf rot(LCAST(float, egg_transform->get_component_vec3(i)), - (float)egg_transform->get_component_number(i)); + LRotation rot(LCAST(PN_stdfloat, egg_transform->get_component_vec3(i)), + (PN_stdfloat)egg_transform->get_component_number(i)); ts = TransformState::make_quat(rot)->compose(ts); } break; case EggTransform::CT_scale2d: { - LVecBase2f scale2d(LCAST(float, egg_transform->get_component_vec2(i))); - LVecBase3f scale3d(scale2d[0], scale2d[1], 1.0f); + LVecBase2 scale2d(LCAST(PN_stdfloat, egg_transform->get_component_vec2(i))); + LVecBase3 scale3d(scale2d[0], scale2d[1], 1.0f); ts = TransformState::make_scale(scale3d)->compose(ts); } break; case EggTransform::CT_scale3d: { - LVecBase3f scale3d(LCAST(float, egg_transform->get_component_vec3(i))); + LVecBase3 scale3d(LCAST(PN_stdfloat, egg_transform->get_component_vec3(i))); ts = TransformState::make_scale(scale3d)->compose(ts); } break; case EggTransform::CT_uniform_scale: { - float scale = (float)egg_transform->get_component_number(i); + PN_stdfloat scale = (PN_stdfloat)egg_transform->get_component_number(i); ts = TransformState::make_scale(scale)->compose(ts); } break; case EggTransform::CT_matrix3: { - LMatrix3f m(LCAST(float, egg_transform->get_component_mat3(i))); - LMatrix4f mat4(m(0, 0), m(0, 1), 0.0, m(0, 2), + LMatrix3 m(LCAST(PN_stdfloat, egg_transform->get_component_mat3(i))); + LMatrix4 mat4(m(0, 0), m(0, 1), 0.0, m(0, 2), m(1, 0), m(1, 1), 0.0, m(1, 2), 0.0, 0.0, 1.0, 0.0, m(2, 0), m(2, 1), 0.0, m(2, 2)); @@ -573,7 +573,7 @@ make_transform(const EggTransform *egg_transform) { case EggTransform::CT_matrix4: { - LMatrix4f mat4(LCAST(float, egg_transform->get_component_mat4(i))); + LMatrix4 mat4(LCAST(PN_stdfloat, egg_transform->get_component_mat4(i))); ts = TransformState::make_mat(mat4)->compose(ts); } break; @@ -624,8 +624,8 @@ show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node) { if (vert->has_normal()) { vertex.add_data3d(pos); vertex.add_data3d(pos + vert->get_normal() * egg_normal_scale); - color.add_data4f(1.0f, 0.0f, 0.0f, 1.0f); - color.add_data4f(1.0f, 0.0f, 0.0f, 1.0f); + color.add_data4(1.0f, 0.0f, 0.0f, 1.0f); + color.add_data4(1.0f, 0.0f, 0.0f, 1.0f); primitive->add_next_vertices(2); primitive->close_primitive(); } @@ -638,16 +638,16 @@ show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node) { if (uv_obj->has_tangent()) { vertex.add_data3d(pos); vertex.add_data3d(pos + uv_obj->get_tangent() * egg_normal_scale); - color.add_data4f(0.0f, 1.0f, 0.0f, 1.0f); - color.add_data4f(0.0f, 1.0f, 0.0f, 1.0f); + color.add_data4(0.0f, 1.0f, 0.0f, 1.0f); + color.add_data4(0.0f, 1.0f, 0.0f, 1.0f); primitive->add_next_vertices(2); primitive->close_primitive(); } if (uv_obj->has_binormal()) { vertex.add_data3d(pos); vertex.add_data3d(pos + uv_obj->get_binormal() * egg_normal_scale); - color.add_data4f(0.0f, 0.0f, 1.0f, 1.0f); - color.add_data4f(0.0f, 0.0f, 1.0f, 1.0f); + color.add_data4(0.0f, 0.0f, 1.0f, 1.0f); + color.add_data4(0.0f, 0.0f, 1.0f, 1.0f); primitive->add_next_vertices(2); primitive->close_primitive(); } @@ -764,7 +764,7 @@ make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, EggPrimitive::const_iterator pi; for (pi = egg_curve->begin(); pi != egg_curve->end(); ++pi) { - nurbs->append_cv(LCAST(float, (*pi)->get_pos4() * mat)); + nurbs->append_cv(LCAST(PN_stdfloat, (*pi)->get_pos4() * mat)); } int num_knots = egg_curve->get_num_knots(); @@ -1783,7 +1783,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { if (!instances.empty()) { // Set up the LOD node's center. All of the children should have // the same center, because that's how we binned them. - lod_node->set_center(LCAST(float, instances[0]._d->_center)); + lod_node->set_center(LCAST(PN_stdfloat, instances[0]._d->_center)); } for (size_t i = 0; i < instances.size(); i++) { @@ -1794,7 +1794,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { // All of the children should have the same center, because that's // how we binned them. nassertr(lod_node->get_center().almost_equal - (LCAST(float, instance._d->_center), 0.01), NULL); + (LCAST(PN_stdfloat, instance._d->_center), 0.01), NULL); // Tell the LOD node about this child's switching distances. lod_node->add_switch(instance._d->_switch_in, instance._d->_switch_out); @@ -1886,9 +1886,9 @@ make_node(EggGroup *egg_group, PandaNode *parent) { // Create a polylight instead of a regular polyset. // use make_sphere to get the center, radius and color //egg2pg_cat.debug() << "polylight node\n"; - LPoint3f center; - Colorf color; - float radius; + LPoint3 center; + LColor color; + PN_stdfloat radius; if (!make_sphere(egg_group, EggGroup::CF_none, center, radius, color)) { egg2pg_cat.warning() @@ -2058,7 +2058,7 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { ColorBlendAttrib::Mode mode = get_color_blend_mode(egg_group->get_blend_mode()); ColorBlendAttrib::Operand a = get_color_blend_operand(egg_group->get_blend_operand_a()); ColorBlendAttrib::Operand b = get_color_blend_operand(egg_group->get_blend_operand_b()); - Colorf color = egg_group->get_blend_color(); + LColor color = egg_group->get_blend_color(); node->set_attrib(ColorBlendAttrib::make(mode, a, b, color)); } @@ -2198,21 +2198,15 @@ make_vertex_data(const EggRenderState *render_state, return (*di).second; } - // Decide on the format for the vertices. - Geom::NumericType vertex_numeric_type = Geom::NT_float32; - if (egg_float64_vertices) { - vertex_numeric_type = Geom::NT_float64; - } - PT(GeomVertexArrayFormat) array_format = new GeomVertexArrayFormat; array_format->add_column (InternalName::get_vertex(), vertex_pool->get_num_dimensions(), - vertex_numeric_type, Geom::C_point); + Geom::NT_stdfloat, Geom::C_point); if (vertex_pool->has_normals()) { array_format->add_column (InternalName::get_normal(), 3, - Geom::NT_float32, Geom::C_vector); + Geom::NT_stdfloat, Geom::C_vector); } if (!ignore_color) { @@ -2232,10 +2226,10 @@ make_vertex_data(const EggRenderState *render_state, if (find(uvw_names.begin(), uvw_names.end(), name) != uvw_names.end()) { // This one actually represents 3-d texture coordinates. array_format->add_column - (iname, 3, Geom::NT_float32, Geom::C_texcoord); + (iname, 3, Geom::NT_stdfloat, Geom::C_texcoord); } else { array_format->add_column - (iname, 2, Geom::NT_float32, Geom::C_texcoord); + (iname, 2, Geom::NT_stdfloat, Geom::C_texcoord); } } for (ni = tbn_names.begin(); ni != tbn_names.end(); ++ni) { @@ -2243,10 +2237,10 @@ make_vertex_data(const EggRenderState *render_state, PT(InternalName) iname = InternalName::get_tangent_name(name); array_format->add_column - (iname, 3, Geom::NT_float32, Geom::C_vector); + (iname, 3, Geom::NT_stdfloat, Geom::C_vector); iname = InternalName::get_binormal_name(name); array_format->add_column - (iname, 3, Geom::NT_float32, Geom::C_vector); + (iname, 3, Geom::NT_stdfloat, Geom::C_vector); } PT(GeomVertexFormat) temp_format = new GeomVertexFormat(array_format); @@ -2397,7 +2391,7 @@ make_vertex_data(const EggRenderState *render_state, if (!ignore_color && vertex->has_color()) { gvw.set_column(InternalName::get_color()); - gvw.add_data4f(vertex->get_color()); + gvw.add_data4(vertex->get_color()); if (is_dynamic) { EggMorphColorList::const_iterator mci; @@ -2406,7 +2400,7 @@ make_vertex_data(const EggRenderState *render_state, CPT(InternalName) delta_name = InternalName::get_morph(InternalName::get_color(), morph.get_name()); gvw.set_column(delta_name); - gvw.add_data4f(morph.get_offset()); + gvw.add_data4(morph.get_offset()); } } } @@ -2513,7 +2507,7 @@ record_morph(GeomVertexArrayFormat *array_format, if (!array_format->has_column(delta_name)) { array_format->add_column (delta_name, num_components, - Geom::NT_float32, Geom::C_morph_delta); + Geom::NT_stdfloat, Geom::C_morph_delta); } } @@ -2527,7 +2521,7 @@ void EggLoader:: make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, EggLoader::UniquePrimitives &unique_primitives, EggLoader::Primitives &primitives, - bool has_overall_color, const Colorf &overall_color) { + bool has_overall_color, const LColor &overall_color) { PT(GeomPrimitive) primitive; if (egg_prim->is_of_type(EggPolygon::get_class_type())) { if (egg_prim->size() == 3) { @@ -2630,7 +2624,7 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { EggPolygon::const_iterator vi; for (vi = poly->begin(); vi != poly->end(); ++vi) { Vertexd vert = (*vi)->get_pos3() * mat; - pnode->add_vertex(LCAST(float, vert)); + pnode->add_vertex(LCAST(PN_stdfloat, vert)); } } } @@ -2656,10 +2650,10 @@ set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { LPoint3d v1 = (*poly)[1]->get_pos3() * mat; LPoint3d v2 = (*poly)[2]->get_pos3() * mat; LPoint3d v3 = (*poly)[3]->get_pos3() * mat; - pnode->set_vertices(LCAST(float, v0), - LCAST(float, v1), - LCAST(float, v2), - LCAST(float, v3)); + pnode->set_vertices(LCAST(PN_stdfloat, v0), + LCAST(PN_stdfloat, v1), + LCAST(PN_stdfloat, v2), + LCAST(PN_stdfloat, v3)); if (poly->get_bface_flag()) { pnode->set_double_sided(true); @@ -2711,7 +2705,7 @@ find_first_polygon(EggGroup *egg_group) { //////////////////////////////////////////////////////////////////// bool EggLoader:: make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, - LPoint3f ¢er, float &radius, Colorf &color) { + LPoint3 ¢er, PN_stdfloat &radius, LColor &color) { bool success=false; EggGroup *geom_group = find_collision_geometry(egg_group, flags); if (geom_group != (EggGroup *)NULL) { @@ -2756,7 +2750,7 @@ make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, radius2 = max(radius2, v.length_squared()); } - center = LCAST(float, d_center); + center = LCAST(PN_stdfloat, d_center); radius = sqrtf(radius2); //egg2pg_cat.debug() << "make_sphere radius: " << radius << "\n"; @@ -2947,9 +2941,9 @@ make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode, void EggLoader:: make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { - LPoint3f center; - float radius; - Colorf dummycolor; + LPoint3 center; + PN_stdfloat radius; + LColor dummycolor; if (make_sphere(egg_group, flags, center, radius, dummycolor)) { CollisionSphere *cssphere = new CollisionSphere(center, radius); @@ -2967,9 +2961,9 @@ make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, void EggLoader:: make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { - LPoint3f center; - float radius; - Colorf dummycolor; + LPoint3 center; + PN_stdfloat radius; + LColor dummycolor; if (make_sphere(egg_group, flags, center, radius, dummycolor)) { CollisionInvSphere *cssphere = new CollisionInvSphere(center, radius); @@ -3171,7 +3165,7 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, LPoint3d point_b = center + half; CollisionTube *cstube = - new CollisionTube(LCAST(float, point_a), LCAST(float, point_b), + new CollisionTube(LCAST(PN_stdfloat, point_a), LCAST(PN_stdfloat, point_b), radius); apply_collision_flags(cstube, flags); cnode->add_solid(cstube); @@ -3193,7 +3187,7 @@ apply_collision_flags(CollisionSolid *solid, EggGroup::CollideFlags flags) { solid->set_tangible(false); } if ((flags & EggGroup::CF_level) != 0) { - solid->set_effective_normal(LVector3f::up()); + solid->set_effective_normal(LVector3::up()); } } @@ -3259,20 +3253,20 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { LMatrix4d mat = egg_poly->get_vertex_to_node(); - pvector vertices; + pvector vertices; if (!egg_poly->empty()) { EggPolygon::const_iterator vi; vi = egg_poly->begin(); Vertexd vert = (*vi)->get_pos3() * mat; - vertices.push_back(LCAST(float, vert)); + vertices.push_back(LCAST(PN_stdfloat, vert)); Vertexd last_vert = vert; ++vi; while (vi != egg_poly->end()) { vert = (*vi)->get_pos3() * mat; if (!vert.almost_equal(last_vert)) { - vertices.push_back(LCAST(float, vert)); + vertices.push_back(LCAST(PN_stdfloat, vert)); } last_vert = vert; @@ -3283,7 +3277,7 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { if (vertices.size() < 3) { return NULL; } - Planef plane(vertices[0], vertices[1], vertices[2]); + LPlane plane(vertices[0], vertices[1], vertices[2]); return new CollisionPlane(plane); } @@ -3321,20 +3315,20 @@ create_collision_polygons(CollisionNode *cnode, EggPolygon *egg_poly, for (ci = group->begin(); ci != group->end(); ++ci) { EggPolygon *poly = DCAST(EggPolygon, *ci); - pvector vertices; + pvector vertices; if (!poly->empty()) { EggPolygon::const_iterator vi; vi = poly->begin(); Vertexd vert = (*vi)->get_pos3() * mat; - vertices.push_back(LCAST(float, vert)); + vertices.push_back(LCAST(PN_stdfloat, vert)); Vertexd last_vert = vert; ++vi; while (vi != poly->end()) { vert = (*vi)->get_pos3() * mat; if (!vert.almost_equal(last_vert)) { - vertices.push_back(LCAST(float, vert)); + vertices.push_back(LCAST(PN_stdfloat, vert)); } last_vert = vert; @@ -3343,8 +3337,8 @@ create_collision_polygons(CollisionNode *cnode, EggPolygon *egg_poly, } if (vertices.size() >= 3) { - const Vertexf *vertices_begin = &vertices[0]; - const Vertexf *vertices_end = vertices_begin + vertices.size(); + const LVertex *vertices_begin = &vertices[0]; + const LVertex *vertices_end = vertices_begin + vertices.size(); PT(CollisionPolygon) cspoly = new CollisionPolygon(vertices_begin, vertices_end); if (cspoly->is_valid()) { @@ -3434,7 +3428,7 @@ create_collision_floor_mesh(CollisionNode *cnode, EggVertexPool::const_iterator vi; for (vi = pool.begin(); vi != pool.end(); vi++) { - csfloor->add_vertex(LCAST(float,(*vi)->get_pos3())); + csfloor->add_vertex(LCAST(PN_stdfloat,(*vi)->get_pos3())); } pvector::iterator ti; diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index 28d4a69c4f..2908f8a62f 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -154,14 +154,14 @@ private: EggPrimitive *egg_prim, UniquePrimitives &unique_primitives, Primitives &primitives, - bool has_overall_color, const Colorf &overall_color); + bool has_overall_color, const LColor &overall_color); void set_portal_polygon(EggGroup *egg_group, PortalNode *pnode); void set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode); PT(EggPolygon) find_first_polygon(EggGroup *egg_group); bool make_sphere(EggGroup *start_group, EggGroup::CollideFlags flags, - LPoint3f ¢er, float &radius, Colorf &color); + LPoint3 ¢er, PN_stdfloat &radius, LColor &color); void make_collision_solids(EggGroup *start_group, EggGroup *egg_group, CollisionNode *cnode); @@ -243,7 +243,7 @@ private: typedef pmap VertexPoolData; VertexPoolData _vertex_pool_data; - typedef pmap TransformStates; + typedef pmap TransformStates; TransformStates _transform_states; DeferredNodes _deferred_nodes; diff --git a/panda/src/egg2pg/egg_parametrics.cxx b/panda/src/egg2pg/egg_parametrics.cxx index aed96ddd30..00b8d91dc9 100644 --- a/panda/src/egg2pg/egg_parametrics.cxx +++ b/panda/src/egg2pg/egg_parametrics.cxx @@ -52,9 +52,9 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { for (int vi = 0; vi < num_v_vertices; vi++) { int i = egg_surface->get_vertex_index(ui, vi); EggVertex *egg_vertex = egg_surface->get_vertex(i); - nurbs->set_vertex(ui, vi, LCAST(float, egg_vertex->get_pos4() * mat)); + nurbs->set_vertex(ui, vi, LCAST(PN_stdfloat, egg_vertex->get_pos4() * mat)); - Colorf color = egg_vertex->get_color(); + LColor color = egg_vertex->get_color(); nurbs->set_extended_vertices(ui, vi, 0, color.get_data(), 4); } } @@ -114,8 +114,8 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { int vi = 0; for (pi = egg_curve->begin(); pi != egg_curve->end(); ++pi) { EggVertex *egg_vertex = (*pi); - nurbs->set_vertex(vi, LCAST(float, egg_vertex->get_pos4() * mat)); - Colorf color = egg_vertex->get_color(); + nurbs->set_vertex(vi, LCAST(PN_stdfloat, egg_vertex->get_pos4() * mat)); + LColor color = egg_vertex->get_color(); nurbs->set_extended_vertices(vi, 0, color.get_data(), 4); vi++; } diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index 49e6a7b897..17e039bb1e 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -49,7 +49,8 @@ pointerToVoid.I pointerToVoid.h \ profileTimer.I profileTimer.h \ pta_int.h \ - pta_uchar.h pta_float.h \ + pta_uchar.h pta_double.h pta_float.h \ + pta_stdfloat.h \ ramfile.I ramfile.h \ referenceCount.I referenceCount.h \ subStream.I subStream.h subStreamBuf.h \ @@ -59,7 +60,8 @@ threadSafePointerToBase.I threadSafePointerToBase.h \ trueClock.I trueClock.h \ typedReferenceCount.I typedReferenceCount.h typedef.h \ - vector_uchar.h vector_float.h \ + vector_uchar.h vector_double.h vector_float.h \ + vector_stdfloat.h \ virtualFile.I virtualFileList.I virtualFileList.h virtualFileMount.h \ virtualFileComposite.h virtualFileComposite.I virtualFile.h \ virtualFileMount.I virtualFileMountMultifile.h \ @@ -105,7 +107,7 @@ pointerToVoid.cxx \ profileTimer.cxx \ pta_int.cxx \ - pta_uchar.cxx pta_float.cxx \ + pta_uchar.cxx pta_double.cxx pta_float.cxx \ ramfile.cxx \ referenceCount.cxx \ subStream.cxx subStreamBuf.cxx \ @@ -115,7 +117,7 @@ threadSafePointerToBase.cxx \ trueClock.cxx \ typedReferenceCount.cxx \ - vector_uchar.cxx vector_float.cxx \ + vector_uchar.cxx vector_double.cxx vector_float.cxx \ virtualFileComposite.cxx virtualFile.cxx virtualFileList.cxx \ virtualFileMount.cxx \ virtualFileMountMultifile.cxx \ @@ -170,7 +172,8 @@ pointerToVoid.I pointerToVoid.h \ profileTimer.I profileTimer.h \ pta_int.h \ - pta_uchar.h pta_float.h \ + pta_uchar.h pta_double.h pta_float.h \ + pta_stdfloat.h \ ramfile.I ramfile.h \ referenceCount.I referenceCount.h \ subStream.I subStream.h subStreamBuf.h \ @@ -180,7 +183,8 @@ threadSafePointerToBase.I threadSafePointerToBase.h \ trueClock.I trueClock.h \ typedReferenceCount.I typedReferenceCount.h typedef.h \ - vector_uchar.h vector_float.h \ + vector_uchar.h vector_double.h vector_float.h \ + vector_stdfloat.h \ virtualFile.I virtualFileList.I virtualFileList.h virtualFileMount.h \ virtualFileComposite.h virtualFileComposite.I virtualFile.h \ virtualFileMount.I virtualFileMountMultifile.h \ diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 4d6e33ebb5..4a77f8f59e 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -167,11 +167,7 @@ add_uint64(PN_uint64 value) { // special care is required. //////////////////////////////////////////////////////////////////// INLINE void Datagram:: -add_float32(float value) { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. - nassertv(sizeof(value) == 4); +add_float32(PN_float32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } @@ -187,6 +183,22 @@ add_float64(PN_float64 value) { append_data(s.get_data(), sizeof(value)); } +//////////////////////////////////////////////////////////////////// +// Function: Datagram::add_stdfloat +// Access: Public +// Description: Adds either a 32-bit or a 64-bit floating-point +// number, according to the current Panda build +// configuration. +//////////////////////////////////////////////////////////////////// +INLINE void Datagram:: +add_stdfloat(PN_stdfloat value) { +#ifndef STDFLOAT_DOUBLE + add_float32(value); +#else + add_float64(value); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: Datagram::add_be_int16 // Access: Public @@ -263,16 +275,10 @@ add_be_uint64(PN_uint64 value) { // Function: Datagram::add_be_float32 // Access: Public // Description: Adds a 32-bit single-precision big-endian -// floating-point number to the datagram. Since this -// kind of float is not necessarily portable across -// different architectures, special care is required. +// floating-point number to the datagram. //////////////////////////////////////////////////////////////////// INLINE void Datagram:: -add_be_float32(float value) { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. - nassertv(sizeof(value) == 4); +add_be_float32(PN_float32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 989b05ca2b..2d9b84d103 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -64,8 +64,9 @@ PUBLISHED: INLINE void add_uint16(PN_uint16 value); INLINE void add_uint32(PN_uint32 value); INLINE void add_uint64(PN_uint64 value); - INLINE void add_float32(float value); + INLINE void add_float32(PN_float32 value); INLINE void add_float64(PN_float64 value); + INLINE void add_stdfloat(PN_stdfloat value); // These functions pack numbers big-endian, in case that's desired. INLINE void add_be_int16(PN_int16 value); @@ -74,7 +75,7 @@ PUBLISHED: INLINE void add_be_uint16(PN_uint16 value); INLINE void add_be_uint32(PN_uint32 value); INLINE void add_be_uint64(PN_uint64 value); - INLINE void add_be_float32(float value); + INLINE void add_be_float32(PN_float32 value); INLINE void add_be_float64(PN_float64 value); INLINE void add_string(const string &str); diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 43dad1f6c3..d02d30647c 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -255,20 +255,14 @@ get_uint64() { // Function: DatagramIterator::get_float32 // Access: Public // Description: Extracts a 32-bit single-precision floating-point -// number. Since this kind of float is not necessarily -// portable across different architectures, special care -// is required. +// number. //////////////////////////////////////////////////////////////////// -INLINE float DatagramIterator:: +INLINE PN_float32 DatagramIterator:: get_float32() { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. - nassertr(sizeof(float) == 4, 0.0f); nassertr(_datagram != (const Datagram *)NULL, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); - float tempvar; + PN_float32 tempvar; // Avoid reading junk data off the end of the datagram: nassertr(_current_index + sizeof(tempvar) <= _datagram->get_length(), 0.0); // Get the Data: @@ -300,6 +294,23 @@ get_float64() { return tempvar; } + +//////////////////////////////////////////////////////////////////// +// Function: DatagramIterator::get_stdfloat +// Access: Public +// Description: Extracts either a 32-bit or a 64-bit floating-point +// number, according to the current Panda build +// configuration. +//////////////////////////////////////////////////////////////////// +INLINE PN_stdfloat DatagramIterator:: +get_stdfloat() { +#ifndef STDFLOAT_DOUBLE + return get_float32(); +#else + return get_float64(); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: DatagramIterator::get_be_int16 // Access: Public @@ -430,20 +441,14 @@ get_be_uint64() { // Function: DatagramIterator::get_be_float32 // Access: Public // Description: Extracts a 32-bit big-endian single-precision -// floating-point number. Since this kind of float is -// not necessarily portable across different -// architectures, special care is required. +// floating-point number. //////////////////////////////////////////////////////////////////// -INLINE float DatagramIterator:: +INLINE PN_float32 DatagramIterator:: get_be_float32() { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. - nassertr(sizeof(float) == 4, 0.0f); nassertr(_datagram != (const Datagram *)NULL, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); - float tempvar; + PN_float32 tempvar; // Avoid reading junk data off the end of the datagram: nassertr(_current_index + sizeof(tempvar) <= _datagram->get_length(), 0); // Get the Data: diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index cf71056982..9b2c51139e 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -47,8 +47,9 @@ PUBLISHED: INLINE PN_uint16 get_uint16(); INLINE PN_uint32 get_uint32(); INLINE PN_uint64 get_uint64(); - INLINE float get_float32(); + INLINE PN_float32 get_float32(); INLINE PN_float64 get_float64(); + INLINE PN_stdfloat get_stdfloat(); INLINE PN_int16 get_be_int16(); INLINE PN_int32 get_be_int32(); @@ -56,7 +57,7 @@ PUBLISHED: INLINE PN_uint16 get_be_uint16(); INLINE PN_uint32 get_be_uint32(); INLINE PN_uint64 get_be_uint64(); - INLINE float get_be_float32(); + INLINE PN_float32 get_be_float32(); INLINE PN_float64 get_be_float64(); string get_string(); diff --git a/panda/src/express/express_composite2.cxx b/panda/src/express/express_composite2.cxx index f7d4177826..f1b2c17828 100644 --- a/panda/src/express/express_composite2.cxx +++ b/panda/src/express/express_composite2.cxx @@ -1,5 +1,6 @@ #include "pta_int.cxx" #include "pta_uchar.cxx" +#include "pta_double.cxx" #include "pta_float.cxx" #include "ramfile.cxx" #include "referenceCount.cxx" @@ -12,6 +13,7 @@ #include "trueClock.cxx" #include "typedReferenceCount.cxx" #include "vector_uchar.cxx" +#include "vector_double.cxx" #include "vector_float.cxx" #include "virtualFile.cxx" #include "virtualFileComposite.cxx" diff --git a/panda/src/express/patchfile.I b/panda/src/express/patchfile.I index 29320b1dc1..d7aae93ef2 100644 --- a/panda/src/express/patchfile.I +++ b/panda/src/express/patchfile.I @@ -21,7 +21,7 @@ // amount of progress through the patchfile, during a // session. //////////////////////////////////////////////////////////////////// -INLINE float Patchfile:: +INLINE PN_stdfloat Patchfile:: get_progress() const { if (!_initiated) { express_cat.warning() @@ -29,7 +29,7 @@ get_progress() const { return 0.0f; } nassertr(_total_bytes_to_process > 0, 0.0f); - return ((float)_total_bytes_processed / (float)_total_bytes_to_process); + return ((PN_stdfloat)_total_bytes_processed / (PN_stdfloat)_total_bytes_to_process); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/patchfile.h b/panda/src/express/patchfile.h index 0704f8b4b9..5821b24016 100644 --- a/panda/src/express/patchfile.h +++ b/panda/src/express/patchfile.h @@ -56,7 +56,7 @@ PUBLISHED: bool apply(Filename &patch_file, Filename &orig_file, const Filename &target_file); - INLINE float get_progress() const; + INLINE PN_stdfloat get_progress() const; INLINE void set_allow_multifile(bool allow_multifile); INLINE bool get_allow_multifile(); diff --git a/panda/src/putil/pta_double.cxx b/panda/src/express/pta_double.cxx similarity index 100% rename from panda/src/putil/pta_double.cxx rename to panda/src/express/pta_double.cxx diff --git a/panda/src/putil/pta_double.h b/panda/src/express/pta_double.h similarity index 77% rename from panda/src/putil/pta_double.h rename to panda/src/express/pta_double.h index 14bd6724c8..73c1d89e1b 100644 --- a/panda/src/putil/pta_double.h +++ b/panda/src/express/pta_double.h @@ -29,10 +29,10 @@ // rather than defining the pta again. //////////////////////////////////////////////////////////////////// -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, PointerToBase >) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, PointerToArrayBase) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, PointerToArray) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ConstPointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArray) typedef PointerToArray PTA_double; typedef ConstPointerToArray CPTA_double; diff --git a/panda/src/express/pta_stdfloat.h b/panda/src/express/pta_stdfloat.h new file mode 100644 index 0000000000..ca6c45dfc0 --- /dev/null +++ b/panda/src/express/pta_stdfloat.h @@ -0,0 +1,31 @@ +// Filename: pta_stdfloat.h +// Created by: drose (07Oct11) +// +//////////////////////////////////////////////////////////////////// +// +// 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 PTA_STDFLOAT_H +#define PTA_STDFLOAT_H + +#include "pandabase.h" + +#include "pta_double.h" +#include "pta_float.h" + +#ifndef STDFLOAT_DOUBLE +typedef PTA_float PTA_stdfloat; +typedef CPTA_float CPTA_stdfloat; +#else +typedef PTA_double PTA_stdfloat; +typedef CPTA_double CPTA_stdfloat; +#endif // STDFLOAT_DOUBLE + +#endif diff --git a/panda/src/putil/vector_double.cxx b/panda/src/express/vector_double.cxx similarity index 100% rename from panda/src/putil/vector_double.cxx rename to panda/src/express/vector_double.cxx diff --git a/panda/src/putil/vector_double.h b/panda/src/express/vector_double.h similarity index 95% rename from panda/src/putil/vector_double.h rename to panda/src/express/vector_double.h index 7b2069c282..35d739b3ac 100644 --- a/panda/src/putil/vector_double.h +++ b/panda/src/express/vector_double.h @@ -28,8 +28,8 @@ // rather than defining the vector again. //////////////////////////////////////////////////////////////////// -#define EXPCL EXPCL_PANDA_PUTIL -#define EXPTP EXPTP_PANDA_PUTIL +#define EXPCL EXPCL_PANDAEXPRESS +#define EXPTP EXPTP_PANDAEXPRESS #define TYPE double #define NAME vector_double diff --git a/panda/src/effects/config_effects.h b/panda/src/express/vector_stdfloat.h similarity index 59% rename from panda/src/effects/config_effects.h rename to panda/src/express/vector_stdfloat.h index bdfec79ac3..9c9885fc0b 100644 --- a/panda/src/effects/config_effects.h +++ b/panda/src/express/vector_stdfloat.h @@ -1,5 +1,5 @@ -// Filename: config_effects.h -// Created by: jason (18Jul00) +// Filename: vector_stdfloat.h +// Created by: drose (07Oct11) // //////////////////////////////////////////////////////////////////// // @@ -12,15 +12,19 @@ // //////////////////////////////////////////////////////////////////// - -#ifndef CONFIG_EFFECTS_H -#define CONFIG_EFFECTS_H +#ifndef VECTOR_STDFLOAT_H +#define VECTOR_STDFLOAT_H #include "pandabase.h" -#include "notifyCategoryProxy.h" -NotifyCategoryDecl(effects, EXPCL_PANDAFX, EXPTP_PANDAFX); +#include "vector_double.h" +#include "vector_float.h" -extern EXPCL_PANDAFX void init_libeffects(); +#ifndef STDFLOAT_DOUBLE +typedef vector_float vector_stdfloat; +#else +typedef vector_double vector_stdfloat; +#endif // STDFLOAT_DOUBLE + +#endif -#endif /* CONFIG_EFFECTS_H */ diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 5452d7b9c3..4e66d66f8e 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -1384,7 +1384,7 @@ event_f9(const Event *event, void *data) { self->_screenshot_text = NodePath(text_node); text_node->set_align(TextNode::A_center); text_node->set_shadow_color(0.0f, 0.0f, 0.0f, 1.0f); - text_node->set_shadow(0.04f, 0.04f); + text_node->set_shadow(0.04, 0.04); text_node->set_text(output_text); self->_screenshot_text.set_scale(0.06); self->_screenshot_text.set_pos(0.0, 0.0, -0.7); @@ -1462,16 +1462,16 @@ event_question(const Event *event, void *data) { self->_help_text = NodePath(text_node); text_node->set_align(TextNode::A_left); text_node->set_shadow_color(0.0f, 0.0f, 0.0f, 1.0f); - text_node->set_shadow(0.04f, 0.04f); + text_node->set_shadow(0.04, 0.04); text_node->set_text(help_text); - LVecBase4f frame = text_node->get_frame_actual(); + LVecBase4 frame = text_node->get_frame_actual(); - float height = frame[3] - frame[2]; - float scale = min(0.06, 1.8 / height); + PN_stdfloat height = frame[3] - frame[2]; + PN_stdfloat scale = min(0.06, 1.8 / height); self->_help_text.set_scale(scale); - float pos_scale = scale / -2.0; + PN_stdfloat pos_scale = scale / -2.0; self->_help_text.set_pos((frame[0] + frame[1]) * pos_scale, 0.0, (frame[2] + frame[3]) * pos_scale); diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 29bf006d41..134e15e6d1 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -283,7 +283,7 @@ get_render_2d() { // Create a display region that matches the size of the 3-d // display region. - float l, r, b, t; + PN_stdfloat l, r, b, t; _display_region_3d->get_dimensions(l, r, b, t); _display_region_2d = _window->make_mono_display_region(l, r, b, t); _display_region_2d->set_sort(10); @@ -294,10 +294,10 @@ get_render_2d() { PT(Lens) lens = new OrthographicLens; - static const float left = -1.0f; - static const float right = 1.0f; - static const float bottom = -1.0f; - static const float top = 1.0f; + static const PN_stdfloat left = -1.0f; + static const PN_stdfloat right = 1.0f; + static const PN_stdfloat bottom = -1.0f; + static const PN_stdfloat top = 1.0f; lens->set_film_size(right - left, top - bottom); lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5); lens->set_near_far(-1000, 1000); @@ -328,7 +328,7 @@ get_aspect_2d() { top->set_mouse_watcher(DCAST(MouseWatcher, mouse_node)); } - float this_aspect_ratio = aspect_ratio; + PN_stdfloat this_aspect_ratio = aspect_ratio; if (this_aspect_ratio == 0.0f) { // An aspect ratio of 0.0 means to try to infer it. this_aspect_ratio = 1.0f; @@ -337,7 +337,7 @@ get_aspect_2d() { int x_size = _window->get_sbs_left_x_size(); int y_size = _window->get_sbs_left_y_size(); if (y_size != 0) { - this_aspect_ratio = (float)x_size / (float)y_size; + this_aspect_ratio = (PN_stdfloat)x_size / (PN_stdfloat)y_size; } } } @@ -443,7 +443,7 @@ setup_trackball() { NodePath camera = get_camera_group(); _trackball = new Trackball("trackball"); - _trackball->set_pos(LVector3f::forward() * 50.0); + _trackball->set_pos(LVector3::forward() * 50.0); mouse.attach_new_node(_trackball); PT(Transform2SG) tball2cam = new Transform2SG("tball2cam"); @@ -501,10 +501,10 @@ center_trackball(const NodePath &object) { return; } - LPoint3f center = sphere->get_center(); - float radius = sphere->get_radius(); + LPoint3 center = sphere->get_center(); + PN_stdfloat radius = sphere->get_radius(); - float distance = 50.0f; + PN_stdfloat distance = 50.0f; // Choose a suitable distance to view the whole volume in our frame. // This is based on the camera lens in use. Determine the lens @@ -520,20 +520,20 @@ center_trackball(const NodePath &object) { } if (lens != (Lens *)NULL) { - LVecBase2f fov = lens->get_fov(); + LVecBase2 fov = lens->get_fov(); distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f)); // Ensure the far plane is far enough back to see the entire object. - float ideal_far_plane = distance + radius * 1.5; + PN_stdfloat ideal_far_plane = distance + radius * 1.5; lens->set_far(max(lens->get_default_far(), ideal_far_plane)); // And that the near plane is far enough forward. - float ideal_near_plane = distance - radius; + PN_stdfloat ideal_near_plane = distance - radius; lens->set_near(min(lens->get_default_near(), ideal_near_plane)); } _trackball->set_origin(center); - _trackball->set_pos(LVector3f::forward() * distance); + _trackball->set_pos(LVector3::forward() * distance); // Also set the movement scale on the trackball to be consistent // with the size of the model and the lens field-of-view. @@ -668,7 +668,7 @@ NodePath WindowFramework:: load_default_model(const NodePath &parent) { CPT(RenderState) state = RenderState::make_empty(); - state = state->add_attrib(ColorAttrib::make_flat(Colorf(0.5, 0.5, 1.0, 1.0))); + state = state->add_attrib(ColorAttrib::make_flat(LColor(0.5, 0.5, 1.0, 1.0))); // Get the default texture to apply to the triangle; it's compiled // into the code these days. @@ -693,17 +693,17 @@ load_default_model(const NodePath &parent) { GeomVertexWriter normal(vdata, InternalName::get_normal()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - vertex.add_data3f(Vertexf::rfu(0.0, 0.0, 0.0)); - vertex.add_data3f(Vertexf::rfu(1.0, 0.0, 0.0)); - vertex.add_data3f(Vertexf::rfu(0.0, 0.0, 1.0)); + vertex.add_data3(LVertex::rfu(0.0, 0.0, 0.0)); + vertex.add_data3(LVertex::rfu(1.0, 0.0, 0.0)); + vertex.add_data3(LVertex::rfu(0.0, 0.0, 1.0)); - normal.add_data3f(Normalf::back()); - normal.add_data3f(Normalf::back()); - normal.add_data3f(Normalf::back()); + normal.add_data3(LNormal::back()); + normal.add_data3(LNormal::back()); + normal.add_data3(LNormal::back()); - texcoord.add_data2f(0.0, 0.0); - texcoord.add_data2f(1.0, 0.0); - texcoord.add_data2f(0.0, 1.0); + texcoord.add_data2(0.0, 0.0); + texcoord.add_data2(1.0, 0.0); + texcoord.add_data2(0.0, 1.0); PT(GeomTriangles) tri = new GeomTriangles(Geom::UH_static); tri->add_consecutive_vertices(0, 3); @@ -806,7 +806,7 @@ set_anim_controls(bool enable) { //////////////////////////////////////////////////////////////////// void WindowFramework:: adjust_aspect_ratio() { - float this_aspect_ratio = aspect_ratio; + PN_stdfloat this_aspect_ratio = aspect_ratio; int x_size = 0, y_size = 0; if (this_aspect_ratio == 0.0f) { // An aspect ratio of 0.0 means to try to infer it. @@ -816,7 +816,7 @@ adjust_aspect_ratio() { x_size = _window->get_sbs_left_x_size(); y_size = _window->get_sbs_left_y_size(); if (y_size != 0) { - this_aspect_ratio = (float)x_size / (float)y_size; + this_aspect_ratio = (PN_stdfloat)x_size / (PN_stdfloat)y_size; } } } @@ -864,7 +864,7 @@ split_window(SplitType split_type) { } } - float left, right, bottom, top; + PN_stdfloat left, right, bottom, top; _display_region_3d->get_dimensions(left, right, bottom, top); new_region = _display_region_3d->get_window()->make_display_region(); @@ -1080,7 +1080,7 @@ set_background_type(WindowFramework::BackgroundType type) { _display_region_3d->set_clear_color_active(true); _display_region_3d->set_clear_depth_active(true); _display_region_3d->set_clear_stencil_active(true); - _display_region_3d->set_clear_color(Colorf(0.0f, 0.0f, 0.0f, 0.0f)); + _display_region_3d->set_clear_color(LColor(0.0f, 0.0f, 0.0f, 0.0f)); _display_region_3d->set_clear_depth(1.0f); _display_region_3d->set_clear_stencil(0); break; @@ -1089,7 +1089,7 @@ set_background_type(WindowFramework::BackgroundType type) { _display_region_3d->set_clear_color_active(true); _display_region_3d->set_clear_depth_active(true); _display_region_3d->set_clear_stencil_active(true); - _display_region_3d->set_clear_color(Colorf(0.3f, 0.3f, 0.3f, 0.0f)); + _display_region_3d->set_clear_color(LColor(0.3, 0.3, 0.3, 0.0f)); _display_region_3d->set_clear_depth(1.0f); _display_region_3d->set_clear_stencil(0); break; @@ -1098,7 +1098,7 @@ set_background_type(WindowFramework::BackgroundType type) { _display_region_3d->set_clear_color_active(true); _display_region_3d->set_clear_depth_active(true); _display_region_3d->set_clear_stencil_active(true); - _display_region_3d->set_clear_color(Colorf(1.0f, 1.0f, 1.0f, 0.0f)); + _display_region_3d->set_clear_color(LColor(1.0f, 1.0f, 1.0f, 0.0f)); _display_region_3d->set_clear_depth(1.0f); _display_region_3d->set_clear_stencil(0); break; @@ -1187,9 +1187,9 @@ setup_lights() { NodePath light_group = camera_group.attach_new_node("lights"); AmbientLight *alight = new AmbientLight("ambient"); - alight->set_color(Colorf(0.2f, 0.2f, 0.2f, 1.0f)); + alight->set_color(LColor(0.2, 0.2, 0.2, 1.0f)); DirectionalLight *dlight = new DirectionalLight("directional"); - dlight->set_color(Colorf(0.8f, 0.8f, 0.8f, 1.0f)); + dlight->set_color(LColor(0.8f, 0.8f, 0.8f, 1.0f)); _alight = light_group.attach_new_node(alight); _dlight = light_group.attach_new_node(dlight); @@ -1218,7 +1218,7 @@ load_image_as_model(const Filename &filename) { // Ok, now make a polygon to show the texture. bool has_alpha = true; - LVecBase2f tex_scale = tex->get_tex_scale(); + LVecBase2 tex_scale = tex->get_tex_scale(); // Get the size from the original image (the texture may have // scaled it to make a power of 2). @@ -1226,8 +1226,8 @@ load_image_as_model(const Filename &filename) { int y_size = tex->get_orig_file_y_size(); // Choose the dimensions of the polygon appropriately. - float left,right,top,bottom; - static const float scale = 10.0; + PN_stdfloat left,right,top,bottom; + static const PN_stdfloat scale = 10.0; if (x_size > y_size) { left = -scale; right = scale; @@ -1271,9 +1271,9 @@ load_image_as_model(const Filename &filename) { vformat = GeomVertexFormat::register_format (new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - GeomEnums::NT_float32, GeomEnums::C_point, + GeomEnums::NT_stdfloat, GeomEnums::C_point, InternalName::get_texcoord(), 3, - GeomEnums::NT_float32, GeomEnums::C_texcoord)); + GeomEnums::NT_stdfloat, GeomEnums::C_texcoord)); } PT(GeomVertexData) vdata = new GeomVertexData @@ -1283,35 +1283,35 @@ load_image_as_model(const Filename &filename) { if (!is_3d) { // A normal 2-d card. - vertex.add_data3f(Vertexf::rfu(left, 0.02f, top)); - vertex.add_data3f(Vertexf::rfu(left, 0.02f, bottom)); - vertex.add_data3f(Vertexf::rfu(right, 0.02f, top)); - vertex.add_data3f(Vertexf::rfu(right, 0.02f, bottom)); + vertex.add_data3(LVertex::rfu(left, 0.02, top)); + vertex.add_data3(LVertex::rfu(left, 0.02, bottom)); + vertex.add_data3(LVertex::rfu(right, 0.02, top)); + vertex.add_data3(LVertex::rfu(right, 0.02, bottom)); - texcoord.add_data2f(0.0f, tex_scale[1]); - texcoord.add_data2f(0.0f, 0.0f); - texcoord.add_data2f(tex_scale[0], tex_scale[1]); - texcoord.add_data2f(tex_scale[0], 0.0f); + texcoord.add_data2(0.0f, tex_scale[1]); + texcoord.add_data2(0.0f, 0.0f); + texcoord.add_data2(tex_scale[0], tex_scale[1]); + texcoord.add_data2(tex_scale[0], 0.0f); } else { // The eight vertices of a 3-d cube. - vertex.add_data3f(-1.0f, -1.0f, 1.0f); // 0 - vertex.add_data3f(-1.0f, -1.0f, -1.0f); // 1 - vertex.add_data3f(1.0f, -1.0f, -1.0f); // 2 - vertex.add_data3f(1.0f, -1.0f, 1.0f); // 3 - vertex.add_data3f(1.0f, 1.0f, 1.0f); // 4 - vertex.add_data3f(1.0f, 1.0f, -1.0f); // 5 - vertex.add_data3f(-1.0f, 1.0f, -1.0f); // 6 - vertex.add_data3f(-1.0f, 1.0f, 1.0f); // 7 + vertex.add_data3(-1.0f, -1.0f, 1.0f); // 0 + vertex.add_data3(-1.0f, -1.0f, -1.0f); // 1 + vertex.add_data3(1.0f, -1.0f, -1.0f); // 2 + vertex.add_data3(1.0f, -1.0f, 1.0f); // 3 + vertex.add_data3(1.0f, 1.0f, 1.0f); // 4 + vertex.add_data3(1.0f, 1.0f, -1.0f); // 5 + vertex.add_data3(-1.0f, 1.0f, -1.0f); // 6 + vertex.add_data3(-1.0f, 1.0f, 1.0f); // 7 - texcoord.add_data3f(-1.0f, -1.0f, 1.0f); // 0 - texcoord.add_data3f(-1.0f, -1.0f, -1.0f); // 1 - texcoord.add_data3f(1.0f, -1.0f, -1.0f); // 2 - texcoord.add_data3f(1.0f, -1.0f, 1.0f); // 3 - texcoord.add_data3f(1.0f, 1.0f, 1.0f); // 4 - texcoord.add_data3f(1.0f, 1.0f, -1.0f); // 5 - texcoord.add_data3f(-1.0f, 1.0f, -1.0f); // 6 - texcoord.add_data3f(-1.0f, 1.0f, 1.0f); // 7 + texcoord.add_data3(-1.0f, -1.0f, 1.0f); // 0 + texcoord.add_data3(-1.0f, -1.0f, -1.0f); // 1 + texcoord.add_data3(1.0f, -1.0f, -1.0f); // 2 + texcoord.add_data3(1.0f, -1.0f, 1.0f); // 3 + texcoord.add_data3(1.0f, 1.0f, 1.0f); // 4 + texcoord.add_data3(1.0f, 1.0f, -1.0f); // 5 + texcoord.add_data3(-1.0f, 1.0f, -1.0f); // 6 + texcoord.add_data3(-1.0f, 1.0f, 1.0f); // 7 } PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); @@ -1369,8 +1369,8 @@ create_anim_controls() { PT(PGItem) group = new PGItem("anim_controls_group"); PGFrameStyle style; style.set_type(PGFrameStyle::T_flat); - style.set_color(0.0f, 0.0f, 0.0f, 0.3f); - group->set_frame(-1.0f, 1.0f, 0.0f, 0.2f); + style.set_color(0.0f, 0.0f, 0.0f, 0.3); + group->set_frame(-1.0f, 1.0f, 0.0f, 0.2); group->set_frame_style(0, style); group->set_suppress_flags(MouseWatcherRegion::SF_mouse_button); group->set_active(true); @@ -1404,7 +1404,7 @@ create_anim_controls() { _anim_slider->set_suppress_flags(MouseWatcherRegion::SF_mouse_button); _anim_slider->get_thumb_button()->set_suppress_flags(MouseWatcherRegion::SF_mouse_button); - _anim_slider->set_range(0.0f, (float)(control->get_num_frames() - 1)); + _anim_slider->set_range(0.0f, (PN_stdfloat)(control->get_num_frames() - 1)); _anim_slider->set_scroll_size(0.0f); _anim_slider->set_page_size(1.0f); NodePath snp = _anim_controls_group.attach_new_node(_anim_slider); @@ -1419,7 +1419,7 @@ create_anim_controls() { fnp.set_pos(0.0f, 0.0f, -0.01f); _play_rate_slider = new PGSliderBar("play_rate_slider"); - _play_rate_slider->setup_slider(false, 0.4f, 0.05f, 0.005f); + _play_rate_slider->setup_slider(false, 0.4, 0.05f, 0.005f); _play_rate_slider->set_suppress_flags(MouseWatcherRegion::SF_mouse_button); _play_rate_slider->get_thumb_button()->set_suppress_flags(MouseWatcherRegion::SF_mouse_button); _play_rate_slider->set_value(control->get_play_rate()); @@ -1469,7 +1469,7 @@ update_anim_controls() { if (_anim_slider->is_button_down()) { control->pose((int)(_anim_slider->get_value() + 0.5)); } else { - _anim_slider->set_value((float)control->get_frame()); + _anim_slider->set_value((PN_stdfloat)control->get_frame()); } _frame_number->set_text(format_string(control->get_frame())); @@ -1489,7 +1489,7 @@ setup_shuttle_button(const string &label, int index, PT(PGButton) button = new PGButton(label); button->set_frame(-0.05f, 0.05f, 0.0f, 0.07f); - float bevel = 0.005f; + PN_stdfloat bevel = 0.005f; PGFrameStyle style; style.set_color(0.8f, 0.8f, 0.8f, 1.0f); @@ -1511,8 +1511,8 @@ setup_shuttle_button(const string &label, int index, tn->set_font(get_shuttle_controls_font()); tn->set_text(label); tn->set_text_color(0.0f, 0.0f, 0.0f, 1.0f); - LMatrix4f xform = LMatrix4f::scale_mat(0.07f); - xform.set_row(3, LVecBase3f(0.0f, 0.0f, 0.016f)); + LMatrix4 xform = LMatrix4::scale_mat(0.07f); + xform.set_row(3, LVecBase3(0.0f, 0.0f, 0.016f)); tn->set_transform(xform); button->get_state_def(PGButton::S_ready).attach_new_node(tn); @@ -1521,7 +1521,7 @@ setup_shuttle_button(const string &label, int index, } NodePath np = _anim_controls_group.attach_new_node(button); - np.set_pos(0.1f * index - 0.15f, 0.0f, 0.12f); + np.set_pos(0.1f * index - 0.15f, 0.0f, 0.12); _panda_framework->get_event_handler().add_hook(button->get_click_event(MouseButton::one()), func, (void *)this); } diff --git a/panda/src/glgsg/glgsg.h b/panda/src/glgsg/glgsg.h index f8d3f49d44..576e974791 100644 --- a/panda/src/glgsg/glgsg.h +++ b/panda/src/glgsg/glgsg.h @@ -22,8 +22,17 @@ #include "pandabase.h" #include "config_glgsg.h" -#define GLP(name) gl##name -#define CLP(name) GL##name +#define GLP(name) gl ## name + +#ifndef STDFLOAT_DOUBLE +#define GLPf(name) gl ## name ## f +#define GLPfv(name) gl ## name ## fv +#else // STDFLOAT_DOUBLE +#define GLPf(name) gl ## name ## d +#define GLPfv(name) gl ## name ## dv +#endif // STDFLOAT_DOUBLE + +#define CLP(name) GL ## name #define GLPREFIX_QUOTED "gl" #define CLASSPREFIX_QUOTED "GL" #define GLSYSTEM_NAME "OpenGL" diff --git a/panda/src/glstuff/Sources.pp b/panda/src/glstuff/Sources.pp index 397ab0f2ea..39e9da3fdd 100644 --- a/panda/src/glstuff/Sources.pp +++ b/panda/src/glstuff/Sources.pp @@ -8,8 +8,7 @@ #define TARGET glstuff #define LOCAL_LIBS \ gsgbase gobj display \ - putil linmath mathutil pnmimage \ - effects + putil linmath mathutil pnmimage #define INSTALL_HEADERS \ diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index cb93bccf2d..7b6b17d45f 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -115,7 +115,7 @@ munge_format_impl(const GeomVertexFormat *orig, PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column (InternalName::get_transform_weight(), animation.get_num_transforms() - 1, - NT_float32, C_other); + NT_stdfloat, C_other); if (animation.get_indexed_transforms()) { // Also, if we'll be indexing into the transform table, reserve @@ -196,11 +196,11 @@ munge_format_impl(const GeomVertexFormat *orig, if (texcoord_type != (const GeomVertexColumn *)NULL) { new_array_format->add_column - (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); + (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord); } else { // We have to add something as a placeholder, even if the // texture coordinates aren't defined. - new_array_format->add_column(name, 2, NT_float32, C_texcoord); + new_array_format->add_column(name, 2, NT_stdfloat, C_texcoord); } new_format->remove_column(name); } @@ -307,11 +307,11 @@ premunge_format_impl(const GeomVertexFormat *orig) { if (texcoord_type != (const GeomVertexColumn *)NULL) { new_array_format->add_column - (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); + (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord); } else { // We have to add something as a placeholder, even if the // texture coordinates aren't defined. - new_array_format->add_column(name, 2, NT_float32, C_texcoord); + new_array_format->add_column(name, 2, NT_stdfloat, C_texcoord); } new_format->remove_column(name); } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index f828c4d1aa..59ae7bb6f6 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -593,6 +593,120 @@ enable_polygon_offset(bool val) { } } +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glFogfv +// Access: Public +// Description: This method is necessary because there is no +// glFogdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glFogfv(GLenum pname, const LColor &color) { +#ifndef STDFLOAT_DOUBLE + GLP(Fogfv)(pname, color.get_data()); +#else // STDFLOAT_DOUBLE + Colorf fcolor = LCAST(float, color); + GLP(Fogfv)(pname, fcolor.get_data()); +#endif // STDFLOAT_DOUBLE +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glMaterialfv +// Access: Public +// Description: This method is necessary because there is no +// glMaterialdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) { +#ifndef STDFLOAT_DOUBLE + GLP(Materialfv)(face, pname, color.get_data()); +#else // STDFLOAT_DOUBLE + Colorf fcolor = LCAST(float, color); + GLP(Materialfv)(face, pname, fcolor.get_data()); +#endif // STDFLOAT_DOUBLE +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glLightfv +// Access: Public +// Description: This method is necessary because there is no +// glLightdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) { +#ifndef STDFLOAT_DOUBLE + GLP(Lightfv)(light, pname, value.get_data()); +#else // STDFLOAT_DOUBLE + LVecBase4f fvalue = LCAST(float, value); + GLP(Lightfv)(light, pname, fvalue.get_data()); +#endif // STDFLOAT_DOUBLE +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glLightfv +// Access: Public +// Description: This method is necessary because there is no +// glLightdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) { +#ifndef STDFLOAT_DOUBLE + GLP(Lightfv)(light, pname, value.get_data()); +#else // STDFLOAT_DOUBLE + LVecBase3f fvalue = LCAST(float, value); + GLP(Lightfv)(light, pname, fvalue.get_data()); +#endif // STDFLOAT_DOUBLE +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glLightModelfv +// Access: Public +// Description: This method is necessary because there is no +// glLightModeldv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glLightModelfv(GLenum pname, const LVecBase4 &value) { +#ifndef OPENGLES_2 +#ifndef STDFLOAT_DOUBLE + GLP(LightModelfv)(pname, value.get_data()); +#else // STDFLOAT_DOUBLE + LVecBase4f fvalue = LCAST(float, value); + GLP(LightModelfv)(pname, fvalue.get_data()); +#endif // STDFLOAT_DOUBLE +#endif // OPENGLES_2 +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glTexEnvfv +// Access: Public +// Description: This method is necessary because there is no +// glTexEnvdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value) { +#ifndef STDFLOAT_DOUBLE + GLP(TexEnvfv)(target, pname, value.get_data()); +#else // STDFLOAT_DOUBLE + LVecBase4f fvalue = LCAST(float, value); + GLP(TexEnvfv)(target, pname, fvalue.get_data()); +#endif // STDFLOAT_DOUBLE +} + +//////////////////////////////////////////////////////////////////// +// Function: GLGraphicsStateGuardian::call_glTexParameterfv +// Access: Public +// Description: This method is necessary because there is no +// glTexParameterdv(). +//////////////////////////////////////////////////////////////////// +INLINE void CLP(GraphicsStateGuardian):: +call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) { +#ifndef STDFLOAT_DOUBLE + GLP(TexParameterfv)(target, pname, value.get_data()); +#else // STDFLOAT_DOUBLE + LVecBase4f fvalue = LCAST(float, value); + GLP(TexParameterfv)(target, pname, fvalue.get_data()); +#endif // STDFLOAT_DOUBLE +} + //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_light_id // Access: Public diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 9bc883ccba..cf4029f78b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -419,15 +419,17 @@ reset() { _supports_vertex_blend = has_extension("GL_ARB_vertex_blend"); if (_supports_vertex_blend) { - _glWeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC) + _glWeightPointer = (PFNGLWEIGHTPOINTERARBPROC) get_extension_func(GLPREFIX_QUOTED, "WeightPointerARB"); - _glVertexBlendARB = (PFNGLVERTEXBLENDARBPROC) + _glVertexBlend = (PFNGLVERTEXBLENDARBPROC) get_extension_func(GLPREFIX_QUOTED, "VertexBlendARB"); - _glWeightfvARB = (PFNGLWEIGHTFVARBPROC) + _glWeightfv = (PFNGLWEIGHTFVARBPROC) get_extension_func(GLPREFIX_QUOTED, "WeightfvARB"); + _glWeightdv = (PFNGLWEIGHTDVARBPROC) + get_extension_func(GLPREFIX_QUOTED, "WeightdvARB"); - if (_glWeightPointerARB == NULL || _glVertexBlendARB == NULL || - _glWeightfvARB == NULL) { + if (_glWeightPointer == NULL || _glVertexBlend == NULL || + GLfv(_glWeight) == NULL) { GLCAT.warning() << "Vertex blending advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_vertex_blend = false; @@ -786,6 +788,14 @@ reset() { get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord3f"); _glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord4f"); + _glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord1d"); + _glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord2d"); + _glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord3d"); + _glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord4d"); } else if (has_extension("GL_ARB_multitexture")) { _supports_multitexture = true; @@ -802,13 +812,21 @@ reset() { get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord3fARB"); _glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord4fARB"); + _glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord1dARB"); + _glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord2dARB"); + _glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord3dARB"); + _glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) + get_extension_func(GLPREFIX_QUOTED, "MultiTexCoord4dARB"); } if (_supports_multitexture) { if (_glActiveTexture == NULL || _glClientActiveTexture == NULL #ifdef SUPPORT_IMMEDIATE_MODE - || _glMultiTexCoord1f == NULL || _glMultiTexCoord2f == NULL - || _glMultiTexCoord3f == NULL || _glMultiTexCoord4f == NULL + || GLf(_glMultiTexCoord1) == NULL || GLf(_glMultiTexCoord2) == NULL + || GLf(_glMultiTexCoord3) == NULL || GLf(_glMultiTexCoord4) == NULL #endif ) { GLCAT.warning() @@ -972,6 +990,8 @@ reset() { get_extension_func(GLPREFIX_QUOTED, "UseProgram"); _glUniform4f = (PFNGLUNIFORM4FPROC) get_extension_func(GLPREFIX_QUOTED, "Uniform4f"); + _glUniform4d = (PFNGLUNIFORM4DPROC) + get_extension_func(GLPREFIX_QUOTED, "Uniform4d"); _glUniform1i = (PFNGLUNIFORM1IPROC) get_extension_func(GLPREFIX_QUOTED, "Uniform1i"); _glUniform1fv = (PFNGLUNIFORM1FVPROC) @@ -982,8 +1002,18 @@ reset() { get_extension_func(GLPREFIX_QUOTED, "Uniform3fv"); _glUniform4fv = (PFNGLUNIFORM4FVPROC) get_extension_func(GLPREFIX_QUOTED, "Uniform4fv"); + _glUniform1dv = (PFNGLUNIFORM1DVPROC) + get_extension_func(GLPREFIX_QUOTED, "Uniform1dv"); + _glUniform2dv = (PFNGLUNIFORM2DVPROC) + get_extension_func(GLPREFIX_QUOTED, "Uniform2dv"); + _glUniform3dv = (PFNGLUNIFORM3DVPROC) + get_extension_func(GLPREFIX_QUOTED, "Uniform3dv"); + _glUniform4dv = (PFNGLUNIFORM4DVPROC) + get_extension_func(GLPREFIX_QUOTED, "Uniform4dv"); _glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) get_extension_func(GLPREFIX_QUOTED, "UniformMatrix4fv"); + _glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC) + get_extension_func(GLPREFIX_QUOTED, "UniformMatrix4dv"); _glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) get_extension_func(GLPREFIX_QUOTED, "ValidateProgram"); _glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) @@ -1023,12 +1053,18 @@ reset() { _glShaderSource = glShaderSource; _glUseProgram = glUseProgram; _glUniform4f = glUniform4f; + _glUniform4d = NULL; _glUniform1i = glUniform1i; _glUniform1fv = glUniform1fv; _glUniform2fv = glUniform2fv; _glUniform3fv = glUniform3fv; _glUniform4fv = glUniform4fv; + _glUniform1dv = NULL; + _glUniform2dv = NULL; + _glUniform3dv = NULL; + _glUniform4dv = NULL; _glUniformMatrix4fv = glUniformMatrix4fv; + _glUniformMatrix4dv = NULL; _glValidateProgram = glValidateProgram; _glVertexAttribPointer = glVertexAttribPointer; @@ -1501,7 +1537,7 @@ reset() { if (has_extension("GL_EXT_texture_filter_anisotropic")) { GLfloat max_anisotropy; GLP(GetFloatv)(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); - _max_anisotropy = (float)max_anisotropy; + _max_anisotropy = (PN_stdfloat)max_anisotropy; _supports_anisotropy = true; } @@ -1819,7 +1855,7 @@ clear(DrawableRegion *clearable) { int layerid = GraphicsOutput::RTP_aux_rgba_0 + i; int layerbit = RenderBuffer::T_aux_rgba_0 << i; if (clearable->get_clear_active(layerid)) { - Colorf v = clearable->get_clear_value(layerid); + LColor v = clearable->get_clear_value(layerid); GLP(ClearColor)(v[0],v[1],v[2],v[3]); set_draw_buffer(layerbit); GLP(Clear)(GL_COLOR_BUFFER_BIT); @@ -1829,7 +1865,7 @@ clear(DrawableRegion *clearable) { int layerid = GraphicsOutput::RTP_aux_hrgba_0 + i; int layerbit = RenderBuffer::T_aux_hrgba_0 << i; if (clearable->get_clear_active(layerid)) { - Colorf v = clearable->get_clear_value(layerid); + LColor v = clearable->get_clear_value(layerid); GLP(ClearColor)(v[0],v[1],v[2],v[3]); set_draw_buffer(layerbit); GLP(Clear)(GL_COLOR_BUFFER_BIT); @@ -1839,7 +1875,7 @@ clear(DrawableRegion *clearable) { int layerid = GraphicsOutput::RTP_aux_float_0 + i; int layerbit = RenderBuffer::T_aux_float_0 << i; if (clearable->get_clear_active(layerid)) { - Colorf v = clearable->get_clear_value(layerid); + LColor v = clearable->get_clear_value(layerid); GLP(ClearColor)(v[0],v[1],v[2],v[3]); set_draw_buffer(layerbit); GLP(Clear)(GL_COLOR_BUFFER_BIT); @@ -1847,7 +1883,7 @@ clear(DrawableRegion *clearable) { } if (clearable->get_clear_color_active()) { - Colorf v = clearable->get_clear_color(); + LColor v = clearable->get_clear_color(); GLP(ClearColor)(v[0],v[1],v[2],v[3]); if (CLP(color_mask)) { GLP(ColorMask)(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -1990,14 +2026,14 @@ calc_projection_mat(const Lens *lens) { // matrix, and store the conversion to our coordinate system of // choice in the modelview matrix. - LMatrix4f result = - LMatrix4f::convert_mat(CS_yup_right, lens->get_coordinate_system()) * + LMatrix4 result = + LMatrix4::convert_mat(CS_yup_right, lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the // projection matrix. - result *= LMatrix4f::scale_mat(1.0f, -1.0f, 1.0f); + result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); @@ -2023,7 +2059,7 @@ prepare_lens() { } #ifndef OPENGLES_2 GLP(MatrixMode)(GL_PROJECTION); - GLP(LoadMatrixf)(_projection_mat->get_mat().get_data()); + GLPf(LoadMatrix)(_projection_mat->get_mat().get_data()); #endif report_my_gl_errors(); @@ -2291,7 +2327,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Set up the transform matrices for vertex blending. nassertr(_supports_vertex_blend, false); GLP(Enable)(GL_VERTEX_BLEND_ARB); - _glVertexBlendARB(animation.get_num_transforms()); + _glVertexBlend(animation.get_num_transforms()); const TransformTable *table = _data_reader->get_transform_table(); if (table != (TransformTable *)NULL) { @@ -2306,10 +2342,10 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, GLP(MatrixMode)(GL_MATRIX_PALETTE_ARB); for (int i = 0; i < table->get_num_transforms(); ++i) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); _glCurrentPaletteMatrix(i); - GLP(LoadMatrixf)(mat.get_data()); + GLPf(LoadMatrix)(mat.get_data()); } // Presumably loading the matrix palette does not step on the @@ -2326,24 +2362,24 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // GL_MODELVIEW0 and 1 are different than the rest. int i = 0; if (i < table->get_num_transforms()) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); GLP(MatrixMode)(GL_MODELVIEW0_ARB); - GLP(LoadMatrixf)(mat.get_data()); + GLPf(LoadMatrix)(mat.get_data()); ++i; } if (i < table->get_num_transforms()) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); GLP(MatrixMode)(GL_MODELVIEW1_ARB); - GLP(LoadMatrixf)(mat.get_data()); + GLPf(LoadMatrix)(mat.get_data()); ++i; } while (i < table->get_num_transforms()) { - LMatrix4f mat; + LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); GLP(MatrixMode)(GL_MODELVIEW2_ARB + i - 2); - GLP(LoadMatrixf)(mat.get_data()); + GLPf(LoadMatrix)(mat.get_data()); ++i; } @@ -2366,7 +2402,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (_transform_stale) { GLP(MatrixMode)(GL_MODELVIEW); - GLP(LoadMatrixf)(_internal_transform->get_mat().get_data()); + GLPf(LoadMatrix)(_internal_transform->get_mat().get_data()); } } #endif @@ -2519,18 +2555,18 @@ update_standard_vertex_arrays(bool force) { _sender.clear(); _sender.add_column(_data_reader, InternalName::get_normal(), - NULL, NULL, GLP(Normal3f), NULL); + NULL, NULL, GLPf(Normal3), NULL); #ifndef NDEBUG if (_show_texture_usage) { // In show_texture_usage mode, all colors are white, so as not // to contaminate the texture color. - GLP(Color4f)(1.0f, 1.0f, 1.0f, 1.0f); + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } else #endif // NDEBUG if (!_sender.add_column(_data_reader, InternalName::get_color(), - NULL, NULL, GLP(Color3f), GLP(Color4f))) { + NULL, NULL, GLPf(Color3), GLPf(Color4))) { // If we didn't have a color column, the item color is white. - GLP(Color4f)(1.0f, 1.0f, 1.0f, 1.0f); + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } // Now set up each of the active texture coordinate stages--or at @@ -2548,14 +2584,14 @@ update_standard_vertex_arrays(bool force) { // Use the original functions for stage 0, in case we don't // support multitexture. _sender.add_column(_data_reader, name, - GLP(TexCoord1f), GLP(TexCoord2f), - GLP(TexCoord3f), GLP(TexCoord4f)); + GLPf(TexCoord1), GLPf(TexCoord2), + GLPf(TexCoord3), GLPf(TexCoord4)); } else { // Other stages require the multitexture functions. _sender.add_texcoord_column(_data_reader, name, stage_index, - _glMultiTexCoord1f, _glMultiTexCoord2f, - _glMultiTexCoord3f, _glMultiTexCoord4f); + GLf(_glMultiTexCoord1), GLf(_glMultiTexCoord2), + GLf(_glMultiTexCoord3), GLf(_glMultiTexCoord4)); } } @@ -2574,7 +2610,7 @@ update_standard_vertex_arrays(bool force) { if (hardware_animation) { // Issue the weights and/or transform indices for vertex blending. _sender.add_vector_column(_data_reader, InternalName::get_transform_weight(), - _glWeightfvARB); + GLfv(_glWeight)); if (animation.get_indexed_transforms()) { // Issue the matrix palette indices. @@ -2587,7 +2623,7 @@ update_standard_vertex_arrays(bool force) { // We must add vertex last, because glVertex3f() is the key // function call that actually issues the vertex. _sender.add_column(_data_reader, InternalName::get_vertex(), - NULL, GLP(Vertex2f), GLP(Vertex3f), GLP(Vertex4f)); + NULL, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); } else #endif // SUPPORT_IMMEDIATE_MODE @@ -2617,7 +2653,7 @@ update_standard_vertex_arrays(bool force) { // In show_texture_usage mode, all colors are white, so as not // to contaminate the texture color. GLP(DisableClientState)(GL_COLOR_ARRAY); - GLP(Color4f)(1.0f, 1.0f, 1.0f, 1.0f); + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } else #endif // NDEBUG if (_data_reader->get_color_info(array_reader, num_values, numeric_type, @@ -2634,7 +2670,7 @@ update_standard_vertex_arrays(bool force) { // Since we don't have per-vertex color, the implicit color is // white. - GLP(Color4f)(1.0f, 1.0f, 1.0f, 1.0f); + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } // Now set up each of the active texture coordinate stages--or at @@ -2691,8 +2727,8 @@ update_standard_vertex_arrays(bool force) { if (!setup_array_data(client_pointer, array_reader, force)) { return false; } - _glWeightPointerARB(num_values, get_numeric_type(numeric_type), - stride, client_pointer + start); + _glWeightPointer(num_values, get_numeric_type(numeric_type), + stride, client_pointer + start); GLP(EnableClientState)(GL_WEIGHT_ARRAY_ARB); } else { GLP(DisableClientState)(GL_WEIGHT_ARRAY_ARB); @@ -2788,7 +2824,7 @@ disable_standard_vertex_arrays() GLP(DisableClientState)(GL_NORMAL_ARRAY); GLP(DisableClientState)(GL_COLOR_ARRAY); - GLP(Color4f)(1.0f, 1.0f, 1.0f, 1.0f); + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); report_my_gl_errors(); for (int stage_index=0; stage_index < _last_max_stage_index; stage_index++) { @@ -3258,7 +3294,7 @@ end_draw_primitives() { #ifndef OPENGLES_2 if (_transform_stale) { GLP(MatrixMode)(GL_MODELVIEW); - GLP(LoadMatrixf)(_internal_transform->get_mat().get_data()); + GLPf(LoadMatrix)(_internal_transform->get_mat().get_data()); } if (_data_reader->is_vertex_transformed()) { @@ -4299,7 +4335,7 @@ apply_fog(Fog *fog) { GLP(Fogf)(GL_FOG_MODE, get_fog_mode_type(fmode)); if (fmode == Fog::M_linear) { - float onset, opaque; + PN_stdfloat onset, opaque; fog->get_linear_range(onset, opaque); GLP(Fogf)(GL_FOG_START, onset); GLP(Fogf)(GL_FOG_END, opaque); @@ -4309,7 +4345,7 @@ apply_fog(Fog *fog) { GLP(Fogf)(GL_FOG_DENSITY, fog->get_exp_density()); } - GLP(Fogfv)(GL_FOG_COLOR, fog->get_color().get_data()); + call_glFogfv(GL_FOG_COLOR, fog->get_color()); report_my_gl_errors(); #endif } @@ -4334,7 +4370,7 @@ do_issue_transform() { DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1)); #ifndef OPENGLES_2 GLP(MatrixMode)(GL_MODELVIEW); - GLP(LoadMatrixf)(transform->get_mat().get_data()); + GLPf(LoadMatrix)(transform->get_mat().get_data()); #endif _transform_stale = false; @@ -4765,24 +4801,24 @@ do_issue_material() { static const GLenum face = GL_FRONT_AND_BACK; #endif // OPENGLES - GLP(Materialfv)(face, GL_SPECULAR, material->get_specular().get_data()); - GLP(Materialfv)(face, GL_EMISSION, material->get_emission().get_data()); - GLP(Materialf)(face, GL_SHININESS, min(material->get_shininess(), 128.0f)); + call_glMaterialfv(face, GL_SPECULAR, material->get_specular()); + call_glMaterialfv(face, GL_EMISSION, material->get_emission()); + GLP(Materialf)(face, GL_SHININESS, min(material->get_shininess(), (PN_stdfloat)128.0)); if (material->has_ambient() && material->has_diffuse()) { // The material has both an ambient and diffuse specified. This // means we do not need glMaterialColor(). GLP(Disable)(GL_COLOR_MATERIAL); - GLP(Materialfv)(face, GL_AMBIENT, material->get_ambient().get_data()); - GLP(Materialfv)(face, GL_DIFFUSE, material->get_diffuse().get_data()); + call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); + call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); } else if (material->has_ambient()) { // The material specifies an ambient, but not a diffuse component. // The diffuse component comes from the object's color. - GLP(Materialfv)(face, GL_AMBIENT, material->get_ambient().get_data()); + call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); if (has_material_force_color) { GLP(Disable)(GL_COLOR_MATERIAL); - GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data()); + call_glMaterialfv(face, GL_DIFFUSE, _material_force_color); } else { #ifndef OPENGLES GLP(ColorMaterial)(face, GL_DIFFUSE); @@ -4793,10 +4829,10 @@ do_issue_material() { } else if (material->has_diffuse()) { // The material specifies a diffuse, but not an ambient component. // The ambient component comes from the object's color. - GLP(Materialfv)(face, GL_DIFFUSE, material->get_diffuse().get_data()); + call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); if (has_material_force_color) { GLP(Disable)(GL_COLOR_MATERIAL); - GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data()); + call_glMaterialfv(face, GL_AMBIENT, _material_force_color); } else { #ifndef OPENGLES GLP(ColorMaterial)(face, GL_AMBIENT); @@ -4809,8 +4845,8 @@ do_issue_material() { // component. Both components come from the object's color. if (has_material_force_color) { GLP(Disable)(GL_COLOR_MATERIAL); - GLP(Materialfv)(face, GL_AMBIENT, _material_force_color.get_data()); - GLP(Materialfv)(face, GL_DIFFUSE, _material_force_color.get_data()); + call_glMaterialfv(face, GL_AMBIENT, _material_force_color); + call_glMaterialfv(face, GL_DIFFUSE, _material_force_color); } else { #ifndef OPENGLES GLP(ColorMaterial)(face, GL_AMBIENT_AND_DIFFUSE); @@ -4892,7 +4928,7 @@ do_issue_blending() { _current_color_scale[2], _current_color_scale[3]); } else { - Colorf c = color_blend->get_color(); + LColor c = color_blend->get_color(); _glBlendColor(c[0], c[1], c[2], c[3]); } return; @@ -4973,20 +5009,19 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // static PStatCollector _draw_set_state_light_bind_point_pcollector("Draw:Set State:Light:Bind:Point"); // PStatTimer timer(_draw_set_state_light_bind_point_pcollector); - float light_color[4]; GLenum id = get_light_id(light_id); - static const Colorf black(0.0f, 0.0f, 0.0f, 1.0f); - GLP(Lightfv)(id, GL_AMBIENT, black.get_data()); - GLP(Lightfv)(id, GL_DIFFUSE, get_light_color(light_color, light_obj)); - GLP(Lightfv)(id, GL_SPECULAR, light_obj->get_specular_color().get_data()); + static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); + call_glLightfv(id, GL_AMBIENT, black); + call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); + call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); // Position needs to specify x, y, z, and w // w == 1 implies non-infinite position CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); - LPoint3f pos = light_obj->get_point() * transform->get_mat(); + LPoint3 pos = light_obj->get_point() * transform->get_mat(); - LPoint4f fpos(pos[0], pos[1], pos[2], 1.0f); - GLP(Lightfv)(id, GL_POSITION, fpos.get_data()); + LPoint4 fpos(pos[0], pos[1], pos[2], 1.0f); + call_glLightfv(id, GL_POSITION, fpos); // GL_SPOT_DIRECTION is not significant when cutoff == 180 @@ -4996,7 +5031,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // Cutoff == 180 means uniform point light source GLP(Lightf)(id, GL_SPOT_CUTOFF, 180.0f); - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); GLP(Lightf)(id, GL_CONSTANT_ATTENUATION, att[0]); GLP(Lightf)(id, GL_LINEAR_ATTENUATION, att[1]); GLP(Lightf)(id, GL_QUADRATIC_ATTENUATION, att[2]); @@ -5024,20 +5059,19 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { if (lookup.second) { // The light was not computed yet this frame. Compute it now. CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); - LVector3f dir = light_obj->get_direction() * transform->get_mat(); + LVector3 dir = light_obj->get_direction() * transform->get_mat(); fdata._neg_dir.set(-dir[0], -dir[1], -dir[2], 0); } - float light_color[4]; GLenum id = get_light_id( light_id ); - static const Colorf black(0.0f, 0.0f, 0.0f, 1.0f); - GLP(Lightfv)(id, GL_AMBIENT, black.get_data()); - GLP(Lightfv)(id, GL_DIFFUSE, get_light_color(light_color, light_obj)); - GLP(Lightfv)(id, GL_SPECULAR, light_obj->get_specular_color().get_data()); + static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); + call_glLightfv(id, GL_AMBIENT, black); + call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); + call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); // Position needs to specify x, y, z, and w. // w == 0 implies light is at infinity - GLP(Lightfv)(id, GL_POSITION, fdata._neg_dir.get_data()); + call_glLightfv(id, GL_POSITION, fdata._neg_dir); // GL_SPOT_DIRECTION is not significant when cutoff == 180 // In this case, position x, y, z specifies direction @@ -5075,28 +5109,27 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { Lens *lens = light_obj->get_lens(); nassertv(lens != (Lens *)NULL); - float light_color[4]; GLenum id = get_light_id(light_id); - static const Colorf black(0.0f, 0.0f, 0.0f, 1.0f); - GLP(Lightfv)(id, GL_AMBIENT, black.get_data()); - GLP(Lightfv)(id, GL_DIFFUSE, get_light_color(light_color, light_obj)); - GLP(Lightfv)(id, GL_SPECULAR, light_obj->get_specular_color().get_data()); + static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); + call_glLightfv(id, GL_AMBIENT, black); + call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); + call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); // Position needs to specify x, y, z, and w // w == 1 implies non-infinite position CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); - const LMatrix4f &light_mat = transform->get_mat(); - LPoint3f pos = lens->get_nodal_point() * light_mat; - LVector3f dir = lens->get_view_vector() * light_mat; + const LMatrix4 &light_mat = transform->get_mat(); + LPoint3 pos = lens->get_nodal_point() * light_mat; + LVector3 dir = lens->get_view_vector() * light_mat; - LPoint4f fpos(pos[0], pos[1], pos[2], 1.0f); - GLP(Lightfv)(id, GL_POSITION, fpos.get_data()); - GLP(Lightfv)(id, GL_SPOT_DIRECTION, dir.get_data()); + LPoint4 fpos(pos[0], pos[1], pos[2], 1.0f); + call_glLightfv(id, GL_POSITION, fpos); + call_glLightfv(id, GL_SPOT_DIRECTION, dir); GLP(Lightf)(id, GL_SPOT_EXPONENT, light_obj->get_exponent()); GLP(Lightf)(id, GL_SPOT_CUTOFF, lens->get_hfov() * 0.5f); - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); GLP(Lightf)(id, GL_CONSTANT_ATTENUATION, att[0]); GLP(Lightf)(id, GL_LINEAR_ATTENUATION, att[1]); GLP(Lightf)(id, GL_QUADRATIC_ATTENUATION, att[2]); @@ -5466,9 +5499,9 @@ get_extension_func(const char *prefix, const char *name) { { "CompressedTexSubImage3D", (void *)&GLP(CompressedTexSubImage3D) }, { "GetCompressedTexImage", (void *)&GLP(GetCompressedTexImage) }, { "MultiTexCoord1f", (void *)&GLP(MultiTexCoord1f) }, - { "MultiTexCoord2f", (void *)&GLP(MultiTexCoord2f) }, - { "MultiTexCoord3f", (void *)&GLP(MultiTexCoord3f) }, - { "MultiTexCoord4f", (void *)&GLP(MultiTexCoord4f) }, + { "MultiTexCoord2", (void *)&GLP(MultiTexCoord2) }, + { "MultiTexCoord3", (void *)&GLP(MultiTexCoord3) }, + { "MultiTexCoord4", (void *)&GLP(MultiTexCoord4) }, #endif #ifdef EXPECT_GL_VERSION_1_4 { "PointParameterfv", (void *)&GLP(PointParameterfv) }, @@ -6795,33 +6828,27 @@ print_gfx_visual() { //////////////////////////////////////////////////////////////////// // Function: GLGraphicsStateGuardian::get_light_color // Access: Public -// Description: Fills the array of four floats with the values that -// that should be issued as the light's color, as scaled -// by the current value of _light_color_scale, in the -// case of color_scale_via_lighting. Returns -// light_color. +// Description: Returns the value that that should be issued as the +// light's color, as scaled by the current value of +// _light_color_scale, in the case of +// color_scale_via_lighting. //////////////////////////////////////////////////////////////////// -float *CLP(GraphicsStateGuardian):: -get_light_color(float light_color[4], Light *light) const { +LVecBase4 CLP(GraphicsStateGuardian):: +get_light_color(Light *light) const { #ifndef NDEBUG if (_show_texture_usage) { // In show_texture_usage mode, all lights are white, so as not to // contaminate the texture color. - light_color[0] = 1.0f; - light_color[1] = 1.0f; - light_color[2] = 1.0f; - light_color[3] = 1.0f; - return light_color; + return LVecBase4(1.0, 1.0, 1.0, 1.0); } #endif // NDEBUG - const Colorf &c = light->get_color(); - - light_color[0] = c[0] * _light_color_scale[0]; - light_color[1] = c[1] * _light_color_scale[1]; - light_color[2] = c[2] * _light_color_scale[2]; - light_color[3] = c[3] * _light_color_scale[3]; + const LColor &c = light->get_color(); + LVecBase4 light_color(c[0] * _light_color_scale[0], + c[1] * _light_color_scale[1], + c[2] * _light_color_scale[2], + c[3] * _light_color_scale[3]); return light_color; } @@ -6871,18 +6898,16 @@ enable_lighting(bool enable) { // all other lights have been enabled or disabled. //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: -set_ambient_light(const Colorf &color) { -#ifndef OPENGLES_2 +set_ambient_light(const LColor &color) { // static PStatCollector _draw_set_state_light_ambient_pcollector("Draw:Set State:Light:Ambient"); // PStatTimer timer(_draw_set_state_light_ambient_pcollector); - Colorf c = color; + LColor c = color; c.set(c[0] * _light_color_scale[0], c[1] * _light_color_scale[1], c[2] * _light_color_scale[2], c[3] * _light_color_scale[3]); - GLP(LightModelfv)(GL_LIGHT_MODEL_AMBIENT, c.get_data()); -#endif + call_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, c); } //////////////////////////////////////////////////////////////////// @@ -6934,7 +6959,7 @@ begin_bind_lights() { GLP(MatrixMode)(GL_MODELVIEW); GLP(PushMatrix)(); - GLP(LoadMatrixf)(render_transform->get_mat().get_data()); + GLPf(LoadMatrix)(render_transform->get_mat().get_data()); #endif } @@ -7002,7 +7027,7 @@ begin_bind_clip_planes() { GLP(MatrixMode)(GL_MODELVIEW); GLP(PushMatrix)(); - GLP(LoadMatrixf)(render_transform->get_mat().get_data()); + GLPf(LoadMatrix)(render_transform->get_mat().get_data()); #endif } @@ -7021,12 +7046,13 @@ bind_clip_plane(const NodePath &plane, int plane_id) { CPT(TransformState) transform = plane.get_transform(_scene_setup->get_scene_root().get_parent()); const PlaneNode *plane_node; DCAST_INTO_V(plane_node, plane.node()); - Planef xformed_plane = plane_node->get_plane() * transform->get_mat(); + LPlane xformed_plane = plane_node->get_plane() * transform->get_mat(); #ifndef OPENGLES_2 // OpenGL ES 2.0 doesn't support clip planes at all. #ifdef OPENGLES // OpenGL ES uses a single-precision call. - GLP(ClipPlanef)(id, xformed_plane.get_data()); + Planef single_plane(LCAST(single, xformed_plane)); + GLP(ClipPlanef)(id, single_plane.get_data()); #else // Mainline OpenGL uses a double-precision call. Planed double_plane(LCAST(double, xformed_plane)); @@ -7553,15 +7579,15 @@ update_standard_texture_bindings() { } if (stage->involves_color_scale() && _color_scale_enabled) { - Colorf color = stage->get_color(); + LColor color = stage->get_color(); color.set(color[0] * _current_color_scale[0], color[1] * _current_color_scale[1], color[2] * _current_color_scale[2], color[3] * _current_color_scale[3]); _texture_involves_color_scale = true; - GLP(TexEnvfv)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color.get_data()); + call_glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); } else { - GLP(TexEnvfv)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, stage->get_color().get_data()); + call_glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, stage->get_color()); } if (stage->get_mode() == TextureStage::M_decal) { @@ -7823,10 +7849,10 @@ upload_usage_texture(int width, int height) { << "upload_usage_texture(" << width << ", " << height << ")\n"; } - static Colorf colors[3] = { - Colorf(0.4f, 0.5f, 0.8f, 1.0f), // mipmap 0: blue - Colorf(1.0f, 1.0f, 0.0f, 1.0f), // mipmap 1: yellow - Colorf(0.8f, 0.3f, 0.3f, 1.0f), // mipmap 2 and higher: red + static LColor colors[3] = { + LColor(0.4, 0.5f, 0.8f, 1.0f), // mipmap 0: blue + LColor(1.0f, 1.0f, 0.0f, 1.0f), // mipmap 1: yellow + LColor(0.8f, 0.3, 0.3, 1.0f), // mipmap 2 and higher: red }; @@ -7837,7 +7863,7 @@ upload_usage_texture(int width, int height) { int n = 0; while (true) { // Choose the color for the nth mipmap. - Colorf c = colors[min(n, 2)]; + LColor c = colors[min(n, 2)]; // A simple union to store the colors values bytewise, and get the // answer wordwise, independently of machine byte-ordernig. @@ -7924,7 +7950,7 @@ do_issue_tex_matrix() { const TexMatrixAttrib *target_tex_matrix = DCAST(TexMatrixAttrib, _target_rs->get_attrib_def(TexMatrixAttrib::get_class_slot())); if (target_tex_matrix->has_stage(stage)) { - GLP(LoadMatrixf)(target_tex_matrix->get_mat(stage).get_data()); + GLPf(LoadMatrix)(target_tex_matrix->get_mat(stage).get_data()); } else { GLP(LoadIdentity)(); @@ -7934,7 +7960,7 @@ do_issue_tex_matrix() { // an identity matrix does work. But this buggy-driver // workaround might have other performance implications, so I // leave it out. - // GLP(LoadMatrixf)(LMatrix4f::ident_mat().get_data()); + // GLPf(LoadMatrix)(LMatrix4::ident_mat().get_data()); } } report_my_gl_errors(); @@ -7957,10 +7983,10 @@ do_issue_tex_gen() { // the spatial coordinates one-for-one to UV's. If you want a // mapping other than identity, use a TexMatrixAttrib (or a // TexProjectorEffect). - static const float s_data[4] = { 1, 0, 0, 0 }; - static const float t_data[4] = { 0, 1, 0, 0 }; - static const float r_data[4] = { 0, 0, 1, 0 }; - static const float q_data[4] = { 0, 0, 0, 1 }; + static const PN_stdfloat s_data[4] = { 1, 0, 0, 0 }; + static const PN_stdfloat t_data[4] = { 0, 1, 0, 0 }; + static const PN_stdfloat r_data[4] = { 0, 0, 1, 0 }; + static const PN_stdfloat q_data[4] = { 0, 0, 0, 1 }; _tex_gen_modifies_mat = false; @@ -8004,10 +8030,10 @@ do_issue_tex_gen() { // We need to rotate the normals out of GL's coordinate // system and into the user's coordinate system. We do this // by composing a transform onto the texture matrix. - LMatrix4f mat = _inv_cs_transform->get_mat(); - mat.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); + LMatrix4 mat = _inv_cs_transform->get_mat(); + mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); GLP(MatrixMode)(GL_TEXTURE); - GLP(MultMatrixf)(mat.get_data()); + GLPf(MultMatrix)(mat.get_data()); // Now we need to reset the texture matrix next time // around to undo this. @@ -8033,10 +8059,10 @@ do_issue_tex_gen() { // GL_REFLECTION_MAP. CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - LMatrix4f mat = camera_transform->get_mat(); - mat.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); + LMatrix4 mat = camera_transform->get_mat(); + mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); GLP(MatrixMode)(GL_TEXTURE); - GLP(MultMatrixf)(mat.get_data()); + GLPf(MultMatrix)(mat.get_data()); // Now we need to reset the texture matrix next time // around to undo this. @@ -8057,10 +8083,10 @@ do_issue_tex_gen() { // We need to rotate the normals out of GL's coordinate // system and into the user's coordinate system. We do this // by composing a transform onto the texture matrix. - LMatrix4f mat = _inv_cs_transform->get_mat(); - mat.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); + LMatrix4 mat = _inv_cs_transform->get_mat(); + mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); GLP(MatrixMode)(GL_TEXTURE); - GLP(MultMatrixf)(mat.get_data()); + GLPf(MultMatrix)(mat.get_data()); // Now we need to reset the texture matrix next time // around to undo this. @@ -8086,10 +8112,10 @@ do_issue_tex_gen() { // GL_NORMAL_MAP. CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); - LMatrix4f mat = camera_transform->get_mat(); - mat.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); + LMatrix4 mat = camera_transform->get_mat(); + mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); GLP(MatrixMode)(GL_TEXTURE); - GLP(MultMatrixf)(mat.get_data()); + GLPf(MultMatrix)(mat.get_data()); // Now we need to reset the texture matrix next time // around to undo this. @@ -8110,17 +8136,17 @@ do_issue_tex_gen() { // load the coordinate-system transform. GLP(MatrixMode)(GL_MODELVIEW); GLP(PushMatrix)(); - GLP(LoadMatrixf)(_cs_transform->get_mat().get_data()); + GLPf(LoadMatrix)(_cs_transform->get_mat().get_data()); GLP(TexGeni)(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - GLP(TexGenfv)(GL_S, GL_EYE_PLANE, s_data); - GLP(TexGenfv)(GL_T, GL_EYE_PLANE, t_data); - GLP(TexGenfv)(GL_R, GL_EYE_PLANE, r_data); - GLP(TexGenfv)(GL_Q, GL_EYE_PLANE, q_data); + GLPfv(TexGen)(GL_S, GL_EYE_PLANE, s_data); + GLPfv(TexGen)(GL_T, GL_EYE_PLANE, t_data); + GLPfv(TexGen)(GL_R, GL_EYE_PLANE, r_data); + GLPfv(TexGen)(GL_Q, GL_EYE_PLANE, q_data); GLP(Enable)(GL_TEXTURE_GEN_S); GLP(Enable)(GL_TEXTURE_GEN_T); @@ -8139,16 +8165,16 @@ do_issue_tex_gen() { GLP(MatrixMode)(GL_MODELVIEW); GLP(PushMatrix)(); CPT(TransformState) root_transform = _cs_transform->compose(_scene_setup->get_world_transform()); - GLP(LoadMatrixf)(root_transform->get_mat().get_data()); + GLPf(LoadMatrix)(root_transform->get_mat().get_data()); GLP(TexGeni)(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); GLP(TexGeni)(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - GLP(TexGenfv)(GL_S, GL_EYE_PLANE, s_data); - GLP(TexGenfv)(GL_T, GL_EYE_PLANE, t_data); - GLP(TexGenfv)(GL_R, GL_EYE_PLANE, r_data); - GLP(TexGenfv)(GL_Q, GL_EYE_PLANE, q_data); + GLPfv(TexGen)(GL_S, GL_EYE_PLANE, s_data); + GLPfv(TexGen)(GL_T, GL_EYE_PLANE, t_data); + GLPfv(TexGen)(GL_R, GL_EYE_PLANE, r_data); + GLPfv(TexGen)(GL_Q, GL_EYE_PLANE, q_data); GLP(Enable)(GL_TEXTURE_GEN_S); GLP(Enable)(GL_TEXTURE_GEN_T); @@ -8177,21 +8203,21 @@ do_issue_tex_gen() { // flattens the vertex position to zero and then adds our // desired value. { - const TexCoord3f &v = _target_tex_gen->get_constant_value(stage); + const LTexCoord3 &v = _target_tex_gen->get_constant_value(stage); GLP(TexGeni)(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); GLP(TexGeni)(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); GLP(TexGeni)(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); GLP(TexGeni)(GL_Q, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); - LVecBase4f s(0.0f, 0.0f, 0.0f, v[0]); - LVecBase4f t(0.0f, 0.0f, 0.0f, v[1]); - LVecBase4f r(0.0f, 0.0f, 0.0f, v[2]); + LVecBase4 s(0.0f, 0.0f, 0.0f, v[0]); + LVecBase4 t(0.0f, 0.0f, 0.0f, v[1]); + LVecBase4 r(0.0f, 0.0f, 0.0f, v[2]); - GLP(TexGenfv)(GL_S, GL_OBJECT_PLANE, s.get_data()); - GLP(TexGenfv)(GL_T, GL_OBJECT_PLANE, t.get_data()); - GLP(TexGenfv)(GL_R, GL_OBJECT_PLANE, r.get_data()); - GLP(TexGenfv)(GL_Q, GL_OBJECT_PLANE, q_data); + GLPfv(TexGen)(GL_S, GL_OBJECT_PLANE, s.get_data()); + GLPfv(TexGen)(GL_T, GL_OBJECT_PLANE, t.get_data()); + GLPfv(TexGen)(GL_R, GL_OBJECT_PLANE, r.get_data()); + GLPfv(TexGen)(GL_Q, GL_OBJECT_PLANE, q_data); GLP(Enable)(GL_TEXTURE_GEN_S); GLP(Enable)(GL_TEXTURE_GEN_T); @@ -8264,9 +8290,8 @@ specify_texture(CLP(TextureContext) *gtc) { get_texture_wrap_mode(tex->get_wrap_w())); } - Colorf border_color = tex->get_border_color(); - GLP(TexParameterfv)(target, GL_TEXTURE_BORDER_COLOR, - border_color.get_data()); + LColor border_color = tex->get_border_color(); + call_glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, border_color); #endif // OPENGLES Texture::FilterType minfilter = tex->get_effective_minfilter(); @@ -8302,9 +8327,9 @@ specify_texture(CLP(TextureContext) *gtc) { // Set anisotropic filtering. if (_supports_anisotropy) { - float anisotropy = tex->get_effective_anisotropic_degree(); + PN_stdfloat anisotropy = tex->get_effective_anisotropic_degree(); anisotropy = min(anisotropy, _max_anisotropy); - anisotropy = max(anisotropy, 1.0f); + anisotropy = max(anisotropy, (PN_stdfloat)1.0); GLP(TexParameterf)(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); } @@ -9571,7 +9596,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { tex->set_wrap_u(get_panda_wrap_mode(wrap_u)); tex->set_wrap_v(get_panda_wrap_mode(wrap_v)); tex->set_wrap_w(get_panda_wrap_mode(wrap_w)); - tex->set_border_color(Colorf(border_color[0], border_color[1], + tex->set_border_color(LColor(border_color[0], border_color[1], border_color[2], border_color[3])); tex->set_minfilter(get_panda_filter_type(minfilter)); @@ -9758,9 +9783,9 @@ do_point_size() { // units. To arrange that, we need to figure out the appropriate // scaling factor based on the current viewport and projection // matrix. - LVector3f height(0.0f, _point_size, 1.0f); + LVector3 height(0.0f, _point_size, 1.0f); height = height * _projection_mat->get_mat(); - float s = height[1] * _viewport_height / _point_size; + PN_stdfloat s = height[1] * _viewport_height / _point_size; if (_current_lens->is_orthographic()) { // If we have an orthographic lens in effect, we don't actually @@ -10080,7 +10105,7 @@ do_issue_stencil() { void CLP(GraphicsStateGuardian):: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); - const LVecBase4f &frame = target_scissor->get_frame(); + const LVecBase4 &frame = target_scissor->get_frame(); int x = (int)(_viewport_x + _viewport_width * frame[0] + 0.5f); int y = (int)(_viewport_y + _viewport_height * frame[2] + 0.5f); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index e95e49ee64..de61a5644c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -64,6 +64,10 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, const GLfloat typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, const GLfloat s, const GLfloat t); typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, const GLfloat s, const GLfloat t, const GLfloat r); typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, const GLfloat s, const GLfloat t, const GLfloat r, const GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, const GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, const GLdouble s, const GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, const GLdouble s, const GLdouble t, const GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, const GLdouble s, const GLdouble t, const GLdouble r, const GLdouble q); typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); @@ -84,6 +88,7 @@ typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); @@ -140,12 +145,18 @@ typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); #endif // OPENGLES_1 @@ -253,7 +264,7 @@ public: void print_gfx_visual(); - float *get_light_color(float light_color[4], Light *light) const; + LVecBase4 get_light_color(Light *light) const; #ifdef SUPPORT_IMMEDIATE_MODE void draw_immediate_simple_primitives(const GeomPrimitivePipelineReader *reader, GLenum mode); @@ -320,7 +331,7 @@ protected: virtual void reissue_transforms(); virtual void enable_lighting(bool enable); - virtual void set_ambient_light(const Colorf &color); + virtual void set_ambient_light(const LColor &color); virtual void enable_light(int light_id, bool enable); virtual void begin_bind_lights(); virtual void end_bind_lights(); @@ -349,6 +360,14 @@ protected: INLINE void enable_alpha_test(bool val); INLINE void enable_polygon_offset(bool val); + INLINE void call_glFogfv(GLenum pname, const LColor &color); + INLINE void call_glMaterialfv(GLenum face, GLenum pname, const LColor &color); + INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value); + INLINE void call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value); + INLINE void call_glLightModelfv(GLenum pname, const LVecBase4 &value); + INLINE void call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value); + INLINE void call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value); + INLINE GLenum get_light_id(int index) const; INLINE GLenum get_clip_plane_id(int index) const; @@ -446,7 +465,7 @@ protected: int _draw_buffer_type; bool _auto_antialias_mode; RenderModeAttrib::Mode _render_mode; - float _point_size; + PN_stdfloat _point_size; bool _point_perspective; bool _vertex_blending_enabled; @@ -472,7 +491,7 @@ protected: // to compute its data once. class DirectionalLightFrameData { public: - LVector4f _neg_dir; + LVector4 _neg_dir; }; typedef pmap DirectionalLights; DirectionalLights _dlights; @@ -484,7 +503,7 @@ protected: GLuint _current_ibuffer_index; GLuint _current_fbo; int _num_active_texture_stages; - float _max_anisotropy; + PN_stdfloat _max_anisotropy; bool _supports_anisotropy; int _error_count; @@ -502,9 +521,10 @@ public: bool _supports_point_sprite; bool _supports_vertex_blend; - PFNGLWEIGHTPOINTERARBPROC _glWeightPointerARB; - PFNGLVERTEXBLENDARBPROC _glVertexBlendARB; - PFNGLWEIGHTFVARBPROC _glWeightfvARB; + PFNGLWEIGHTPOINTERARBPROC _glWeightPointer; + PFNGLVERTEXBLENDARBPROC _glVertexBlend; + PFNGLWEIGHTFVARBPROC _glWeightfv; + PFNGLWEIGHTDVARBPROC _glWeightdv; bool _supports_matrix_palette; #ifdef OPENGLES @@ -541,6 +561,10 @@ public: PFNGLMULTITEXCOORD2FPROC _glMultiTexCoord2f; PFNGLMULTITEXCOORD3FPROC _glMultiTexCoord3f; PFNGLMULTITEXCOORD4FPROC _glMultiTexCoord4f; + PFNGLMULTITEXCOORD1DPROC _glMultiTexCoord1d; + PFNGLMULTITEXCOORD2DPROC _glMultiTexCoord2d; + PFNGLMULTITEXCOORD3DPROC _glMultiTexCoord3d; + PFNGLMULTITEXCOORD4DPROC _glMultiTexCoord4d; bool _supports_buffers; PFNGLGENBUFFERSPROC _glGenBuffers; @@ -622,12 +646,18 @@ public: PFNGLSHADERSOURCEPROC _glShaderSource; PFNGLUSEPROGRAMPROC _glUseProgram; PFNGLUNIFORM4FPROC _glUniform4f; + PFNGLUNIFORM4DPROC _glUniform4d; PFNGLUNIFORM1IPROC _glUniform1i; PFNGLUNIFORM1FVPROC _glUniform1fv; PFNGLUNIFORM2FVPROC _glUniform2fv; PFNGLUNIFORM3FVPROC _glUniform3fv; PFNGLUNIFORM4FVPROC _glUniform4fv; + PFNGLUNIFORM1DVPROC _glUniform1dv; + PFNGLUNIFORM2DVPROC _glUniform2dv; + PFNGLUNIFORM3DVPROC _glUniform3dv; + PFNGLUNIFORM4DVPROC _glUniform4dv; PFNGLUNIFORMMATRIX4FVPROC _glUniformMatrix4fv; + PFNGLUNIFORMMATRIX4DVPROC _glUniformMatrix4dv; PFNGLVALIDATEPROGRAMPROC _glValidateProgram; PFNGLVERTEXATTRIBPOINTERPROC _glVertexAttribPointer; #endif // OPENGLES_1 diff --git a/panda/src/glstuff/glImmediateModeSender_src.I b/panda/src/glstuff/glImmediateModeSender_src.I index 4fbed67dd5..f1d75efb4f 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.I +++ b/panda/src/glstuff/glImmediateModeSender_src.I @@ -213,36 +213,36 @@ VectorSender1ui(GeomVertexReader *reader, VectorUintFunc *func) : } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2ui::Constructor +// Function: CLP(ImmediateModeSender)::VectorSender2fui::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE CLP(ImmediateModeSender)::VectorSender2ui:: -VectorSender2ui(GeomVertexReader *reader, VectorUintFunc *func) : +INLINE CLP(ImmediateModeSender)::VectorSender2fui:: +VectorSender2fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), _func(func) { } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3ui::Constructor +// Function: CLP(ImmediateModeSender)::VectorSender3fui::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE CLP(ImmediateModeSender)::VectorSender3ui:: -VectorSender3ui(GeomVertexReader *reader, VectorUintFunc *func) : +INLINE CLP(ImmediateModeSender)::VectorSender3fui:: +VectorSender3fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), _func(func) { } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4ui::Constructor +// Function: CLP(ImmediateModeSender)::VectorSender4fui::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE CLP(ImmediateModeSender)::VectorSender4ui:: -VectorSender4ui(GeomVertexReader *reader, VectorUintFunc *func) : +INLINE CLP(ImmediateModeSender)::VectorSender4fui:: +VectorSender4fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), _func(func) { diff --git a/panda/src/glstuff/glImmediateModeSender_src.cxx b/panda/src/glstuff/glImmediateModeSender_src.cxx index 8c2bd6d23b..6e1ca3dd85 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.cxx +++ b/panda/src/glstuff/glImmediateModeSender_src.cxx @@ -86,7 +86,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// bool CLP(ImmediateModeSender):: add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, - Func1f *func1f, Func2f *func2f, Func3f *func3f, Func4f *func4f) { + Func1f *func1f, Func2f *func2, Func3f *func3, Func4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); ComponentSender *sender = NULL; @@ -99,20 +99,20 @@ add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName * break; case 2: - if (func2f != (Func2f *)NULL) { - sender = new ComponentSender2f(reader, func2f); + if (func2 != (Func2f *)NULL) { + sender = new ComponentSender2f(reader, func2); } break; case 3: - if (func3f != (Func3f *)NULL) { - sender = new ComponentSender3f(reader, func3f); + if (func3 != (Func3f *)NULL) { + sender = new ComponentSender3f(reader, func3); } break; case 4: - if (func4f != (Func4f *)NULL) { - sender = new ComponentSender4f(reader, func4f); + if (func4 != (Func4f *)NULL) { + sender = new ComponentSender4f(reader, func4); } break; } @@ -149,8 +149,8 @@ add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName * bool CLP(ImmediateModeSender):: add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, int stage_index, - TexcoordFunc1f *func1f, TexcoordFunc2f *func2f, - TexcoordFunc3f *func3f, TexcoordFunc4f *func4f) { + TexcoordFunc1f *func1f, TexcoordFunc2f *func2, + TexcoordFunc3f *func3, TexcoordFunc4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); ComponentSender *sender = NULL; @@ -161,15 +161,15 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, break; case 2: - sender = new TexcoordSender2f(reader, func2f, stage_index); + sender = new TexcoordSender2f(reader, func2, stage_index); break; case 3: - sender = new TexcoordSender3f(reader, func3f, stage_index); + sender = new TexcoordSender3f(reader, func3, stage_index); break; case 4: - sender = new TexcoordSender4f(reader, func4f, stage_index); + sender = new TexcoordSender4f(reader, func4, stage_index); break; } @@ -270,15 +270,15 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, break; case 2: - sender = new VectorSender2ui(reader, func); + sender = new VectorSender2fui(reader, func); break; case 3: - sender = new VectorSender3ui(reader, func); + sender = new VectorSender3fui(reader, func); break; case 4: - sender = new VectorSender4ui(reader, func); + sender = new VectorSender4fui(reader, func); break; } @@ -326,7 +326,7 @@ CLP(ImmediateModeSender)::ComponentSender:: //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::ComponentSender1f:: issue_vertex() { - float d = _reader->get_data1f(); + PN_stdfloat d = _reader->get_data1f(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -344,7 +344,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::ComponentSender2f:: issue_vertex() { - const LVecBase2f &d = _reader->get_data2f(); + const LVecBase2 &d = _reader->get_data2(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -362,7 +362,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::ComponentSender3f:: issue_vertex() { - const LVecBase3f &d = _reader->get_data3f(); + const LVecBase3 &d = _reader->get_data3(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -380,7 +380,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::ComponentSender4f:: issue_vertex() { - const LVecBase4f &d = _reader->get_data4f(); + const LVecBase4 &d = _reader->get_data4(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -398,7 +398,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::TexcoordSender1f:: issue_vertex() { - float d = _reader->get_data1f(); + PN_stdfloat d = _reader->get_data1f(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -417,7 +417,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::TexcoordSender2f:: issue_vertex() { - const LVecBase2f &d = _reader->get_data2f(); + const LVecBase2 &d = _reader->get_data2(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -436,7 +436,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::TexcoordSender3f:: issue_vertex() { - const LVecBase3f &d = _reader->get_data3f(); + const LVecBase3 &d = _reader->get_data3(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -455,7 +455,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::TexcoordSender4f:: issue_vertex() { - const LVecBase4f &d = _reader->get_data4f(); + const LVecBase4 &d = _reader->get_data4(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -474,7 +474,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::VectorSender1f:: issue_vertex() { - float d = _reader->get_data1f(); + PN_stdfloat d = _reader->get_data1f(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -492,7 +492,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::VectorSender2f:: issue_vertex() { - const LVecBase2f &d = _reader->get_data2f(); + const LVecBase2 &d = _reader->get_data2(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -510,7 +510,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::VectorSender3f:: issue_vertex() { - const LVecBase3f &d = _reader->get_data3f(); + const LVecBase3 &d = _reader->get_data3(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -528,7 +528,7 @@ issue_vertex() { //////////////////////////////////////////////////////////////////// void CLP(ImmediateModeSender)::VectorSender4f:: issue_vertex() { - const LVecBase4f &d = _reader->get_data4f(); + const LVecBase4 &d = _reader->get_data4(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() @@ -558,11 +558,11 @@ issue_vertex() { } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2ui::issue_vertex +// Function: CLP(ImmediateModeSender)::VectorSender2fui::issue_vertex // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CLP(ImmediateModeSender)::VectorSender2ui:: +void CLP(ImmediateModeSender)::VectorSender2fui:: issue_vertex() { const int *d = _reader->get_data2i(); #ifndef NDEBUG @@ -577,11 +577,11 @@ issue_vertex() { } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3ui::issue_vertex +// Function: CLP(ImmediateModeSender)::VectorSender3fui::issue_vertex // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CLP(ImmediateModeSender)::VectorSender3ui:: +void CLP(ImmediateModeSender)::VectorSender3fui:: issue_vertex() { const int *d = _reader->get_data3i(); #ifndef NDEBUG @@ -596,11 +596,11 @@ issue_vertex() { } //////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4ui::issue_vertex +// Function: CLP(ImmediateModeSender)::VectorSender4fui::issue_vertex // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -void CLP(ImmediateModeSender)::VectorSender4ui:: +void CLP(ImmediateModeSender)::VectorSender4fui:: issue_vertex() { const int *d = _reader->get_data4i(); #ifndef NDEBUG diff --git a/panda/src/glstuff/glImmediateModeSender_src.h b/panda/src/glstuff/glImmediateModeSender_src.h index 40007071a0..1668c3eaed 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.h +++ b/panda/src/glstuff/glImmediateModeSender_src.h @@ -43,6 +43,8 @@ public: void issue_vertex(); class ComponentSender; + +#ifndef STDFLOAT_DOUBLE typedef void APIENTRY Func1f(GLfloat a); typedef void APIENTRY Func2f(GLfloat a, GLfloat b); typedef void APIENTRY Func3f(GLfloat a, GLfloat b, GLfloat c); @@ -52,15 +54,26 @@ public: typedef void APIENTRY TexcoordFunc3f(GLenum texture, GLfloat a, GLfloat b, GLfloat c); typedef void APIENTRY TexcoordFunc4f(GLenum texture, GLfloat a, GLfloat b, GLfloat c, GLfloat d); typedef void APIENTRY VectorFunc(GLint, const GLfloat *); +#else // STDFLOAT_DOUBLE + typedef void APIENTRY Func1f(GLdouble a); + typedef void APIENTRY Func2f(GLdouble a, GLdouble b); + typedef void APIENTRY Func3f(GLdouble a, GLdouble b, GLdouble c); + typedef void APIENTRY Func4f(GLdouble a, GLdouble b, GLdouble c, GLdouble d); + typedef void APIENTRY TexcoordFunc1f(GLenum texture, GLdouble a); + typedef void APIENTRY TexcoordFunc2f(GLenum texture, GLdouble a, GLdouble b); + typedef void APIENTRY TexcoordFunc3f(GLenum texture, GLdouble a, GLdouble b, GLdouble c); + typedef void APIENTRY TexcoordFunc4f(GLenum texture, GLdouble a, GLdouble b, GLdouble c, GLdouble d); + typedef void APIENTRY VectorFunc(GLint, const GLdouble *); +#endif // STDFLOAT_DOUBLE typedef void APIENTRY VectorUintFunc(GLint, const GLuint *); bool add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, Func1f *func1f, - Func2f *func2f, Func3f *func3f, Func4f *func4f); + Func2f *func2, Func3f *func3, Func4f *func4); bool add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, int stage_index, - TexcoordFunc1f *func1f, TexcoordFunc2f *func2f, - TexcoordFunc3f *func3f, TexcoordFunc4f *func4f); + TexcoordFunc1f *func1f, TexcoordFunc2f *func2, + TexcoordFunc3f *func3, TexcoordFunc4f *func4); bool add_vector_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorFunc *func); @@ -193,25 +206,25 @@ public: VectorUintFunc *_func; }; - class VectorSender2ui : public ComponentSender { + class VectorSender2fui : public ComponentSender { public: - INLINE VectorSender2ui(GeomVertexReader *reader, VectorUintFunc *func); + INLINE VectorSender2fui(GeomVertexReader *reader, VectorUintFunc *func); virtual void issue_vertex(); private: VectorUintFunc *_func; }; - class VectorSender3ui : public ComponentSender { + class VectorSender3fui : public ComponentSender { public: - INLINE VectorSender3ui(GeomVertexReader *reader, VectorUintFunc *func); + INLINE VectorSender3fui(GeomVertexReader *reader, VectorUintFunc *func); virtual void issue_vertex(); private: VectorUintFunc *_func; }; - class VectorSender4ui : public ComponentSender { + class VectorSender4fui : public ComponentSender { public: - INLINE VectorSender4ui(GeomVertexReader *reader, VectorUintFunc *func); + INLINE VectorSender4fui(GeomVertexReader *reader, VectorUintFunc *func); virtual void issue_vertex(); private: VectorUintFunc *_func; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index b23b2d8dad..c25b3c84e0 100755 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -511,7 +511,7 @@ unbind(GSG *gsg) { // transforms. //////////////////////////////////////////////////////////////////// void CLP(ShaderContext):: -issue_parameters(GSG *gsg, int altered) { + issue_parameters(GSG *gsg, int altered) { _last_gsg = gsg; PStatTimer timer(gsg->_draw_set_state_shader_parameters_pcollector); @@ -531,88 +531,88 @@ issue_parameters(GSG *gsg, int altered) { #if defined(HAVE_CG) && !defined(OPENGLES) else if (_shader->get_language() == Shader::SL_Cg) { const Shader::ShaderPtrSpec& _ptr = _shader->_ptr_spec[i]; - Shader::ShaderPtrData* _ptr_data = + Shader::ShaderPtrData* ptr_data = const_cast< Shader::ShaderPtrData*>(gsg->fetch_ptr_parameter(_ptr)); - if (_ptr_data == NULL){ //the input is not contained in ShaderPtrData + if (ptr_data == NULL){ //the input is not contained in ShaderPtrData release_resources(gsg); return; } //check if the data must be shipped to the GPU - /*if (!_ptr_data->_updated) + /*if (!ptr_data->_updated) continue; - _ptr_data->_updated = false;*/ + ptr_data->_updated = false;*/ - //Check if the size of the shader input and _ptr_data match + //Check if the size of the shader input and ptr_data match int input_size = _ptr._dim[0] * _ptr._dim[1] * _ptr._dim[2]; // dimension is negative only if the parameter had the (deprecated)k_ prefix. - if ((input_size != _ptr_data->_size) && (_ptr._dim[0] > 0)) { + if ((input_size != ptr_data->_size) && (_ptr._dim[0] > 0)) { GLCAT.error() << _ptr._id._name << ": incorrect number of elements, expected " - << input_size <<" got " << _ptr_data->_size << "\n"; + << input_size <<" got " << ptr_data->_size << "\n"; release_resources(gsg); return; } CGparameter p = _cg_parameter_map[_ptr._id._seqno]; - switch(_ptr_data->_type) { - case Shader::SPT_float: - switch(_ptr._info._class) { - case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)_ptr_data->_ptr); continue; - case Shader::SAC_vector: - switch(_ptr._info._type) { - case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)_ptr_data->_ptr); continue; - case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)_ptr_data->_ptr); continue; - case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)_ptr_data->_ptr); continue; - case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)_ptr_data->_ptr); continue; - } - case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)_ptr_data->_ptr); continue; - case Shader::SAC_array: { - switch(_ptr._info._subclass) { - case Shader::SAC_scalar: - cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - case Shader::SAC_vector: - switch(_ptr._dim[2]) { - case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - case 4: cgGLSetParameterArray4f(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - } - case Shader::SAC_matrix: - cgGLSetMatrixParameterArrayfc(p,0,_ptr._dim[0],(float*)_ptr_data->_ptr); continue; - } - } + switch(ptr_data->_type) { + case Shader::SPT_float: + switch(_ptr._info._class) { + case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue; + case Shader::SAC_vector: + switch(_ptr._info._type) { + case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue; + case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue; + case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue; + case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue; } - case Shader::SPT_double: - switch(_ptr._info._class) { - case Shader::SAC_scalar: cgSetParameter1dv(p,(double*)_ptr_data->_ptr); continue; - case Shader::SAC_vector: - switch(_ptr._info._type) { - case Shader::SAT_vec1: cgSetParameter1dv(p,(double*)_ptr_data->_ptr); continue; - case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)_ptr_data->_ptr); continue; - case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)_ptr_data->_ptr); continue; - case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)_ptr_data->_ptr); continue; - } - case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)_ptr_data->_ptr); continue; - case Shader::SAC_array: { - switch(_ptr._info._subclass) { - case Shader::SAC_scalar: - cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - case Shader::SAC_vector: - switch(_ptr._dim[2]) { - case 1: cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - case 2: cgGLSetParameterArray2d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - case 3: cgGLSetParameterArray3d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - case 4: cgGLSetParameterArray4d(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - } - case Shader::SAC_matrix: - cgGLSetMatrixParameterArraydc(p,0,_ptr._dim[0],(double*)_ptr_data->_ptr); continue; - } - } + case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue; + case Shader::SAC_array: { + switch(_ptr._info._subclass) { + case Shader::SAC_scalar: + cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + case Shader::SAC_vector: + switch(_ptr._dim[2]) { + case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + case 4: cgGLSetParameterArray4f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + } + case Shader::SAC_matrix: + cgGLSetMatrixParameterArrayfc(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; } - default: GLCAT.error() << _ptr._id._name << ":" << "unrecognized parameter type\n"; - release_resources(gsg); - return; + } + } + case Shader::SPT_double: + switch(_ptr._info._class) { + case Shader::SAC_scalar: cgSetParameter1dv(p,(double*)ptr_data->_ptr); continue; + case Shader::SAC_vector: + switch(_ptr._info._type) { + case Shader::SAT_vec1: cgSetParameter1dv(p,(double*)ptr_data->_ptr); continue; + case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue; + case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue; + case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue; + } + case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue; + case Shader::SAC_array: { + switch(_ptr._info._subclass) { + case Shader::SAC_scalar: + cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + case Shader::SAC_vector: + switch(_ptr._dim[2]) { + case 1: cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + case 2: cgGLSetParameterArray2d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + case 3: cgGLSetParameterArray3d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + case 4: cgGLSetParameterArray4d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + } + case Shader::SAC_matrix: + cgGLSetMatrixParameterArraydc(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + } + } + } + default: GLCAT.error() << _ptr._id._name << ":" << "unrecognized parameter type\n"; + release_resources(gsg); + return; } } #endif @@ -623,44 +623,44 @@ issue_parameters(GSG *gsg, int altered) { for (int i=0; i<(int)_shader->_mat_spec.size(); i++) { if (altered & (_shader->_mat_spec[i]._dep[0] | _shader->_mat_spec[i]._dep[1])) { - const LMatrix4f *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered); + const LMatrix4 *val = gsg->fetch_specified_value(_shader->_mat_spec[i], altered); if (!val) continue; - const float *data = val->get_data(); + const PN_stdfloat *data = val->get_data(); if (_shader->get_language() == Shader::SL_GLSL) { GLint p = _shader->_glsl_parameter_map[_shader->_mat_spec[i]._id._seqno]; switch (_shader->_mat_spec[i]._piece) { - case Shader::SMP_whole: gsg->_glUniformMatrix4fv(p, 1, false, data); continue; - case Shader::SMP_transpose: gsg->_glUniformMatrix4fv(p, 1, true, data); continue; - case Shader::SMP_col0: gsg->_glUniform4f(p, data[0], data[4], data[ 8], data[12]); continue; - case Shader::SMP_col1: gsg->_glUniform4f(p, data[1], data[5], data[ 9], data[13]); continue; - case Shader::SMP_col2: gsg->_glUniform4f(p, data[2], data[6], data[10], data[14]); continue; - case Shader::SMP_col3: gsg->_glUniform4f(p, data[3], data[7], data[11], data[15]); continue; - case Shader::SMP_row0: gsg->_glUniform4fv(p, 1, data+ 0); continue; - case Shader::SMP_row1: gsg->_glUniform4fv(p, 1, data+ 4); continue; - case Shader::SMP_row2: gsg->_glUniform4fv(p, 1, data+ 8); continue; - case Shader::SMP_row3: gsg->_glUniform4fv(p, 1, data+12); continue; - case Shader::SMP_row3x1: gsg->_glUniform1fv(p, 1, data+12); continue; - case Shader::SMP_row3x2: gsg->_glUniform2fv(p, 1, data+12); continue; - case Shader::SMP_row3x3: gsg->_glUniform3fv(p, 1, data+12); continue; + case Shader::SMP_whole: gsg->GLfv(_glUniformMatrix4)(p, 1, false, data); continue; + case Shader::SMP_transpose: gsg->GLfv(_glUniformMatrix4)(p, 1, true, data); continue; + case Shader::SMP_col0: gsg->GLf(_glUniform4)(p, data[0], data[4], data[ 8], data[12]); continue; + case Shader::SMP_col1: gsg->GLf(_glUniform4)(p, data[1], data[5], data[ 9], data[13]); continue; + case Shader::SMP_col2: gsg->GLf(_glUniform4)(p, data[2], data[6], data[10], data[14]); continue; + case Shader::SMP_col3: gsg->GLf(_glUniform4)(p, data[3], data[7], data[11], data[15]); continue; + case Shader::SMP_row0: gsg->GLfv(_glUniform4)(p, 1, data+ 0); continue; + case Shader::SMP_row1: gsg->GLfv(_glUniform4)(p, 1, data+ 4); continue; + case Shader::SMP_row2: gsg->GLfv(_glUniform4)(p, 1, data+ 8); continue; + case Shader::SMP_row3: gsg->GLfv(_glUniform4)(p, 1, data+12); continue; + case Shader::SMP_row3x1: gsg->GLfv(_glUniform1)(p, 1, data+12); continue; + case Shader::SMP_row3x2: gsg->GLfv(_glUniform2)(p, 1, data+12); continue; + case Shader::SMP_row3x3: gsg->GLfv(_glUniform3)(p, 1, data+12); continue; } } #if defined(HAVE_CG) && !defined(OPENGLES) else if (_shader->get_language() == Shader::SL_Cg) { CGparameter p = _cg_parameter_map[_shader->_mat_spec[i]._id._seqno]; switch (_shader->_mat_spec[i]._piece) { - case Shader::SMP_whole: cgGLSetMatrixParameterfc(p, data); continue; - case Shader::SMP_transpose: cgGLSetMatrixParameterfr(p, data); continue; - case Shader::SMP_col0: cgGLSetParameter4f(p, data[0], data[4], data[ 8], data[12]); continue; - case Shader::SMP_col1: cgGLSetParameter4f(p, data[1], data[5], data[ 9], data[13]); continue; - case Shader::SMP_col2: cgGLSetParameter4f(p, data[2], data[6], data[10], data[14]); continue; - case Shader::SMP_col3: cgGLSetParameter4f(p, data[3], data[7], data[11], data[15]); continue; - case Shader::SMP_row0: cgGLSetParameter4fv(p, data+ 0); continue; - case Shader::SMP_row1: cgGLSetParameter4fv(p, data+ 4); continue; - case Shader::SMP_row2: cgGLSetParameter4fv(p, data+ 8); continue; - case Shader::SMP_row3: cgGLSetParameter4fv(p, data+12); continue; - case Shader::SMP_row3x1: cgGLSetParameter1fv(p, data+12); continue; - case Shader::SMP_row3x2: cgGLSetParameter2fv(p, data+12); continue; - case Shader::SMP_row3x3: cgGLSetParameter3fv(p, data+12); continue; + case Shader::SMP_whole: GLfc(cgGLSetMatrixParameter)(p, data); continue; + case Shader::SMP_transpose: GLfr(cgGLSetMatrixParameter)(p, data); continue; + case Shader::SMP_col0: GLf(cgGLSetParameter4)(p, data[0], data[4], data[ 8], data[12]); continue; + case Shader::SMP_col1: GLf(cgGLSetParameter4)(p, data[1], data[5], data[ 9], data[13]); continue; + case Shader::SMP_col2: GLf(cgGLSetParameter4)(p, data[2], data[6], data[10], data[14]); continue; + case Shader::SMP_col3: GLf(cgGLSetParameter4)(p, data[3], data[7], data[11], data[15]); continue; + case Shader::SMP_row0: GLfv(cgGLSetParameter4)(p, data+ 0); continue; + case Shader::SMP_row1: GLfv(cgGLSetParameter4)(p, data+ 4); continue; + case Shader::SMP_row2: GLfv(cgGLSetParameter4)(p, data+ 8); continue; + case Shader::SMP_row3: GLfv(cgGLSetParameter4)(p, data+12); continue; + case Shader::SMP_row3x1: GLfv(cgGLSetParameter1)(p, data+12); continue; + case Shader::SMP_row3x2: GLfv(cgGLSetParameter2)(p, data+12); continue; + case Shader::SMP_row3x3: GLfv(cgGLSetParameter3)(p, data+12); continue; } } #endif diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index 9813ffda17..748564647a 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -18,6 +18,26 @@ #include "configVariableEnum.h" #include "geomEnums.h" +// Define some macros to transparently map to the double or float +// versions of the OpenGL function names. +#ifndef GLf + +#ifndef STDFLOAT_DOUBLE +#define GLf(name) name ## f +#define GLfv(name) name ## fv +#define GLfc(name) name ## fc +#define GLfr(name) name ## fr +#define GLf_str "f" +#else // STDFLOAT_DOUBLE +#define GLf(name) name ## d +#define GLfv(name) name ## dv +#define GLfc(name) name ## dc +#define GLfr(name) name ## dr +#define GLf_str "d" +#endif // STDFLOAT_DOUBLE + +#endif // GLf + //#define GSG_VERBOSE 1 extern ConfigVariableBool CLP(cheap_textures); diff --git a/panda/src/gobj/adaptiveLru.I b/panda/src/gobj/adaptiveLru.I index 8c30c7f2bc..3c31c14bf2 100644 --- a/panda/src/gobj/adaptiveLru.I +++ b/panda/src/gobj/adaptiveLru.I @@ -102,7 +102,7 @@ validate() { // exponential moving average. //////////////////////////////////////////////////////////////////// INLINE void AdaptiveLru:: -set_weight(float weight) { +set_weight(PN_stdfloat weight) { _weight = weight; } @@ -112,7 +112,7 @@ set_weight(float weight) { // Description: Returns the weight value used to compute the // exponential moving average. //////////////////////////////////////////////////////////////////// -INLINE float AdaptiveLru:: +INLINE PN_stdfloat AdaptiveLru:: get_weight() const { return _weight; } @@ -146,8 +146,8 @@ get_max_updates_per_frame() const { // Access: Private // Description: //////////////////////////////////////////////////////////////////// -INLINE float AdaptiveLru:: -calculate_exponential_moving_average(float value, float average) const { +INLINE PN_stdfloat AdaptiveLru:: +calculate_exponential_moving_average(PN_stdfloat value, PN_stdfloat average) const { return ((value - average) * _weight) + average; } diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 5bdabaf325..64dfaadde9 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -125,8 +125,8 @@ update_page(AdaptiveLruPage *page) { update_frames = (_current_frame_identifier - page->_update_frame_identifier); if (update_frames > 0) { - float update_average_frame_utilization = - (float) (page->_update_total_usage) / (float)update_frames; + PN_stdfloat update_average_frame_utilization = + (PN_stdfloat) (page->_update_total_usage) / (PN_stdfloat)update_frames; page->_average_frame_utilization = calculate_exponential_moving_average(update_average_frame_utilization, @@ -138,7 +138,7 @@ update_page(AdaptiveLruPage *page) { integer_average_frame_utilization = (int) ((page->_average_frame_utilization - 1.0f) * - (float) HIGH_PRIORITY_SCALE); + (PN_stdfloat) HIGH_PRIORITY_SCALE); if (integer_average_frame_utilization >= LPP_New) { integer_average_frame_utilization = LPP_New; } @@ -150,7 +150,7 @@ update_page(AdaptiveLruPage *page) { integer_average_frame_utilization = (int) (page->_average_frame_utilization * - (float) LOW_PRIORITY_RANGE); + (PN_stdfloat) LOW_PRIORITY_RANGE); integer_average_frame_utilization = LOW_PRIORITY_RANGE - integer_average_frame_utilization; target_priority = LPP_New + integer_average_frame_utilization; diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index 2d38758918..eab6df8a1a 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -69,8 +69,8 @@ PUBLISHED: // exist in the SimpleLru implementation. In most cases, the // defaults will be sufficient, so you do not need to mess with // them. - INLINE void set_weight(float weight); - INLINE float get_weight() const; + INLINE void set_weight(PN_stdfloat weight); + INLINE PN_stdfloat get_weight() const; INLINE void set_max_updates_per_frame(int max_updates_per_frame); INLINE int get_max_updates_per_frame() const; @@ -87,7 +87,7 @@ private: LPP_TotalPriorities = 50, }; - INLINE float calculate_exponential_moving_average(float value, float average) const; + INLINE PN_stdfloat calculate_exponential_moving_average(PN_stdfloat value, PN_stdfloat average) const; void do_partial_lru_update(int num_updates); void update_page(AdaptiveLruPage *page); @@ -185,7 +185,7 @@ private: int _total_usage; int _update_total_usage; - float _average_frame_utilization; + PN_stdfloat _average_frame_utilization; friend class AdaptiveLru; }; diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index ff01eb9498..5082353427 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -261,6 +261,17 @@ ConfigVariableBool enforce_attrib_lock "generator, but doing so may be necessary for backward " "compatibility with old code.")); +ConfigVariableBool vertices_float64 +("vertices-float64", false, + PRC_DESC("When this is true, the default float format for vertices " + "will be a 64-bit double-precision float, instead " + "of the normal 32-bit single-precision float. This must be set " + "at static init time to have the broadest effect. You almost never " + "want to set this true, since current hardware does not support " + "double-precision vertices, and setting this will just require the " + "driver to downsample the vertices at load time, making everything " + "slower.")); + ConfigVariableEnum textures_power_2 ("textures-power-2", ATS_down, PRC_DESC("Specify whether textures should automatically be constrained to " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index 3e933c4868..2014fa8444 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -71,6 +71,7 @@ extern EXPCL_PANDA_GOBJ ConfigVariableBool connect_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool preserve_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool dump_generated_shaders; extern EXPCL_PANDA_GOBJ ConfigVariableBool enforce_attrib_lock; +extern EXPCL_PANDA_GOBJ ConfigVariableBool vertices_float64; extern EXPCL_PANDA_GOBJ ConfigVariableEnum textures_power_2; extern EXPCL_PANDA_GOBJ ConfigVariableEnum textures_square; diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 5ea853472f..f34df85a75 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -366,10 +366,10 @@ clear_bounds() { // specifying a transform matrix. //////////////////////////////////////////////////////////////////// INLINE void Geom:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -393,11 +393,11 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, // the Geom's own coordinate space. //////////////////////////////////////////////////////////////////// INLINE void Geom:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const { calc_tight_bounds(min_point, max_point, found_any, get_vertex_data(current_thread), false, - LMatrix4f::ident_mat(), + LMatrix4::ident_mat(), current_thread); } @@ -408,10 +408,10 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, // other named columns. //////////////////////////////////////////////////////////////////// INLINE void Geom:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 6de98138da..99aa45ef3f 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -889,7 +889,7 @@ request_resident() const { // same transform to multiple Geoms. //////////////////////////////////////////////////////////////////// void Geom:: -transform_vertices(const LMatrix4f &mat) { +transform_vertices(const LMatrix4 &mat) { PT(GeomVertexData) new_data = modify_vertex_data(); CPT(GeomVertexFormat) format = new_data->get_format(); @@ -898,16 +898,16 @@ transform_vertices(const LMatrix4f &mat) { GeomVertexRewriter data(new_data, format->get_point(ci)); while (!data.is_at_end()) { - const LPoint3f &point = data.get_data3f(); - data.set_data3f(point * mat); + const LPoint3 &point = data.get_data3(); + data.set_data3(point * mat); } } for (ci = 0; ci < format->get_num_vectors(); ci++) { GeomVertexRewriter data(new_data, format->get_vector(ci)); while (!data.is_at_end()) { - const LVector3f &vector = data.get_data3f(); - data.set_data3f(normalize(vector * mat)); + const LVector3 &vector = data.get_data3(); + data.set_data3(normalize(vector * mat)); } } } @@ -1254,10 +1254,10 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { // Now actually compute the bounding volume. We do this by using // calc_tight_bounds to determine our box first. - LPoint3f min, max; + LPoint3 min, max; bool found_any = false; do_calc_tight_bounds(min, max, found_any, vertex_data, - false, LMatrix4f::ident_mat(), + false, LMatrix4::ident_mat(), InternalName::get_vertex(), cdata, current_thread); @@ -1309,10 +1309,10 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { // Description: The private implementation of calc_tight_bounds(). //////////////////////////////////////////////////////////////////// void Geom:: -do_calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +do_calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, const CData *cdata, Thread *current_thread) const { Primitives::const_iterator pi; diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 0f0fa7425d..075c92c765 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -117,7 +117,7 @@ PUBLISHED: bool request_resident() const; - void transform_vertices(const LMatrix4f &mat); + void transform_vertices(const LMatrix4 &mat); bool check_valid() const; bool check_valid(const GeomVertexData *vertex_data) const; @@ -149,17 +149,17 @@ public: const GeomVertexData *vertex_data, bool force, Thread *current_thread) const; - INLINE void calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + INLINE void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, Thread *current_thread) const; - INLINE void calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + INLINE void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const; - INLINE void calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + INLINE void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const; @@ -171,10 +171,10 @@ private: INLINE void mark_internal_bounds_stale(CData *cdata); void compute_internal_bounds(CData *cdata, Thread *current_thread) const; - void do_calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + void do_calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, const CData *cdata, Thread *current_thread) const; diff --git a/panda/src/gobj/geomEnums.h b/panda/src/gobj/geomEnums.h index 2b5e4a49ab..df2418822b 100644 --- a/panda/src/gobj/geomEnums.h +++ b/panda/src/gobj/geomEnums.h @@ -183,6 +183,7 @@ PUBLISHED: NT_packed_dabc, // DirectX packed color order (ARGB) NT_float32, // A single-precision float NT_float64, // A double-precision float + NT_stdfloat // Either single- or double-precision, according to vertices-float64. }; // The contents determine the semantic meaning of a numeric value diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index 8169e18bbf..94bb463707 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -1472,10 +1472,10 @@ get_highest_index_value(NumericType index_type) { // before calling this function. //////////////////////////////////////////////////////////////////// void GeomPrimitive:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const { GeomVertexReader reader(vertex_data, column_name, current_thread); @@ -1492,7 +1492,7 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, if (got_mat) { for (int i = 0; i < cdata->_num_vertices; i++) { reader.set_row_unsafe(cdata->_first_vertex + i); - LPoint3f vertex = mat.xform_point(reader.get_data3f()); + LPoint3 vertex = mat.xform_point(reader.get_data3()); if (found_any) { min_point.set(min(min_point[0], vertex[0]), @@ -1510,7 +1510,7 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, } else { for (int i = 0; i < cdata->_num_vertices; i++) { reader.set_row_unsafe(cdata->_first_vertex + i); - const LVecBase3f &vertex = reader.get_data3f(); + const LVecBase3 &vertex = reader.get_data3(); if (found_any) { min_point.set(min(min_point[0], vertex[0]), @@ -1535,7 +1535,7 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, while (!index.is_at_end()) { int ii = index.get_data1i(); reader.set_row_unsafe(ii); - LPoint3f vertex = mat.xform_point(reader.get_data3f()); + LPoint3 vertex = mat.xform_point(reader.get_data3()); if (found_any) { min_point.set(min(min_point[0], vertex[0]), @@ -1554,7 +1554,7 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, while (!index.is_at_end()) { int ii = index.get_data1i(); reader.set_row_unsafe(ii); - const LVecBase3f &vertex = reader.get_data3f(); + const LVecBase3 &vertex = reader.get_data3(); if (found_any) { min_point.set(min(min_point[0], vertex[0]), diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index aa729fc5ce..0d96ec3109 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -198,10 +198,10 @@ public: const GeomPrimitivePipelineReader *reader, bool force) const=0; - void calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, - bool got_mat, const LMatrix4f &mat, + bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const; diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index 1048f4f241..18246f2a67 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -72,6 +72,10 @@ output(ostream &out) const { case NT_float64: out << "d"; break; + + case NT_stdfloat: + out << "?"; + break; } out << ")"; @@ -89,6 +93,14 @@ setup() { _num_values = _num_components; + if (_numeric_type == NT_stdfloat) { + if (vertices_float64) { + _numeric_type = NT_float64; + } else { + _numeric_type = NT_float32; + } + } + switch (_numeric_type) { case NT_uint16: _component_bytes = 2; // sizeof(PN_uint16) @@ -115,6 +127,10 @@ setup() { case NT_float64: _component_bytes = 8; // sizeof(PN_float64) break; + + case NT_stdfloat: + nassertv(false); + break; } _total_bytes = _component_bytes * _num_components; @@ -362,6 +378,9 @@ get_data1f(const unsigned char *pointer) { case NT_float64: return *(const PN_float64 *)pointer; + + default: + nassertr(false, 0.0f); } return 0.0f; @@ -427,6 +446,9 @@ get_data2f(const unsigned char *pointer) { _v2.set(pi[0], pi[1]); } return _v2; + + case NT_stdfloat: + nassertr(false, _v2); } } @@ -503,6 +525,9 @@ get_data3f(const unsigned char *pointer) { _v3.set(pi[0], pi[1], pi[2]); } return _v3; + + case NT_stdfloat: + nassertr(false, _v3); } } @@ -588,6 +613,9 @@ get_data4f(const unsigned char *pointer) { _v4.set(pi[0], pi[1], pi[2], pi[3]); } return _v4; + + case NT_stdfloat: + nassertr(false, _v4); } } @@ -628,6 +656,9 @@ get_data1d(const unsigned char *pointer) { case NT_float64: return *(const PN_float64 *)pointer; + + case NT_stdfloat: + nassertr(false, 0.0f); } return 0.0f; @@ -693,6 +724,9 @@ get_data2d(const unsigned char *pointer) { _v2d.set(pi[0], pi[1]); } return _v2d; + + case NT_stdfloat: + nassertr(false, _v2d); } } @@ -769,6 +803,9 @@ get_data3d(const unsigned char *pointer) { _v3d.set(pi[0], pi[1], pi[2]); } return _v3d; + + case NT_stdfloat: + nassertr(false, _v3d); } } @@ -854,6 +891,9 @@ get_data4d(const unsigned char *pointer) { _v4d.set(pi[0], pi[1], pi[2], pi[3]); } return _v4d; + + case NT_stdfloat: + nassertr(false, _v4d); } } @@ -894,6 +934,9 @@ get_data1i(const unsigned char *pointer) { case NT_float64: return (int)*(const PN_float64 *)pointer; + + case NT_stdfloat: + nassertr(false, 0); } return 0; @@ -966,6 +1009,9 @@ get_data2i(const unsigned char *pointer) { _i[1] = (int)pi[1]; } return _i; + + case NT_stdfloat: + nassertr(false, _i); } } @@ -1056,6 +1102,9 @@ get_data3i(const unsigned char *pointer) { _i[2] = (int)pi[2]; } return _i; + + case NT_stdfloat: + nassertr(false, _i); } } @@ -1165,6 +1214,9 @@ get_data4i(const unsigned char *pointer) { _i[3] = (int)pi[3]; } return _i; + + case NT_stdfloat: + nassertr(false, _i); } } @@ -1205,6 +1257,9 @@ set_data1f(unsigned char *pointer, float data) { case NT_float64: *(PN_float64 *)pointer = data; break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1277,6 +1332,9 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) { pi[1] = data[1]; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1355,6 +1413,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { pi[2] = data[2]; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1443,6 +1504,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { pi[3] = data[3]; } break; + + case NT_stdfloat: + nassertv(false); } break; } @@ -1482,6 +1546,9 @@ set_data1d(unsigned char *pointer, double data) { case NT_float64: *(PN_float64 *)pointer = data; break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1554,6 +1621,9 @@ set_data2d(unsigned char *pointer, const LVecBase2d &data) { pi[1] = data[1]; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1632,6 +1702,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { pi[2] = data[2]; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1720,6 +1793,9 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { pi[3] = data[3]; } break; + + case NT_stdfloat: + nassertv(false); } break; } @@ -1761,6 +1837,9 @@ set_data1i(unsigned char *pointer, int a) { case NT_float64: *(PN_float64 *)pointer = (double)a; break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1833,6 +1912,9 @@ set_data2i(unsigned char *pointer, int a, int b) { pi[1] = b; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1910,6 +1992,9 @@ set_data3i(unsigned char *pointer, int a, int b, int c) { pi[2] = c; } break; + + case NT_stdfloat: + nassertv(false); } break; @@ -1995,6 +2080,9 @@ set_data4i(unsigned char *pointer, int a, int b, int c, int d) { pi[3] = d; } break; + + case NT_stdfloat: + nassertv(false); } break; } @@ -2126,6 +2214,9 @@ get_data4f(const unsigned char *pointer) { _v4.set(pi[0], pi[1], pi[2], pi[3]); } return _v4; + + case NT_stdfloat: + nassertr(false, _v4); } } @@ -2258,6 +2349,9 @@ get_data4d(const unsigned char *pointer) { _v4d.set(pi[0], pi[1], pi[2], pi[3]); } return _v4d; + + case NT_stdfloat: + nassertr(false, _v4d); } } @@ -2385,6 +2479,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { pi[3] = data[3]; } break; + + case NT_stdfloat: + nassertv(false); } break; } @@ -2511,6 +2608,9 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { pi[3] = data[3]; } break; + + case NT_stdfloat: + nassertv(false); } break; } @@ -2595,6 +2695,9 @@ get_data4f(const unsigned char *pointer) { _v4.set(pi[0], pi[1], pi[2], pi[3]); } return _v4; + + case NT_stdfloat: + nassertr(false, _v4); } } @@ -2680,6 +2783,9 @@ get_data4d(const unsigned char *pointer) { _v4d.set(pi[0], pi[1], pi[2], pi[3]); } return _v4d; + + case NT_stdfloat: + nassertr(false, _v4d); } } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 2c61b8db31..08789b92ce 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -615,7 +615,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, from.set_column(source_i, source_column); while (!from.is_at_end()) { - to.set_data4f(from.get_data4f()); + to.set_data4(from.get_data4()); } } } @@ -643,7 +643,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, while (!from.is_at_end()) { const TransformBlend &blend = blend_table->get_blend(from.get_data1i()); - LVecBase4f weights = LVecBase4f::zero(); + LVecBase4 weights = LVecBase4::zero(); int indices[4] = {0, 0, 0, 0}; nassertv(blend.get_num_transforms() <= 4); @@ -653,7 +653,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, already_added); } if (weight.has_column()) { - weight.set_data4f(weights); + weight.set_data4(weights); } index.set_data4i(indices); } @@ -665,7 +665,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, while (!from.is_at_end()) { const TransformBlend &blend = blend_table->get_blend(from.get_data1i()); - LVecBase4f weights = LVecBase4f::zero(); + LVecBase4 weights = LVecBase4::zero(); for (int i = 0; i < blend.get_num_transforms(); i++) { int index = add_transform(transform_table, blend.get_transform(i), @@ -674,7 +674,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, weights[index] = blend.get_weight(i); } if (weight.has_column()) { - weight.set_data4f(weights); + weight.set_data4(weights); } } } @@ -832,7 +832,7 @@ convert_to(const GeomVertexFormat *new_format) const { // new one will not be added. //////////////////////////////////////////////////////////////////// CPT(GeomVertexData) GeomVertexData:: -scale_color(const LVecBase4f &color_scale) const { +scale_color(const LVecBase4 &color_scale) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); if (old_column == (GeomVertexColumn *)NULL) { @@ -842,8 +842,8 @@ scale_color(const LVecBase4f &color_scale) const { PT(GeomVertexData) new_data = new GeomVertexData(*this); GeomVertexRewriter data(new_data, InternalName::get_color()); while (!data.is_at_end()) { - Colorf color = data.get_data4f(); - data.set_data4f(color[0] * color_scale[0], + LColor color = data.get_data4(); + data.set_data4(color[0] * color_scale[0], color[1] * color_scale[1], color[2] * color_scale[2], color[3] * color_scale[3]); @@ -863,7 +863,7 @@ scale_color(const LVecBase4f &color_scale) const { // array will not be repacked. //////////////////////////////////////////////////////////////////// CPT(GeomVertexData) GeomVertexData:: -scale_color(const LVecBase4f &color_scale, int num_components, +scale_color(const LVecBase4 &color_scale, int num_components, GeomVertexData::NumericType numeric_type, GeomVertexData::Contents contents) const { int old_color_array = get_format()->get_array_with(InternalName::get_color()); @@ -889,8 +889,8 @@ scale_color(const LVecBase4f &color_scale, int num_components, GeomVertexReader from(this, InternalName::get_color()); for (int i = 0; i < num_rows; i++) { - Colorf color = from.get_data4f(); - to.set_data4f(color[0] * color_scale[0], + LColor color = from.get_data4(); + to.set_data4(color[0] * color_scale[0], color[1] * color_scale[1], color[2] * color_scale[2], color[3] * color_scale[3]); @@ -909,7 +909,7 @@ scale_color(const LVecBase4f &color_scale, int num_components, // new one will not be added. //////////////////////////////////////////////////////////////////// CPT(GeomVertexData) GeomVertexData:: -set_color(const Colorf &color) const { +set_color(const LColor &color) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); if (old_column == (GeomVertexColumn *)NULL) { @@ -919,7 +919,7 @@ set_color(const Colorf &color) const { PT(GeomVertexData) new_data = new GeomVertexData(*this); GeomVertexWriter to(new_data, InternalName::get_color()); while (!to.is_at_end()) { - to.set_data4f(color); + to.set_data4(color); } return new_data; @@ -936,7 +936,7 @@ set_color(const Colorf &color) const { // array will not be repacked. //////////////////////////////////////////////////////////////////// CPT(GeomVertexData) GeomVertexData:: -set_color(const Colorf &color, int num_components, +set_color(const LColor &color, int num_components, GeomVertexData::NumericType numeric_type, GeomVertexData::Contents contents) const { if (gobj_cat.is_debug()) { @@ -952,7 +952,7 @@ set_color(const Colorf &color, int num_components, // Now go through and set the new color value. GeomVertexWriter to(new_data, InternalName::get_color()); while (!to.is_at_end()) { - to.set_data4f(color); + to.set_data4(color); } return new_data; @@ -980,7 +980,7 @@ reverse_normals() const { PT(GeomVertexData) new_data = new GeomVertexData(*this); GeomVertexRewriter to(new_data, InternalName::get_normal()); while (!to.is_at_end()) { - to.set_data3f(-to.get_data3f()); + to.set_data3(-to.get_data3()); } return new_data; @@ -1274,7 +1274,7 @@ describe_vertex(ostream &out, int row) const { reader.set_column(ai, column); int num_values = min(column->get_num_values(), 4); - const LVecBase4f &d = reader.get_data4f(); + const LVecBase4 &d = reader.get_data4(); out << " " << *column->get_name(); for (int v = 0; v < num_values; v++) { @@ -1475,7 +1475,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { const SparseArray &rows = slider_table->get_slider_rows(sn); nassertv(!rows.is_inverse()); - float slider_value = slider->get_slider(); + PN_stdfloat slider_value = slider->get_slider(); if (slider_value != 0.0f) { CPT(InternalName) base_name = orig_format->get_morph_base(mi); CPT(InternalName) delta_name = orig_format->get_morph_delta(mi); @@ -1493,10 +1493,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); delta.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LPoint4f vertex = data.get_data4f(); - LPoint3f d = delta.get_data3f(); + LPoint4 vertex = data.get_data4(); + LPoint3 d = delta.get_data3(); d *= slider_value * vertex[3]; - data.set_data4f(vertex[0] + d[0], + data.set_data4(vertex[0] + d[0], vertex[1] + d[1], vertex[2] + d[2], vertex[3]); @@ -1510,9 +1510,9 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); delta.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - const LPoint4f &vertex = data.get_data4f(); - LPoint4f d = delta.get_data4f(); - data.set_data4f(vertex + d * slider_value); + const LPoint4 &vertex = data.get_data4(); + LPoint4 d = delta.get_data4(); + data.set_data4(vertex + d * slider_value); } } } @@ -1525,9 +1525,9 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); delta.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - const LPoint3f &vertex = data.get_data3f(); - LPoint3f d = delta.get_data3f(); - data.set_data3f(vertex + d * slider_value); + const LPoint3 &vertex = data.get_data3(); + LPoint3 d = delta.get_data3(); + data.set_data3(vertex + d * slider_value); } } } @@ -1607,10 +1607,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { int end = rows.get_subrange_end(i); data.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LPoint4f vertex = data.get_data4f(); + LPoint4 vertex = data.get_data4(); int bi = blendt[j]; tb_table->get_blend(bi).transform_point(vertex, current_thread); - data.set_data4f(vertex); + data.set_data4(vertex); } } @@ -1622,10 +1622,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { int end = rows.get_subrange_end(i); data.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LPoint3f vertex = data.get_data3f(); + LPoint3 vertex = data.get_data3(); int bi = blendt[j]; tb_table->get_blend(bi).transform_point(vertex, current_thread); - data.set_data3f(vertex); + data.set_data3(vertex); } } } @@ -1664,10 +1664,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { int end = rows.get_subrange_end(i); data.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LVector3f vertex = data.get_data3f(); + LVector3 vertex = data.get_data3(); int bi = blendt[j]; tb_table->get_blend(bi).transform_vector(vertex, current_thread); - data.set_data3f(vertex); + data.set_data3(vertex); } } } @@ -1691,10 +1691,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); blendi.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LPoint4f vertex = data.get_data4f(); + LPoint4 vertex = data.get_data4(); int bi = blendi.get_data1i(); tb_table->get_blend(bi).transform_point(vertex, current_thread); - data.set_data4f(vertex); + data.set_data4(vertex); } } } else { @@ -1704,10 +1704,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); blendi.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LPoint3f vertex = data.get_data3f(); + LPoint3 vertex = data.get_data3(); int bi = blendi.get_data1i(); tb_table->get_blend(bi).transform_point(vertex, current_thread); - data.set_data3f(vertex); + data.set_data3(vertex); } } } @@ -1720,10 +1720,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { data.set_row_unsafe(begin); blendi.set_row_unsafe(begin); for (int j = begin; j < end; ++j) { - LVector3f vertex = data.get_data3f(); + LVector3 vertex = data.get_data3(); int bi = blendi.get_data1i(); tb_table->get_blend(bi).transform_vector(vertex, current_thread); - data.set_data3f(vertex); + data.set_data3(vertex); } } } diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 7772330a70..284b0b6e9f 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -138,14 +138,14 @@ PUBLISHED: int source_row, Thread *current_thread); CPT(GeomVertexData) convert_to(const GeomVertexFormat *new_format) const; CPT(GeomVertexData) - scale_color(const LVecBase4f &color_scale) const; + scale_color(const LVecBase4 &color_scale) const; CPT(GeomVertexData) - scale_color(const LVecBase4f &color_scale, int num_components, + scale_color(const LVecBase4 &color_scale, int num_components, NumericType numeric_type, Contents contents) const; CPT(GeomVertexData) - set_color(const Colorf &color) const; + set_color(const LColor &color) const; CPT(GeomVertexData) - set_color(const Colorf &color, int num_components, + set_color(const LColor &color, int num_components, NumericType numeric_type, Contents contents) const; CPT(GeomVertexData) reverse_normals() const; diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index f391141dbd..a665234b32 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -950,95 +950,95 @@ void GeomVertexFormat::Registry:: make_standard_formats() { _v3 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point)); + NT_stdfloat, C_point)); _v3n3 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector)); + NT_stdfloat, C_vector)); _v3t2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); _v3n3t2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector, + NT_stdfloat, C_vector, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); // Define the DirectX-style packed color formats _v3cp = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_color(), 1, NT_packed_dabc, C_color)); _v3n3cp = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector, + NT_stdfloat, C_vector, InternalName::get_color(), 1, NT_packed_dabc, C_color)); _v3cpt2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_color(), 1, NT_packed_dabc, C_color, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); _v3n3cpt2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector, + NT_stdfloat, C_vector, InternalName::get_color(), 1, NT_packed_dabc, C_color, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); // Define the OpenGL-style per-byte color formats. This is not the // same as a packed format, above, because the resulting byte order // is endian-independent. _v3c4 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_color(), 4, NT_uint8, C_color)); _v3n3c4 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector, + NT_stdfloat, C_vector, InternalName::get_color(), 4, NT_uint8, C_color)); _v3c4t2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_color(), 4, NT_uint8, C_color, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); _v3n3c4t2 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - NT_float32, C_point, + NT_stdfloat, C_point, InternalName::get_normal(), 3, - NT_float32, C_vector, + NT_stdfloat, C_vector, InternalName::get_color(), 4, NT_uint8, C_color, InternalName::get_texcoord(), 2, - NT_float32, C_texcoord)); + NT_stdfloat, C_texcoord)); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index a2c36fc81a..b8abb6eabb 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -551,6 +551,70 @@ get_data4d() { return _packer->get_data4d(inc_pointer()); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexReader::get_data1 +// Access: Published +// Description: Returns the data associated with the read row, +// expressed as a 1-component value, and advances the +// read row. +//////////////////////////////////////////////////////////////////// +INLINE PN_stdfloat GeomVertexReader:: +get_data1() { +#ifndef STDFLOAT_DOUBLE + return get_data1f(); +#else + return get_data1d(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexReader::get_data2 +// Access: Published +// Description: Returns the data associated with the read row, +// expressed as a 2-component value, and advances the +// read row. +//////////////////////////////////////////////////////////////////// +INLINE const LVecBase2 &GeomVertexReader:: +get_data2() { +#ifndef STDFLOAT_DOUBLE + return get_data2f(); +#else + return get_data2d(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexReader::get_data3 +// Access: Published +// Description: Returns the data associated with the read row, +// expressed as a 3-component value, and advances the +// read row. +//////////////////////////////////////////////////////////////////// +INLINE const LVecBase3 &GeomVertexReader:: +get_data3() { +#ifndef STDFLOAT_DOUBLE + return get_data3f(); +#else + return get_data3d(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexReader::get_data4 +// Access: Published +// Description: Returns the data associated with the read row, +// expressed as a 4-component value, and advances the +// read row. +//////////////////////////////////////////////////////////////////// +INLINE const LVecBase4 &GeomVertexReader:: +get_data4() { +#ifndef STDFLOAT_DOUBLE + return get_data4f(); +#else + return get_data4d(); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexReader::get_data1i // Access: Published diff --git a/panda/src/gobj/geomVertexReader.h b/panda/src/gobj/geomVertexReader.h index 43e93e959c..71f34898df 100644 --- a/panda/src/gobj/geomVertexReader.h +++ b/panda/src/gobj/geomVertexReader.h @@ -114,6 +114,11 @@ PUBLISHED: INLINE const LVecBase3d &get_data3d(); INLINE const LVecBase4d &get_data4d(); + INLINE PN_stdfloat get_data1(); + INLINE const LVecBase2 &get_data2(); + INLINE const LVecBase3 &get_data3(); + INLINE const LVecBase4 &get_data4(); + INLINE int get_data1i(); INLINE const int *get_data2i(); INLINE const int *get_data3i(); diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index 13584da240..bac37ae9d2 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -613,6 +613,132 @@ set_data4d(const LVecBase4d &data) { _packer->set_data4d(inc_pointer(), data); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data1 +// Access: Published +// Description: Sets the write row to a particular 1-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data1(PN_stdfloat data) { +#ifndef STDFLOAT_DOUBLE + set_data1f(data); +#else + set_data1d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data2 +// Access: Published +// Description: Sets the write row to a particular 2-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data2(PN_stdfloat x, PN_stdfloat y) { +#ifndef STDFLOAT_DOUBLE + set_data2f(x, y); +#else + set_data2d(x, y); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data2 +// Access: Published +// Description: Sets the write row to a particular 2-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data2(const LVecBase2 &data) { +#ifndef STDFLOAT_DOUBLE + set_data2f(data); +#else + set_data2d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data3 +// Access: Published +// Description: Sets the write row to a particular 3-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { +#ifndef STDFLOAT_DOUBLE + set_data3f(x, y, z); +#else + set_data3d(x, y, z); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data3 +// Access: Published +// Description: Sets the write row to a particular 3-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data3(const LVecBase3 &data) { +#ifndef STDFLOAT_DOUBLE + set_data3f(data); +#else + set_data3d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data4 +// Access: Published +// Description: Sets the write row to a particular 4-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { +#ifndef STDFLOAT_DOUBLE + set_data4f(x, y, z, w); +#else + set_data4d(x, y, z, w); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::set_data4 +// Access: Published +// Description: Sets the write row to a particular 4-component +// value, and advances the write row. +// +// It is an error for the write row to advance past +// the end of data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +set_data4(const LVecBase4 &data) { +#ifndef STDFLOAT_DOUBLE + set_data4f(data); +#else + set_data4d(data); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexWriter::set_data1i // Access: Published @@ -919,6 +1045,132 @@ add_data4d(const LVecBase4d &data) { _packer->set_data4d(inc_add_pointer(), data); } +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data1 +// Access: Published +// Description: Sets the write row to a particular 1-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data1(PN_stdfloat data) { +#ifndef STDFLOAT_DOUBLE + add_data1f(data); +#else + add_data1d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data2 +// Access: Published +// Description: Sets the write row to a particular 2-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data2(PN_stdfloat x, PN_stdfloat y) { +#ifndef STDFLOAT_DOUBLE + add_data2f(x, y); +#else + add_data2d(x, y); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data2 +// Access: Published +// Description: Sets the write row to a particular 2-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data2(const LVecBase2 &data) { +#ifndef STDFLOAT_DOUBLE + add_data2f(data); +#else + add_data2d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data3 +// Access: Published +// Description: Sets the write row to a particular 3-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { +#ifndef STDFLOAT_DOUBLE + add_data3f(x, y, z); +#else + add_data3d(x, y, z); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data3 +// Access: Published +// Description: Sets the write row to a particular 3-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data3(const LVecBase3 &data) { +#ifndef STDFLOAT_DOUBLE + add_data3f(data); +#else + add_data3d(data); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data4 +// Access: Published +// Description: Sets the write row to a particular 4-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { +#ifndef STDFLOAT_DOUBLE + add_data4f(x, y, z, w); +#else + add_data4d(x, y, z, w); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: GeomVertexWriter::add_data4 +// Access: Published +// Description: Sets the write row to a particular 4-component +// value, and advances the write row. +// +// If the write row advances past the end of data, +// implicitly adds a new row to the data. +//////////////////////////////////////////////////////////////////// +INLINE void GeomVertexWriter:: +add_data4(const LVecBase4 &data) { +#ifndef STDFLOAT_DOUBLE + add_data4f(data); +#else + add_data4d(data); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: GeomVertexWriter::add_data1i // Access: Published diff --git a/panda/src/gobj/geomVertexWriter.h b/panda/src/gobj/geomVertexWriter.h index 13cd5d1780..374f89852d 100644 --- a/panda/src/gobj/geomVertexWriter.h +++ b/panda/src/gobj/geomVertexWriter.h @@ -130,6 +130,14 @@ PUBLISHED: INLINE void set_data4d(double x, double y, double z, double w); INLINE void set_data4d(const LVecBase4d &data); + INLINE void set_data1(PN_stdfloat data); + INLINE void set_data2(PN_stdfloat x, PN_stdfloat y); + INLINE void set_data2(const LVecBase2 &data); + INLINE void set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE void set_data3(const LVecBase3 &data); + INLINE void set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w); + INLINE void set_data4(const LVecBase4 &data); + INLINE void set_data1i(int data); INLINE void set_data2i(int a, int b); INLINE void set_data2i(const int data[2]); @@ -154,6 +162,14 @@ PUBLISHED: INLINE void add_data4d(double x, double y, double z, double w); INLINE void add_data4d(const LVecBase4d &data); + INLINE void add_data1(PN_stdfloat data); + INLINE void add_data2(PN_stdfloat x, PN_stdfloat y); + INLINE void add_data2(const LVecBase2 &data); + INLINE void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE void add_data3(const LVecBase3 &data); + INLINE void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w); + INLINE void add_data4(const LVecBase4 &data); + INLINE void add_data1i(int data); INLINE void add_data2i(int a, int b); INLINE void add_data2i(const int data[2]); diff --git a/panda/src/gobj/lens.I b/panda/src/gobj/lens.I index 0d437607e8..06c5413736 100644 --- a/panda/src/gobj/lens.I +++ b/panda/src/gobj/lens.I @@ -29,8 +29,8 @@ // otherwise. //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -extrude(const LPoint2f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { - return extrude_impl(LPoint3f(point2d[0], point2d[1], 0.0f), +extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { + return extrude_impl(LPoint3(point2d[0], point2d[1], 0.0f), near_point, far_point); } @@ -52,7 +52,7 @@ extrude(const LPoint2f &point2d, LPoint3f &near_point, LPoint3f &far_point) cons // otherwise. //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -extrude(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { +extrude(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { return extrude_impl(point2d, near_point, far_point); } @@ -75,8 +75,8 @@ extrude(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) cons // otherwise. //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -extrude_vec(const LPoint2f &point2d, LVector3f &vec) const { - return extrude_vec_impl(LPoint3f(point2d[0], point2d[1], 0.0f), vec); +extrude_vec(const LPoint2 &point2d, LVector3 &vec) const { + return extrude_vec_impl(LPoint3(point2d[0], point2d[1], 0.0f), vec); } //////////////////////////////////////////////////////////////////// @@ -100,7 +100,7 @@ extrude_vec(const LPoint2f &point2d, LVector3f &vec) const { // otherwise. //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -extrude_vec(const LPoint3f &point2d, LVector3f &vec) const { +extrude_vec(const LPoint3 &point2d, LVector3 &vec) const { return extrude_vec_impl(point2d, vec); } @@ -119,8 +119,8 @@ extrude_vec(const LPoint3f &point2d, LVector3f &vec) const { // or may not be meaningful). //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -project(const LPoint3f &point3d, LPoint2f &point2d) const { - LPoint3f result; +project(const LPoint3 &point3d, LPoint2 &point2d) const { + LPoint3 result; bool okflag = project_impl(point3d, result); point2d.set(result[0], result[1]); return okflag; @@ -145,7 +145,7 @@ project(const LPoint3f &point3d, LPoint2f &point2d) const { // or may not be meaningful). //////////////////////////////////////////////////////////////////// INLINE bool Lens:: -project(const LPoint3f &point3d, LPoint3f &point2d) const { +project(const LPoint3 &point3d, LPoint3 &point2d) const { return project_impl(point3d, point2d); } @@ -212,8 +212,8 @@ get_coordinate_system() const { // and aspect ratio of the lens directly. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_film_size(float width, float height) { - set_film_size(LVecBase2f(width, height)); +set_film_size(PN_stdfloat width, PN_stdfloat height) { + set_film_size(LVecBase2(width, height)); } //////////////////////////////////////////////////////////////////// @@ -226,8 +226,8 @@ set_film_size(float width, float height) { // This can be used to establish an off-axis lens. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_film_offset(float x, float y) { - set_film_offset(LVecBase2f(x, y)); +set_film_offset(PN_stdfloat x, PN_stdfloat y) { + set_film_offset(LVecBase2(x, y)); } //////////////////////////////////////////////////////////////////// @@ -240,7 +240,7 @@ set_film_offset(float x, float y) { // This can be used to establish an off-axis lens. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_film_offset(const LVecBase2f &film_offset) { +set_film_offset(const LVecBase2 &film_offset) { _film_offset = film_offset; adjust_comp_flags(CF_mat, 0); throw_change_event(); @@ -252,7 +252,7 @@ set_film_offset(const LVecBase2f &film_offset) { // Description: Returns the horizontal and vertical offset amounts of // this Lens. See set_film_offset(). //////////////////////////////////////////////////////////////////// -INLINE const LVector2f &Lens:: +INLINE const LVector2 &Lens:: get_film_offset() const { return _film_offset; } @@ -270,8 +270,8 @@ get_film_offset() const { // the field of view has no meaning. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_fov(float hfov, float vfov) { - set_fov(LVecBase2f(hfov, vfov)); +set_fov(PN_stdfloat hfov, PN_stdfloat vfov) { + set_fov(LVecBase2(hfov, vfov)); } //////////////////////////////////////////////////////////////////// @@ -280,7 +280,7 @@ set_fov(float hfov, float vfov) { // Description: Returns the horizontal component of fov only. See // get_fov(). //////////////////////////////////////////////////////////////////// -INLINE float Lens:: +INLINE PN_stdfloat Lens:: get_hfov() const { return get_fov()[0]; } @@ -291,7 +291,7 @@ get_hfov() const { // Description: Returns the vertical component of fov only. See // get_fov(). //////////////////////////////////////////////////////////////////// -INLINE float Lens:: +INLINE PN_stdfloat Lens:: get_vfov() const { return get_fov()[1]; } @@ -304,7 +304,7 @@ get_vfov() const { // this may not be rendered. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_near(float near_distance) { +set_near(PN_stdfloat near_distance) { _near_distance = near_distance; adjust_comp_flags(CF_projection_mat | CF_projection_mat_inv, 0); throw_change_event(); @@ -316,7 +316,7 @@ set_near(float near_distance) { // Description: Returns the position of the near plane (or cylinder, // sphere, whatever). //////////////////////////////////////////////////////////////////// -INLINE float Lens:: +INLINE PN_stdfloat Lens:: get_near() const { return _near_distance; } @@ -329,7 +329,7 @@ get_near() const { // this may not be rendered. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_far(float far_distance) { +set_far(PN_stdfloat far_distance) { _far_distance = far_distance; adjust_comp_flags(CF_projection_mat | CF_projection_mat_inv, 0); throw_change_event(); @@ -341,7 +341,7 @@ set_far(float far_distance) { // Description: Returns the position of the far plane (or cylinder, // sphere, whatever). //////////////////////////////////////////////////////////////////// -INLINE float Lens:: +INLINE PN_stdfloat Lens:: get_far() const { return _far_distance; } @@ -352,7 +352,7 @@ get_far() const { // Description: Simultaneously changes the near and far planes. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_near_far(float near_distance, float far_distance) { +set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance) { _near_distance = near_distance; _far_distance = far_distance; adjust_comp_flags(CF_projection_mat | CF_projection_mat_inv, 0); @@ -370,8 +370,8 @@ set_near_far(float near_distance, float far_distance) { // complete transformation matrix. //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_view_hpr(float h, float p, float r) { - set_view_hpr(LVecBase3f(h, p, r)); +set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_view_hpr(LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// // Function: Lens::set_view_vector @@ -383,8 +383,8 @@ set_view_hpr(float h, float p, float r) { // See also set_view_hpr(). //////////////////////////////////////////////////////////////////// INLINE void Lens:: -set_view_vector(float x, float y, float z, float i, float j, float k) { - set_view_vector(LVector3f(x, y, z), LVector3f(i, j, k)); +set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k) { + set_view_vector(LVector3(x, y, z), LVector3(i, j, k)); } //////////////////////////////////////////////////////////////////// @@ -393,7 +393,7 @@ set_view_vector(float x, float y, float z, float i, float j, float k) { // Description: Returns the keystone correction specified for the // lens. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase2f &Lens:: +INLINE const LVecBase2 &Lens:: get_keystone() const { return _keystone; } diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index a1388982e9..69a79148f3 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -140,7 +140,7 @@ clear() { // automatically maintain the aspect ratio. //////////////////////////////////////////////////////////////////// void Lens:: -set_film_size(float width) { +set_film_size(PN_stdfloat width) { nassertv(!cnan(width)); _film_size.set(width, width / get_aspect_ratio()); @@ -185,7 +185,7 @@ set_film_size(float width) { // and aspect ratio of the lens directly. //////////////////////////////////////////////////////////////////// void Lens:: -set_film_size(const LVecBase2f &film_size) { +set_film_size(const LVecBase2 &film_size) { nassertv(!film_size.is_nan()); _film_size = film_size; @@ -220,7 +220,7 @@ set_film_size(const LVecBase2f &film_size) { // Description: Returns the horizontal and vertical film size of // the virtual film. See set_film_size(). //////////////////////////////////////////////////////////////////// -const LVecBase2f &Lens:: +const LVecBase2 &Lens:: get_film_size() const { if ((_comp_flags & CF_film_size) == 0) { // We pretend this is a const method, even though it may call a @@ -242,7 +242,7 @@ get_film_size() const { // the focal length has no meaning. //////////////////////////////////////////////////////////////////// void Lens:: -set_focal_length(float focal_length) { +set_focal_length(PN_stdfloat focal_length) { nassertv(!cnan(focal_length)); _focal_length = focal_length; @@ -275,7 +275,7 @@ set_focal_length(float focal_length) { // the lens' fov and film_size. For certain kinds of // lenses, the focal length has no meaning. //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_focal_length() const { if ((_comp_flags & CF_focal_length) == 0) { ((Lens *)this)->compute_focal_length(); @@ -299,7 +299,7 @@ get_focal_length() const { // what you expect to happen. //////////////////////////////////////////////////////////////////// void Lens:: -set_min_fov(float min_fov) { +set_min_fov(PN_stdfloat min_fov) { nassertv(!cnan(min_fov)); _min_fov = min_fov; @@ -336,7 +336,7 @@ set_min_fov(float min_fov) { // view is adjusted to maintain the same aspect ratio. //////////////////////////////////////////////////////////////////// void Lens:: -set_fov(float hfov) { +set_fov(PN_stdfloat hfov) { nassertv(!cnan(hfov)); _fov[0] = hfov; @@ -378,7 +378,7 @@ set_fov(float hfov) { // the field of view has no meaning. //////////////////////////////////////////////////////////////////// void Lens:: -set_fov(const LVecBase2f &fov) { +set_fov(const LVecBase2 &fov) { nassertv(!fov.is_nan()); _fov = fov; @@ -413,7 +413,7 @@ set_fov(const LVecBase2f &fov) { // Description: Returns the horizontal and vertical film size of // the virtual film. See set_fov(). //////////////////////////////////////////////////////////////////// -const LVecBase2f &Lens:: +const LVecBase2 &Lens:: get_fov() const { if ((_comp_flags & CF_fov) == 0) { ((Lens *)this)->compute_fov(); @@ -427,7 +427,7 @@ get_fov() const { // Description: Returns the field of view of the narrowest dimension // of the window. See set_min_fov(). //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_min_fov() const { if ((_comp_flags & CF_fov) == 0) { ((Lens *)this)->compute_fov(); @@ -445,7 +445,7 @@ get_min_fov() const { // size setting. //////////////////////////////////////////////////////////////////// void Lens:: -set_aspect_ratio(float aspect_ratio) { +set_aspect_ratio(PN_stdfloat aspect_ratio) { nassertv(!cnan(aspect_ratio)); _aspect_ratio = aspect_ratio; adjust_user_flags(UF_film_height | UF_vfov, @@ -462,7 +462,7 @@ set_aspect_ratio(float aspect_ratio) { // determined based on the indicated film size; see // set_film_size(). //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_aspect_ratio() const { if ((_comp_flags & CF_aspect_ratio) == 0) { ((Lens *)this)->compute_aspect_ratio(); @@ -477,7 +477,7 @@ get_aspect_ratio() const { // assigned to each newly-created lens. This is read // from the Configrc file. //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_default_near() { return default_near; } @@ -489,7 +489,7 @@ get_default_near() { // assigned to each newly-created lens. This is read // from the Configrc file. //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_default_far() { return default_far; } @@ -505,7 +505,7 @@ get_default_far() { // complete transformation matrix. //////////////////////////////////////////////////////////////////// void Lens:: -set_view_hpr(const LVecBase3f &view_hpr) { +set_view_hpr(const LVecBase3 &view_hpr) { nassertv(!view_hpr.is_nan()); _view_hpr = view_hpr; adjust_user_flags(UF_view_vector | UF_view_mat, @@ -520,7 +520,7 @@ set_view_hpr(const LVecBase3f &view_hpr) { // Access: Published // Description: Returns the direction in which the lens is facing. //////////////////////////////////////////////////////////////////// -const LVecBase3f &Lens:: +const LVecBase3 &Lens:: get_view_hpr() const { if ((_comp_flags & CF_view_hpr) == 0) { ((Lens *)this)->compute_view_hpr(); @@ -538,7 +538,7 @@ get_view_hpr() const { // See also set_view_hpr(). //////////////////////////////////////////////////////////////////// void Lens:: -set_view_vector(const LVector3f &view_vector, const LVector3f &up_vector) { +set_view_vector(const LVector3 &view_vector, const LVector3 &up_vector) { nassertv(!view_vector.is_nan()); _view_vector = view_vector; _up_vector = up_vector; @@ -554,7 +554,7 @@ set_view_vector(const LVector3f &view_vector, const LVector3f &up_vector) { // Access: Published // Description: Returns the axis along which the lens is facing. //////////////////////////////////////////////////////////////////// -const LVector3f &Lens:: +const LVector3 &Lens:: get_view_vector() const { if ((_comp_flags & CF_view_vector) == 0) { ((Lens *)this)->compute_view_vector(); @@ -568,7 +568,7 @@ get_view_vector() const { // Description: Returns the axis perpendicular to the camera's view // vector that indicates the "up" direction. //////////////////////////////////////////////////////////////////// -const LVector3f &Lens:: +const LVector3 &Lens:: get_up_vector() const { if ((_comp_flags & CF_view_vector) == 0) { ((Lens *)this)->compute_view_vector(); @@ -582,7 +582,7 @@ get_up_vector() const { // Description: Returns the center point of the lens: the point from // which the lens is viewing. //////////////////////////////////////////////////////////////////// -LPoint3f Lens:: +LPoint3 Lens:: get_nodal_point() const { return get_view_mat().get_row3(3); } @@ -603,7 +603,7 @@ get_nodal_point() const { // Also see set_convergence_distance(), which relates. //////////////////////////////////////////////////////////////////// void Lens:: -set_interocular_distance(float interocular_distance) { +set_interocular_distance(PN_stdfloat interocular_distance) { nassertv(!cnan(interocular_distance)); _interocular_distance = interocular_distance; if (_interocular_distance == 0.0f) { @@ -621,7 +621,7 @@ set_interocular_distance(float interocular_distance) { // Access: Published // Description: See set_interocular_distance(). //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_interocular_distance() const { return _interocular_distance; } @@ -649,7 +649,7 @@ get_interocular_distance() const { // Also see set_interocular_distance(), which relates. //////////////////////////////////////////////////////////////////// void Lens:: -set_convergence_distance(float convergence_distance) { +set_convergence_distance(PN_stdfloat convergence_distance) { nassertv(!cnan(convergence_distance)); _convergence_distance = convergence_distance; if (_convergence_distance == 0.0f) { @@ -667,7 +667,7 @@ set_convergence_distance(float convergence_distance) { // Access: Published // Description: See set_convergence_distance(). //////////////////////////////////////////////////////////////////// -float Lens:: +PN_stdfloat Lens:: get_convergence_distance() const { return _convergence_distance; } @@ -688,7 +688,7 @@ get_convergence_distance() const { // transformed by this matrix. //////////////////////////////////////////////////////////////////// void Lens:: -set_view_mat(const LMatrix4f &view_mat) { +set_view_mat(const LMatrix4 &view_mat) { nassertv(!view_mat.is_nan()); _lens_mat = view_mat; adjust_user_flags(UF_view_vector | UF_view_hpr, @@ -705,7 +705,7 @@ set_view_mat(const LMatrix4f &view_mat) { // Access: Published // Description: Returns the direction in which the lens is facing. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_view_mat() const { if ((_comp_flags & CF_lens_mat) == 0) { ((Lens *)this)->compute_lens_mat(); @@ -720,7 +720,7 @@ get_view_mat() const { //////////////////////////////////////////////////////////////////// void Lens:: clear_view_mat() { - _lens_mat = LMatrix4f::ident_mat(); + _lens_mat = LMatrix4::ident_mat(); adjust_user_flags(0, UF_view_vector | UF_view_hpr | UF_view_mat); adjust_comp_flags(CF_projection_mat | CF_projection_mat_inv | CF_projection_mat_left_inv | CF_projection_mat_right_inv | @@ -747,7 +747,7 @@ clear_view_mat() { // generate a keystone correction in that axis. //////////////////////////////////////////////////////////////////// void Lens:: -set_keystone(const LVecBase2f &keystone) { +set_keystone(const LVecBase2 &keystone) { nassertv(!keystone.is_nan()); _keystone = keystone; adjust_user_flags(0, UF_keystone); @@ -832,26 +832,26 @@ clear_keystone() { // possibly screwy. //////////////////////////////////////////////////////////////////// void Lens:: -set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, - const LVecBase3f &ll, const LVecBase3f &lr, +set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, + const LVecBase3 &ll, const LVecBase3 &lr, int flags) { nassertv(!ul.is_nan() && !ur.is_nan() && !ll.is_nan() && !lr.is_nan()); // We'll need to know the pre-existing eyepoint translation from the // center, so we can preserve it in the new frustum. This is // usually (0, 0, 0), but it could be an arbitrary vector. - const LMatrix4f &lens_mat_inv = get_lens_mat_inv(); - LVector3f eye_offset; + const LMatrix4 &lens_mat_inv = get_lens_mat_inv(); + LVector3 eye_offset; lens_mat_inv.get_row3(eye_offset, 3); // Now choose the viewing axis. If FC_camera_plane is specified, // we'll pass it through the centroid for the best camera plane; // otherwise, it's perpendicular to the plane in which the points // lie. - LVector3f view_vector; + LVector3 view_vector; if ((flags & FC_camera_plane) != 0) { - view_vector = (ul + ur + ll + lr) * 0.25f; + view_vector = (ul + ur + ll + lr) * 0.25; } else { - Planef plane(ll, ul, ur); + LPlane plane(ll, ul, ur); view_vector = plane.get_normal(); nassertv(!view_vector.is_nan() && view_vector.length_squared() != 0.0f); } @@ -860,27 +860,27 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, // view vector is straight up, it is the vector perpendicular to // both the viewing axis and the top line. Otherwise, it is the // standard up axis. - LVector3f up_vector = LVector3f::up(_cs); + LVector3 up_vector = LVector3::up(_cs); if (view_vector == up_vector || ((flags & FC_roll) != 0)) { - LVector3f top = ul - ur; + LVector3 top = ul - ur; up_vector = view_vector.cross(top); nassertv(!up_vector.is_nan() && up_vector.length_squared() != 0.0f); } // Now compute the matrix that applies this rotation. - LMatrix4f rot_mat; + LMatrix4 rot_mat; look_at(rot_mat, view_vector, up_vector, CS_zup_right); // And invert it. - LMatrix4f inv_rot_mat; + LMatrix4 inv_rot_mat; inv_rot_mat.invert_affine_from(rot_mat); // Use that inverse matrix to convert the four corners to a local // coordinate system, looking down the Y axis. - LPoint3f cul = inv_rot_mat.xform_point(ul); - LPoint3f cur = inv_rot_mat.xform_point(ur); - LPoint3f cll = inv_rot_mat.xform_point(ll); - LPoint3f clr = inv_rot_mat.xform_point(lr); + LPoint3 cul = inv_rot_mat.xform_point(ul); + LPoint3 cur = inv_rot_mat.xform_point(ur); + LPoint3 cll = inv_rot_mat.xform_point(ll); + LPoint3 clr = inv_rot_mat.xform_point(lr); // Project all points into the Y == 1 plane, so we can do 2-d // manipulation on them. @@ -890,8 +890,8 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, cll /= cll[1]; clr /= clr[1]; - LMatrix4f shear_mat = LMatrix4f::ident_mat(); - LMatrix4f inv_shear_mat = LMatrix4f::ident_mat(); + LMatrix4 shear_mat = LMatrix4::ident_mat(); + LMatrix4 inv_shear_mat = LMatrix4::ident_mat(); // Now, if we're allowed to shear the frustum, do so. if ((flags & FC_shear) != 0) { @@ -900,21 +900,21 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, } // Now build the complete view matrix. - LMatrix4f inv_view_mat = + LMatrix4 inv_view_mat = inv_rot_mat * inv_shear_mat; // And reapply the eye offset to this matrix. inv_view_mat.set_row(3, eye_offset); - LMatrix4f view_mat; + LMatrix4 view_mat; view_mat.invert_from(inv_view_mat); set_view_mat(view_mat); - LPoint3f ful = inv_view_mat.xform_point(ul); - LPoint3f fur = inv_view_mat.xform_point(ur); - LPoint3f fll = inv_view_mat.xform_point(ll); - LPoint3f flr = inv_view_mat.xform_point(lr); + LPoint3 ful = inv_view_mat.xform_point(ul); + LPoint3 fur = inv_view_mat.xform_point(ur); + LPoint3 fll = inv_view_mat.xform_point(ll); + LPoint3 flr = inv_view_mat.xform_point(lr); // Normalize *these* points into the y == 1 plane. nassertv(ful[1] != 0.0f && fur[1] != 0.0f && fll[1] != 0.0f && flr[1] != 0.0f); @@ -925,12 +925,12 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, // Determine the minimum field of view necesary to cover all four // transformed points. - float min_x = min(min(ful[0], fur[0]), min(fll[0], flr[0])); - float max_x = max(max(ful[0], fur[0]), max(fll[0], flr[0])); - float min_z = min(min(ful[2], fur[2]), min(fll[2], flr[2])); - float max_z = max(max(ful[2], fur[2]), max(fll[2], flr[2])); + PN_stdfloat min_x = min(min(ful[0], fur[0]), min(fll[0], flr[0])); + PN_stdfloat max_x = max(max(ful[0], fur[0]), max(fll[0], flr[0])); + PN_stdfloat min_z = min(min(ful[2], fur[2]), min(fll[2], flr[2])); + PN_stdfloat max_z = max(max(ful[2], fur[2]), max(fll[2], flr[2])); - float x_spread, x_center, z_spread, z_center; + PN_stdfloat x_spread, x_center, z_spread, z_center; if ((flags & FC_off_axis) != 0) { // If we're allowed to make an off-axis projection, then pick the @@ -947,7 +947,7 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, z_spread = max(cabs(max_z), cabs(min_z)); } - float aspect_ratio = get_aspect_ratio(); + PN_stdfloat aspect_ratio = get_aspect_ratio(); nassertv(aspect_ratio != 0.0f); if ((flags & FC_aspect_ratio) == 0) { // If we must preserve the aspect ratio, then the x and z spreads @@ -961,8 +961,8 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, } } - float hfov = rad_2_deg(catan(x_spread)) * 2.0f; - float vfov = rad_2_deg(catan(z_spread)) * 2.0f; + PN_stdfloat hfov = rad_2_deg(catan(x_spread)) * 2.0f; + PN_stdfloat vfov = rad_2_deg(catan(z_spread)) * 2.0f; set_fov(hfov, vfov); @@ -973,7 +973,7 @@ set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, set_aspect_ratio(aspect_ratio); } - const LVecBase2f &film_size = get_film_size(); + const LVecBase2 &film_size = get_film_size(); nassertv(x_spread != 0.0f && z_spread != 0.0f); set_film_offset(film_size[0] * x_center / (x_spread * 2.0f), film_size[1] * z_center / (z_spread * 2.0f)); @@ -1118,9 +1118,9 @@ PT(BoundingVolume) Lens:: make_bounds() const { // The default bounding volume is a hexahedron based on the eight // corners of the frustum. - LPoint3f fll, flr, ful, fur; - LPoint3f nll, nlr, nul, nur; - LPoint2f corner; + LPoint3 fll, flr, ful, fur; + LPoint3 nll, nlr, nul, nur; + LPoint2 corner; // Upper left. corner.set(-1.0f, 1.0f); @@ -1157,7 +1157,7 @@ make_bounds() const { // matrix exists, or the identity matrix if the lens is // nonlinear. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_projection_mat(StereoChannel channel) const { if ((_comp_flags & CF_projection_mat) == 0) { ((Lens *)this)->compute_projection_mat(); @@ -1183,14 +1183,14 @@ get_projection_mat(StereoChannel channel) const { // on the film to a 3-d vector in space, if such a // matrix exists. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_projection_mat_inv(StereoChannel stereo_channel) const { switch (stereo_channel) { case SC_left: { if ((_comp_flags & CF_projection_mat_left_inv) == 0) { Lens *non_const = (Lens *)this; - const LMatrix4f &projection_mat_left = get_projection_mat(SC_left); + const LMatrix4 &projection_mat_left = get_projection_mat(SC_left); non_const->_projection_mat_left_inv.invert_from(projection_mat_left); non_const->adjust_comp_flags(0, CF_projection_mat_left_inv); } @@ -1201,7 +1201,7 @@ get_projection_mat_inv(StereoChannel stereo_channel) const { { if ((_comp_flags & CF_projection_mat_right_inv) == 0) { Lens *non_const = (Lens *)this; - const LMatrix4f &projection_mat_right = get_projection_mat(SC_right); + const LMatrix4 &projection_mat_right = get_projection_mat(SC_right); non_const->_projection_mat_right_inv.invert_from(projection_mat_right); non_const->adjust_comp_flags(0, CF_projection_mat_right_inv); } @@ -1215,7 +1215,7 @@ get_projection_mat_inv(StereoChannel stereo_channel) const { if ((_comp_flags & CF_projection_mat_inv) == 0) { Lens *non_const = (Lens *)this; - const LMatrix4f &projection_mat = get_projection_mat(); + const LMatrix4 &projection_mat = get_projection_mat(); non_const->_projection_mat_inv.invert_from(projection_mat); non_const->adjust_comp_flags(0, CF_projection_mat_inv); } @@ -1228,7 +1228,7 @@ get_projection_mat_inv(StereoChannel stereo_channel) const { // Description: Returns the matrix that transforms from a point // behind the lens to a point on the film. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_film_mat() const { if ((_comp_flags & CF_film_mat) == 0) { ((Lens *)this)->compute_film_mat(); @@ -1242,11 +1242,11 @@ get_film_mat() const { // Description: Returns the matrix that transforms from a point on // the film to a point behind the lens. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_film_mat_inv() const { if ((_comp_flags & CF_film_mat_inv) == 0) { Lens *non_const = (Lens *)this; - const LMatrix4f &film_mat = get_film_mat(); + const LMatrix4 &film_mat = get_film_mat(); non_const->_film_mat_inv.invert_from(film_mat); non_const->adjust_comp_flags(0, CF_film_mat_inv); } @@ -1259,7 +1259,7 @@ get_film_mat_inv() const { // Description: Returns the matrix that transforms from a point // in front of the lens to a point in space. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_lens_mat() const { if ((_comp_flags & CF_lens_mat) == 0) { ((Lens *)this)->compute_lens_mat(); @@ -1273,11 +1273,11 @@ get_lens_mat() const { // Description: Returns the matrix that transforms from a point in // space to a point in front of the lens. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Lens:: +const LMatrix4 &Lens:: get_lens_mat_inv() const { if ((_comp_flags & CF_lens_mat_inv) == 0) { Lens *non_const = (Lens *)this; - const LMatrix4f &lens_mat = get_lens_mat(); + const LMatrix4 &lens_mat = get_lens_mat(); non_const->_lens_mat_inv.invert_from(lens_mat); non_const->adjust_comp_flags(0, CF_lens_mat_inv); } @@ -1350,19 +1350,19 @@ throw_change_event() { // otherwise. //////////////////////////////////////////////////////////////////// bool Lens:: -extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) const { - const LMatrix4f &projection_mat_inv = get_projection_mat_inv(); +extrude_impl(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { + const LMatrix4 &projection_mat_inv = get_projection_mat_inv(); { - LVecBase4f full(point2d[0], point2d[1], -1.0f, 1.0f); + LVecBase4 full(point2d[0], point2d[1], -1.0f, 1.0f); full = projection_mat_inv.xform(full); - float recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); + PN_stdfloat recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); near_point.set(full[0] * recip_full3, full[1] * recip_full3, full[2] * recip_full3); } { - LVecBase4f full(point2d[0], point2d[1], 1.0f, 1.0f); + LVecBase4 full(point2d[0], point2d[1], 1.0f, 1.0f); full = projection_mat_inv.xform(full); // We can truncate the weight factor at near 0. If it goes too @@ -1370,7 +1370,7 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // past infinity and comes back in behind the lens, which is just // crazy. Truncating it to zero keeps the far plane from moving // too far out. - float recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); + PN_stdfloat recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); far_point.set(full[0] * recip_full3, full[1] * recip_full3, full[2] * recip_full3); @@ -1408,8 +1408,8 @@ extrude_impl(const LPoint3f &point2d, LPoint3f &near_point, LPoint3f &far_point) // otherwise. //////////////////////////////////////////////////////////////////// bool Lens:: -extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { - vec = LVector3f::forward(_cs) * get_lens_mat(); +extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const { + vec = LVector3::forward(_cs) * get_lens_mat(); return true; } @@ -1432,15 +1432,15 @@ extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const { // or may not be meaningful). //////////////////////////////////////////////////////////////////// bool Lens:: -project_impl(const LPoint3f &point3d, LPoint3f &point2d) const { - const LMatrix4f &projection_mat = get_projection_mat(); - LVecBase4f full(point3d[0], point3d[1], point3d[2], 1.0f); +project_impl(const LPoint3 &point3d, LPoint3 &point2d) const { + const LMatrix4 &projection_mat = get_projection_mat(); + LVecBase4 full(point3d[0], point3d[1], point3d[2], 1.0f); full = projection_mat.xform(full); if (full[3] == 0.0f) { point2d.set(0.0f, 0.0f, 0.0f); return false; } - float recip_full3 = 1.0f/full[3]; + PN_stdfloat recip_full3 = 1.0f/full[3]; point2d.set(full[0] * recip_full3, full[1] * recip_full3, full[2] * recip_full3); return (full[3] > 0.0f) && @@ -1460,7 +1460,7 @@ compute_film_size() { // If we just have a min FOV and a focal length, that determines // the smaller of the two film_sizes, and the larger is simply // chosen according to the aspect ratio. - float fs = fov_to_film(_min_fov, _focal_length, true); + PN_stdfloat fs = fov_to_film(_min_fov, _focal_length, true); nassertv((_user_flags & UF_aspect_ratio) != 0 || (_comp_flags & CF_aspect_ratio) != 0); @@ -1520,8 +1520,8 @@ compute_film_size() { void Lens:: compute_focal_length() { if ((_user_flags & UF_focal_length) == 0) { - const LVecBase2f &film_size = get_film_size(); - const LVecBase2f &fov = get_fov(); + const LVecBase2 &film_size = get_film_size(); + const LVecBase2 &fov = get_fov(); _focal_length = fov_to_focal_length(fov[0], film_size[0], true); } @@ -1536,7 +1536,7 @@ compute_focal_length() { //////////////////////////////////////////////////////////////////// void Lens:: compute_fov() { - const LVecBase2f &film_size = get_film_size(); + const LVecBase2 &film_size = get_film_size(); bool got_hfov = ((_user_flags & UF_hfov) != 0); bool got_vfov = ((_user_flags & UF_vfov) != 0); @@ -1615,7 +1615,7 @@ compute_fov() { void Lens:: compute_aspect_ratio() { if ((_user_flags & UF_aspect_ratio) == 0) { - const LVecBase2f &film_size = get_film_size(); + const LVecBase2 &film_size = get_film_size(); if (film_size[1] == 0.0f) { _aspect_ratio = 1.0f; } else { @@ -1634,8 +1634,8 @@ compute_aspect_ratio() { void Lens:: compute_view_hpr() { if ((_user_flags & UF_view_hpr) == 0) { - const LMatrix4f &view_mat = get_view_mat(); - LVecBase3f scale, shear, translate; + const LMatrix4 &view_mat = get_view_mat(); + LVecBase3 scale, shear, translate; decompose_matrix(view_mat, scale, shear, _view_hpr, translate, _cs); } adjust_comp_flags(0, CF_view_hpr); @@ -1649,9 +1649,9 @@ compute_view_hpr() { void Lens:: compute_view_vector() { if ((_user_flags & UF_view_vector) == 0) { - const LMatrix4f &view_mat = get_view_mat(); - _view_vector = LVector3f::forward(_cs) * view_mat; - _up_vector = LVector3f::up(_cs) * view_mat; + const LMatrix4 &view_mat = get_view_mat(); + _view_vector = LVector3::forward(_cs) * view_mat; + _up_vector = LVector3::up(_cs) * view_mat; } adjust_comp_flags(0, CF_view_vector); } @@ -1670,7 +1670,7 @@ compute_projection_mat() { _projection_mat_inv = _projection_mat_left_inv = _projection_mat_right_inv = - LMatrix4f::ident_mat(); + LMatrix4::ident_mat(); adjust_comp_flags(0, CF_projection_mat | CF_projection_mat_inv | CF_projection_mat_left_inv |CF_projection_mat_right_inv); } @@ -1689,18 +1689,18 @@ compute_film_mat() { // We declare these two as local variables, instead of references, // to work around a VC7 compiler bug. - LVecBase2f film_size = get_film_size(); - LVector2f film_offset = get_film_offset(); + LVecBase2 film_size = get_film_size(); + LVector2 film_offset = get_film_offset(); - float scale_x = 2.0f / film_size[0]; - float scale_y = 2.0f / film_size[1]; + PN_stdfloat scale_x = 2.0f / film_size[0]; + PN_stdfloat scale_y = 2.0f / film_size[1]; _film_mat.set(scale_x, 0.0f, 0.0f, 0.0f, 0.0f, scale_y, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -film_offset[0] * scale_x, -film_offset[1] * scale_y, 0.0f, 1.0f); if ((_user_flags & UF_keystone) != 0) { - _film_mat = LMatrix4f(1.0f, 0.0f, _keystone[0], _keystone[0], + _film_mat = LMatrix4(1.0f, 0.0f, _keystone[0], _keystone[0], 0.0f, 1.0f, _keystone[1], _keystone[1], 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f) * _film_mat; @@ -1721,16 +1721,16 @@ compute_lens_mat() { if ((_user_flags & UF_view_mat) == 0) { if ((_user_flags & UF_view_hpr) != 0) { compose_matrix(_lens_mat, - LVecBase3f(1.0f, 1.0f, 1.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), + LVecBase3(1.0f, 1.0f, 1.0f), + LVecBase3(0.0f, 0.0f, 0.0f), _view_hpr, - LVecBase3f(0.0f, 0.0f, 0.0f), _cs); + LVecBase3(0.0f, 0.0f, 0.0f), _cs); } else if ((_user_flags & UF_view_vector) != 0) { look_at(_lens_mat, _view_vector, _up_vector, _cs); } else { - _lens_mat = LMatrix4f::ident_mat(); + _lens_mat = LMatrix4::ident_mat(); } } adjust_comp_flags(CF_lens_mat_inv, @@ -1746,8 +1746,8 @@ compute_lens_mat() { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float Lens:: -fov_to_film(float, float, bool) const { +PN_stdfloat Lens:: +fov_to_film(PN_stdfloat, PN_stdfloat, bool) const { return 1.0f; } @@ -1760,8 +1760,8 @@ fov_to_film(float, float, bool) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float Lens:: -fov_to_focal_length(float, float, bool) const { +PN_stdfloat Lens:: +fov_to_focal_length(PN_stdfloat, PN_stdfloat, bool) const { return 1.0f; } @@ -1774,8 +1774,8 @@ fov_to_focal_length(float, float, bool) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float Lens:: -film_to_fov(float, float, bool) const { +PN_stdfloat Lens:: +film_to_fov(PN_stdfloat, PN_stdfloat, bool) const { return default_fov; } @@ -1871,55 +1871,55 @@ define_geom_data() { } GeomVertexWriter vertex(_geom_data, InternalName::get_vertex()); - LPoint3f near_point, far_point; + LPoint3 near_point, far_point; for (int si = 0; si < num_segments; si++) { - float t = 2.0f * (float)si / (float)num_segments; + PN_stdfloat t = 2.0f * (PN_stdfloat)si / (PN_stdfloat)num_segments; // Upper left, top edge. - LPoint2f p1(-1.0f + t, 1.0f); + LPoint2 p1(-1.0f + t, 1.0f); if (!extrude(p1, near_point, far_point)) { // Hey, this point is off the lens! Can't do a frustum. return 0; } - vertex.add_data3f(near_point); - vertex.add_data3f(far_point); + vertex.add_data3(near_point); + vertex.add_data3(far_point); // Upper right, right edge. - LPoint2f p2(1.0f, 1.0f - t); + LPoint2 p2(1.0f, 1.0f - t); if (!extrude(p2, near_point, far_point)) { // Hey, this point is off the lens! Can't do a frustum. return 0; } - vertex.add_data3f(near_point); - vertex.add_data3f(far_point); + vertex.add_data3(near_point); + vertex.add_data3(far_point); // Lower right, bottom edge. - LPoint2f p3(1.0f - t, -1.0f); + LPoint2 p3(1.0f - t, -1.0f); if (!extrude(p3, near_point, far_point)) { // Hey, this point is off the lens! Can't do a frustum. return 0; } - vertex.add_data3f(near_point); - vertex.add_data3f(far_point); + vertex.add_data3(near_point); + vertex.add_data3(far_point); // Lower left, left edge. - LPoint2f p4(-1.0f, -1.0f + t); + LPoint2 p4(-1.0f, -1.0f + t); if (!extrude(p4, near_point, far_point)) { // Hey, this point is off the lens! Can't do a frustum. return 0; } - vertex.add_data3f(near_point); - vertex.add_data3f(far_point); + vertex.add_data3(near_point); + vertex.add_data3(far_point); } // Finally, add one more pair for the viewing axis. - LPoint3f near_axis = LPoint3f::origin(_cs) + LVector3f::forward(_cs) * _near_distance; - LPoint3f far_axis = LPoint3f::origin(_cs) + LVector3f::forward(_cs) * _far_distance; - const LMatrix4f &lens_mat = get_lens_mat(); + LPoint3 near_axis = LPoint3::origin(_cs) + LVector3::forward(_cs) * _near_distance; + LPoint3 far_axis = LPoint3::origin(_cs) + LVector3::forward(_cs) * _far_distance; + const LMatrix4 &lens_mat = get_lens_mat(); near_axis = near_axis * lens_mat; far_axis = far_axis * lens_mat; - vertex.add_data3f(near_axis); - vertex.add_data3f(far_axis); + vertex.add_data3(near_axis); + vertex.add_data3(far_axis); return num_segments; } @@ -1932,32 +1932,32 @@ define_geom_data() { // indicated points to the most nearly rectangular. //////////////////////////////////////////////////////////////////// void Lens:: -build_shear_mat(LMatrix4f &shear_mat, - const LPoint3f &cul, const LPoint3f &cur, - const LPoint3f &cll, const LPoint3f &clr) { +build_shear_mat(LMatrix4 &shear_mat, + const LPoint3 &cul, const LPoint3 &cur, + const LPoint3 &cll, const LPoint3 &clr) { // Fit a parallelogram around these four points. // Put the points in an array so we can rotate it around to find // the longest edge. - LPoint3f points[4] = { + LPoint3 points[4] = { cul, cur, clr, cll }; - float max_edge_length = -1.0f; + PN_stdfloat max_edge_length = -1.0f; int base_edge = -1; for (int i = 0; i < 4; i++) { - LVector3f edge = points[(i + 1) % 4] - points[i]; - float length = edge.length_squared(); + LVector3 edge = points[(i + 1) % 4] - points[i]; + PN_stdfloat length = edge.length_squared(); if (length > max_edge_length) { base_edge = i; max_edge_length = length; } } - const LPoint3f &base_origin = points[base_edge]; - LVector3f base_vec = points[(base_edge + 1) % 4] - base_origin; + const LPoint3 &base_origin = points[base_edge]; + LVector3 base_vec = points[(base_edge + 1) % 4] - base_origin; - float base_edge_length = csqrt(max_edge_length); + PN_stdfloat base_edge_length = csqrt(max_edge_length); // The longest edge is the base of our parallelogram. The parallel // edge must pass through the point furthest from this edge. @@ -1965,11 +1965,11 @@ build_shear_mat(LMatrix4f &shear_mat, int a = (base_edge + 2) % 4; int b = (base_edge + 3) % 4; - float a_dist = sqr_dist_to_line(points[a], base_origin, base_vec); - float b_dist = sqr_dist_to_line(points[b], base_origin, base_vec); + PN_stdfloat a_dist = sqr_dist_to_line(points[a], base_origin, base_vec); + PN_stdfloat b_dist = sqr_dist_to_line(points[b], base_origin, base_vec); int far_point; - float dist; + PN_stdfloat dist; if (a_dist > b_dist) { far_point = a; dist = csqrt(a_dist); @@ -1980,17 +1980,17 @@ build_shear_mat(LMatrix4f &shear_mat, // Try to make the parallelogram as nearly rectangular as possible. // How suitable is a true rectangle? - LVector3f perpendic = base_vec.cross(LVector3f(0.0f, -1.0f, 0.0f)); + LVector3 perpendic = base_vec.cross(LVector3(0.0f, -1.0f, 0.0f)); perpendic.normalize(); perpendic *= dist; - LPoint3f parallel_origin = points[base_edge] + perpendic; + LPoint3 parallel_origin = points[base_edge] + perpendic; // It follows that far_point is on the line passing through the // parallel edge. Is it within the endpoints? - LVector3f base_norm_vec = base_vec / base_edge_length; + LVector3 base_norm_vec = base_vec / base_edge_length; - LVector3f far_point_delta = points[far_point] - parallel_origin; - float far_point_pos = far_point_delta.dot(base_norm_vec); + LVector3 far_point_delta = points[far_point] - parallel_origin; + PN_stdfloat far_point_pos = far_point_delta.dot(base_norm_vec); if (far_point_pos < 0.0f) { // We have to slide the parallel_origin back to include far_point. @@ -2003,23 +2003,23 @@ build_shear_mat(LMatrix4f &shear_mat, } // Finally, is the other point within the parallelogram? - float t; - float Ox = parallel_origin[0]; - float Oy = parallel_origin[2]; - float Vx = base_vec[0]; - float Vy = base_vec[2]; - float Ax, Ay, Bx, By; + PN_stdfloat t; + PN_stdfloat Ox = parallel_origin[0]; + PN_stdfloat Oy = parallel_origin[2]; + PN_stdfloat Vx = base_vec[0]; + PN_stdfloat Vy = base_vec[2]; + PN_stdfloat Ax, Ay, Bx, By; if (far_point == a) { // near point is b - LVector3f v = points[b] - base_origin; + LVector3 v = points[b] - base_origin; Ax = points[b][0]; Ay = points[b][2]; Bx = v[0]; By = v[2]; } else { // near point is a - LVector3f v = points[a] - (base_origin + base_vec); + LVector3 v = points[a] - (base_origin + base_vec); Ax = points[a][0]; Ay = points[a][2]; Bx = v[0]; @@ -2037,12 +2037,12 @@ build_shear_mat(LMatrix4f &shear_mat, parallel_origin += base_vec * (1.0f - t); } - LVector3f adjacent_norm_vec = parallel_origin - base_origin; + LVector3 adjacent_norm_vec = parallel_origin - base_origin; adjacent_norm_vec.normalize(); // Now we've defined a parallelogram that includes all four points, // and we're ready to build a shear transform. - shear_mat = LMatrix4f::ident_mat(); + shear_mat = LMatrix4::ident_mat(); // The edges of the parallelogram become the axes. switch (base_edge) { @@ -2086,14 +2086,14 @@ build_shear_mat(LMatrix4f &shear_mat, // computes the minimum distance from a point to a line, // and returns the distance squared. //////////////////////////////////////////////////////////////////// -float Lens:: -sqr_dist_to_line(const LPoint3f &point, const LPoint3f &origin, - const LVector3f &vec) { - LVector3f norm = vec; +PN_stdfloat Lens:: +sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, + const LVector3 &vec) { + LVector3 norm = vec; norm.normalize(); - LVector3f d = point - origin; - float hyp_2 = d.length_squared(); - float leg = d.dot(norm); + LVector3 d = point - origin; + PN_stdfloat hyp_2 = d.length_squared(); + PN_stdfloat leg = d.dot(norm); return hyp_2 - leg * leg; } @@ -2111,11 +2111,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint8((int)_cs); _film_size.write_datagram(dg); _film_offset.write_datagram(dg); - dg.add_float32(_focal_length); + dg.add_stdfloat(_focal_length); _fov.write_datagram(dg); - dg.add_float32(_aspect_ratio); - dg.add_float32(_near_distance); - dg.add_float32(_far_distance); + dg.add_stdfloat(_aspect_ratio); + dg.add_stdfloat(_near_distance); + dg.add_stdfloat(_far_distance); dg.add_uint16(_user_flags); } @@ -2134,11 +2134,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { _cs = (CoordinateSystem)scan.get_uint8(); _film_size.read_datagram(scan); _film_offset.read_datagram(scan); - _focal_length = scan.get_float32(); + _focal_length = scan.get_stdfloat(); _fov.read_datagram(scan); - _aspect_ratio = scan.get_float32(); - _near_distance = scan.get_float32(); - _far_distance = scan.get_float32(); + _aspect_ratio = scan.get_stdfloat(); + _near_distance = scan.get_stdfloat(); + _far_distance = scan.get_stdfloat(); _user_flags = scan.get_uint16(); _comp_flags = 0; diff --git a/panda/src/gobj/lens.h b/panda/src/gobj/lens.h index 8982c5dae0..3c72cb02a9 100644 --- a/panda/src/gobj/lens.h +++ b/panda/src/gobj/lens.h @@ -54,14 +54,14 @@ PUBLISHED: virtual PT(Lens) make_copy() const=0; - INLINE bool extrude(const LPoint2f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - INLINE bool extrude(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - INLINE bool extrude_vec(const LPoint2f &point2d, LVector3f &vec3d) const; - INLINE bool extrude_vec(const LPoint3f &point2d, LVector3f &vec3d) const; - INLINE bool project(const LPoint3f &point3d, LPoint3f &point2d) const; - INLINE bool project(const LPoint3f &point3d, LPoint2f &point2d) const; + INLINE bool extrude(const LPoint2 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + INLINE bool extrude(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + INLINE bool extrude_vec(const LPoint2 &point2d, LVector3 &vec3d) const; + INLINE bool extrude_vec(const LPoint3 &point2d, LVector3 &vec3d) const; + INLINE bool project(const LPoint3 &point3d, LPoint3 &point2d) const; + INLINE bool project(const LPoint3 &point3d, LPoint2 &point2d) const; INLINE void set_change_event(const string &event); INLINE const string &get_change_event() const; @@ -71,59 +71,59 @@ PUBLISHED: void clear(); - void set_film_size(float width); - INLINE void set_film_size(float width, float height); - void set_film_size(const LVecBase2f &film_size); - const LVecBase2f &get_film_size() const; + void set_film_size(PN_stdfloat width); + INLINE void set_film_size(PN_stdfloat width, PN_stdfloat height); + void set_film_size(const LVecBase2 &film_size); + const LVecBase2 &get_film_size() const; - INLINE void set_film_offset(float x, float y); - INLINE void set_film_offset(const LVecBase2f &film_offset); - INLINE const LVector2f &get_film_offset() const; + INLINE void set_film_offset(PN_stdfloat x, PN_stdfloat y); + INLINE void set_film_offset(const LVecBase2 &film_offset); + INLINE const LVector2 &get_film_offset() const; - void set_focal_length(float focal_length); - float get_focal_length() const; + void set_focal_length(PN_stdfloat focal_length); + PN_stdfloat get_focal_length() const; - void set_min_fov(float min_fov); - void set_fov(float fov); - INLINE void set_fov(float hfov, float vfov); - void set_fov(const LVecBase2f &fov); - const LVecBase2f &get_fov() const; - INLINE float get_hfov() const; - INLINE float get_vfov() const; - float get_min_fov() const; + void set_min_fov(PN_stdfloat min_fov); + void set_fov(PN_stdfloat fov); + INLINE void set_fov(PN_stdfloat hfov, PN_stdfloat vfov); + void set_fov(const LVecBase2 &fov); + const LVecBase2 &get_fov() const; + INLINE PN_stdfloat get_hfov() const; + INLINE PN_stdfloat get_vfov() const; + PN_stdfloat get_min_fov() const; - void set_aspect_ratio(float aspect_ratio); - float get_aspect_ratio() const; + void set_aspect_ratio(PN_stdfloat aspect_ratio); + PN_stdfloat get_aspect_ratio() const; - INLINE void set_near(float near_distance); - INLINE float get_near() const; - INLINE void set_far(float far_distance); - INLINE float get_far() const; - INLINE void set_near_far(float near_distance, float far_distance); + INLINE void set_near(PN_stdfloat near_distance); + INLINE PN_stdfloat get_near() const; + INLINE void set_far(PN_stdfloat far_distance); + INLINE PN_stdfloat get_far() const; + INLINE void set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance); - static float get_default_near(); - static float get_default_far(); + static PN_stdfloat get_default_near(); + static PN_stdfloat get_default_far(); - INLINE void set_view_hpr(float h, float p, float r); - void set_view_hpr(const LVecBase3f &view_hpr); - const LVecBase3f &get_view_hpr() const; - INLINE void set_view_vector(float x, float y, float z, float i, float j, float k); - void set_view_vector(const LVector3f &view_vector, const LVector3f &up_vector); - const LVector3f &get_view_vector() const; - const LVector3f &get_up_vector() const; - LPoint3f get_nodal_point() const; + INLINE void set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + void set_view_hpr(const LVecBase3 &view_hpr); + const LVecBase3 &get_view_hpr() const; + INLINE void set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k); + void set_view_vector(const LVector3 &view_vector, const LVector3 &up_vector); + const LVector3 &get_view_vector() const; + const LVector3 &get_up_vector() const; + LPoint3 get_nodal_point() const; - void set_interocular_distance(float interocular_distance); - float get_interocular_distance() const; - void set_convergence_distance(float convergence_distance); - float get_convergence_distance() const; + void set_interocular_distance(PN_stdfloat interocular_distance); + PN_stdfloat get_interocular_distance() const; + void set_convergence_distance(PN_stdfloat convergence_distance); + PN_stdfloat get_convergence_distance() const; - void set_view_mat(const LMatrix4f &view_mat); - const LMatrix4f &get_view_mat() const; + void set_view_mat(const LMatrix4 &view_mat); + const LMatrix4 &get_view_mat() const; void clear_view_mat(); - void set_keystone(const LVecBase2f &keystone); - INLINE const LVecBase2f &get_keystone() const; + void set_keystone(const LVecBase2 &keystone); + INLINE const LVecBase2 &get_keystone() const; void clear_keystone(); // These flags are passed in as the last parameter to control the @@ -137,8 +137,8 @@ PUBLISHED: FC_shear = 0x0010, FC_keystone = 0x0020, }; - void set_frustum_from_corners(const LVecBase3f &ul, const LVecBase3f &ur, - const LVecBase3f &ll, const LVecBase3f &lr, + void set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, + const LVecBase3 &ll, const LVecBase3 &lr, int flags); void recompute_all(); @@ -150,14 +150,14 @@ PUBLISHED: virtual PT(BoundingVolume) make_bounds() const; - const LMatrix4f &get_projection_mat(StereoChannel channel = SC_mono) const; - const LMatrix4f &get_projection_mat_inv(StereoChannel channel = SC_mono) const; + const LMatrix4 &get_projection_mat(StereoChannel channel = SC_mono) const; + const LMatrix4 &get_projection_mat_inv(StereoChannel channel = SC_mono) const; - const LMatrix4f &get_film_mat() const; - const LMatrix4f &get_film_mat_inv() const; + const LMatrix4 &get_film_mat() const; + const LMatrix4 &get_film_mat_inv() const; - const LMatrix4f &get_lens_mat() const; - const LMatrix4f &get_lens_mat_inv() const; + const LMatrix4 &get_lens_mat() const; + const LMatrix4 &get_lens_mat_inv() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; @@ -171,10 +171,10 @@ protected: void throw_change_event(); - virtual bool extrude_impl(const LPoint3f &point2d, - LPoint3f &near_point, LPoint3f &far_point) const; - virtual bool extrude_vec_impl(const LPoint3f &point2d, LVector3f &vec) const; - virtual bool project_impl(const LPoint3f &point3d, LPoint3f &point2d) const; + virtual bool extrude_impl(const LPoint3 &point2d, + LPoint3 &near_point, LPoint3 &far_point) const; + virtual bool extrude_vec_impl(const LPoint3 &point2d, LVector3 &vec) const; + virtual bool project_impl(const LPoint3 &point3d, LPoint3 &point2d) const; virtual void compute_film_size(); virtual void compute_focal_length(); @@ -186,43 +186,43 @@ protected: virtual void compute_film_mat(); virtual void compute_lens_mat(); - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; private: void resequence_fov_triad(char &newest, char &older_a, char &older_b) const; int define_geom_data(); - static void build_shear_mat(LMatrix4f &shear_mat, - const LPoint3f &cul, const LPoint3f &cur, - const LPoint3f &cll, const LPoint3f &clr); - static float sqr_dist_to_line(const LPoint3f &point, const LPoint3f &origin, - const LVector3f &vec); + static void build_shear_mat(LMatrix4 &shear_mat, + const LPoint3 &cul, const LPoint3 &cur, + const LPoint3 &cll, const LPoint3 &clr); + static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, + const LVector3 &vec); protected: string _change_event; UpdateSeq _last_change; CoordinateSystem _cs; - LVecBase2f _film_size; - LVector2f _film_offset; - float _focal_length; - LVecBase2f _fov; - float _min_fov; - float _aspect_ratio; - float _near_distance, _far_distance; + LVecBase2 _film_size; + LVector2 _film_offset; + PN_stdfloat _focal_length; + LVecBase2 _fov; + PN_stdfloat _min_fov; + PN_stdfloat _aspect_ratio; + PN_stdfloat _near_distance, _far_distance; - LVecBase3f _view_hpr; - LVector3f _view_vector, _up_vector; - float _interocular_distance; - float _convergence_distance; - LVecBase2f _keystone; + LVecBase3 _view_hpr; + LVector3 _view_vector, _up_vector; + PN_stdfloat _interocular_distance; + PN_stdfloat _convergence_distance; + LVecBase2 _keystone; - LMatrix4f _film_mat, _film_mat_inv; - LMatrix4f _lens_mat, _lens_mat_inv; - LMatrix4f _projection_mat, _projection_mat_inv; - LMatrix4f _projection_mat_left, _projection_mat_left_inv; - LMatrix4f _projection_mat_right, _projection_mat_right_inv; + LMatrix4 _film_mat, _film_mat_inv; + LMatrix4 _lens_mat, _lens_mat_inv; + LMatrix4 _projection_mat, _projection_mat_inv; + LMatrix4 _projection_mat_left, _projection_mat_left_inv; + LMatrix4 _projection_mat_right, _projection_mat_right_inv; enum UserFlags { // Parameters the user may have explicitly specified. diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index ea03e70504..fd72d42545 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -78,7 +78,7 @@ has_ambient() const { // set. Returns (0,0,0,0) if the ambient color has not // been set. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Material:: +INLINE const LColor &Material:: get_ambient() const { return _ambient; } @@ -115,7 +115,7 @@ has_diffuse() const { // set. Returns (1,1,1,1) if the diffuse color has not // been set. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Material:: +INLINE const LColor &Material:: get_diffuse() const { return _diffuse; } @@ -152,7 +152,7 @@ has_specular() const { // set. Returns (0,0,0,0) if the specular color has not // been set. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Material:: +INLINE const LColor &Material:: get_specular() const { return _specular; } @@ -189,7 +189,7 @@ has_emission() const { // set. Returns (0,0,0,0) if the emission color has not // been set. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Material:: +INLINE const LColor &Material:: get_emission() const { return _emission; } @@ -213,7 +213,7 @@ clear_emission() { // Access: Published // Description: Returns the shininess exponent of the material. //////////////////////////////////////////////////////////////////// -INLINE float Material:: +INLINE PN_stdfloat Material:: get_shininess() const { return _shininess; } @@ -229,7 +229,7 @@ get_shininess() const { // makes the object appear less shiny. //////////////////////////////////////////////////////////////////// INLINE void Material:: -set_shininess(float shininess) { +set_shininess(PN_stdfloat shininess) { _shininess = shininess; } diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 75e02cd2f0..f16e9a714d 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -52,7 +52,7 @@ operator = (const Material ©) { // If this is not set, the object color will be used. //////////////////////////////////////////////////////////////////// void Material:: -set_ambient(const Colorf &color) { +set_ambient(const LColor &color) { if (enforce_attrib_lock) { if ((_flags & F_ambient)==0) { nassertv(!is_attrib_locked()); @@ -77,7 +77,7 @@ set_ambient(const Colorf &color) { // If this is not set, the object color will be used. //////////////////////////////////////////////////////////////////// void Material:: -set_diffuse(const Colorf &color) { +set_diffuse(const LColor &color) { if (enforce_attrib_lock) { if ((_flags & F_diffuse)==0) { nassertv(!is_attrib_locked()); @@ -101,7 +101,7 @@ set_diffuse(const Colorf &color) { // If this is not set, highlights will not appear. //////////////////////////////////////////////////////////////////// void Material:: -set_specular(const Colorf &color) { +set_specular(const LColor &color) { if (enforce_attrib_lock) { if ((_flags & F_specular)==0) { nassertv(!is_attrib_locked()); @@ -126,7 +126,7 @@ set_specular(const Colorf &color) { // presence of one or more lights. //////////////////////////////////////////////////////////////////// void Material:: -set_emission(const Colorf &color) { +set_emission(const LColor &color) { if (enforce_attrib_lock) { if ((_flags & F_emission)==0) { nassertv(!is_attrib_locked()); @@ -244,7 +244,7 @@ write_datagram(BamWriter *manager, Datagram &me) { _diffuse.write_datagram(me); _specular.write_datagram(me); _emission.write_datagram(me); - me.add_float32(_shininess); + me.add_stdfloat(_shininess); me.add_int32(_flags); } @@ -279,6 +279,6 @@ fillin(DatagramIterator &scan, BamReader *manager) { _diffuse.read_datagram(scan); _specular.read_datagram(scan); _emission.read_datagram(scan); - _shininess = scan.get_float32(); + _shininess = scan.get_stdfloat(); _flags = scan.get_int32(); } diff --git a/panda/src/gobj/material.h b/panda/src/gobj/material.h index 08f4ab3032..7fe26b0e82 100644 --- a/panda/src/gobj/material.h +++ b/panda/src/gobj/material.h @@ -20,6 +20,7 @@ #include "typedWritableReferenceCount.h" #include "namable.h" #include "luse.h" +#include "numeric_types.h" #include "config_gobj.h" class FactoryParams; @@ -40,27 +41,27 @@ PUBLISHED: INLINE static Material *get_default(); INLINE bool has_ambient() const; - INLINE const Colorf &get_ambient() const; - void set_ambient(const Colorf &color); + INLINE const LColor &get_ambient() const; + void set_ambient(const LColor &color); INLINE void clear_ambient(); INLINE bool has_diffuse() const; - INLINE const Colorf &get_diffuse() const; - void set_diffuse(const Colorf &color); + INLINE const LColor &get_diffuse() const; + void set_diffuse(const LColor &color); INLINE void clear_diffuse(); INLINE bool has_specular() const; - INLINE const Colorf &get_specular() const; - void set_specular(const Colorf &color); + INLINE const LColor &get_specular() const; + void set_specular(const LColor &color); INLINE void clear_specular(); INLINE bool has_emission() const; - INLINE const Colorf &get_emission() const; - void set_emission(const Colorf &color); + INLINE const LColor &get_emission() const; + void set_emission(const LColor &color); INLINE void clear_emission(); - INLINE float get_shininess() const; - INLINE void set_shininess(float shininess); + INLINE PN_stdfloat get_shininess() const; + INLINE void set_shininess(PN_stdfloat shininess); INLINE bool get_local() const; INLINE void set_local(bool local); @@ -80,11 +81,11 @@ PUBLISHED: INLINE void set_attrib_lock(); private: - Colorf _ambient; - Colorf _diffuse; - Colorf _specular; - Colorf _emission; - float _shininess; + LColor _ambient; + LColor _diffuse; + LColor _specular; + LColor _emission; + PN_stdfloat _shininess; static PT(Material) _default; diff --git a/panda/src/gobj/matrixLens.I b/panda/src/gobj/matrixLens.I index 95bd6a141a..00acbb0ab6 100644 --- a/panda/src/gobj/matrixLens.I +++ b/panda/src/gobj/matrixLens.I @@ -19,13 +19,13 @@ //////////////////////////////////////////////////////////////////// INLINE MatrixLens:: MatrixLens() : - _user_mat(LMatrix4f::ident_mat()), + _user_mat(LMatrix4::ident_mat()), _ml_flags(0) { // The default film size for a MatrixLens is 2, which makes the // default range for both X and Y be [-1, 1]. This also, // incidentally, makes the film_mat be identity. - set_film_size(2.0f); + set_film_size(2.0); } //////////////////////////////////////////////////////////////////// @@ -75,7 +75,7 @@ operator = (const MatrixLens ©) { // matrices. //////////////////////////////////////////////////////////////////// INLINE void MatrixLens:: -set_user_mat(const LMatrix4f &user_mat) { +set_user_mat(const LMatrix4 &user_mat) { _user_mat = user_mat; adjust_comp_flags(CF_mat, 0); } @@ -87,7 +87,7 @@ set_user_mat(const LMatrix4f &user_mat) { // user. This does not include transforms on the lens // or film (e.g. a film offset or view hpr). //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &MatrixLens:: +INLINE const LMatrix4 &MatrixLens:: get_user_mat() const { return _user_mat; } @@ -107,7 +107,7 @@ get_user_mat() const { // errors may become obvious. //////////////////////////////////////////////////////////////////// INLINE void MatrixLens:: -set_left_eye_mat(const LMatrix4f &left_eye_mat) { +set_left_eye_mat(const LMatrix4 &left_eye_mat) { _left_eye_mat = left_eye_mat; _ml_flags |= MF_has_left_eye; adjust_comp_flags(CF_mat, 0); @@ -146,7 +146,7 @@ has_left_eye_mat() const { // eye, if any, or the center matrix if there is no // custom matrix set for the left eye. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &MatrixLens:: +INLINE const LMatrix4 &MatrixLens:: get_left_eye_mat() const { if ((_ml_flags & MF_has_left_eye) != 0) { return _left_eye_mat; @@ -169,7 +169,7 @@ get_left_eye_mat() const { // errors may become obvious. //////////////////////////////////////////////////////////////////// INLINE void MatrixLens:: -set_right_eye_mat(const LMatrix4f &right_eye_mat) { +set_right_eye_mat(const LMatrix4 &right_eye_mat) { _right_eye_mat = right_eye_mat; _ml_flags |= MF_has_right_eye; adjust_comp_flags(CF_mat, 0); @@ -208,7 +208,7 @@ has_right_eye_mat() const { // eye, if any, or the center matrix if there is no // custom matrix set for the right eye. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &MatrixLens:: +INLINE const LMatrix4 &MatrixLens:: get_right_eye_mat() const { if ((_ml_flags & MF_has_right_eye) != 0) { return _right_eye_mat; diff --git a/panda/src/gobj/matrixLens.h b/panda/src/gobj/matrixLens.h index 65e41b8f2a..1a1b7b992e 100644 --- a/panda/src/gobj/matrixLens.h +++ b/panda/src/gobj/matrixLens.h @@ -37,18 +37,18 @@ public: INLINE void operator = (const MatrixLens ©); PUBLISHED: - INLINE void set_user_mat(const LMatrix4f &user_mat); - INLINE const LMatrix4f &get_user_mat() const; + INLINE void set_user_mat(const LMatrix4 &user_mat); + INLINE const LMatrix4 &get_user_mat() const; - INLINE void set_left_eye_mat(const LMatrix4f &user_mat); + INLINE void set_left_eye_mat(const LMatrix4 &user_mat); INLINE void clear_left_eye_mat(); INLINE bool has_left_eye_mat() const; - INLINE const LMatrix4f &get_left_eye_mat() const; + INLINE const LMatrix4 &get_left_eye_mat() const; - INLINE void set_right_eye_mat(const LMatrix4f &user_mat); + INLINE void set_right_eye_mat(const LMatrix4 &user_mat); INLINE void clear_right_eye_mat(); INLINE bool has_right_eye_mat() const; - INLINE const LMatrix4f &get_right_eye_mat() const; + INLINE const LMatrix4 &get_right_eye_mat() const; public: virtual PT(Lens) make_copy() const; @@ -60,9 +60,9 @@ protected: virtual void compute_projection_mat(); private: - LMatrix4f _user_mat; - LMatrix4f _left_eye_mat; - LMatrix4f _right_eye_mat; + LMatrix4 _user_mat; + LMatrix4 _left_eye_mat; + LMatrix4 _right_eye_mat; enum MLFlags { MF_has_left_eye = 0x001, diff --git a/panda/src/gobj/orthographicLens.cxx b/panda/src/gobj/orthographicLens.cxx index a81faef62a..2a18e8840c 100644 --- a/panda/src/gobj/orthographicLens.cxx +++ b/panda/src/gobj/orthographicLens.cxx @@ -77,10 +77,10 @@ compute_projection_mat() { cs = get_default_coordinate_system(); } - float a = 2.0f / (_far_distance - _near_distance); - float b = -(_far_distance + _near_distance) / (_far_distance - _near_distance); + PN_stdfloat a = 2.0f / (_far_distance - _near_distance); + PN_stdfloat b = -(_far_distance + _near_distance) / (_far_distance - _near_distance); - LMatrix4f canonical; + LMatrix4 canonical; switch (cs) { case CS_zup_right: canonical.set(1.0f, 0.0f, 0.0f, 0.0f, @@ -113,7 +113,7 @@ compute_projection_mat() { default: gobj_cat.error() << "Invalid coordinate system " << (int)cs << " in OrthographicLens!\n"; - canonical = LMatrix4f::ident_mat(); + canonical = LMatrix4::ident_mat(); } _projection_mat = get_lens_mat_inv() * canonical * get_film_mat(); diff --git a/panda/src/gobj/perspectiveLens.I b/panda/src/gobj/perspectiveLens.I index 1ca054df41..1deb077c3c 100644 --- a/panda/src/gobj/perspectiveLens.I +++ b/panda/src/gobj/perspectiveLens.I @@ -27,7 +27,7 @@ PerspectiveLens() { // Description: //////////////////////////////////////////////////////////////////// INLINE PerspectiveLens:: -PerspectiveLens(float hfov, float vfov) { +PerspectiveLens(PN_stdfloat hfov, PN_stdfloat vfov) { _fov.set(hfov, vfov); } diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index af728d4e44..5ef9b7dbcd 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -66,17 +66,17 @@ compute_projection_mat() { cs = get_default_coordinate_system(); } - float fl = get_focal_length(); - float fFar = get_far(); - float fNear = get_near(); - float far_minus_near = fFar-fNear; - float a = (fFar + fNear); - float b = -2.0f * fFar * fNear; + PN_stdfloat fl = get_focal_length(); + PN_stdfloat fFar = get_far(); + PN_stdfloat fNear = get_near(); + PN_stdfloat far_minus_near = fFar-fNear; + PN_stdfloat a = (fFar + fNear); + PN_stdfloat b = -2.0f * fFar * fNear; a /= far_minus_near; b /= far_minus_near; - LMatrix4f canonical; + LMatrix4 canonical; switch (cs) { case CS_zup_right: canonical.set( fl, 0.0f, 0.0f, 0.0f, @@ -109,7 +109,7 @@ compute_projection_mat() { default: gobj_cat.error() << "Invalid coordinate system " << (int)cs << " in PerspectiveLens!\n"; - canonical = LMatrix4f::ident_mat(); + canonical = LMatrix4::ident_mat(); } _projection_mat = get_lens_mat_inv() * canonical * get_film_mat(); @@ -121,15 +121,15 @@ compute_projection_mat() { // Compute the left and right projection matrices in case this // lens is assigned to a stereo DisplayRegion. - LVector3f iod = _interocular_distance * 0.5f * LVector3f::left(_cs); - _projection_mat_left = get_lens_mat_inv() * LMatrix4f::translate_mat(-iod) * canonical * get_film_mat(); - _projection_mat_right = get_lens_mat_inv() * LMatrix4f::translate_mat(iod) * canonical * get_film_mat(); + LVector3 iod = _interocular_distance * 0.5f * LVector3::left(_cs); + _projection_mat_left = get_lens_mat_inv() * LMatrix4::translate_mat(-iod) * canonical * get_film_mat(); + _projection_mat_right = get_lens_mat_inv() * LMatrix4::translate_mat(iod) * canonical * get_film_mat(); if (_user_flags & UF_convergence_distance) { nassertv(_convergence_distance != 0.0f); - LVector3f cd = (0.25f / _convergence_distance) * LVector3f::left(_cs); - _projection_mat_left *= LMatrix4f::translate_mat(cd); - _projection_mat_right *= LMatrix4f::translate_mat(-cd); + LVector3 cd = (0.25f / _convergence_distance) * LVector3::left(_cs); + _projection_mat_left *= LMatrix4::translate_mat(cd); + _projection_mat_right *= LMatrix4::translate_mat(-cd); } } @@ -147,8 +147,8 @@ compute_projection_mat() { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PerspectiveLens:: -fov_to_film(float fov, float focal_length, bool) const { +PN_stdfloat PerspectiveLens:: +fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return (ctan(deg_2_rad(fov * 0.5f)) * focal_length) * 2.0f; } @@ -161,8 +161,8 @@ fov_to_film(float fov, float focal_length, bool) const { // direction; otherwise, it is in the vertical direction // (some lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PerspectiveLens:: -fov_to_focal_length(float fov, float film_size, bool) const { +PN_stdfloat PerspectiveLens:: +fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * 0.5f / ctan(deg_2_rad(fov * 0.5f)); } @@ -175,8 +175,8 @@ fov_to_focal_length(float fov, float film_size, bool) const { // otherwise, it is in the vertical direction (some // lenses behave differently in each direction). //////////////////////////////////////////////////////////////////// -float PerspectiveLens:: -film_to_fov(float film_size, float focal_length, bool) const { +PN_stdfloat PerspectiveLens:: +film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return rad_2_deg(catan(film_size * 0.5f / focal_length)) * 2.0f; } diff --git a/panda/src/gobj/perspectiveLens.h b/panda/src/gobj/perspectiveLens.h index 3104b67769..9ccf615231 100644 --- a/panda/src/gobj/perspectiveLens.h +++ b/panda/src/gobj/perspectiveLens.h @@ -27,7 +27,7 @@ class EXPCL_PANDA_GOBJ PerspectiveLens : public Lens { PUBLISHED: INLINE PerspectiveLens(); - INLINE PerspectiveLens(float hfov, float vfov); + INLINE PerspectiveLens(PN_stdfloat hfov, PN_stdfloat vfov); public: INLINE PerspectiveLens(const PerspectiveLens ©); @@ -41,9 +41,9 @@ public: protected: virtual void compute_projection_mat(); - virtual float fov_to_film(float fov, float focal_length, bool horiz) const; - virtual float fov_to_focal_length(float fov, float film_size, bool horiz) const; - virtual float film_to_fov(float film_size, float focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; + virtual PN_stdfloat fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const; + virtual PN_stdfloat film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const; public: static void register_with_read_factory(); diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index 79082c4990..dfd9297a96 100755 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -169,14 +169,7 @@ operator == (const ShaderCaps &other) const { // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData() : _ptr(NULL), _type(SPT_unknown), _updated(true), @@ -190,14 +183,8 @@ ShaderPtrData(): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_float& ptr): - _pta_float(ptr), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const PTA_float &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), @@ -211,39 +198,12 @@ ShaderPtrData(const PTA_float& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_double& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(ptr), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), - _ptr(ptr.p()), - _type(SPT_double), - _updated(true), - _size(ptr.size()) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_LMatrix4f& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(ptr), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const PTA_LMatrix4f &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), - _size(ptr.size()*16) + _size(ptr.size() * 16) { } @@ -253,18 +213,12 @@ ShaderPtrData(const PTA_LMatrix4f& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_LMatrix3f& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(ptr), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const PTA_LMatrix3f &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), - _size(ptr.size()*9) + _size(ptr.size() * 9) { } @@ -274,18 +228,12 @@ ShaderPtrData(const PTA_LMatrix3f& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_LVecBase4f& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(ptr), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const PTA_LVecBase4f &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), - _size(ptr.size()*4) + _size(ptr.size() * 4) { } @@ -295,18 +243,12 @@ ShaderPtrData(const PTA_LVecBase4f& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_LVecBase3f& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(ptr), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const PTA_LVecBase3f &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), - _size(ptr.size()*3) + _size(ptr.size() * 3) { } @@ -316,18 +258,12 @@ ShaderPtrData(const PTA_LVecBase3f& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const PTA_LVecBase2f& ptr): - _pta_float(PTA_float::empty_array(0)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(ptr), +ShaderPtrData(const PTA_LVecBase2f &ptr): + _pta(ptr.v0()), _ptr(ptr.p()), _type(SPT_float), _updated(true), - _size(ptr.size()*2) + _size(ptr.size() * 2) { } @@ -337,20 +273,16 @@ ShaderPtrData(const PTA_LVecBase2f& ptr): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const LVecBase4f& lvec4): - _pta_float(PTA_float::empty_array(4)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const LVecBase4f &vec) : _type(SPT_float), _updated(true), _size(4) { - _ptr = _pta_float.p(); - memcpy(_pta_float, lvec4._v.data, sizeof(lvec4._v.data)); + PTA_float pta = PTA_float::empty_array(4); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); } //////////////////////////////////////////////////////////////////// @@ -359,20 +291,16 @@ ShaderPtrData(const LVecBase4f& lvec4): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const LVecBase3f& lvec3): - _pta_float(PTA_float::empty_array(3)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const LVecBase3f &vec) : _type(SPT_float), _updated(true), _size(3) { - _ptr = _pta_float.p(); - memcpy(_pta_float, lvec3._v.data, sizeof(lvec3._v.data)); + PTA_float pta = PTA_float::empty_array(3); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); } //////////////////////////////////////////////////////////////////// @@ -381,20 +309,16 @@ ShaderPtrData(const LVecBase3f& lvec3): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const LVecBase2f& lvec2): - _pta_float(PTA_float::empty_array(2)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), - _type(SPT_double), +ShaderPtrData(const LVecBase2f &vec) : + _type(SPT_float), _updated(true), _size(2) { - _ptr = _pta_float.p(); - memcpy(_pta_float,lvec2._v.data, sizeof(lvec2._v.data)); + PTA_float pta = PTA_float::empty_array(2); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); } //////////////////////////////////////////////////////////////////// @@ -403,20 +327,16 @@ ShaderPtrData(const LVecBase2f& lvec2): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const LMatrix4f& lmat4): - _pta_float(PTA_float::empty_array(16)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const LMatrix4f &mat) : _type(SPT_float), _updated(true), _size(16) { - _ptr = _pta_float.p(); - memcpy(_pta_float,lmat4._m.data, sizeof(lmat4._m.data)); + PTA_float pta = PTA_float::empty_array(16); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, mat._m.data, sizeof(mat._m.data)); } //////////////////////////////////////////////////////////////////// @@ -425,18 +345,194 @@ ShaderPtrData(const LMatrix4f& lmat4): // Description: //////////////////////////////////////////////////////////////////// INLINE Shader::ShaderPtrData:: -ShaderPtrData(const LMatrix3f& lmat3): - _pta_float(PTA_float::empty_array(9)), - _pta_double(PTA_double::empty_array(0)), - _pta_lmat4f(PTA_LMatrix4f::empty_array(0)), - _pta_lmat3f(PTA_LMatrix3f::empty_array(0)), - _pta_lvec4f(PTA_LVecBase4f::empty_array(0)), - _pta_lvec3f(PTA_LVecBase3f::empty_array(0)), - _pta_lvec2f(PTA_LVecBase2f::empty_array(0)), +ShaderPtrData(const LMatrix3f &mat) : _type(SPT_float), _updated(true), _size(9) { - _ptr = _pta_float.p(); - memcpy(_pta_float,lmat3._m.data, sizeof(lmat3._m.data)); + PTA_float pta = PTA_float::empty_array(9); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, mat._m.data, sizeof(mat._m.data)); +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_double &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size()) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_LMatrix4d &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size() * 16) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_LMatrix3d &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size() * 9) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_LVecBase4d &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size() * 4) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_LVecBase3d &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size() * 3) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const PTA_LVecBase2d &ptr): + _pta(ptr.v0()), + _ptr(ptr.p()), + _type(SPT_double), + _updated(true), + _size(ptr.size() * 2) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const LVecBase4d &vec) : + _type(SPT_double), + _updated(true), + _size(4) +{ + PTA_double pta = PTA_double::empty_array(4); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const LVecBase3d &vec) : + _type(SPT_double), + _updated(true), + _size(3) +{ + PTA_double pta = PTA_double::empty_array(3); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const LVecBase2d &vec) : + _type(SPT_double), + _updated(true), + _size(2) +{ + PTA_double pta = PTA_double::empty_array(2); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(vec._v.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, vec._v.data, sizeof(vec._v.data)); +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const LMatrix4d &mat) : + _type(SPT_double), + _updated(true), + _size(16) +{ + PTA_double pta = PTA_double::empty_array(16); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, mat._m.data, sizeof(mat._m.data)); +} + +//////////////////////////////////////////////////////////////////// +// Function: Shader::ShaderPtrData Constructor +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE Shader::ShaderPtrData:: +ShaderPtrData(const LMatrix3d &mat) : + _type(SPT_double), + _updated(true), + _size(9) +{ + PTA_double pta = PTA_double::empty_array(9); + _pta = pta.v0(); + _ptr = pta.p(); + nassertv(sizeof(mat._m.data) == pta.size() * sizeof(pta[0])); + memcpy(_ptr, mat._m.data, sizeof(mat._m.data)); } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 604146486f..08adba0c6a 100755 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -22,11 +22,12 @@ #include "internalName.h" #include "pta_float.h" #include "pta_double.h" -#include "pta_LMatrix4f.h" -#include "pta_LMatrix3f.h" -#include "pta_LVecBase4f.h" -#include "pta_LVecBase3f.h" -#include "pta_LVecBase2f.h" +#include "pta_stdfloat.h" +#include "pta_LMatrix4.h" +#include "pta_LMatrix3.h" +#include "pta_LVecBase4.h" +#include "pta_LVecBase3.h" +#include "pta_LVecBase2.h" #ifdef HAVE_CG // I don't want to include the Cg header file into panda as a @@ -265,36 +266,41 @@ public: }; // Container structure for data of parameters ShaderPtrSpec. - struct ShaderPtrData{ + struct ShaderPtrData { private: - PTA_float _pta_float; - PTA_double _pta_double; - PTA_LMatrix4f _pta_lmat4f; - PTA_LMatrix3f _pta_lmat3f; - PTA_LVecBase4f _pta_lvec4f; - PTA_LVecBase3f _pta_lvec3f; - PTA_LVecBase2f _pta_lvec2f; + PT(ReferenceCount) _pta; public: - void* _ptr; + void *_ptr; ShaderPtrType _type; - bool _updated; - int _size; //number of elements vec3[4]=12 + bool _updated; + int _size; //number of elements vec3[4]=12 public: INLINE ShaderPtrData(); - INLINE ShaderPtrData(const PTA_float& ptr); - INLINE ShaderPtrData(const PTA_double& ptr); - INLINE ShaderPtrData(const PTA_LVecBase4f& ptr); - INLINE ShaderPtrData(const PTA_LVecBase3f& ptr); - INLINE ShaderPtrData(const PTA_LVecBase2f& ptr); - INLINE ShaderPtrData(const PTA_LMatrix4f& mat); - INLINE ShaderPtrData(const PTA_LMatrix3f& mat); - INLINE ShaderPtrData(const LVecBase4f& vec); - INLINE ShaderPtrData(const LVecBase3f& vec); - INLINE ShaderPtrData(const LVecBase2f& vec); - INLINE ShaderPtrData(const LMatrix4f& mat); - INLINE ShaderPtrData(const LMatrix3f& mat); + INLINE ShaderPtrData(const PTA_float &ptr); + INLINE ShaderPtrData(const PTA_LVecBase4f &ptr); + INLINE ShaderPtrData(const PTA_LVecBase3f &ptr); + INLINE ShaderPtrData(const PTA_LVecBase2f &ptr); + INLINE ShaderPtrData(const PTA_LMatrix4f &mat); + INLINE ShaderPtrData(const PTA_LMatrix3f &mat); + INLINE ShaderPtrData(const LVecBase4f &vec); + INLINE ShaderPtrData(const LVecBase3f &vec); + INLINE ShaderPtrData(const LVecBase2f &vec); + INLINE ShaderPtrData(const LMatrix4f &mat); + INLINE ShaderPtrData(const LMatrix3f &mat); + + INLINE ShaderPtrData(const PTA_double &ptr); + INLINE ShaderPtrData(const PTA_LVecBase4d &ptr); + INLINE ShaderPtrData(const PTA_LVecBase3d &ptr); + INLINE ShaderPtrData(const PTA_LVecBase2d &ptr); + INLINE ShaderPtrData(const PTA_LMatrix4d &mat); + INLINE ShaderPtrData(const PTA_LMatrix3d &mat); + INLINE ShaderPtrData(const LVecBase4d &vec); + INLINE ShaderPtrData(const LVecBase3d &vec); + INLINE ShaderPtrData(const LVecBase2d &vec); + INLINE ShaderPtrData(const LMatrix4d &mat); + INLINE ShaderPtrData(const LMatrix3d &mat); }; struct ShaderMatSpec { @@ -303,8 +309,8 @@ public: ShaderMatInput _part[2]; PT(InternalName) _arg[2]; int _dep[2]; - LMatrix4f _cache[2]; - LMatrix4f _value; + LMatrix4 _cache[2]; + LMatrix4 _value; ShaderMatPiece _piece; }; @@ -393,8 +399,8 @@ public: #ifdef HAVE_CG void cg_recurse_parameters(CGparameter parameter, - const ShaderType& type, - bool& success); + const ShaderType &type, + bool &success); #endif bool compile_parameter(const ShaderArgId &arg_id, @@ -428,7 +434,7 @@ public: // Determines the appropriate cg profile settings and stores them in the active shader caps // based on any profile settings stored in the shader's header - void cg_get_profile_from_header(ShaderCaps& caps); + void cg_get_profile_from_header(ShaderCaps &caps); ShaderCaps _cg_last_caps; CGcontext _cg_context; diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index c1759fcd59..188492663e 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -577,15 +577,15 @@ get_pad_z_size() const { // this case, this is a convenient way to generate UV's // that reflect the built-in padding size. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f Texture:: +INLINE LVecBase2 Texture:: get_tex_scale() const { CDReader cdata(_cycler); if (cdata->_pad_x_size == 0 || cdata->_pad_y_size == 0 || cdata->_x_size == 0 || cdata->_y_size == 0) { - LVecBase2f(1.0f, 1.0f); + LVecBase2(1.0f, 1.0f); } - return LVecBase2f((float)(cdata->_x_size - cdata->_pad_x_size) / (float)cdata->_x_size, - (float)(cdata->_y_size - cdata->_pad_y_size) / (float)cdata->_y_size); + return LVecBase2((PN_stdfloat)(cdata->_x_size - cdata->_pad_x_size) / (PN_stdfloat)cdata->_x_size, + (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size); } //////////////////////////////////////////////////////////////////// @@ -798,7 +798,7 @@ set_anisotropic_degree(int anisotropic_degree) { // the clamp color. //////////////////////////////////////////////////////////////////// INLINE void Texture:: -set_border_color(const Colorf &color) { +set_border_color(const LColor &color) { CDWriter cdata(_cycler, true); do_set_border_color(cdata, color); } @@ -956,7 +956,7 @@ get_effective_anisotropic_degree() const { // textures; in Panda, it is only used for specifying // the clamp color. //////////////////////////////////////////////////////////////////// -INLINE Colorf Texture:: +INLINE LColor Texture:: get_border_color() const { CDReader cdata(_cycler); return cdata->_border_color; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index d9a8805846..f3c97b154f 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -239,10 +239,10 @@ generate_normalization_cube_map(int size) { ++(cdata->_image_modified); ++(cdata->_properties_modified); - float half_size = (float)size * 0.5f; - float center = half_size - 0.5f; + PN_stdfloat half_size = (PN_stdfloat)size * 0.5f; + PN_stdfloat center = half_size - 0.5f; - LMatrix4f scale + LMatrix4 scale (127.5f, 0.0f, 0.0f, 0.0f, 0.0f, 127.5f, 0.0f, 0.0f, 0.0f, 0.0f, 127.5f, 0.0f, @@ -254,7 +254,7 @@ generate_normalization_cube_map(int size) { // Page 0: positive X. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(half_size, center - yi, center - xi); + LVector3 vec(half_size, center - yi, center - xi); vec.normalize(); vec = scale.xform_point(vec); @@ -267,7 +267,7 @@ generate_normalization_cube_map(int size) { // Page 1: negative X. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(-half_size, center - yi, xi - center); + LVector3 vec(-half_size, center - yi, xi - center); vec.normalize(); vec = scale.xform_point(vec); *p++ = (unsigned char)vec[2]; @@ -279,7 +279,7 @@ generate_normalization_cube_map(int size) { // Page 2: positive Y. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(xi - center, half_size, yi - center); + LVector3 vec(xi - center, half_size, yi - center); vec.normalize(); vec = scale.xform_point(vec); *p++ = (unsigned char)vec[2]; @@ -291,7 +291,7 @@ generate_normalization_cube_map(int size) { // Page 3: negative Y. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(xi - center, -half_size, center - yi); + LVector3 vec(xi - center, -half_size, center - yi); vec.normalize(); vec = scale.xform_point(vec); *p++ = (unsigned char)vec[2]; @@ -303,7 +303,7 @@ generate_normalization_cube_map(int size) { // Page 4: positive Z. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(xi - center, center - yi, half_size); + LVector3 vec(xi - center, center - yi, half_size); vec.normalize(); vec = scale.xform_point(vec); *p++ = (unsigned char)vec[2]; @@ -315,7 +315,7 @@ generate_normalization_cube_map(int size) { // Page 5: negative Z. for (yi = 0; yi < size; ++yi) { for (xi = 0; xi < size; ++xi) { - LVector3f vec(center - xi, center - yi, -half_size); + LVector3 vec(center - xi, center - yi, -half_size); vec.normalize(); vec = scale.xform_point(vec); *p++ = (unsigned char)vec[2]; @@ -4958,7 +4958,7 @@ do_set_anisotropic_degree(CData *cdata, int anisotropic_degree) { // Description: //////////////////////////////////////////////////////////////////// void Texture:: -do_set_border_color(CData *cdata, const Colorf &color) { +do_set_border_color(CData *cdata, const LColor &color) { if (cdata->_border_color != color) { ++(cdata->_properties_modified); cdata->_border_color = color; diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index cc157b96dc..f241a38af6 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -292,7 +292,7 @@ PUBLISHED: INLINE void set_minfilter(FilterType filter); INLINE void set_magfilter(FilterType filter); INLINE void set_anisotropic_degree(int anisotropic_degree); - INLINE void set_border_color(const Colorf &color); + INLINE void set_border_color(const LColor &color); INLINE void set_compression(CompressionMode compression); INLINE void set_render_to_texture(bool render_to_texture); @@ -305,7 +305,7 @@ PUBLISHED: FilterType get_effective_magfilter() const; INLINE int get_anisotropic_degree() const; INLINE int get_effective_anisotropic_degree() const; - INLINE Colorf get_border_color() const; + INLINE LColor get_border_color() const; INLINE CompressionMode get_compression() const; INLINE bool has_compression() const; INLINE bool get_render_to_texture() const; @@ -430,7 +430,7 @@ PUBLISHED: INLINE int get_pad_x_size() const; INLINE int get_pad_y_size() const; INLINE int get_pad_z_size() const; - INLINE LVecBase2f get_tex_scale() const; + INLINE LVecBase2 get_tex_scale() const; INLINE void set_pad_size(int x=0, int y=0, int z=0); void set_size_padded(int x=1, int y=1, int z=1); @@ -598,7 +598,7 @@ protected: void do_set_minfilter(CData *cdata, FilterType filter); void do_set_magfilter(CData *cdata, FilterType filter); void do_set_anisotropic_degree(CData *cdata, int anisotropic_degree); - void do_set_border_color(CData *cdata, const Colorf &color); + void do_set_border_color(CData *cdata, const LColor &color); void do_set_compression(CData *cdata, CompressionMode compression); void do_set_quality_level(CData *cdata, QualityLevel quality_level); @@ -786,7 +786,7 @@ protected: FilterType _magfilter; int _anisotropic_degree; bool _keep_ram_image; - Colorf _border_color; + LColor _border_color; CompressionMode _compression; bool _render_to_texture; bool _match_framebuffer_format; diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index 1eeb4f789d..c27a1ba979 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -160,9 +160,9 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { // the texture's wrap mode. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -lookup(Colorf &color, float u, float v) const { - int x = int((u - cfloor(u)) * (float)_x_size) % _x_size; - int y = int((v - cfloor(v)) * (float)_y_size) % _y_size; +lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const { + int x = int((u - cfloor(u)) * (PN_stdfloat)_x_size) % _x_size; + int y = int((v - cfloor(v)) * (PN_stdfloat)_y_size) % _y_size; nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); const unsigned char *p = _image.p() + (y * _x_size + x) * _pixel_width; @@ -183,10 +183,10 @@ lookup(Colorf &color, float u, float v) const { // the texture's wrap mode. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -lookup(Colorf &color, float u, float v, float w) const { - int x = int((u - cfloor(u)) * (float)_x_size) % _x_size; - int y = int((v - cfloor(v)) * (float)_y_size) % _y_size; - int z = int((w - cfloor(w)) * (float)_z_size) % _z_size; +lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const { + int x = int((u - cfloor(u)) * (PN_stdfloat)_x_size) % _x_size; + int y = int((v - cfloor(v)) * (PN_stdfloat)_y_size) % _y_size; + int z = int((w - cfloor(w)) * (PN_stdfloat)_z_size) % _z_size; nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size && z >= 0 && z < _z_size); @@ -207,8 +207,8 @@ lookup(Colorf &color, float u, float v, float w) const { // the texture's wrap mode. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -filter_rect(Colorf &color, - float min_u, float min_v, float max_u, float max_v) const { +filter_rect(LColor &color, + PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat max_u, PN_stdfloat max_v) const { int min_x, max_x; init_rect_minmax(min_x, max_x, min_u, max_u, _x_size); @@ -216,7 +216,7 @@ filter_rect(Colorf &color, init_rect_minmax(min_y, max_y, min_v, max_v, _y_size); color.set(0.0f, 0.0f, 0.0f, 0.0f); - float net = 0.0f; + PN_stdfloat net = 0.0f; accum_filter_y(color, net, 0, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, @@ -239,9 +239,9 @@ filter_rect(Colorf &color, // the texture's wrap mode. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -filter_rect(Colorf &color, - float min_u, float min_v, float min_w, - float max_u, float max_v, float max_w) const { +filter_rect(LColor &color, + PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat min_w, + PN_stdfloat max_u, PN_stdfloat max_v, PN_stdfloat max_w) const { int min_x, max_x; init_rect_minmax(min_x, max_x, min_u, max_u, _x_size); @@ -252,7 +252,7 @@ filter_rect(Colorf &color, init_rect_minmax(min_z, max_z, min_w, max_w, _z_size); color.set(0.0f, 0.0f, 0.0f, 0.0f); - float net = 0.0f; + PN_stdfloat net = 0.0f; accum_filter_z(color, net, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, @@ -270,10 +270,10 @@ filter_rect(Colorf &color, // min_y based on them. Also works for y and z. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -init_rect_minmax(int &min_x, int &max_x, float &min_u, float &max_u, +init_rect_minmax(int &min_x, int &max_x, PN_stdfloat &min_u, PN_stdfloat &max_u, int x_size) { if (min_u > max_u) { - float t = min_u; + PN_stdfloat t = min_u; min_u = max_u; max_u = t; } @@ -281,8 +281,8 @@ init_rect_minmax(int &min_x, int &max_x, float &min_u, float &max_u, min_u = 0.0f; max_u = 1.0f; } - min_x = (int)cfloor(min_u * (float)x_size); - max_x = (int)cceil(max_u * (float)x_size); + min_x = (int)cfloor(min_u * (PN_stdfloat)x_size); + max_x = (int)cceil(max_u * (PN_stdfloat)x_size); nassertv(min_x <= max_x); } @@ -292,10 +292,10 @@ init_rect_minmax(int &min_x, int &max_x, float &min_u, float &max_u, // Description: Accumulates the range of pixels from min_z to max_z. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -accum_filter_z(Colorf &color, float &net, - int min_x, int max_x, float min_u, float max_u, - int min_y, int max_y, float min_v, float max_v, - int min_z, int max_z, float min_w, float max_w) const { +accum_filter_z(LColor &color, PN_stdfloat &net, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, + int min_z, int max_z, PN_stdfloat min_w, PN_stdfloat max_w) const { nassertv(min_z >= 0 && min_z <= _z_size && max_z >= 0 && max_z <= _z_size); int zi = min_z; @@ -309,7 +309,7 @@ accum_filter_z(Colorf &color, float &net, } else { // First part-texel. - float w = (min_z + 1) - min_w * _z_size; + PN_stdfloat w = (min_z + 1) - min_w * _z_size; accum_filter_y(color, net, zi % _z_size, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, @@ -341,10 +341,10 @@ accum_filter_z(Colorf &color, float &net, // Description: Accumulates the range of pixels from min_y to max_y. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -accum_filter_y(Colorf &color, float &net, int zi, - int min_x, int max_x, float min_u, float max_u, - int min_y, int max_y, float min_v, float max_v, - float weight) const { +accum_filter_y(LColor &color, PN_stdfloat &net, int zi, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, + PN_stdfloat weight) const { nassertv(zi >= 0 && zi < _z_size); nassertv(min_y >= 0 && min_y <= _y_size && max_y >= 0 && max_y <= _y_size); @@ -356,7 +356,7 @@ accum_filter_y(Colorf &color, float &net, int zi, } else { // First part-texel. - float w = (min_y + 1) - min_v * _y_size; + PN_stdfloat w = (min_y + 1) - min_v * _y_size; accum_filter_x(color, net, yi % _y_size, zi, min_x, max_x, min_u, max_u, weight * w); int ys = max_y - 1; @@ -379,9 +379,9 @@ accum_filter_y(Colorf &color, float &net, int zi, // Description: Accumulates the range of pixels from min_x to max_x. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -accum_filter_x(Colorf &color, float &net, int yi, int zi, - int min_x, int max_x, float min_u, float max_u, - float weight) const { +accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + PN_stdfloat weight) const { nassertv(yi >= 0 && yi < _y_size && zi >= 0 && zi < _z_size); nassertv(min_x >= 0 && min_x <= _x_size && max_x >= 0 && max_x <= _x_size); @@ -396,7 +396,7 @@ accum_filter_x(Colorf &color, float &net, int yi, int zi, } else { // First part-texel. - float w = (min_x + 1) - min_u * _x_size; + PN_stdfloat w = (min_x + 1) - min_u * _x_size; accum_texel(color, net, p, weight * w); int xs = max_x - 1; @@ -429,8 +429,8 @@ accum_filter_x(Colorf &color, float &net, int yi, int zi, // filter_rect(). //////////////////////////////////////////////////////////////////// void TexturePeeker:: -accum_texel(Colorf &color, float &net, const unsigned char *&p, float weight) const { - Colorf c; +accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, PN_stdfloat weight) const { + LColor c; (*_get_texel)(c, p, _get_component); color += c * weight; net += weight; @@ -443,7 +443,7 @@ accum_texel(Colorf &color, float &net, const unsigned char *&p, float weight) co // texture is in format F_red. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_r(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_r(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); color[1] = 0.0f; color[2] = 0.0f; @@ -457,7 +457,7 @@ get_texel_r(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compon // texture is in format F_green. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_g(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_g(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; color[1] = (*get_component)(p); color[2] = 0.0f; @@ -471,7 +471,7 @@ get_texel_g(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compon // texture is in format F_blue. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_b(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_b(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; color[1] = 0.0f; color[2] = (*get_component)(p); @@ -485,7 +485,7 @@ get_texel_b(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compon // texture is in format F_alpha. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_a(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; color[1] = 0.0f; color[2] = 1.0f; @@ -499,7 +499,7 @@ get_texel_a(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compon // texture is in format F_luminance. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_l(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); color[1] = color[0]; color[2] = color[0]; @@ -513,7 +513,7 @@ get_texel_l(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compon // texture is in format F_luminance_alpha or similar. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_la(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); color[1] = color[0]; color[2] = color[0]; @@ -527,7 +527,7 @@ get_texel_la(Colorf &color, const unsigned char *&p, GetComponentFunc *get_compo // texture is in format F_rgb or similar. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_rgb(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[2] = (*get_component)(p); color[1] = (*get_component)(p); color[0] = (*get_component)(p); @@ -541,7 +541,7 @@ get_texel_rgb(Colorf &color, const unsigned char *&p, GetComponentFunc *get_comp // texture is in format F_rgba or similar. //////////////////////////////////////////////////////////////////// void TexturePeeker:: -get_texel_rgba(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component) { +get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[2] = (*get_component)(p); color[1] = (*get_component)(p); color[0] = (*get_component)(p); diff --git a/panda/src/gobj/texturePeeker.h b/panda/src/gobj/texturePeeker.h index 541969ca0f..909dc66a70 100644 --- a/panda/src/gobj/texturePeeker.h +++ b/panda/src/gobj/texturePeeker.h @@ -39,46 +39,46 @@ PUBLISHED: INLINE int get_y_size() const; INLINE int get_z_size() const; - void lookup(Colorf &color, float u, float v) const; - void lookup(Colorf &color, float u, float v, float w) const; - void filter_rect(Colorf &color, - float min_u, float min_v, - float max_u, float max_v) const; - void filter_rect(Colorf &color, - float min_u, float min_v, float min_w, - float max_u, float max_v, float max_w) const; + void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const; + void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const; + void filter_rect(LColor &color, + PN_stdfloat min_u, PN_stdfloat min_v, + PN_stdfloat max_u, PN_stdfloat max_v) const; + void filter_rect(LColor &color, + PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat min_w, + PN_stdfloat max_u, PN_stdfloat max_v, PN_stdfloat max_w) const; private: static void init_rect_minmax(int &min_x, int &max_x, - float &min_u, float &max_u, + PN_stdfloat &min_u, PN_stdfloat &max_u, int x_size); - void accum_filter_z(Colorf &color, float &net, - int min_x, int max_x, float min_u, float max_u, - int min_y, int max_y, float min_v, float max_v, - int min_z, int max_z, float min_w, float max_w) const; - void accum_filter_y(Colorf &color, float &net, int zi, - int min_x, int max_x, float min_u, float max_u, - int min_y, int max_y, float min_v, float max_v, - float weight) const; - void accum_filter_x(Colorf &color, float &net, int yi, int zi, - int min_x, int max_x, float min_u, float max_u, - float weight) const; - void accum_texel(Colorf &color, float &net, const unsigned char *&p, - float weight) const; + void accum_filter_z(LColor &color, PN_stdfloat &net, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, + int min_z, int max_z, PN_stdfloat min_w, PN_stdfloat max_w) const; + void accum_filter_y(LColor &color, PN_stdfloat &net, int zi, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, + PN_stdfloat weight) const; + void accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, + int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, + PN_stdfloat weight) const; + void accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, + PN_stdfloat weight) const; typedef double GetComponentFunc(const unsigned char *&p); - typedef void GetTexelFunc(Colorf &color, const unsigned char *&p, + typedef void GetTexelFunc(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_r(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_g(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_b(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_a(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_l(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_la(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_rgb(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); - static void get_texel_rgba(Colorf &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_r(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_g(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_b(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); int _x_size; int _y_size; diff --git a/panda/src/gobj/textureStage.I b/panda/src/gobj/textureStage.I index 07a4b0ad90..e5ca4d94d8 100755 --- a/panda/src/gobj/textureStage.I +++ b/panda/src/gobj/textureStage.I @@ -192,7 +192,7 @@ is_fixed_function() const { // Description: Set the color for this stage //////////////////////////////////////////////////////////////////// INLINE void TextureStage:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; } @@ -201,7 +201,7 @@ set_color(const Colorf &color) { // Access: Published // Description: return the color for this stage //////////////////////////////////////////////////////////////////// -INLINE Colorf TextureStage:: +INLINE LColor TextureStage:: get_color() const { return _color; } diff --git a/panda/src/gobj/textureStage.h b/panda/src/gobj/textureStage.h index ab81a864d9..d616154f1e 100644 --- a/panda/src/gobj/textureStage.h +++ b/panda/src/gobj/textureStage.h @@ -118,8 +118,8 @@ PUBLISHED: INLINE bool is_fixed_function() const; - INLINE void set_color(const Colorf &color); - INLINE Colorf get_color() const; + INLINE void set_color(const LColor &color); + INLINE LColor get_color() const; INLINE void set_rgb_scale(int rgb_scale); INLINE int get_rgb_scale() const; @@ -200,7 +200,7 @@ private: int _priority; PT(InternalName) _texcoord_name; Mode _mode; - Colorf _color; + LColor _color; int _rgb_scale; int _alpha_scale; bool _saved_result; diff --git a/panda/src/gobj/transformBlend.I b/panda/src/gobj/transformBlend.I index 11282596fa..a10ec14689 100644 --- a/panda/src/gobj/transformBlend.I +++ b/panda/src/gobj/transformBlend.I @@ -28,7 +28,7 @@ TransformBlend() { // Description: //////////////////////////////////////////////////////////////////// INLINE TransformBlend:: -TransformBlend(const VertexTransform *transform0, float) { +TransformBlend(const VertexTransform *transform0, PN_stdfloat) { add_transform(transform0, 1.0f); } @@ -38,8 +38,8 @@ TransformBlend(const VertexTransform *transform0, float) { // Description: //////////////////////////////////////////////////////////////////// INLINE TransformBlend:: -TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1) { +TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1) { add_transform(transform0, weight0); add_transform(transform1, weight1); normalize_weights(); @@ -51,9 +51,9 @@ TransformBlend(const VertexTransform *transform0, float weight0, // Description: //////////////////////////////////////////////////////////////////// INLINE TransformBlend:: -TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1, - const VertexTransform *transform2, float weight2) { +TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1, + const VertexTransform *transform2, PN_stdfloat weight2) { add_transform(transform0, weight0); add_transform(transform1, weight1); add_transform(transform2, weight2); @@ -66,10 +66,10 @@ TransformBlend(const VertexTransform *transform0, float weight0, // Description: //////////////////////////////////////////////////////////////////// INLINE TransformBlend:: -TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1, - const VertexTransform *transform2, float weight2, - const VertexTransform *transform3, float weight3) { +TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1, + const VertexTransform *transform2, PN_stdfloat weight2, + const VertexTransform *transform3, PN_stdfloat weight3) { add_transform(transform0, weight0); add_transform(transform1, weight1); add_transform(transform2, weight2); @@ -168,7 +168,7 @@ get_transform(int n) const { // Description: Returns the weight associated with the nth transform // stored in the blend object. //////////////////////////////////////////////////////////////////// -INLINE float TransformBlend:: +INLINE PN_stdfloat TransformBlend:: get_weight(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), 0.0f); return _entries[n]._weight; @@ -193,7 +193,7 @@ set_transform(int n, const VertexTransform *transform) { // stored in the blend object. //////////////////////////////////////////////////////////////////// INLINE void TransformBlend:: -set_weight(int n, float weight) { +set_weight(int n, PN_stdfloat weight) { nassertv(n >= 0 && n < (int)_entries.size()); _entries[n]._weight = weight; } @@ -225,7 +225,7 @@ update_blend(Thread *current_thread) const { // cache is up-to-date before calling this. //////////////////////////////////////////////////////////////////// INLINE void TransformBlend:: -get_blend(LMatrix4f &result, Thread *current_thread) const { +get_blend(LMatrix4 &result, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); result = cdata->_result; } @@ -239,7 +239,7 @@ get_blend(LMatrix4f &result, Thread *current_thread) const { // cache is up-to-date before calling this. //////////////////////////////////////////////////////////////////// INLINE void TransformBlend:: -transform_point(LPoint4f &point, Thread *current_thread) const { +transform_point(LPoint4 &point, Thread *current_thread) const { if (!_entries.empty()) { CDReader cdata(_cycler, current_thread); point = point * cdata->_result; @@ -255,7 +255,7 @@ transform_point(LPoint4f &point, Thread *current_thread) const { // cache is up-to-date before calling this. //////////////////////////////////////////////////////////////////// INLINE void TransformBlend:: -transform_point(LPoint3f &point, Thread *current_thread) const { +transform_point(LPoint3 &point, Thread *current_thread) const { if (!_entries.empty()) { CDReader cdata(_cycler, current_thread); point = point * cdata->_result; @@ -271,13 +271,115 @@ transform_point(LPoint3f &point, Thread *current_thread) const { // cache is up-to-date before calling this. //////////////////////////////////////////////////////////////////// INLINE void TransformBlend:: -transform_vector(LVector3f &vector, Thread *current_thread) const { +transform_vector(LVector3 &vector, Thread *current_thread) const { if (!_entries.empty()) { CDReader cdata(_cycler, current_thread); vector = vector * cdata->_result; } } +#ifndef STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_point (double) +// Access: Published +// Description: Transforms the indicated point by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_point(LPoint4d &point, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + point = point * LCAST(double, cdata->_result); + } +} +#else // STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_point (float) +// Access: Published +// Description: Transforms the indicated point by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_point(LPoint4f &point, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + point = point * LCAST(float, cdata->_result); + } +} +#endif // STDFLOAT_DOUBLE + +#ifndef STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_point (double) +// Access: Published +// Description: Transforms the indicated point by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_point(LPoint3d &point, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + point = point * LCAST(double, cdata->_result); + } +} +#else // STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_point (float) +// Access: Published +// Description: Transforms the indicated point by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_point(LPoint3f &point, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + point = point * LCAST(float, cdata->_result); + } +} +#endif // STDFLOAT_DOUBLE + +#ifndef STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_vector (double) +// Access: Published +// Description: Transforms the indicated vector by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_vector(LVector3d &vector, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + vector = vector * LCAST(double, cdata->_result); + } +} +#else // STDFLOAT_DOUBLE +//////////////////////////////////////////////////////////////////// +// Function: TransformBlend::transform_vector (float) +// Access: Published +// Description: Transforms the indicated vector by the blend matrix. +// +// You should call update_blend() to ensure that the +// cache is up-to-date before calling this. +//////////////////////////////////////////////////////////////////// +INLINE void TransformBlend:: +transform_vector(LVector3f &vector, Thread *current_thread) const { + if (!_entries.empty()) { + CDReader cdata(_cycler, current_thread); + vector = vector * LCAST(float, cdata->_result); + } +} +#endif // STDFLOAT_DOUBLE + //////////////////////////////////////////////////////////////////// // Function: TransformBlend::get_modified // Access: Published @@ -316,7 +418,7 @@ operator < (const TransformBlend::TransformEntry &other) const { //////////////////////////////////////////////////////////////////// INLINE TransformBlend::CData:: CData() : - _result(LMatrix4f::ident_mat()) + _result(LMatrix4::ident_mat()) { } diff --git a/panda/src/gobj/transformBlend.cxx b/panda/src/gobj/transformBlend.cxx index 08a46d5efd..2fd2a72d5d 100644 --- a/panda/src/gobj/transformBlend.cxx +++ b/panda/src/gobj/transformBlend.cxx @@ -55,7 +55,7 @@ compare_to(const TransformBlend &other) const { // already existed, increases its weight factor. //////////////////////////////////////////////////////////////////// void TransformBlend:: -add_transform(const VertexTransform *transform, float weight) { +add_transform(const VertexTransform *transform, PN_stdfloat weight) { if (!IS_NEARLY_ZERO(weight)) { TransformEntry entry; entry._transform = transform; @@ -104,7 +104,7 @@ remove_transform(const VertexTransform *transform) { //////////////////////////////////////////////////////////////////// void TransformBlend:: normalize_weights() { - float net_weight = 0.0f; + PN_stdfloat net_weight = 0.0f; Entries::iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { net_weight += (*ei)._weight; @@ -140,7 +140,7 @@ has_transform(const VertexTransform *transform) const { // transform, or 0 if there is no entry for the // transform. //////////////////////////////////////////////////////////////////// -float TransformBlend:: +PN_stdfloat TransformBlend:: get_weight(const VertexTransform *transform) const { TransformEntry entry; entry._transform = transform; @@ -184,11 +184,11 @@ write(ostream &out, int indent_level) const { for (ei = _entries.begin(); ei != _entries.end(); ++ei) { indent(out, indent_level) << *(*ei)._transform << ":" << (*ei)._weight << "\n"; - LMatrix4f mat; + LMatrix4 mat; (*ei)._transform->get_matrix(mat); mat.write(out, indent_level + 4); } - LMatrix4f blend; + LMatrix4 blend; update_blend(current_thread); get_blend(blend, current_thread); indent(out, indent_level) @@ -241,7 +241,7 @@ clear_result(Thread *current_thread) { cdata->_global_modified = UpdateSeq(); if (cdata->_modified != UpdateSeq()) { cdata->_modified = UpdateSeq(); - cdata->_result = LMatrix4f::ident_mat(); + cdata->_result = LMatrix4::ident_mat(); } } @@ -258,7 +258,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { manager->write_pointer(dg, (*ei)._transform); - dg.add_float32((*ei)._weight); + dg.add_stdfloat((*ei)._weight); } } @@ -299,7 +299,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (size_t i = 0; i < num_entries; ++i) { TransformEntry entry; manager->read_pointer(scan); - entry._weight = scan.get_float32(); + entry._weight = scan.get_stdfloat(); _entries.push_back(entry); } } diff --git a/panda/src/gobj/transformBlend.h b/panda/src/gobj/transformBlend.h index c1bfd046fc..26b00cf372 100644 --- a/panda/src/gobj/transformBlend.h +++ b/panda/src/gobj/transformBlend.h @@ -36,16 +36,16 @@ class EXPCL_PANDA_GOBJ TransformBlend { PUBLISHED: INLINE TransformBlend(); - INLINE TransformBlend(const VertexTransform *transform0, float weight0); - INLINE TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1); - INLINE TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1, - const VertexTransform *transform2, float weight2); - INLINE TransformBlend(const VertexTransform *transform0, float weight0, - const VertexTransform *transform1, float weight1, - const VertexTransform *transform2, float weight2, - const VertexTransform *transform3, float weight3); + INLINE TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0); + INLINE TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1); + INLINE TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1, + const VertexTransform *transform2, PN_stdfloat weight2); + INLINE TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, + const VertexTransform *transform1, PN_stdfloat weight1, + const VertexTransform *transform2, PN_stdfloat weight2, + const VertexTransform *transform3, PN_stdfloat weight3); INLINE TransformBlend(const TransformBlend ©); INLINE void operator = (const TransformBlend ©); INLINE ~TransformBlend(); @@ -55,25 +55,31 @@ PUBLISHED: INLINE bool operator == (const TransformBlend &other) const; INLINE bool operator != (const TransformBlend &other) const; - void add_transform(const VertexTransform *transform, float weight); + void add_transform(const VertexTransform *transform, PN_stdfloat weight); void remove_transform(const VertexTransform *transform); void normalize_weights(); bool has_transform(const VertexTransform *transform) const; - float get_weight(const VertexTransform *transform) const; + PN_stdfloat get_weight(const VertexTransform *transform) const; INLINE int get_num_transforms() const; INLINE const VertexTransform *get_transform(int n) const; MAKE_SEQ(get_transforms, get_num_transforms, get_transform); - INLINE float get_weight(int n) const; + INLINE PN_stdfloat get_weight(int n) const; INLINE void set_transform(int n, const VertexTransform *transform); - INLINE void set_weight(int n, float weight); + INLINE void set_weight(int n, PN_stdfloat weight); INLINE void update_blend(Thread *current_thread) const; - INLINE void get_blend(LMatrix4f &result, Thread *current_thread) const; + INLINE void get_blend(LMatrix4 &result, Thread *current_thread) const; + INLINE void transform_point(LPoint4f &point, Thread *current_thread) const; INLINE void transform_point(LPoint3f &point, Thread *current_thread) const; INLINE void transform_vector(LVector3f &point, Thread *current_thread) const; + + INLINE void transform_point(LPoint4d &point, Thread *current_thread) const; + INLINE void transform_point(LPoint3d &point, Thread *current_thread) const; + INLINE void transform_vector(LVector3d &point, Thread *current_thread) const; + INLINE UpdateSeq get_modified(Thread *current_thread) const; void output(ostream &out) const; @@ -90,7 +96,7 @@ private: INLINE bool operator < (const TransformEntry &other) const; CPT(VertexTransform) _transform; - float _weight; + PN_stdfloat _weight; }; typedef ov_set Entries; Entries _entries; @@ -106,7 +112,7 @@ private: return TransformBlend::get_class_type(); } - LMatrix4f _result; + LMatrix4 _result; UpdateSeq _modified; UpdateSeq _global_modified; }; diff --git a/panda/src/gobj/userVertexSlider.I b/panda/src/gobj/userVertexSlider.I index a409562594..9feaa42793 100644 --- a/panda/src/gobj/userVertexSlider.I +++ b/panda/src/gobj/userVertexSlider.I @@ -19,7 +19,7 @@ // Description: Stores the indicated slider value. //////////////////////////////////////////////////////////////////// INLINE void UserVertexSlider:: -set_slider(float slider) { +set_slider(PN_stdfloat slider) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); cdata->_slider = slider; diff --git a/panda/src/gobj/userVertexSlider.cxx b/panda/src/gobj/userVertexSlider.cxx index 7a08a9b651..4bf212e20e 100644 --- a/panda/src/gobj/userVertexSlider.cxx +++ b/panda/src/gobj/userVertexSlider.cxx @@ -45,7 +45,7 @@ UserVertexSlider(const InternalName *name) : // Access: Published, Virtual // Description: Returns the current slider value. //////////////////////////////////////////////////////////////////// -float UserVertexSlider:: +PN_stdfloat UserVertexSlider:: get_slider() const { CDReader cdata(_cycler); return cdata->_slider; @@ -127,7 +127,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { //////////////////////////////////////////////////////////////////// void UserVertexSlider::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { - dg.add_float32(_slider); + dg.add_stdfloat(_slider); } //////////////////////////////////////////////////////////////////// @@ -139,5 +139,5 @@ write_datagram(BamWriter *manager, Datagram &dg) const { //////////////////////////////////////////////////////////////////// void UserVertexSlider::CData:: fillin(DatagramIterator &scan, BamReader *manager) { - _slider = scan.get_float32(); + _slider = scan.get_stdfloat(); } diff --git a/panda/src/gobj/userVertexSlider.h b/panda/src/gobj/userVertexSlider.h index 378cf3dc6d..e2817e5add 100644 --- a/panda/src/gobj/userVertexSlider.h +++ b/panda/src/gobj/userVertexSlider.h @@ -36,8 +36,8 @@ PUBLISHED: UserVertexSlider(const string &name); UserVertexSlider(const InternalName *name); - INLINE void set_slider(float slider); - virtual float get_slider() const; + INLINE void set_slider(PN_stdfloat slider); + virtual PN_stdfloat get_slider() const; private: // This is the data that must be cycled between pipeline stages. @@ -52,7 +52,7 @@ private: return UserVertexSlider::get_class_type(); } - float _slider; + PN_stdfloat _slider; }; PipelineCycler _cycler; diff --git a/panda/src/gobj/userVertexTransform.I b/panda/src/gobj/userVertexTransform.I index a4abd0ae70..ce6937ba54 100644 --- a/panda/src/gobj/userVertexTransform.I +++ b/panda/src/gobj/userVertexTransform.I @@ -30,7 +30,7 @@ get_name() const { // Description: Stores the indicated matrix. //////////////////////////////////////////////////////////////////// INLINE void UserVertexTransform:: -set_matrix(const LMatrix4f &matrix) { +set_matrix(const LMatrix4 &matrix) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); cdata->_matrix = matrix; @@ -44,7 +44,7 @@ set_matrix(const LMatrix4f &matrix) { //////////////////////////////////////////////////////////////////// INLINE UserVertexTransform::CData:: CData() : - _matrix(LMatrix4f::ident_mat()) + _matrix(LMatrix4::ident_mat()) { } diff --git a/panda/src/gobj/userVertexTransform.cxx b/panda/src/gobj/userVertexTransform.cxx index cf46f36352..d1875fadf8 100644 --- a/panda/src/gobj/userVertexTransform.cxx +++ b/panda/src/gobj/userVertexTransform.cxx @@ -35,7 +35,7 @@ UserVertexTransform(const string &name) : // Description: Returns the transform's matrix. //////////////////////////////////////////////////////////////////// void UserVertexTransform:: -get_matrix(LMatrix4f &matrix) const { +get_matrix(LMatrix4 &matrix) const { CDReader cdata(_cycler); matrix = cdata->_matrix; } diff --git a/panda/src/gobj/userVertexTransform.h b/panda/src/gobj/userVertexTransform.h index 9b1265fbcb..1869858858 100644 --- a/panda/src/gobj/userVertexTransform.h +++ b/panda/src/gobj/userVertexTransform.h @@ -37,8 +37,8 @@ PUBLISHED: INLINE const string &get_name() const; - INLINE void set_matrix(const LMatrix4f &matrix); - virtual void get_matrix(LMatrix4f &matrix) const; + INLINE void set_matrix(const LMatrix4 &matrix); + virtual void get_matrix(LMatrix4 &matrix) const; virtual void output(ostream &out) const; @@ -57,7 +57,7 @@ private: return UserVertexTransform::get_class_type(); } - LMatrix4f _matrix; + LMatrix4 _matrix; }; PipelineCycler _cycler; diff --git a/panda/src/gobj/vertexSlider.h b/panda/src/gobj/vertexSlider.h index c74d42472a..122bf9a1d0 100644 --- a/panda/src/gobj/vertexSlider.h +++ b/panda/src/gobj/vertexSlider.h @@ -45,7 +45,7 @@ PUBLISHED: INLINE const InternalName *get_name() const; - virtual float get_slider() const=0; + virtual PN_stdfloat get_slider() const=0; INLINE UpdateSeq get_modified(Thread *current_thread) const; virtual void output(ostream &out) const; diff --git a/panda/src/gobj/vertexTransform.cxx b/panda/src/gobj/vertexTransform.cxx index 2a4504168e..dc624de28e 100644 --- a/panda/src/gobj/vertexTransform.cxx +++ b/panda/src/gobj/vertexTransform.cxx @@ -55,9 +55,9 @@ VertexTransform:: // previous. //////////////////////////////////////////////////////////////////// void VertexTransform:: -mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const { +mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { nassertv(&result != &previous); - LMatrix4f me; + LMatrix4 me; get_matrix(me); result.multiply(me, previous); } @@ -71,8 +71,8 @@ mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const { // result of several blended transforms. //////////////////////////////////////////////////////////////////// void VertexTransform:: -accumulate_matrix(LMatrix4f &accum, float weight) const { - LMatrix4f me; +accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { + LMatrix4 me; get_matrix(me); accum._m.m._00 += me._m.m._00 * weight; @@ -115,7 +115,7 @@ void VertexTransform:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; - LMatrix4f mat; + LMatrix4 mat; get_matrix(mat); mat.write(out, indent_level + 2); } diff --git a/panda/src/gobj/vertexTransform.h b/panda/src/gobj/vertexTransform.h index 551a91c1db..66f16a95e5 100644 --- a/panda/src/gobj/vertexTransform.h +++ b/panda/src/gobj/vertexTransform.h @@ -41,9 +41,9 @@ PUBLISHED: VertexTransform(); virtual ~VertexTransform(); - virtual void get_matrix(LMatrix4f &matrix) const=0; - virtual void mult_matrix(LMatrix4f &result, const LMatrix4f &previous) const; - virtual void accumulate_matrix(LMatrix4f &accum, float weight) const; + virtual void get_matrix(LMatrix4 &matrix) const=0; + virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const; + virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const; INLINE UpdateSeq get_modified(Thread *current_thread) const; diff --git a/panda/src/grutil/cardMaker.I b/panda/src/grutil/cardMaker.I index 7576532af7..d728cc1fe3 100644 --- a/panda/src/grutil/cardMaker.I +++ b/panda/src/grutil/cardMaker.I @@ -62,7 +62,7 @@ set_has_3d_uvs(bool flag) { // Description: Sets the size of the card. //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_frame(float left, float right, float bottom, float top) { +set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _ll_pos.set(left, 0.0f, bottom); _lr_pos.set(right, 0.0f, bottom); _ur_pos.set(right, 0.0f, top); @@ -75,7 +75,7 @@ set_frame(float left, float right, float bottom, float top) { // Description: Sets the size of the card. //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_frame(const LVecBase4f &frame) { +set_frame(const LVecBase4 &frame) { set_frame(frame[0], frame[1], frame[2], frame[3]); } @@ -85,7 +85,7 @@ set_frame(const LVecBase4f &frame) { // Description: Sets the size of the card. //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_frame(const Vertexf &ll, const Vertexf &lr, const Vertexf &ur, const Vertexf &ul) +set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul) { _ll_pos = ll; _lr_pos = lr; @@ -112,8 +112,8 @@ set_frame_fullscreen_quad() // Description: Sets the color of the card. //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_color(float r, float g, float b, float a) { - set_color(LVecBase4f(r, g, b, a)); +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_color(LVecBase4(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -122,7 +122,7 @@ set_color(float r, float g, float b, float a) { // Description: Sets the color of the card. //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_color(const LVecBase4f &color) { +set_color(const LVecBase4 &color) { _color = color; _has_color = true; } @@ -159,7 +159,7 @@ set_has_normals(bool flag) { // set_frame(). //////////////////////////////////////////////////////////////////// INLINE void CardMaker:: -set_source_geometry(PandaNode *node, const LVecBase4f &frame) { +set_source_geometry(PandaNode *node, const LVecBase4 &frame) { _source_geometry = node; _source_frame = frame; } diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index 5199d45eb0..65ecfc6c2d 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -72,11 +72,11 @@ generate() { format = GeomVertexFormat::register_format (new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - GeomEnums::NT_float32, GeomEnums::C_point, + GeomEnums::NT_stdfloat, GeomEnums::C_point, InternalName::get_normal(), 3, - GeomEnums::NT_float32, GeomEnums::C_vector, + GeomEnums::NT_stdfloat, GeomEnums::C_vector, InternalName::get_texcoord(), 3, - GeomEnums::NT_float32, GeomEnums::C_texcoord)); + GeomEnums::NT_stdfloat, GeomEnums::C_texcoord)); } else { format = GeomVertexFormat::get_v3n3t2(); } @@ -89,9 +89,9 @@ generate() { format = GeomVertexFormat::register_format (new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - GeomEnums::NT_float32, GeomEnums::C_point, + GeomEnums::NT_stdfloat, GeomEnums::C_point, InternalName::get_texcoord(), 3, - GeomEnums::NT_float32, GeomEnums::C_texcoord)); + GeomEnums::NT_stdfloat, GeomEnums::C_texcoord)); } else { format = GeomVertexFormat::get_v3t2(); } @@ -104,34 +104,34 @@ generate() { ("card", format, Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(_ul_pos); - vertex.add_data3f(_ll_pos); - vertex.add_data3f(_ur_pos); - vertex.add_data3f(_lr_pos); + vertex.add_data3(_ul_pos); + vertex.add_data3(_ll_pos); + vertex.add_data3(_ur_pos); + vertex.add_data3(_lr_pos); if (_has_uvs) { GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - texcoord.add_data3f(_ul_tex); - texcoord.add_data3f(_ll_tex); - texcoord.add_data3f(_ur_tex); - texcoord.add_data3f(_lr_tex); + texcoord.add_data3(_ul_tex); + texcoord.add_data3(_ll_tex); + texcoord.add_data3(_ur_tex); + texcoord.add_data3(_lr_tex); } if (_has_normals) { GeomVertexWriter normal(vdata, InternalName::get_normal()); - LVector3f n; + LVector3 n; n = (_ll_pos - _ul_pos).cross(_ur_pos - _ul_pos); n.normalize(); - normal.add_data3f(n); + normal.add_data3(n); n = (_lr_pos - _ll_pos).cross(_ul_pos - _ll_pos); n.normalize(); - normal.add_data3f(n); + normal.add_data3(n); n = (_ul_pos - _ur_pos).cross(_lr_pos - _ur_pos); n.normalize(); - normal.add_data3f(n); + normal.add_data3(n); n = (_ur_pos - _lr_pos).cross(_ll_pos - _lr_pos); n.normalize(); - normal.add_data3f(n); + normal.add_data3(n); } PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); @@ -162,7 +162,7 @@ generate() { // texture is applied. //////////////////////////////////////////////////////////////////// void CardMaker:: -set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, const TexCoord3f &ul) { +set_uv_range(const LTexCoord3 &ll, const LTexCoord3 &lr, const LTexCoord3 &ur, const LTexCoord3 &ul) { _ll_tex = ll; _lr_tex = lr; _ur_tex = ur; @@ -181,7 +181,7 @@ set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, c // texture is applied. //////////////////////////////////////////////////////////////////// void CardMaker:: -set_uv_range(const TexCoordf &ll, const TexCoordf &lr, const TexCoordf &ur, const TexCoordf &ul) { +set_uv_range(const LTexCoord &ll, const LTexCoord &lr, const LTexCoord &ur, const LTexCoord &ul) { _ll_tex.set(ll[0], ll[1], 0.0f); _lr_tex.set(lr[0], lr[1], 0.0f); _ur_tex.set(ur[0], ur[1], 0.0f); @@ -200,7 +200,7 @@ set_uv_range(const TexCoordf &ll, const TexCoordf &lr, const TexCoordf &ur, cons // texture is applied. //////////////////////////////////////////////////////////////////// void CardMaker:: -set_uv_range(const TexCoordf &ll, const TexCoordf &ur) { +set_uv_range(const LTexCoord &ll, const LTexCoord &ur) { _ll_tex.set(ll[0], ll[1], 0.0f); _lr_tex.set(ur[0], ll[1], 0.0f); _ur_tex.set(ur[0], ur[1], 0.0f); @@ -219,7 +219,7 @@ set_uv_range(const TexCoordf &ll, const TexCoordf &ur) { // texture is applied. //////////////////////////////////////////////////////////////////// void CardMaker:: -set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z) { +set_uv_range(const LVector4 &x, const LVector4 &y, const LVector4 &z) { _ll_tex.set(x[0], y[0], z[0]); _lr_tex.set(x[1], y[1], z[1]); _ur_tex.set(x[2], y[2], z[2]); @@ -236,9 +236,9 @@ set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z) { //////////////////////////////////////////////////////////////////// void CardMaker:: set_uv_range_cube(int face) { - LVector4f varya(-1, 1, 1, -1); - LVector4f varyb(-1, -1, 1, 1); - LVector4f fixed( 1, 1, 1, 1); + LVector4 varya(-1, 1, 1, -1); + LVector4 varyb(-1, -1, 1, 1); + LVector4 fixed( 1, 1, 1, 1); switch(face) { case 0: set_uv_range( fixed, -varyb, -varya); break; // positive_x case 1: set_uv_range(-fixed, -varyb, varya); break; // negative_x @@ -263,7 +263,7 @@ set_uv_range(const Texture *tex) { int nonpady = tex->get_y_size() - tex->get_pad_y_size(); double maxu = (nonpadx*1.0) / tex->get_x_size(); double maxv = (nonpady*1.0) / tex->get_y_size(); - set_uv_range(TexCoordf(0.0,0.0), TexCoordf(maxu,maxv)); + set_uv_range(LTexCoord(0.0,0.0), LTexCoord(maxu,maxv)); } //////////////////////////////////////////////////////////////////// @@ -277,22 +277,22 @@ rescale_source_geometry() { PT(PandaNode) root = _source_geometry->copy_subgraph(); // Determine the translate and scale appropriate for our geometry. - LVector3f frame_max = _ll_pos.fmax(_lr_pos.fmax(_ur_pos.fmax(_ul_pos))); - LVector3f frame_min = _ll_pos.fmin(_lr_pos.fmin(_ur_pos.fmax(_ul_pos))); - LVector3f frame_ctr = (frame_max + frame_min) * 0.5f; + LVector3 frame_max = _ll_pos.fmax(_lr_pos.fmax(_ur_pos.fmax(_ul_pos))); + LVector3 frame_min = _ll_pos.fmin(_lr_pos.fmin(_ur_pos.fmax(_ul_pos))); + LVector3 frame_ctr = (frame_max + frame_min) * 0.5f; - LVector3f geom_center((_source_frame[0] + _source_frame[1]) * 0.5f, + LVector3 geom_center((_source_frame[0] + _source_frame[1]) * 0.5f, frame_ctr[1], (_source_frame[2] + _source_frame[3]) * 0.5f); - LVector3f scale((frame_max[0] - frame_min[0]) / (_source_frame[1] - _source_frame[0]), + LVector3 scale((frame_max[0] - frame_min[0]) / (_source_frame[1] - _source_frame[0]), 0.0, (frame_max[2] - frame_min[2]) / (_source_frame[3] - _source_frame[2])); - LVector3f trans = frame_ctr - geom_center; + LVector3 trans = frame_ctr - geom_center; CPT(TransformState) transform = - TransformState::make_pos_hpr_scale(trans, LPoint3f(0.0f, 0.0f, 0.0f), scale); + TransformState::make_pos_hpr_scale(trans, LPoint3(0.0f, 0.0f, 0.0f), scale); root->set_transform(transform); if (_has_color) { diff --git a/panda/src/grutil/cardMaker.h b/panda/src/grutil/cardMaker.h index 2f977966e4..47778cb1d9 100644 --- a/panda/src/grutil/cardMaker.h +++ b/panda/src/grutil/cardMaker.h @@ -35,27 +35,27 @@ PUBLISHED: INLINE ~CardMaker(); void reset(); - void set_uv_range(const TexCoordf &ll, const TexCoordf &ur); - void set_uv_range(const TexCoordf &ll, const TexCoordf &lr, const TexCoordf &ur, const TexCoordf &ul); - void set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, const TexCoord3f &ul); - void set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z); + void set_uv_range(const LTexCoord &ll, const LTexCoord &ur); + void set_uv_range(const LTexCoord &ll, const LTexCoord &lr, const LTexCoord &ur, const LTexCoord &ul); + void set_uv_range(const LTexCoord3 &ll, const LTexCoord3 &lr, const LTexCoord3 &ur, const LTexCoord3 &ul); + void set_uv_range(const LVector4 &x, const LVector4 &y, const LVector4 &z); void set_uv_range_cube(int face); void set_uv_range(const Texture *tex); INLINE void set_has_uvs(bool flag); INLINE void set_has_3d_uvs(bool flag); - INLINE void set_frame(float left, float right, float bottom, float top); - INLINE void set_frame(const LVecBase4f &frame); - INLINE void set_frame(const Vertexf &ll, const Vertexf &lr, const Vertexf &ur, const Vertexf &ul); + INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_frame(const LVecBase4 &frame); + INLINE void set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul); INLINE void set_frame_fullscreen_quad(); - INLINE void set_color(float r, float g, float b, float a); - INLINE void set_color(const Colorf &color); + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_color(const LColor &color); INLINE void set_has_normals(bool flag); - INLINE void set_source_geometry(PandaNode *node, const LVecBase4f &frame); + INLINE void set_source_geometry(PandaNode *node, const LVecBase4 &frame); INLINE void clear_source_geometry(); PT(PandaNode) generate(); @@ -64,16 +64,16 @@ private: PT(PandaNode) rescale_source_geometry(); bool _has_uvs, _has_3d_uvs; - Vertexf _ul_tex, _ll_tex, _lr_tex, _ur_tex; - TexCoord3f _ul_pos, _ll_pos, _lr_pos, _ur_pos; + LVertex _ul_tex, _ll_tex, _lr_tex, _ur_tex; + LTexCoord3 _ul_pos, _ll_pos, _lr_pos, _ur_pos; bool _has_color; - Colorf _color; + LColor _color; bool _has_normals; PT(PandaNode) _source_geometry; - LVecBase4f _source_frame; + LVecBase4 _source_frame; }; #include "cardMaker.I" diff --git a/panda/src/grutil/fisheyeMaker.I b/panda/src/grutil/fisheyeMaker.I index 22b4f6637d..1a57b8167e 100644 --- a/panda/src/grutil/fisheyeMaker.I +++ b/panda/src/grutil/fisheyeMaker.I @@ -64,7 +64,7 @@ set_num_vertices(int num_vertices) { // artifacts due to numerical imprecision when mapping. //////////////////////////////////////////////////////////////////// INLINE void FisheyeMaker:: -set_square_inscribed(bool square_inscribed, float square_radius) { +set_square_inscribed(bool square_inscribed, PN_stdfloat square_radius) { _square_inscribed = square_inscribed; _square_radius = square_radius; } diff --git a/panda/src/grutil/fisheyeMaker.cxx b/panda/src/grutil/fisheyeMaker.cxx index bfbdfbe1c1..43b78d3035 100644 --- a/panda/src/grutil/fisheyeMaker.cxx +++ b/panda/src/grutil/fisheyeMaker.cxx @@ -48,7 +48,7 @@ reset() { // field of view (and this is the default). //////////////////////////////////////////////////////////////////// void FisheyeMaker:: -set_fov(float fov) { +set_fov(PN_stdfloat fov) { _fov = fov; _half_fov_rad = deg_2_rad(_fov * 0.5f); } @@ -84,8 +84,8 @@ generate() { // number of vertices per square unit is (_num_vertices / pi), and // thus the number of vertices per linear unit is the square root of // that. - float vertices_per_unit = csqrt(_num_vertices / MathNumbers::pi_f); - float two_pi = 2.0f * MathNumbers::pi_f; + PN_stdfloat vertices_per_unit = csqrt(_num_vertices / MathNumbers::pi_f); + PN_stdfloat two_pi = 2.0f * MathNumbers::pi_f; // The rose will be made up of concentric rings, originating from // the center, to a radius of 1.0. @@ -94,9 +94,9 @@ generate() { CPT(GeomVertexFormat) format = GeomVertexFormat::register_format (new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - Geom::NT_float32, Geom::C_point, + Geom::NT_stdfloat, Geom::C_point, InternalName::get_texcoord(), 3, - Geom::NT_float32, Geom::C_texcoord)); + Geom::NT_stdfloat, Geom::C_texcoord)); PT(GeomVertexData) vdata = new GeomVertexData(get_name(), format, Geom::UH_static); @@ -111,14 +111,14 @@ generate() { int last_ring_size = 3; int last_ring_vertex = 0; - float last_r = 1.0f / (float)num_rings; + PN_stdfloat last_r = 1.0f / (PN_stdfloat)num_rings; // Make the first triangle. We actually make a one-triangle strip, // but that seems more sensible than making a single isolated // triangle. for (int vi = 0; vi < last_ring_size; ++vi) { add_vertex(vertex, texcoord, last_r, - two_pi * (float)vi / (float)last_ring_size); + two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); tristrips->add_vertex(vi); } // Actually, we need to add one more degenerate triangle to make it @@ -128,10 +128,10 @@ generate() { // Now make all of the rings. for (int ri = 1; ri < num_rings; ++ri) { - float r = (float)(ri + 1) / (float)num_rings; + PN_stdfloat r = (PN_stdfloat)(ri + 1) / (PN_stdfloat)num_rings; // The circumference of a ring of radius r is 2*pi*r. - float c = two_pi * r; + PN_stdfloat c = two_pi * r; int ring_size = (int)floor(c * vertices_per_unit + 0.5f); // Each ring must either have exactly the same number of vertices @@ -168,7 +168,7 @@ generate() { last_ring_vertex = 0; for (int vi = 0; vi < last_ring_size; ++vi) { add_vertex(vertex, texcoord, last_r, - two_pi * (float)vi / (float)last_ring_size); + two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); } } @@ -176,7 +176,7 @@ generate() { int ring_vertex = vdata->get_num_rows(); for (int vi = 0; vi < ring_size; ++vi) { add_vertex(vertex, texcoord, r, - two_pi * (float)vi / (float)ring_size); + two_pi * (PN_stdfloat)vi / (PN_stdfloat)ring_size); } // Now draw the triangle strip to connect the rings. @@ -277,7 +277,7 @@ generate() { last_ring_vertex = 0; for (int vi = 0; vi < last_ring_size; ++vi) { add_vertex(vertex, texcoord, last_r, - two_pi * (float)vi / (float)last_ring_size); + two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); } } @@ -285,7 +285,7 @@ generate() { int ring_vertex = vdata->get_num_rows(); for (int vi = 0; vi < ring_size; ++vi) { add_square_vertex(vertex, texcoord, - two_pi * (float)vi / (float)ring_size); + two_pi * (PN_stdfloat)vi / (PN_stdfloat)ring_size); } // Now draw the triangle strip to connect the rings. @@ -346,28 +346,28 @@ generate() { //////////////////////////////////////////////////////////////////// void FisheyeMaker:: add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, - float r, float a) { - float sina, cosa; + PN_stdfloat r, PN_stdfloat a) { + PN_stdfloat sina, cosa; csincos(a, &sina, &cosa); // The 2-d point is just a point r units from the center of the // circle. - LPoint3f point(r * cosa, 0.0f, r * sina); - vertex.add_data3f(point); + LPoint3 point(r * cosa, 0.0f, r * sina); + vertex.add_data3(point); // The 3-d point is the same thing, bent through the third dimension // around the surface of a sphere to the point in the back. - float b = r * _half_fov_rad; + PN_stdfloat b = r * _half_fov_rad; if (b >= MathNumbers::pi_f) { // Special case: we want to stop at the back pole, not continue // around it. - texcoord.add_data3f(0, _reflect, 0); + texcoord.add_data3(0, _reflect, 0); } else { - float sinb, cosb; + PN_stdfloat sinb, cosb; csincos(b, &sinb, &cosb); - LPoint3f tc(sinb * cosa, cosb * _reflect, sinb * sina); - texcoord.add_data3f(tc); + LPoint3 tc(sinb * cosa, cosb * _reflect, sinb * sina); + texcoord.add_data3(tc); } } @@ -384,25 +384,25 @@ add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, //////////////////////////////////////////////////////////////////// void FisheyeMaker:: add_square_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, - float a) { - float sina, cosa; + PN_stdfloat a) { + PN_stdfloat sina, cosa; csincos(a, &sina, &cosa); // Extend the 2-d point to the edge of the square of the indicated // size. if (cabs(sina) > cabs(cosa)) { - float y = (sina > 0.0f) ? _square_radius : -_square_radius; - float x = y * cosa / sina; - LPoint3f point(x, 0.0f, y); - vertex.add_data3f(point); + PN_stdfloat y = (sina > 0.0f) ? _square_radius : -_square_radius; + PN_stdfloat x = y * cosa / sina; + LPoint3 point(x, 0.0f, y); + vertex.add_data3(point); } else { - float x = (cosa > 0.0f) ? _square_radius : -_square_radius; - float y = x * sina / cosa; - LPoint3f point(x, 0.0f, y); - vertex.add_data3f(point); + PN_stdfloat x = (cosa > 0.0f) ? _square_radius : -_square_radius; + PN_stdfloat y = x * sina / cosa; + LPoint3 point(x, 0.0f, y); + vertex.add_data3(point); } - texcoord.add_data3f(0, _reflect, 0); + texcoord.add_data3(0, _reflect, 0); } diff --git a/panda/src/grutil/fisheyeMaker.h b/panda/src/grutil/fisheyeMaker.h index 425882575b..2d8d8f6694 100644 --- a/panda/src/grutil/fisheyeMaker.h +++ b/panda/src/grutil/fisheyeMaker.h @@ -42,26 +42,26 @@ PUBLISHED: INLINE ~FisheyeMaker(); void reset(); - void set_fov(float fov); + void set_fov(PN_stdfloat fov); INLINE void set_num_vertices(int num_vertices); - INLINE void set_square_inscribed(bool square_inscribed, float square_radius); + INLINE void set_square_inscribed(bool square_inscribed, PN_stdfloat square_radius); INLINE void set_reflection(bool reflection); PT(PandaNode) generate(); private: void add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, - float r, float a); + PN_stdfloat r, PN_stdfloat a); void add_square_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, - float a); + PN_stdfloat a); - float _fov; - float _half_fov_rad; + PN_stdfloat _fov; + PN_stdfloat _half_fov_rad; int _num_vertices; bool _square_inscribed; - float _square_radius; - float _reflect; + PN_stdfloat _square_radius; + PN_stdfloat _reflect; }; #include "fisheyeMaker.I" diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 129d2c33f2..fb5b82f0e1 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -45,16 +45,16 @@ FrameRateMeter(const string &name) : TextNode(name) { // The top of the visible frame is 80% of the line height, based on // the calculation within TextAssembler. - float height = 1.0f; + PN_stdfloat height = 1.0f; TextFont *font = get_font(); if (font != NULL){ height = font->get_line_height() * 0.8; } set_align(A_right); - set_transform(LMatrix4f::scale_mat(frame_rate_meter_scale) * - LMatrix4f::translate_mat(LVector3f::rfu(1.0f - frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, 1.0f - frame_rate_meter_scale * height))); - set_card_color(0.0f, 0.0f, 0.0f, 0.4f); + set_transform(LMatrix4::scale_mat(frame_rate_meter_scale) * + LMatrix4::translate_mat(LVector3::rfu(1.0f - frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, 1.0f - frame_rate_meter_scale * height))); + set_card_color(0.0f, 0.0f, 0.0f, 0.4); set_card_as_margin(frame_rate_meter_side_margins, frame_rate_meter_side_margins, 0.1f, 0.0f); // set_usage_hint(Geom::UH_client); @@ -104,10 +104,10 @@ setup_window(GraphicsOutput *window) { PT(Lens) lens = new OrthographicLens; - static const float left = -1.0f; - static const float right = 1.0f; - static const float bottom = -1.0f; - static const float top = 1.0f; + static const PN_stdfloat left = -1.0f; + static const PN_stdfloat right = 1.0f; + static const PN_stdfloat bottom = -1.0f; + static const PN_stdfloat top = 1.0f; lens->set_film_size(right - left, top - bottom); lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5); lens->set_near_far(-1000, 1000); diff --git a/panda/src/grutil/geoMipTerrain.I b/panda/src/grutil/geoMipTerrain.I index c3ec8f8a09..a3e6a560ab 100644 --- a/panda/src/grutil/geoMipTerrain.I +++ b/panda/src/grutil/geoMipTerrain.I @@ -293,7 +293,7 @@ is_dirty() { // The default value is 100. //////////////////////////////////////////////////////////////////// INLINE void GeoMipTerrain:: -set_factor(float factor) { +set_factor(PN_stdfloat factor) { grutil_cat.debug() << "Using deprecated method set_factor, use set_near and set_far instead!\n"; _use_near_far = false; _factor = factor; @@ -401,7 +401,7 @@ get_block_node_path(unsigned short mx, unsigned short my) { // the block index of the block which you can use // in GeoMipTerrain::get_block_node_path. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f GeoMipTerrain:: +INLINE LVecBase2 GeoMipTerrain:: get_block_from_pos(double x, double y) { if (x < 0) x = 0; if (y < 0) y = 0; @@ -409,7 +409,7 @@ get_block_from_pos(double x, double y) { if (y > _ysize - 1) y = _ysize - 1; x = floor(x / _block_size); y = floor(y / _block_size); - return LVecBase2f(x, y); + return LVecBase2(x, y); } //////////////////////////////////////////////////////////////////// // Function: GeoMipTerrain::lod_decide @@ -418,11 +418,11 @@ get_block_from_pos(double x, double y) { //////////////////////////////////////////////////////////////////// INLINE unsigned short GeoMipTerrain:: lod_decide(unsigned short mx, unsigned short my) { - float cx = mx; - float cy = my; + PN_stdfloat cx = mx; + PN_stdfloat cy = my; cx = (cx * _block_size + _block_size / 2) * _root.get_sx(); cy = (cy * _block_size + _block_size / 2) * _root.get_sy(); - float d; + PN_stdfloat d; if (_use_near_far) { d = sqrt(pow(_focal_point.get_x(_root) - cx, 2) + pow(_focal_point.get_y(_root) - cy, 2)); @@ -604,7 +604,7 @@ get_pixel_value(unsigned short mx, unsigned short my, int x, int y) { // accurate normals, please divide it by the // terrain scale and normalize it again! //////////////////////////////////////////////////////////////////// -INLINE LVector3f GeoMipTerrain:: +INLINE LVector3 GeoMipTerrain:: get_normal(unsigned short mx, unsigned short my, int x, int y) { nassertr_always(mx < (_xsize - 1) / _block_size, false); nassertr_always(my < (_ysize - 1) / _block_size, false); diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 3942a44d5b..2398e56e4b 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -56,14 +56,14 @@ generate_block(unsigned short mx, PT(GeomVertexArrayFormat) array = new GeomVertexArrayFormat(); if (_has_color_map) { array->add_column(InternalName::make("color"), 4, - Geom::NT_float32, Geom::C_color); + Geom::NT_stdfloat, Geom::C_color); } array->add_column(InternalName::make("vertex"), 3, - Geom::NT_float32, Geom::C_point); + Geom::NT_stdfloat, Geom::C_point); array->add_column(InternalName::make("texcoord"), 2, - Geom::NT_float32, Geom::C_texcoord); + Geom::NT_stdfloat, Geom::C_texcoord); array->add_column(InternalName::make("normal"), 3, - Geom::NT_float32, Geom::C_vector); + Geom::NT_stdfloat, Geom::C_vector); PT(GeomVertexFormat) format = new GeomVertexFormat(); format->add_array(array); @@ -117,12 +117,12 @@ generate_block(unsigned short mx, / double(_xsize) * _color_map.get_x_size()), int((my * _block_size + y) / double(_ysize) * _color_map.get_y_size())); - cwriter.add_data4f(LCAST(float, color)); + cwriter.add_data4(LCAST(PN_stdfloat, color)); } - vwriter.add_data3f(x - 0.5 * _block_size, y - 0.5 * _block_size, get_pixel_value(mx, my, x, y)); - twriter.add_data2f((mx * _block_size + x) / double(_xsize - 1), + vwriter.add_data3(x - 0.5 * _block_size, y - 0.5 * _block_size, get_pixel_value(mx, my, x, y)); + twriter.add_data2((mx * _block_size + x) / double(_xsize - 1), (my * _block_size + y) / double(_ysize - 1)); - nwriter.add_data3f(get_normal(mx, my, x, y)); + nwriter.add_data3(get_normal(mx, my, x, y)); if (x > 0 && y > 0) { // Left border if (x == level && ljunction) { @@ -132,7 +132,7 @@ generate_block(unsigned short mx, prim->add_vertex(vcounter); prim->close_primitive(); } - if (f_part((y / level) / float(pow(2.0, int(lnlevel - reallevel)))) == 0.5) { + if (f_part((y / level) / PN_stdfloat(pow(2.0, int(lnlevel - reallevel)))) == 0.5) { prim->add_vertex(min(max(sfav(y / level + 1, lnlevel, reallevel), 0), lowblocksize - 1)); prim->add_vertex(min(max(sfav(y / level - 1, lnlevel, reallevel), 0), lowblocksize - 1)); prim->add_vertex(vcounter); @@ -173,7 +173,7 @@ generate_block(unsigned short mx, prim->add_vertex(vcounter - 1); prim->close_primitive(); } - if (f_part((y / level) / float(pow(2.0, int(rnlevel - reallevel)))) == 0.5) { + if (f_part((y / level) / PN_stdfloat(pow(2.0, int(rnlevel - reallevel)))) == 0.5) { prim->add_vertex(lowblocksize * (lowblocksize - 1) + min(max(sfav(y / level - 1, rnlevel, reallevel), 0), lowblocksize - 1)); prim->add_vertex(lowblocksize * (lowblocksize - 1) + min(max(sfav(y / level + 1, rnlevel, reallevel), 0), lowblocksize - 1)); prim->add_vertex(vcounter); @@ -188,7 +188,7 @@ generate_block(unsigned short mx, prim->add_vertex(min(max(sfav(x / level, bnlevel, reallevel), 0), lowblocksize - 1) * lowblocksize); prim->close_primitive(); } - if (f_part((x / level) / float(pow(2.0, int(bnlevel - reallevel)))) == 0.5) { + if (f_part((x / level) / PN_stdfloat(pow(2.0, int(bnlevel - reallevel)))) == 0.5) { prim->add_vertex(min(max(sfav(x / level - 1, bnlevel, reallevel), 0), lowblocksize - 1) * lowblocksize); prim->add_vertex(min(max(sfav(x / level + 1, bnlevel, reallevel), 0), lowblocksize - 1) * lowblocksize); prim->add_vertex(vcounter); @@ -229,7 +229,7 @@ generate_block(unsigned short mx, prim->add_vertex(vcounter); prim->close_primitive(); } - if (f_part((x / level) / float(pow(2.0, int(tnlevel - reallevel)))) == 0.5) { + if (f_part((x / level) / PN_stdfloat(pow(2.0, int(tnlevel - reallevel)))) == 0.5) { prim->add_vertex(min(max(sfav(x / level + 1, tnlevel, reallevel), 0), lowblocksize - 1) * lowblocksize + lowblocksize - 1); prim->add_vertex(min(max(sfav(x / level - 1, tnlevel, reallevel), 0), lowblocksize - 1) * lowblocksize + lowblocksize - 1); prim->add_vertex(vcounter); @@ -305,13 +305,13 @@ get_elevation(double x, double y) { // accurate normals, please divide it by the // terrain scale and normalize it again, like this: // -// LVector3f normal (terr.get_normal(x, y)); +// LVector3 normal (terr.get_normal(x, y)); // normal.set(normal.get_x() / root.get_sx(), // normal.get_y() / root.get_sy(), // normal.get_z() / root.get_sz()); // normal.normalize(); //////////////////////////////////////////////////////////////////// -LVector3f GeoMipTerrain:: +LVector3 GeoMipTerrain:: get_normal(int x, int y) { int nx = x - 1; int px = x + 1; @@ -323,7 +323,7 @@ get_normal(int x, int y) { if (py >= int(_ysize)) py--; double drx = get_pixel_value(px, y) - get_pixel_value(nx, y); double dry = get_pixel_value(x, py) - get_pixel_value(x, ny); - LVector3f normal(drx * 0.5, dry * 0.5, 1); + LVector3 normal(drx * 0.5, dry * 0.5, 1); normal.normalize(); return normal; @@ -350,12 +350,12 @@ make_slope_image() { result.make_grayscale(); for (unsigned int x = 0; x < _xsize; ++x) { for (unsigned int y = 0; y < _ysize; ++y) { - LVector3f normal (get_normal(x, y)); + LVector3 normal (get_normal(x, y)); normal.set(normal.get_x() / _root.get_sx(), normal.get_y() / _root.get_sy(), normal.get_z() / _root.get_sz()); normal.normalize(); - result.set_xel(x, y, normal.angle_deg(LVector3f::up()) / 90.0); + result.set_xel(x, y, normal.angle_deg(LVector3::up()) / 90.0); } } return result; @@ -371,7 +371,7 @@ make_slope_image() { // You need to call this before generating the geometry. //////////////////////////////////////////////////////////////////// void GeoMipTerrain:: -calc_ambient_occlusion(float radius, float contrast, float brightness) { +calc_ambient_occlusion(PN_stdfloat radius, PN_stdfloat contrast, PN_stdfloat brightness) { _color_map = PNMImage(_xsize, _ysize); _color_map.make_grayscale(); _color_map.set_maxval(_heightfield.get_maxval()); diff --git a/panda/src/grutil/geoMipTerrain.h b/panda/src/grutil/geoMipTerrain.h index 45be5cb39f..8c4b2dd5f4 100644 --- a/panda/src/grutil/geoMipTerrain.h +++ b/panda/src/grutil/geoMipTerrain.h @@ -54,10 +54,10 @@ PUBLISHED: INLINE bool set_color_map(const string &path); INLINE bool has_color_map() const; INLINE void clear_color_map(); - void calc_ambient_occlusion(float radius = 32, float contrast = 2.0f, float brightness = 0.75f); + void calc_ambient_occlusion(PN_stdfloat radius = 32, PN_stdfloat contrast = 2.0f, PN_stdfloat brightness = 0.75f); double get_elevation(double x, double y); - LVector3f get_normal(int x, int y); - INLINE LVector3f get_normal(unsigned short mx, unsigned short my, + LVector3 get_normal(int x, int y); + INLINE LVector3 get_normal(unsigned short mx, unsigned short my, int x,int y); INLINE void set_bruteforce(bool bf); INLINE bool get_bruteforce(); @@ -96,13 +96,13 @@ PUBLISHED: INLINE void set_min_level(unsigned short minlevel); INLINE unsigned short get_min_level(); INLINE bool is_dirty(); - INLINE void set_factor(float factor); + INLINE void set_factor(PN_stdfloat factor); INLINE void set_near_far(double input_near, double input_far); INLINE void set_near(double input_near); INLINE void set_far(double input_far); INLINE const NodePath get_block_node_path(unsigned short mx, unsigned short my); - INLINE LVecBase2f get_block_from_pos(double x, double y); + INLINE LVecBase2 get_block_from_pos(double x, double y); INLINE void set_border_stitching(bool stitching); INLINE bool get_border_stitching(); INLINE double get_far(); @@ -140,7 +140,7 @@ private: bool _has_color_map; unsigned int _xsize; unsigned int _ysize; - float _factor; + PN_stdfloat _factor; double _near; double _far; bool _use_near_far; // False to use the _factor, True to use the _near and _far values. diff --git a/panda/src/grutil/heightfieldTesselator.cxx b/panda/src/grutil/heightfieldTesselator.cxx index 69da06a643..4bc32174f0 100644 --- a/panda/src/grutil/heightfieldTesselator.cxx +++ b/panda/src/grutil/heightfieldTesselator.cxx @@ -120,11 +120,11 @@ get_vertex(int x, int y) { if (py >= _heightfield.get_y_size()) py--; double drx = _heightfield.get_gray(px,y) - _heightfield.get_gray(nx,y); double dry = _heightfield.get_gray(x,py) - _heightfield.get_gray(x,ny); - LVector3f normal(drx * _vertical_scale * 0.5, dry * _vertical_scale * 0.5, _horizontal_scale); + LVector3 normal(drx * _vertical_scale * 0.5, dry * _vertical_scale * 0.5, _horizontal_scale); normal.normalize(); double z = _heightfield.get_gray(x,y); - _vertex_writer->add_data3f(x*_horizontal_scale,-y*_horizontal_scale,z*_vertical_scale); - _normal_writer->add_data3f(normal); + _vertex_writer->add_data3(x*_horizontal_scale,-y*_horizontal_scale,z*_vertical_scale); + _normal_writer->add_data3(normal); vtx = _next_index++; _dirty_vertices[vtx] = x+y*xsize; _vertex_index[x+y*xsize] = vtx; diff --git a/panda/src/grutil/lineSegs.I b/panda/src/grutil/lineSegs.I index 2c78a60a30..94291b54de 100644 --- a/panda/src/grutil/lineSegs.I +++ b/panda/src/grutil/lineSegs.I @@ -27,7 +27,7 @@ Point() { // Description: //////////////////////////////////////////////////////////////////// INLINE LineSegs::Point:: -Point(const LVecBase3f &point, const Colorf &color) : +Point(const LVecBase3 &point, const LColor &color) : _point(point[0], point[1], point[2]), _color(color) { @@ -65,7 +65,7 @@ operator = (const LineSegs::Point ©) { // draw_to(). //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -set_color(float r, float g, float b, float a) { +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { _color.set(r, g, b, a); } @@ -77,7 +77,7 @@ set_color(float r, float g, float b, float a) { // draw_to(). //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; } @@ -89,7 +89,7 @@ set_color(const Colorf &color) { // created by future calls to create(). //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -set_thickness(float thick) { +set_thickness(PN_stdfloat thick) { _thick = thick; } @@ -102,8 +102,8 @@ set_thickness(float thick) { // move_to() or create(), this creates a single point. //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -move_to(float x, float y, float z) { - move_to(Vertexf(x, y, z)); +move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + move_to(LVertex(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -116,8 +116,8 @@ move_to(float x, float y, float z) { // is called. //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -draw_to(float x, float y, float z) { - draw_to(Vertexf(x, y, z)); +draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + draw_to(LVertex(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -165,8 +165,8 @@ get_num_vertices() const { // higher vertex numbers. //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -set_vertex(int n, float x, float y, float z) { - set_vertex(n, Vertexf(x, y, z)); +set_vertex(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_vertex(n, LVertex(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -176,6 +176,6 @@ set_vertex(int n, float x, float y, float z) { // See set_vertex(). //////////////////////////////////////////////////////////////////// INLINE void LineSegs:: -set_vertex_color(int n, float r, float g, float b, float a) { - set_vertex_color(n, Colorf(r, g, b, a)); +set_vertex_color(int n, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_vertex_color(n, LColor(r, g, b, a)); } diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index d6196560ac..dfd6bd3d89 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -69,7 +69,7 @@ reset() { // move_to() or create(), this creates a single point. //////////////////////////////////////////////////////////////////// void LineSegs:: -move_to(const LVecBase3f &v) { +move_to(const LVecBase3 &v) { // We create a new SegmentList with the initial point in it. SegmentList segs; segs.push_back(Point(v, _color)); @@ -88,7 +88,7 @@ move_to(const LVecBase3f &v) { // is called. //////////////////////////////////////////////////////////////////// void LineSegs:: -draw_to(const LVecBase3f &v) { +draw_to(const LVecBase3 &v) { if (_list.empty()) { // Let our first call to draw_to() be an implicit move_to(). move_to(v); @@ -124,12 +124,12 @@ is_empty() { // move_to() and draw_to() calls generate consecutively // higher vertex numbers. //////////////////////////////////////////////////////////////////// -Vertexf LineSegs:: +LVertex LineSegs:: get_vertex(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, Vertexf::zero()); + nassertr(_created_data != (GeomVertexData *)NULL, LVertex::zero()); GeomVertexReader vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); - return vertex.get_data3f(); + return vertex.get_data3(); } //////////////////////////////////////////////////////////////////// @@ -142,11 +142,11 @@ get_vertex(int n) const { // higher vertex numbers. //////////////////////////////////////////////////////////////////// void LineSegs:: -set_vertex(int n, const Vertexf &vert) { +set_vertex(int n, const LVertex &vert) { nassertv(_created_data != (GeomVertexData *)NULL); GeomVertexWriter vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); - vertex.set_data3f(vert); + vertex.set_data3(vert); } //////////////////////////////////////////////////////////////////// @@ -154,12 +154,12 @@ set_vertex(int n, const Vertexf &vert) { // Access: Public // Description: Returns the color of the nth point or vertex. //////////////////////////////////////////////////////////////////// -Colorf LineSegs:: +LColor LineSegs:: get_vertex_color(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, Colorf::zero()); + nassertr(_created_data != (GeomVertexData *)NULL, LColor::zero()); GeomVertexReader color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); - return color.get_data4f(); + return color.get_data4(); } //////////////////////////////////////////////////////////////////// @@ -169,11 +169,11 @@ get_vertex_color(int n) const { // See set_vertex(). //////////////////////////////////////////////////////////////////// void LineSegs:: -set_vertex_color(int n, const Colorf &c) { +set_vertex_color(int n, const LColor &c) { nassertv(_created_data != (GeomVertexData *)NULL); GeomVertexWriter color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); - color.set_data4f(c); + color.set_data4(c); } //////////////////////////////////////////////////////////////////// @@ -182,11 +182,11 @@ set_vertex_color(int n, const Colorf &c) { // Description: Returns the pen's current position. The next call to // draw_to() will draw a line segment from this point. //////////////////////////////////////////////////////////////////// -const Vertexf &LineSegs:: +const LVertex &LineSegs:: get_current_position() { if (_list.empty()) { // Our pen isn't anywhere. We'll put it somewhere. - move_to(Vertexf(0.0f, 0.0f, 0.0f)); + move_to(LVertex(0.0f, 0.0f, 0.0f)); } return _list.back().back()._point; @@ -233,8 +233,8 @@ create(GeomNode *previous, bool dynamic) { // A segment of length 1 is just a point. for (sl = segs.begin(); sl != segs.end(); sl++) { points->add_vertex(v); - vertex.add_data3f((*sl)._point); - color.add_data4f((*sl)._color); + vertex.add_data3((*sl)._point); + color.add_data4((*sl)._color); v++; } points->close_primitive(); @@ -244,8 +244,8 @@ create(GeomNode *previous, bool dynamic) { // segments. for (sl = segs.begin(); sl != segs.end(); sl++) { lines->add_vertex(v); - vertex.add_data3f((*sl)._point); - color.add_data4f((*sl)._color); + vertex.add_data3((*sl)._point); + color.add_data4((*sl)._color); v++; } lines->close_primitive(); diff --git a/panda/src/grutil/lineSegs.h b/panda/src/grutil/lineSegs.h index 28880a7aed..81524a8c94 100644 --- a/panda/src/grutil/lineSegs.h +++ b/panda/src/grutil/lineSegs.h @@ -39,17 +39,17 @@ PUBLISHED: ~LineSegs(); void reset(); - INLINE void set_color(float r, float g, float b, float a = 1.0f); - INLINE void set_color(const Colorf &color); - INLINE void set_thickness(float thick); + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f); + INLINE void set_color(const LColor &color); + INLINE void set_thickness(PN_stdfloat thick); - INLINE void move_to(float x, float y, float z); - void move_to(const LVecBase3f &v); + INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void move_to(const LVecBase3 &v); - INLINE void draw_to(float x, float y, float z); - void draw_to(const LVecBase3f &v); + INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void draw_to(const LVecBase3 &v); - const Vertexf &get_current_position(); + const LVertex &get_current_position(); bool is_empty(); INLINE GeomNode *create(bool dynamic = false); @@ -57,34 +57,34 @@ PUBLISHED: // Functions to move the line vertices after they have been created. INLINE int get_num_vertices() const; - Vertexf get_vertex(int n) const; + LVertex get_vertex(int n) const; MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); - void set_vertex(int n, const Vertexf &vert); - INLINE void set_vertex(int vertex, float x, float y, float z); + void set_vertex(int n, const LVertex &vert); + INLINE void set_vertex(int vertex, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); - Colorf get_vertex_color(int vertex) const; + LColor get_vertex_color(int vertex) const; MAKE_SEQ(get_vertex_colors, get_num_vertices, get_vertex_color); - void set_vertex_color(int vertex, const Colorf &c); - INLINE void set_vertex_color(int vertex, float r, float g, float b, float a = 1.0f); + void set_vertex_color(int vertex, const LColor &c); + INLINE void set_vertex_color(int vertex, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0f); private: class Point { public: INLINE Point(); - INLINE Point(const LVecBase3f &point, const Colorf &color); + INLINE Point(const LVecBase3 &point, const LColor &color); INLINE Point(const Point ©); INLINE void operator = (const Point ©); - Vertexf _point; - Colorf _color; + LVertex _point; + LColor _color; }; typedef pvector SegmentList; typedef pvector LineList; LineList _list; - Colorf _color; - float _thick; + LColor _color; + PN_stdfloat _thick; PT(GeomVertexData) _created_data; }; diff --git a/panda/src/grutil/meshDrawer.I b/panda/src/grutil/meshDrawer.I index d777914fd1..1b22a93462 100644 --- a/panda/src/grutil/meshDrawer.I +++ b/panda/src/grutil/meshDrawer.I @@ -86,23 +86,23 @@ get_budget() { // Access: Published // Description: Draws a triangle with the given parameters. //////////////////////////////////////////////////////////////////// -INLINE void MeshDrawer::tri(LVector3f v1, LVector4f c1, LVector2f uv1, - LVector3f v2, LVector4f c2, LVector2f uv2, - LVector3f v3, LVector4f c3, LVector2f uv3) { +INLINE void MeshDrawer::tri(LVector3 v1, LVector4 c1, LVector2 uv1, + LVector3 v2, LVector4 c2, LVector2 uv2, + LVector3 v3, LVector4 c3, LVector2 uv3) { if( _clear_index > _end_clear_index) return; - _vertex->add_data3f(v1); - _color->add_data4f(c1); - _uv->add_data2f(uv1); + _vertex->add_data3(v1); + _color->add_data4(c1); + _uv->add_data2(uv1); - _vertex->add_data3f(v2); - _color->add_data4f(c2); - _uv->add_data2f(uv2); + _vertex->add_data3(v2); + _color->add_data4(c2); + _uv->add_data2(uv2); - _vertex->add_data3f(v3); - _color->add_data4f(c3); - _uv->add_data2f(uv3); + _vertex->add_data3(v3); + _color->add_data4(c3); + _uv->add_data2(uv3); _clear_index += 1; } diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index 5f0c6fa8c3..5d508ee2cb 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -33,8 +33,8 @@ TypeHandle MeshDrawer::_type_handle; -float randFloat() { - return ((float) rand() / (float) 0x7fffffff); +PN_stdfloat randFloat() { + return ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff); } //////////////////////////////////////////////////////////////////// @@ -55,13 +55,13 @@ void MeshDrawer::generator(int budget) { // not be optimized out by panda3d system for(int i = 0; i < budget; i++) { for( int vert = 0; vert < 3; vert++) { - LVector3f vec3 = LVector3f(randFloat()+1000,randFloat(),randFloat())*.001; - LVector4f vec4 = LVector4f(1,1,1,randFloat()); - LVector2f vec2 = LVector2f(0,randFloat()); - tvertex->add_data3f(vec3); - tcolor->add_data4f(vec4); - tuv->add_data2f(vec2); - tnormal->add_data3f(vec3); + LVector3 vec3 = LVector3(randFloat()+1000,randFloat(),randFloat())*.001; + LVector4 vec4 = LVector4(1,1,1,randFloat()); + LVector2 vec2 = LVector2(0,randFloat()); + tvertex->add_data3(vec3); + tcolor->add_data4(vec4); + tuv->add_data2(vec2); + tnormal->add_data3(vec3); } _prim->add_vertices(i * 3, i * 3 + 1, i * 3 + 2); } @@ -98,8 +98,8 @@ void MeshDrawer::begin(NodePath camera, NodePath render) { // compute some help vectors _eyePos = camera.get_pos(); - _up = _render.get_relative_vector(camera, LVector3f(0, 0, 1)); - _right = _render.get_relative_vector(camera, LVector3f(1, 0, 0)); + _up = _render.get_relative_vector(camera, LVector3(0, 0, 1)); + _right = _render.get_relative_vector(camera, LVector3(1, 0, 0)); _b1 = - _right - _up; _b2 = _right - _up; _b3 = _right + _up; @@ -133,9 +133,9 @@ void MeshDrawer::end() { // clear the unused triangles at the end of the buffer for(int i = _clear_index ; i < _last_clear_index; i ++ ) { - _vertex->add_data3f(0,0,0); - _vertex->add_data3f(0,0,0); - _vertex->add_data3f(0,0,0); + _vertex->add_data3(0,0,0); + _vertex->add_data3(0,0,0); + _vertex->add_data3(0,0,0); } // don't clear more then you have too _last_clear_index = _clear_index; @@ -155,29 +155,29 @@ void MeshDrawer::end() { // but has an extra rotation component. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::particle(LVector3f pos, LVector4f frame, float size, - LVector4f color, float rotation) { +void MeshDrawer::particle(LVector3 pos, LVector4 frame, PN_stdfloat size, + LVector4 color, PN_stdfloat rotation) { rotation = rotation / 57.29578; - LVector3f v1 = pos + _b1*size*sin(rotation) + _b2*size*cos(rotation); - LVector3f v2 = pos + _b2*size*sin(rotation) + _b3*size*cos(rotation); - LVector3f v3 = pos + _b3*size*sin(rotation) + _b4*size*cos(rotation); - LVector3f v4 = pos + _b4*size*sin(rotation) + _b1*size*cos(rotation); + LVector3 v1 = pos + _b1*size*sin(rotation) + _b2*size*cos(rotation); + LVector3 v2 = pos + _b2*size*sin(rotation) + _b3*size*cos(rotation); + LVector3 v3 = pos + _b3*size*sin(rotation) + _b4*size*cos(rotation); + LVector3 v4 = pos + _b4*size*sin(rotation) + _b1*size*cos(rotation); - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); tri( - v1, color, LVector2f(u,v), - v2, color, LVector2f(u+us,v), - v3, color, LVector2f(u+us,v+vs)); + v1, color, LVector2(u,v), + v2, color, LVector2(u+us,v), + v3, color, LVector2(u+us,v+vs)); tri( - v3, color, LVector2f(u+us,v+vs), - v4, color, LVector2f(u,v+vs), - v1, color, LVector2f(u,v)); + v3, color, LVector2(u+us,v+vs), + v4, color, LVector2(u,v+vs), + v1, color, LVector2(u,v)); } //////////////////////////////////////////////////////////////////// @@ -187,10 +187,10 @@ void MeshDrawer::particle(LVector3f pos, LVector4f frame, float size, // a blend (from 0 to 1) component between them // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::blended_particle(LVector3f pos, LVector4f frame1, - LVector4f frame2, float blend, float size, LVector4f color, float rotation) { +void MeshDrawer::blended_particle(LVector3 pos, LVector4 frame1, + LVector4 frame2, PN_stdfloat blend, PN_stdfloat size, LVector4 color, PN_stdfloat rotation) { - float original_w = color.get_w(); + PN_stdfloat original_w = color.get_w(); color.set_w((1.f-blend)*original_w); particle(pos,frame1,size,color,rotation); color.set_w(blend*original_w); @@ -205,27 +205,27 @@ void MeshDrawer::blended_particle(LVector3f pos, LVector4f frame1, // Billboards always face the camera. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::billboard(LVector3f pos, LVector4f frame, float size, - LVector4f _color) { +void MeshDrawer::billboard(LVector3 pos, LVector4 frame, PN_stdfloat size, + LVector4 _color) { - LVector3f v1 = pos + _b1*size; - LVector3f v2 = pos + _b2*size; - LVector3f v3 = pos + _b3*size; - LVector3f v4 = pos + _b4*size; + LVector3 v1 = pos + _b1*size; + LVector3 v2 = pos + _b2*size; + LVector3 v3 = pos + _b3*size; + LVector3 v4 = pos + _b4*size; - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); tri( - v1, _color, LVector2f(u,v), - v2, _color, LVector2f(u+us,v), - v3, _color, LVector2f(u+us,v+vs)); + v1, _color, LVector2(u,v), + v2, _color, LVector2(u+us,v), + v3, _color, LVector2(u+us,v+vs)); tri( - v3, _color, LVector2f(u+us,v+vs), - v4, _color, LVector2f(u,v+vs), - v1, _color, LVector2f(u,v)); + v3, _color, LVector2(u+us,v+vs), + v4, _color, LVector2(u,v+vs), + v1, _color, LVector2(u,v)); } @@ -236,8 +236,8 @@ void MeshDrawer::billboard(LVector3f pos, LVector4f frame, float size, // billboarding effect. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::segment(LVector3f start, LVector3f stop, LVector4f frame, - float thickness, LVector4f color) { +void MeshDrawer::segment(LVector3 start, LVector3 stop, LVector4 frame, + PN_stdfloat thickness, LVector4 color) { link_segment(start, frame, thickness, color); link_segment(stop, frame, thickness, color); link_segment_end(frame, color); @@ -251,37 +251,37 @@ void MeshDrawer::segment(LVector3f start, LVector3f stop, LVector4f frame, // Stars at start and ends at stop. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::cross_segment(LVector3f start, LVector3f stop, LVector4f frame, - float thickness, LVector4f color) { +void MeshDrawer::cross_segment(LVector3 start, LVector3 stop, LVector4 frame, + PN_stdfloat thickness, LVector4 color) { - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); - LVector3f v1 = start - _up*thickness; - LVector3f v2 = stop - _up*thickness; - LVector3f v3 = stop + _up*thickness; - LVector3f v4 = start + _up*thickness; + LVector3 v1 = start - _up*thickness; + LVector3 v2 = stop - _up*thickness; + LVector3 v3 = stop + _up*thickness; + LVector3 v4 = start + _up*thickness; - tri(v1, color, LVector2f(u,v), - v2, color, LVector2f(u+us,v), - v3, color, LVector2f(u+us,v+vs)); - tri(v3, color, LVector2f(u+us,v+vs), - v4, color, LVector2f(u,v+vs), - v1, color, LVector2f(u,v)); + tri(v1, color, LVector2(u,v), + v2, color, LVector2(u+us,v), + v3, color, LVector2(u+us,v+vs)); + tri(v3, color, LVector2(u+us,v+vs), + v4, color, LVector2(u,v+vs), + v1, color, LVector2(u,v)); v1 = start - _right*thickness; v2 = stop - _right*thickness; v3 = stop + _right*thickness; v4 = start + _right*thickness; - tri(v1, color, LVector2f(u,v), - v2, color, LVector2f(u+us,v), - v3, color, LVector2f(u+us,v+vs)); - tri(v3, color, LVector2f(u+us,v+vs), - v4, color, LVector2f(u,v+vs), - v1, color, LVector2f(u,v)); + tri(v1, color, LVector2(u,v), + v2, color, LVector2(u+us,v), + v3, color, LVector2(u+us,v+vs)); + tri(v3, color, LVector2(u+us,v+vs), + v4, color, LVector2(u,v+vs), + v1, color, LVector2(u,v)); } @@ -296,38 +296,38 @@ void MeshDrawer::cross_segment(LVector3f start, LVector3f stop, LVector4f frame, // Stars at start and ends at stop. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::uneven_segment(LVector3f start, LVector3f stop, - LVector4f frame, float thickness_start, LVector4f color_start, - float thickness_stop, LVector4f color_stop) { +void MeshDrawer::uneven_segment(LVector3 start, LVector3 stop, + LVector4 frame, PN_stdfloat thickness_start, LVector4 color_start, + PN_stdfloat thickness_stop, LVector4 color_stop) { - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); - LVector3f v1 = start - _up*thickness_start; - LVector3f v2 = stop - _up*thickness_stop; - LVector3f v3 = stop + _up*thickness_stop; - LVector3f v4 = start + _up*thickness_start; + LVector3 v1 = start - _up*thickness_start; + LVector3 v2 = stop - _up*thickness_stop; + LVector3 v3 = stop + _up*thickness_stop; + LVector3 v4 = start + _up*thickness_start; - tri(v1, color_start, LVector2f(u,v), - v2, color_stop, LVector2f(u+us,v), - v3, color_stop, LVector2f(u+us,v+vs)); - tri(v3, color_stop, LVector2f(u+us,v+vs), - v4, color_start, LVector2f(u,v+vs), - v1, color_start, LVector2f(u,v)); + tri(v1, color_start, LVector2(u,v), + v2, color_stop, LVector2(u+us,v), + v3, color_stop, LVector2(u+us,v+vs)); + tri(v3, color_stop, LVector2(u+us,v+vs), + v4, color_start, LVector2(u,v+vs), + v1, color_start, LVector2(u,v)); v1 = start - _right*thickness_start; v2 = stop - _right*thickness_stop; v3 = stop + _right*thickness_stop; v4 = start + _right*thickness_start; - tri(v1, color_start, LVector2f(u,v), - v2, color_stop, LVector2f(u+us,v), - v3, color_stop, LVector2f(u+us,v+vs)); - tri(v3, color_stop, LVector2f(u+us,v+vs), - v4, color_start, LVector2f(u,v+vs), - v1, color_start, LVector2f(u,v)); + tri(v1, color_start, LVector2(u,v), + v2, color_stop, LVector2(u+us,v), + v3, color_stop, LVector2(u+us,v+vs)); + tri(v3, color_stop, LVector2(u+us,v+vs), + v4, color_start, LVector2(u,v+vs), + v1, color_start, LVector2(u,v)); } //////////////////////////////////////////////////////////////////// @@ -337,12 +337,12 @@ void MeshDrawer::uneven_segment(LVector3f start, LVector3f stop, // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// void MeshDrawer::explosion( - LVector3f pos, LVector4f frame, float size, LVector4f _color, - int seed, int number, float distance) { + LVector3 pos, LVector4 frame, PN_stdfloat size, LVector4 _color, + int seed, int number, PN_stdfloat distance) { srand(seed); - LVector3f relative_pos; + LVector3 relative_pos; for(int i = 0; i < number; i++) { - relative_pos = LVector3f(randFloat()-.5f,randFloat()-.5f,randFloat()-.5f); + relative_pos = LVector3(randFloat()-.5f,randFloat()-.5f,randFloat()-.5f); relative_pos.normalize(); relative_pos *= randFloat()*distance; particle(relative_pos+pos,frame,size,_color,randFloat()*360.0f); @@ -356,15 +356,15 @@ void MeshDrawer::explosion( // shift dictated by the offset. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::stream(LVector3f start, LVector3f stop, LVector4f frame, float size, LVector4f _color, - int number, float offset) { +void MeshDrawer::stream(LVector3 start, LVector3 stop, LVector4 frame, PN_stdfloat size, LVector4 _color, + int number, PN_stdfloat offset) { offset = offset-floor(offset); - LVector3f relative_pos = stop; - LVector3f vec = stop - start; - float distance = vec.length(); + LVector3 relative_pos = stop; + LVector3 vec = stop - start; + PN_stdfloat distance = vec.length(); for(int i = 0; i < number; i++) { - relative_pos = stop + vec * ((i-offset)*(distance/float(number))); + relative_pos = stop + vec * ((i-offset)*(distance/PN_stdfloat(number))); billboard(relative_pos,frame,size,_color); } } @@ -384,9 +384,9 @@ void MeshDrawer::stream(LVector3f start, LVector3f stop, LVector4f frame, float void MeshDrawer::geometry(NodePath draw_node) { assert(_render.get_error_type() == NodePath::ET_ok); - LVector4f color = LVector4f(1,1,1,1); - LVector3f vec[3]; - LVector2f uv[3]; + LVector4 color = LVector4(1,1,1,1); + LVector3 vec[3]; + LVector2 uv[3]; // process node NodePathCollection geom_collection = draw_node.find_all_matches("**/+GeomNode"); @@ -416,8 +416,8 @@ void MeshDrawer::geometry(NodePath draw_node) { prim_vertex_reader->set_row_unsafe(vidx); prim_uv_reader->set_row_unsafe(vidx); vec[indx_over] = _render.get_relative_point( - current_node_path,prim_vertex_reader->get_data3f()); - uv[indx_over] = prim_uv_reader->get_data2f(); + current_node_path,prim_vertex_reader->get_data3()); + uv[indx_over] = prim_uv_reader->get_data2(); indx_over++; if (indx_over > 2) break; } @@ -448,8 +448,8 @@ void MeshDrawer::geometry(NodePath draw_node) { // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// void MeshDrawer:: -link_segment(LVector3f pos, LVector4f frame, - float thickness, LVector4f color) { +link_segment(LVector3 pos, LVector4 frame, + PN_stdfloat thickness, LVector4 color) { assert(_render.get_error_type() == NodePath::ET_ok); assert(_camera.get_error_type() == NodePath::ET_ok); /* @@ -477,13 +477,13 @@ link_segment(LVector3f pos, LVector4f frame, return; } - LVector3f start = _last_pos; - LVector3f stop = pos; + LVector3 start = _last_pos; + LVector3 stop = pos; - LVector3f cam_start3d = _camera.get_relative_point(_render, start); - LPoint2f cam_start2d = LVector2f(); - LVector3f cam_stop3d = _camera.get_relative_point(_render, stop); - LPoint2f cam_stop2d = LVector2f(); + LVector3 cam_start3d = _camera.get_relative_point(_render, start); + LPoint2 cam_start2d = LVector2(); + LVector3 cam_stop3d = _camera.get_relative_point(_render, stop); + LPoint2 cam_stop2d = LVector2(); PT(Camera) camera = DCAST(Camera, _camera.node()); PT(Lens) lens = camera->get_lens(); @@ -491,13 +491,13 @@ link_segment(LVector3f pos, LVector4f frame, lens->project(cam_start3d, cam_start2d); lens->project(cam_stop3d, cam_stop2d); - LVector2f dif = cam_stop2d - cam_start2d; - float rotation = atan2(dif.get_x(),dif.get_y()); + LVector2 dif = cam_stop2d - cam_start2d; + PN_stdfloat rotation = atan2(dif.get_x(),dif.get_y()); - LVector3f now_v1 = start + _b1*(float)(thickness*sin(rotation)) + _b2*(float)(thickness*cos(rotation)); - LVector3f now_v4 = start + _b4*(float)(thickness*sin(rotation)) + _b1*(float)(thickness*cos(rotation)); - LVector3f now_v2 = stop + _b2*(float)(thickness*sin(rotation)) + _b3*(float)(thickness*cos(rotation)); - LVector3f now_v3 = stop + _b3*(float)(thickness*sin(rotation)) + _b4*(float)(thickness*cos(rotation)); + LVector3 now_v1 = start + _b1*(PN_stdfloat)(thickness*sin(rotation)) + _b2*(PN_stdfloat)(thickness*cos(rotation)); + LVector3 now_v4 = start + _b4*(PN_stdfloat)(thickness*sin(rotation)) + _b1*(PN_stdfloat)(thickness*cos(rotation)); + LVector3 now_v2 = stop + _b2*(PN_stdfloat)(thickness*sin(rotation)) + _b3*(PN_stdfloat)(thickness*cos(rotation)); + LVector3 now_v3 = stop + _b3*(PN_stdfloat)(thickness*sin(rotation)) + _b4*(PN_stdfloat)(thickness*cos(rotation)); // mark the segment we going to draw // we need to draw it when we know what the next segment looks like @@ -512,23 +512,23 @@ link_segment(LVector3f pos, LVector4f frame, } // draw the last segment a little bent - LVector3f v1 = _last_v1; - LVector3f v2 = (_last_v2+now_v1)/2.0f; - LVector3f v3 = (_last_v3+now_v4)/2.0f; - LVector3f v4 = _last_v4; + LVector3 v1 = _last_v1; + LVector3 v2 = (_last_v2+now_v1)/2.0f; + LVector3 v3 = (_last_v3+now_v4)/2.0f; + LVector3 v4 = _last_v4; // compute this frame - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); - tri(v1, _last_color, LVector2f(u,v), - v2, color, LVector2f(u+us,v), - v3, color, LVector2f(u+us,v+vs)); - tri(v3, color, LVector2f(u+us,v+vs), - v4, _last_color, LVector2f(u,v+vs), - v1, _last_color, LVector2f(u,v)); + tri(v1, _last_color, LVector2(u,v), + v2, color, LVector2(u+us,v), + v3, color, LVector2(u+us,v+vs)); + tri(v3, color, LVector2(u+us,v+vs), + v4, _last_color, LVector2(u,v+vs), + v1, _last_color, LVector2(u,v)); // save this segment _last_v1 = v2; @@ -550,19 +550,19 @@ link_segment(LVector3f pos, LVector4f frame, // the linked segment. // Frame contains u,v,u-size,v-size quadruple. //////////////////////////////////////////////////////////////////// -void MeshDrawer::link_segment_end(LVector4f frame, LVector4f color) +void MeshDrawer::link_segment_end(LVector4 frame, LVector4 color) { - float u = frame.get_x(); - float v = frame.get_y(); - float us = frame.get_z(); - float vs = frame.get_w(); + PN_stdfloat u = frame.get_x(); + PN_stdfloat v = frame.get_y(); + PN_stdfloat us = frame.get_z(); + PN_stdfloat vs = frame.get_w(); - tri(_last_v1, _last_color, LVector2f(u,v), - _last_v2, color, LVector2f(u+us,v), - _last_v3, color, LVector2f(u+us,v+vs)); - tri(_last_v3, color, LVector2f(u+us,v+vs), - _last_v4, _last_color, LVector2f(u,v+vs), - _last_v1, _last_color, LVector2f(u,v)); + tri(_last_v1, _last_color, LVector2(u,v), + _last_v2, color, LVector2(u+us,v), + _last_v3, color, LVector2(u+us,v+vs)); + tri(_last_v3, color, LVector2(u+us,v+vs), + _last_v4, _last_color, LVector2(u,v+vs), + _last_v1, _last_color, LVector2(u,v)); _at_start = 0; } diff --git a/panda/src/grutil/meshDrawer.h b/panda/src/grutil/meshDrawer.h index 17b7dcab2e..34d206e84d 100644 --- a/panda/src/grutil/meshDrawer.h +++ b/panda/src/grutil/meshDrawer.h @@ -66,27 +66,27 @@ PUBLISHED: INLINE NodePath get_root(); void begin(NodePath camera, NodePath render); - INLINE void tri(LVector3f v1, LVector4f c1, LVector2f uv1, - LVector3f v2, LVector4f c2, LVector2f uv2, - LVector3f v3, LVector4f c3, LVector2f uv3); + INLINE void tri(LVector3 v1, LVector4 c1, LVector2 uv1, + LVector3 v2, LVector4 c2, LVector2 uv2, + LVector3 v3, LVector4 c3, LVector2 uv3); - void particle(LVector3f pos, LVector4f frame, float size, LVector4f color, float rotation); - void blended_particle(LVector3f pos, LVector4f frame1, LVector4f frame2, - float blend, float size, LVector4f color, float rotation); - void billboard(LVector3f pos, LVector4f frame, float size, LVector4f color); - void segment(LVector3f start, LVector3f stop, LVector4f frame, float thickness, LVector4f color); - void cross_segment(LVector3f start, LVector3f stop, LVector4f frame, float thickness, LVector4f color); - void uneven_segment(LVector3f start, LVector3f stop, - LVector4f frame, float thickness_start, LVector4f color_start, - float thickness_stop, LVector4f color_stop); + void particle(LVector3 pos, LVector4 frame, PN_stdfloat size, LVector4 color, PN_stdfloat rotation); + void blended_particle(LVector3 pos, LVector4 frame1, LVector4 frame2, + PN_stdfloat blend, PN_stdfloat size, LVector4 color, PN_stdfloat rotation); + void billboard(LVector3 pos, LVector4 frame, PN_stdfloat size, LVector4 color); + void segment(LVector3 start, LVector3 stop, LVector4 frame, PN_stdfloat thickness, LVector4 color); + void cross_segment(LVector3 start, LVector3 stop, LVector4 frame, PN_stdfloat thickness, LVector4 color); + void uneven_segment(LVector3 start, LVector3 stop, + LVector4 frame, PN_stdfloat thickness_start, LVector4 color_start, + PN_stdfloat thickness_stop, LVector4 color_stop); - void link_segment(LVector3f pos, LVector4f frame, float thickness, LVector4f color); - void link_segment_end(LVector4f frame, LVector4f color); + void link_segment(LVector3 pos, LVector4 frame, PN_stdfloat thickness, LVector4 color); + void link_segment_end(LVector4 frame, LVector4 color); - void explosion(LVector3f pos, LVector4f frame, float size, LVector4f color, - int seed, int number, float distance); - void stream(LVector3f start, LVector3f stop, LVector4f frame, float size, LVector4f color, - int number, float offset); + void explosion(LVector3 pos, LVector4 frame, PN_stdfloat size, LVector4 color, + int seed, int number, PN_stdfloat distance); + void stream(LVector3 start, LVector3 stop, LVector4 frame, PN_stdfloat size, LVector4 color, + int number, PN_stdfloat offset); void geometry(NodePath node); void end(); @@ -111,20 +111,20 @@ private: GeomVertexRewriter *_color; // billboard vectors - LVector4f _colorv; - LVector3f _normalv; - LVector3f _eyePos; - LVector3f _b1, _b2, _b3, _b4; - LVector3f _up, _right; + LVector4 _colorv; + LVector3 _normalv; + LVector3 _eyePos; + LVector3 _b1, _b2, _b3, _b4; + LVector3 _up, _right; // clear indexes int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index; // used for curves int _at_start; - LVector3f _last_v1,_last_v2,_last_v3,_last_v4,_last_pos; - float _last_thickness; - LVector4f _last_color; + LVector3 _last_v1,_last_v2,_last_v3,_last_v4,_last_pos; + PN_stdfloat _last_thickness; + LVector4 _last_color; // bounding volume PT(BoundingVolume) _bv; diff --git a/panda/src/grutil/meshDrawer2D.I b/panda/src/grutil/meshDrawer2D.I index ab47fdef91..154a39f986 100644 --- a/panda/src/grutil/meshDrawer2D.I +++ b/panda/src/grutil/meshDrawer2D.I @@ -84,7 +84,7 @@ get_budget() { // Description: Sets clipping rectangle //////////////////////////////////////////////////////////////////// INLINE void MeshDrawer2D:: -set_clip(float x, float y, float w, float h) { +set_clip(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h) { _clip_x = x; _clip_y = y; _clip_w = w; @@ -98,45 +98,45 @@ set_clip(float x, float y, float w, float h) { // Ignores the cliping rectangle //////////////////////////////////////////////////////////////////// INLINE void MeshDrawer2D:: -quad_raw(LVector3f v1, LVector4f c1, LVector2f uv1, - LVector3f v2, LVector4f c2, LVector2f uv2, - LVector3f v3, LVector4f c3, LVector2f uv3, - LVector3f v4, LVector4f c4, LVector2f uv4 +quad_raw(LVector3 v1, LVector4 c1, LVector2 uv1, + LVector3 v2, LVector4 c2, LVector2 uv2, + LVector3 v3, LVector4 c3, LVector2 uv3, + LVector3 v4, LVector4 c4, LVector2 uv4 ) { if( _clear_index > _end_clear_index) return; - _vertex->add_data3f(v1); - _color->add_data4f(c1); - _uv->add_data2f(uv1); + _vertex->add_data3(v1); + _color->add_data4(c1); + _uv->add_data2(uv1); - _vertex->add_data3f(v2); - _color->add_data4f(c2); - _uv->add_data2f(uv2); + _vertex->add_data3(v2); + _color->add_data4(c2); + _uv->add_data2(uv2); - _vertex->add_data3f(v3); - _color->add_data4f(c3); - _uv->add_data2f(uv3); + _vertex->add_data3(v3); + _color->add_data4(c3); + _uv->add_data2(uv3); - _vertex->add_data3f(v4); - _color->add_data4f(c4); - _uv->add_data2f(uv4); + _vertex->add_data3(v4); + _color->add_data4(c4); + _uv->add_data2(uv4); _clear_index += 1; } INLINE void MeshDrawer2D:: -rectangle_raw(float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color +rectangle_raw(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color ) { quad_raw( - LVector3f(x, 0, y), color, LVector2f(u , v), - LVector3f(x, 0, y+h), color, LVector2f(u , v+vs), - LVector3f(x+w, 0, y), color, LVector2f(u+us, v), - LVector3f(x+w, 0, y+h), color, LVector2f(u+us, v+vs) + LVector3(x, 0, y), color, LVector2(u , v), + LVector3(x, 0, y+h), color, LVector2(u , v+vs), + LVector3(x+w, 0, y), color, LVector2(u+us, v), + LVector3(x+w, 0, y+h), color, LVector2(u+us, v+vs) ); } @@ -146,9 +146,9 @@ rectangle_raw(float x, float y, float w, float h, // Description: Draws a 2d rectangle, that can be cliped //////////////////////////////////////////////////////////////////// INLINE void MeshDrawer2D:: -rectangle(float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color +rectangle(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color ) { if( w == 0 && h == 0 ) return; // no size return @@ -159,9 +159,9 @@ rectangle(float x, float y, float w, float h, // the rectange fits but it might need to be cliped - float x_uv_ratio = us/w; - float y_uv_ratio = vs/h; - float dt = 0; + PN_stdfloat x_uv_ratio = us/w; + PN_stdfloat y_uv_ratio = vs/h; + PN_stdfloat dt = 0; if (x < _clip_x){ // clip right diff --git a/panda/src/grutil/meshDrawer2D.cxx b/panda/src/grutil/meshDrawer2D.cxx index 6dce3e49be..acee6f51e5 100644 --- a/panda/src/grutil/meshDrawer2D.cxx +++ b/panda/src/grutil/meshDrawer2D.cxx @@ -34,7 +34,7 @@ TypeHandle MeshDrawer2D::_type_handle; -#define RANDF ((float) rand() / (float) 0x7fffffff) +#define RANDF ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff) //////////////////////////////////////////////////////////////////// @@ -55,13 +55,13 @@ void MeshDrawer2D::generator(int budget) { for(int i = 0; i < budget; i++) { for( int vert = 0; vert < 4; vert++) { - LVector3f vec3 = LVector3f(RANDF+10000,RANDF,RANDF); - LVector4f vec4 = LVector4f(RANDF,RANDF,RANDF,0); - LVector2f vec2 = LVector2f(RANDF,RANDF); + LVector3 vec3 = LVector3(RANDF+10000,RANDF,RANDF); + LVector4 vec4 = LVector4(RANDF,RANDF,RANDF,0); + LVector2 vec2 = LVector2(RANDF,RANDF); - tvertex->add_data3f(vec3); - tcolor->add_data4f(vec4); - tuv->add_data2f(vec2); + tvertex->add_data3(vec3); + tcolor->add_data4(vec4); + tuv->add_data2(vec2); } @@ -120,10 +120,10 @@ void MeshDrawer2D::end() { // clear the unused triangles at the end of the buffer for(int i = _clear_index ; i < _last_clear_index; i ++ ) { - _vertex->add_data3f(0,0,0); - _vertex->add_data3f(0,0,0); - _vertex->add_data3f(0,0,0); - _vertex->add_data3f(0,0,0); + _vertex->add_data3(0,0,0); + _vertex->add_data3(0,0,0); + _vertex->add_data3(0,0,0); + _vertex->add_data3(0,0,0); } // don't clear more then you have too _last_clear_index = _clear_index; @@ -144,22 +144,22 @@ void MeshDrawer2D::end() { // us and vs //////////////////////////////////////////////////////////////////// void MeshDrawer2D:: -rectangle_tiled(float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color +rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color ) { - float x_fit = w/us; - float y_fit = h/vs; - float x_pos = x; + PN_stdfloat x_fit = w/us; + PN_stdfloat y_fit = h/vs; + PN_stdfloat x_pos = x; while (x_fit > 0){ - float y_pos = y; + PN_stdfloat y_pos = y; y_fit = h/vs; while (y_fit > 0){ - float fixed_us = us; - float fixed_vs = vs; + PN_stdfloat fixed_us = us; + PN_stdfloat fixed_vs = vs; // we are cuttin in the middle of a tile x direction if (x_fit < 1){ @@ -198,11 +198,11 @@ rectangle_tiled(float x, float y, float w, float h, //////////////////////////////////////////////////////////////////// void MeshDrawer2D:: rectangle_border( - float x, float y, float w, float h, - float r, float t, float l, float b, - float tr, float tt, float tl, float tb, - float u, float v, float us, float vs, - LVector4f color){ + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b, + PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color){ rectangle(x,y,w,h,u,v,us,vs,color); // center @@ -230,11 +230,11 @@ rectangle_border( //////////////////////////////////////////////////////////////////// void MeshDrawer2D:: rectangle_border_tiled( - float x, float y, float w, float h, - float r, float t, float l, float b, - float tr, float tt, float tl, float tb, - float u, float v, float us, float vs, - LVector4f color){ + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b, + PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color){ rectangle_tiled(x,y,w,h,u,v,us,vs,color); // center diff --git a/panda/src/grutil/meshDrawer2D.h b/panda/src/grutil/meshDrawer2D.h index bd47606b26..50eb679429 100644 --- a/panda/src/grutil/meshDrawer2D.h +++ b/panda/src/grutil/meshDrawer2D.h @@ -56,41 +56,41 @@ PUBLISHED: INLINE NodePath get_root(); INLINE void quad_raw( - LVector3f v1, LVector4f c1, LVector2f uv1, - LVector3f v2, LVector4f c2, LVector2f uv2, - LVector3f v3, LVector4f c3, LVector2f uv3, - LVector3f v4, LVector4f c4, LVector2f uv4); + LVector3 v1, LVector4 c1, LVector2 uv1, + LVector3 v2, LVector4 c2, LVector2 uv2, + LVector3 v3, LVector4 c3, LVector2 uv3, + LVector3 v4, LVector4 c4, LVector2 uv4); INLINE void rectangle_raw( - float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color); - INLINE void set_clip(float x, float y, float w, float h); + INLINE void set_clip(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h); INLINE void rectangle( - float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color); void rectangle_border( - float x, float y, float w, float h, - float r, float t, float l, float b, - float tr, float tt, float tl, float tb, - float u, float v, float us, float vs, - LVector4f color); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b, + PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color); void rectangle_border_tiled( - float x, float y, float w, float h, - float r, float t, float l, float b, - float tr, float tt, float tl, float tb, - float u, float v, float us, float vs, - LVector4f color); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b, + PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color); void rectangle_tiled( - float x, float y, float w, float h, - float u, float v, float us, float vs, - LVector4f color); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, + PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, + LVector4 color); void begin(); void end(); @@ -102,10 +102,10 @@ private: int _budget; // clip - float _clip_x; - float _clip_y; - float _clip_w; - float _clip_h; + PN_stdfloat _clip_x; + PN_stdfloat _clip_y; + PN_stdfloat _clip_w; + PN_stdfloat _clip_h; // store regeneration geoms & nodes PT(Geom) _geom; diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 032b273f5b..c727b9858b 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -250,13 +250,13 @@ flatten(GraphicsOutput *window) { Texture::FilterType magfilter = model_tex->get_magfilter(); // What is the UV range of the model stage? - TexCoordf min_uv, max_uv; + LTexCoord min_uv, max_uv; determine_uv_range(min_uv, max_uv, model_stage, geom_list); // Maybe we only use a small portion of the texture, or maybe we // need to repeat the texture several times. - LVecBase2f uv_scale; - LVecBase2f uv_trans; + LVecBase2 uv_scale; + LVecBase2 uv_trans; get_uv_scale(uv_scale, uv_trans, min_uv, max_uv); // Also, if there is now a scale on the UV's (in conjunction with @@ -294,7 +294,7 @@ flatten(GraphicsOutput *window) { lens->set_film_size(1.0f, 1.0f); lens->set_film_offset(0.5f, 0.5f); lens->set_near_far(-1000.0f, 1000.0f); - lens->set_view_mat(LMatrix4f(uv_scale[0], 0.0f, 0.0, 0.0f, + lens->set_view_mat(LMatrix4(uv_scale[0], 0.0f, 0.0, 0.0f, 0.0f, 1.0f, 0.0, 0.0f, 0.0f, 0.0f, uv_scale[1], 0.0f, uv_trans[0], 0.0f, uv_trans[1], 1.0f)); @@ -316,11 +316,11 @@ flatten(GraphicsOutput *window) { // might prefer not to). bool force_use_geom = _use_geom; bool bake_in_color = _use_geom; - Colorf geom_color(1.0f, 1.0f, 1.0f, 1.0f); + LColor geom_color(1.0f, 1.0f, 1.0f, 1.0f); //override the base color in the transparent pass down case. if(use_transparent_bg) - geom_color = Colorf(0.0f,0.0f,0.0f,0.0f); + geom_color = LColor(0.0f,0.0f,0.0f,0.0f); if (!force_use_geom) { bool uses_decal = scan_decal(stage_list); @@ -387,7 +387,7 @@ flatten(GraphicsOutput *window) { if (bake_in_color) { // If we have baked the color into the texture, we have to be // sure to disable coloring on the new fragment. - geom_state = geom_state->add_attrib(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 1.0f, 1.0f))); + geom_state = geom_state->add_attrib(ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 1.0f))); // And we invent a ColorScaleAttrib to undo the effect of any // color scale we're getting from above. This is not the same @@ -414,9 +414,9 @@ flatten(GraphicsOutput *window) { } tex_mat = tex_mat->compose(TransformState::make_pos_hpr_scale - (LVecBase3f(uv_trans[0], uv_trans[1], 0.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(uv_scale[0], uv_scale[1], 1.0f))); + (LVecBase3(uv_trans[0], uv_trans[1], 0.0f), + LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(uv_scale[0], uv_scale[1], 1.0f))); if (tex_mat->is_identity()) { // There should be no texture matrix on the Geom. @@ -584,7 +584,7 @@ choose_model_stage(const MultitexReducer::StageList &stage_list) const { // if any UV's are found, false otherwise. //////////////////////////////////////////////////////////////////// bool MultitexReducer:: -determine_uv_range(TexCoordf &min_uv, TexCoordf &max_uv, +determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, const MultitexReducer::StageInfo &model_stage, const MultitexReducer::GeomList &geom_list) const { const InternalName *model_name = model_stage._stage->get_texcoord_name(); @@ -603,7 +603,7 @@ determine_uv_range(TexCoordf &min_uv, TexCoordf &max_uv, GeomVertexReader texcoord(vdata, model_name); if (!texcoord.is_at_end()) { - const LVecBase2f &uv = texcoord.get_data2f(); + const LVecBase2 &uv = texcoord.get_data2(); if (!got_any) { min_uv = max_uv = uv; got_any = true; @@ -614,7 +614,7 @@ determine_uv_range(TexCoordf &min_uv, TexCoordf &max_uv, } while (!texcoord.is_at_end()) { - const LVecBase2f &uv = texcoord.get_data2f(); + const LVecBase2 &uv = texcoord.get_data2(); min_uv.set(min(min_uv[0], uv[0]), min(min_uv[1], uv[1])); max_uv.set(max(max_uv[0], uv[0]), max(max_uv[1], uv[1])); } @@ -642,8 +642,8 @@ determine_uv_range(TexCoordf &min_uv, TexCoordf &max_uv, // to include all of the repeating image. //////////////////////////////////////////////////////////////////// void MultitexReducer:: -get_uv_scale(LVecBase2f &uv_scale, LVecBase2f &uv_trans, - const TexCoordf &min_uv, const TexCoordf &max_uv) const { +get_uv_scale(LVecBase2 &uv_scale, LVecBase2 &uv_trans, + const LTexCoord &min_uv, const LTexCoord &max_uv) const { if (max_uv[0] != min_uv[0]) { uv_scale[0] = (max_uv[0] - min_uv[0]); } else { @@ -670,7 +670,7 @@ get_uv_scale(LVecBase2f &uv_scale, LVecBase2f &uv_trans, void MultitexReducer:: choose_texture_size(int &x_size, int &y_size, const MultitexReducer::StageInfo &model_stage, - const LVecBase2f &uv_scale, + const LVecBase2 &uv_scale, GraphicsOutput *window) const { Texture *model_tex = model_stage._tex; @@ -683,9 +683,9 @@ choose_texture_size(int &x_size, int &y_size, // should adjust the pixel size accordingly, although we have to // keep it to a power of 2. - LVecBase3f inherited_scale = model_stage._tex_mat->get_scale(); + LVecBase3 inherited_scale = model_stage._tex_mat->get_scale(); - float u_scale = cabs(inherited_scale[0]) * uv_scale[0]; + PN_stdfloat u_scale = cabs(inherited_scale[0]) * uv_scale[0]; if (u_scale != 0.0f) { while (u_scale >= 2.0f) { x_size *= 2; @@ -697,7 +697,7 @@ choose_texture_size(int &x_size, int &y_size, } } - float v_scale = cabs(inherited_scale[1]) * uv_scale[1]; + PN_stdfloat v_scale = cabs(inherited_scale[1]) * uv_scale[1]; if (v_scale != 0.0f) { while (v_scale >= 2.0f) { y_size *= 2; @@ -755,7 +755,7 @@ void MultitexReducer:: make_texture_layer(const NodePath &render, const MultitexReducer::StageInfo &stage_info, const MultitexReducer::GeomList &geom_list, - const TexCoordf &min_uv, const TexCoordf &max_uv, + const LTexCoord &min_uv, const LTexCoord &max_uv, bool force_use_geom, bool transparent_base) { CPT(RenderAttrib) cba; @@ -892,7 +892,7 @@ make_texture_layer(const NodePath &render, geom = render.attach_new_node(geom_node); - geom.set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + geom.set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } if (!stage_info._tex_mat->is_identity()) { @@ -940,8 +940,8 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, GeomVertexReader texcoord(vdata, _target_stage->get_texcoord_name(), current_thread); while (!texcoord.is_at_end()) { - const LVecBase2f &tc = texcoord.get_data2f(); - vertex.set_data3f(tc[0], 0.0f, tc[1]); + const LVecBase2 &tc = texcoord.get_data2(); + vertex.set_data3(tc[0], 0.0f, tc[1]); } } @@ -960,7 +960,7 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, GeomVertexReader from(vdata, texcoord_name, current_thread); GeomVertexWriter to(vdata, InternalName::get_texcoord(), current_thread); while (!from.is_at_end()) { - to.add_data2f(from.get_data2f()); + to.add_data2(from.get_data2()); } } } @@ -996,17 +996,17 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, // color in use. //////////////////////////////////////////////////////////////////// void MultitexReducer:: -scan_color(const MultitexReducer::GeomList &geom_list, Colorf &geom_color, +scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, int &num_colors) const { GeomList::const_iterator gi; for (gi = geom_list.begin(); gi != geom_list.end() && num_colors < 2; ++gi) { const GeomInfo &geom_info = (*gi); - Colorf flat_color; + LColor flat_color; bool has_flat_color = false; bool has_vertex_color = false; - Colorf color_scale(1.0f, 1.0f, 1.0f, 1.0f); + LColor color_scale(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *csa = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); if (csa != (const RenderAttrib *)NULL) { const ColorScaleAttrib *a = DCAST(ColorScaleAttrib, csa); diff --git a/panda/src/grutil/multitexReducer.h b/panda/src/grutil/multitexReducer.h index 8e9dbc1ea6..f5d054abd9 100644 --- a/panda/src/grutil/multitexReducer.h +++ b/panda/src/grutil/multitexReducer.h @@ -119,27 +119,27 @@ private: const GeomInfo &geom_info); size_t choose_model_stage(const StageList &stage_list) const; - bool determine_uv_range(TexCoordf &min_uv, TexCoordf &max_uv, + bool determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, const StageInfo &model_stage, const GeomList &geom_list) const; - void get_uv_scale(LVecBase2f &uv_scale, LVecBase2f &uv_trans, - const TexCoordf &min_uv, const TexCoordf &max_uv) const; + void get_uv_scale(LVecBase2 &uv_scale, LVecBase2 &uv_trans, + const LTexCoord &min_uv, const LTexCoord &max_uv) const; void choose_texture_size(int &x_size, int &y_size, const StageInfo &model_stage, - const LVecBase2f &uv_scale, + const LVecBase2 &uv_scale, GraphicsOutput *window) const; void make_texture_layer(const NodePath &render, const StageInfo &stage_info, const GeomList &geom_list, - const TexCoordf &min_uv, const TexCoordf &max_uv, + const LTexCoord &min_uv, const LTexCoord &max_uv, bool force_use_geom, bool transparent_base); void transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, const GeomList &geom_list, bool preserve_color); - void scan_color(const GeomList &geom_list, Colorf &geom_color, + void scan_color(const GeomList &geom_list, LColor &geom_color, int &num_colors) const; bool scan_decal(const StageList &stage_list) const; diff --git a/panda/src/grutil/nodeVertexTransform.I b/panda/src/grutil/nodeVertexTransform.I index e5119962bb..97e4da32b8 100644 --- a/panda/src/grutil/nodeVertexTransform.I +++ b/panda/src/grutil/nodeVertexTransform.I @@ -1,5 +1,5 @@ // Filename: nodeVertexTransform.I -// Created by: drose (22Feb07) +// Created by: drose (22eb07) // //////////////////////////////////////////////////////////////////// // diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index fbdb2db064..decfc95fb3 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -1,5 +1,5 @@ // Filename: nodeVertexTransform.cxx -// Created by: drose (22Feb07) +// Created by: drose (22eb07) // //////////////////////////////////////////////////////////////////// // @@ -37,9 +37,9 @@ NodeVertexTransform(const PandaNode *node, // expressed as a matrix. //////////////////////////////////////////////////////////////////// void NodeVertexTransform:: -get_matrix(LMatrix4f &matrix) const { +get_matrix(LMatrix4 &matrix) const { if (_prev != (const VertexTransform *)NULL) { - LMatrix4f prev_matrix; + LMatrix4 prev_matrix; _prev->get_matrix(prev_matrix); matrix.multiply(_node->get_transform()->get_mat(), prev_matrix); diff --git a/panda/src/grutil/nodeVertexTransform.h b/panda/src/grutil/nodeVertexTransform.h index 3faf1b9897..6b5652cadb 100644 --- a/panda/src/grutil/nodeVertexTransform.h +++ b/panda/src/grutil/nodeVertexTransform.h @@ -1,5 +1,5 @@ // Filename: nodeVertexTransform.h -// Created by: drose (22Feb07) +// Created by: drose (22eb07) // //////////////////////////////////////////////////////////////////// // @@ -38,7 +38,7 @@ PUBLISHED: INLINE const PandaNode *get_node() const; INLINE const VertexTransform *get_prev() const; - virtual void get_matrix(LMatrix4f &matrix) const; + virtual void get_matrix(LMatrix4 &matrix) const; virtual void output(ostream &out) const; diff --git a/panda/src/grutil/pfmFile.I b/panda/src/grutil/pfmFile.I index 3c60251ecf..9cbd4d0ab5 100755 --- a/panda/src/grutil/pfmFile.I +++ b/panda/src/grutil/pfmFile.I @@ -49,7 +49,7 @@ get_y_size() const { // Description: The "scale" is reported in the pfm header and is // probably meaningless. //////////////////////////////////////////////////////////////////// -INLINE float PfmFile:: +INLINE PN_stdfloat PfmFile:: get_scale() const { return _scale; } @@ -81,7 +81,7 @@ INLINE bool PfmFile:: has_point(int x, int y) const { if ((x >= 0 && x < _x_size) && (y >= 0 && y < _y_size)) { - return (!_zero_special || _table[y * _x_size + x] != LPoint3f::zero()); + return (!_zero_special || _table[y * _x_size + x] != LPoint3::zero()); } return false; } @@ -93,10 +93,10 @@ has_point(int x, int y) const { // point. In a 1-channel image, the channel value is in // the x component. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &PfmFile:: +INLINE const LPoint3 &PfmFile:: get_point(int x, int y) const { - nassertr(x >= 0 && x < _x_size, LPoint3f::zero()); - nassertr(y >= 0 && y < _y_size, LPoint3f::zero()); + nassertr(x >= 0 && x < _x_size, LPoint3::zero()); + nassertr(y >= 0 && y < _y_size, LPoint3::zero()); return _table[y * _x_size + x]; } @@ -108,7 +108,7 @@ get_point(int x, int y) const { // the x component. //////////////////////////////////////////////////////////////////// INLINE void PfmFile:: -set_point(int x, int y, const LVecBase3f &point) { +set_point(int x, int y, const LVecBase3 &point) { nassertv(x >= 0 && x < _x_size); nassertv(y >= 0 && y < _y_size); _table[y * _x_size + x] = point; @@ -120,10 +120,10 @@ set_point(int x, int y, const LVecBase3f &point) { // Description: Returns a modifiable 3-component point value at the // indicated point. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f &PfmFile:: +INLINE LPoint3 &PfmFile:: modify_point(int x, int y) { #ifndef NDEBUG - static LPoint3f dummy_value = LPoint3f::zero(); + static LPoint3 dummy_value = LPoint3::zero(); nassertr(x >= 0 && x < _x_size, dummy_value); nassertr(y >= 0 && y < _y_size, dummy_value); #endif diff --git a/panda/src/grutil/pfmFile.cxx b/panda/src/grutil/pfmFile.cxx index 0c409697f0..cff7c4c98a 100755 --- a/panda/src/grutil/pfmFile.cxx +++ b/panda/src/grutil/pfmFile.cxx @@ -106,7 +106,7 @@ clear(int x_size, int y_size, int num_channels) { _table.clear(); int size = _x_size * _y_size; - _table.insert(_table.end(), size, LPoint3f::zero()); + _table.insert(_table.end(), size, LPoint3::zero()); } //////////////////////////////////////////////////////////////////// @@ -164,7 +164,7 @@ read(istream &in) { } int width, height; - float scale; + PN_stdfloat scale; in >> width >> height >> scale; if (!in) { grutil_cat.error() @@ -200,7 +200,7 @@ read(istream &in) { if (little_endian) { for (int i = 0; i < size; ++i) { - LPoint3f point = LPoint3f::zero(); + LPoint3 point = LPoint3::zero(); for (int ci = 0; ci < _num_channels; ++ci) { PN_float32 data; in.read((char *)&data, sizeof(data)); @@ -213,7 +213,7 @@ read(istream &in) { } } else { for (int i = 0; i < size; ++i) { - LPoint3f point = LPoint3f::zero(); + LPoint3 point = LPoint3::zero(); for (int ci = 0; ci < _num_channels; ++ci) { PN_float32 data; in.read((char *)&data, sizeof(data)); @@ -275,7 +275,7 @@ write(ostream &out) { } out << _x_size << " " << _y_size << "\n"; - float scale = cabs(_scale); + PN_stdfloat scale = cabs(_scale); if (scale == 0.0f) { scale = 1.0f; } @@ -288,7 +288,7 @@ write(ostream &out) { int size = _x_size * _y_size; for (int i = 0; i < size; ++i) { - const LPoint3f &point = _table[i]; + const LPoint3 &point = _table[i]; for (int ci = 0; ci < _num_channels; ++ci) { PN_float32 data = point[ci]; out.write((const char *)&data, sizeof(data)); @@ -313,8 +313,8 @@ write(ostream &out) { // value cannot be determined. //////////////////////////////////////////////////////////////////// bool PfmFile:: -calc_average_point(LPoint3f &result, double x, double y, double radius) const { - result = LPoint3f::zero(); +calc_average_point(LPoint3 &result, double x, double y, double radius) const { + result = LPoint3::zero(); int min_x = int(ceil(x - radius)); int min_y = int(ceil(y - radius)); @@ -346,8 +346,8 @@ calc_average_point(LPoint3f &result, double x, double y, double radius) const { int xi, yi; for (yi = min_y; yi <= max_y; ++yi) { for (xi = min_x; xi <= max_x; ++xi) { - const LPoint3f &p = _table[yi * _x_size + xi]; - if (_zero_special && p == LPoint3f::zero()) { + const LPoint3 &p = _table[yi * _x_size + xi]; + if (_zero_special && p == LPoint3::zero()) { continue; } @@ -385,7 +385,7 @@ calc_average_point(LPoint3f &result, double x, double y, double radius) const { result += _table[ti]; } - result /= float(size); + result /= PN_stdfloat(size); return true; } @@ -399,16 +399,16 @@ calc_average_point(LPoint3f &result, double x, double y, double radius) const { // mesh contains no points. //////////////////////////////////////////////////////////////////// bool PfmFile:: -calc_min_max(LVecBase3f &min_depth, LVecBase3f &max_depth) const { +calc_min_max(LVecBase3 &min_depth, LVecBase3 &max_depth) const { bool any_points = false; - min_depth = LVecBase3f::zero(); - max_depth = LVecBase3f::zero(); + min_depth = LVecBase3::zero(); + max_depth = LVecBase3::zero(); Table::const_iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { - const LPoint3f &p = (*ti); - if (_zero_special && p == LPoint3f::zero()) { + const LPoint3 &p = (*ti); + if (_zero_special && p == LPoint3::zero()) { continue; } @@ -468,7 +468,7 @@ resize(int new_x_size, int new_y_size) { // Now the box from (from_x0, from_y0) - (from_x1, from_y1) // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). - LPoint3f result; + LPoint3 result; box_filter_region(result, from_x0, from_y0, from_x1, from_y1); new_data.push_back(result); @@ -511,12 +511,12 @@ reverse_rows() { // in-place. //////////////////////////////////////////////////////////////////// void PfmFile:: -xform(const LMatrix4f &transform) { +xform(const LMatrix4 &transform) { nassertv(is_valid()); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { - if (_zero_special && (*ti) == LPoint3f::zero()) { + if (_zero_special && (*ti) == LPoint3::zero()) { continue; } @@ -543,12 +543,12 @@ xform(const LMatrix4f &transform) { //////////////////////////////////////////////////////////////////// PT(BoundingHexahedron) PfmFile:: compute_planar_bounds(double point_dist, double sample_radius) const { - LPoint3f p0, p1, p2; + LPoint3 p0, p1, p2; compute_sample_point(p0, 0.5 + point_dist, 0.5 - point_dist, sample_radius); compute_sample_point(p1, 0.5 + point_dist, 0.5 + point_dist, sample_radius); compute_sample_point(p2, 0.5 - point_dist, 0.5 + point_dist, sample_radius); - LPoint3f normal; + LPoint3 normal; normal[0] = p0[1] * p1[2] - p0[2] * p1[1]; normal[1] = p0[2] * p1[0] - p0[0] * p1[2]; @@ -566,25 +566,25 @@ compute_planar_bounds(double point_dist, double sample_radius) const { // Compute the transform necessary to rotate all of the points into // the Y = 0 plane. - LMatrix4f rotate; + LMatrix4 rotate; look_at(rotate, normal, p1 - p0); - LMatrix4f rinv; + LMatrix4 rinv; rinv.invert_from(rotate); - LPoint3f trans = p0 * rinv; + LPoint3 trans = p0 * rinv; rinv.set_row(3, -trans); rotate.invert_from(rinv); // Now determine the minmax in the XZ plane. - float min_x, min_z, max_x, max_z; + PN_stdfloat min_x, min_z, max_x, max_z; bool got_point = false; Table::const_iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { - if (_zero_special && (*ti) == LPoint3f::zero()) { + if (_zero_special && (*ti) == LPoint3::zero()) { continue; } - LPoint3f point = (*ti) * rinv; + LPoint3 point = (*ti) * rinv; if (!got_point) { min_x = point[0]; min_z = point[2]; @@ -600,10 +600,10 @@ compute_planar_bounds(double point_dist, double sample_radius) const { } PT(BoundingHexahedron) bounds = new BoundingHexahedron - (LPoint3f(min_x, 0, min_z), LPoint3f(max_x, 0, min_z), - LPoint3f(min_x, 0, max_z), LPoint3f(max_x, 0, max_z), - LPoint3f(min_x, 0, min_z), LPoint3f(max_x, 0, min_z), - LPoint3f(min_x, 0, max_z), LPoint3f(max_x, 0, max_z)); + (LPoint3(min_x, 0, min_z), LPoint3(max_x, 0, min_z), + LPoint3(min_x, 0, max_z), LPoint3(max_x, 0, max_z), + LPoint3(min_x, 0, min_z), LPoint3(max_x, 0, min_z), + LPoint3(min_x, 0, max_z), LPoint3(max_x, 0, max_z)); // Rotate the bounding volume back into the original space of the // screen. @@ -633,9 +633,9 @@ generate_vis_points() const { // and it's 3-d. GeomVertexArrayFormat *v3t3 = new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - Geom::NT_float32, Geom::C_point, + Geom::NT_stdfloat, Geom::C_point, InternalName::get_texcoord(), 3, - Geom::NT_float32, Geom::C_texcoord); + Geom::NT_stdfloat, Geom::C_texcoord); format = GeomVertexFormat::register_format(v3t3); } } else { @@ -650,18 +650,18 @@ generate_vis_points() const { for (int yi = 0; yi < _y_size; ++yi) { for (int xi = 0; xi < _x_size; ++xi) { - const LPoint3f &point = get_point(xi, yi); - LPoint2f uv(float(xi) / float(_x_size - 1), - float(yi) / float(_y_size - 1)); + const LPoint3 &point = get_point(xi, yi); + LPoint2 uv(PN_stdfloat(xi) / PN_stdfloat(_x_size - 1), + PN_stdfloat(yi) / PN_stdfloat(_y_size - 1)); if (_vis_inverse) { - vertex.add_data2f(uv); - texcoord.add_data3f(point); + vertex.add_data2(uv); + texcoord.add_data3(point); } else if (_vis_2d) { - vertex.add_data2f(point[0], point[1]); - texcoord.add_data2f(uv); + vertex.add_data2(point[0], point[1]); + texcoord.add_data2(uv); } else { - vertex.add_data3f(point); - texcoord.add_data2f(uv); + vertex.add_data3(point); + texcoord.add_data2(uv); } } } @@ -754,9 +754,9 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { // and it's 3-d. But we still don't need normals in that case. GeomVertexArrayFormat *v3t3 = new GeomVertexArrayFormat (InternalName::get_vertex(), 3, - Geom::NT_float32, Geom::C_point, + Geom::NT_stdfloat, Geom::C_point, InternalName::get_texcoord(), 3, - Geom::NT_float32, Geom::C_texcoord); + Geom::NT_stdfloat, Geom::C_texcoord); format = GeomVertexFormat::register_format(v3t3); } else { // Otherwise, we only need a 2-d texture coordinate, and we do @@ -802,22 +802,22 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { for (int yi = y_begin; yi < y_end; ++yi) { for (int xi = x_begin; xi < x_end; ++xi) { - const LPoint3f &point = get_point(xi, yi); - LPoint2f uv(float(xi) / float(_x_size - 1), - float(yi) / float(_y_size - 1)); + const LPoint3 &point = get_point(xi, yi); + LPoint2 uv(PN_stdfloat(xi) / PN_stdfloat(_x_size - 1), + PN_stdfloat(yi) / PN_stdfloat(_y_size - 1)); if (_vis_inverse) { - vertex.add_data2f(uv); - texcoord.add_data3f(point); + vertex.add_data2(uv); + texcoord.add_data3(point); } else if (_vis_2d) { - vertex.add_data2f(point[0], point[1]); - texcoord.add_data2f(uv); + vertex.add_data2(point[0], point[1]); + texcoord.add_data2(uv); } else { - vertex.add_data3f(point); - texcoord.add_data2f(uv); + vertex.add_data3(point); + texcoord.add_data2(uv); // Calculate the normal based on two neighboring vertices. - LPoint3f v[3]; + LPoint3 v[3]; v[0] = get_point(xi, yi); if (xi + 1 < _x_size) { v[1] = get_point(xi + 1, yi); @@ -833,10 +833,10 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { v[0] = get_point(xi, yi - 1); } - LVector3f n = LVector3f::zero(); + LVector3 n = LVector3::zero(); for (int i = 0; i < 3; ++i) { - const LPoint3f &v0 = v[i]; - const LPoint3f &v1 = v[(i + 1) % 3]; + const LPoint3 &v0 = v[i]; + const LPoint3 &v1 = v[(i + 1) % 3]; n[0] += v0[1] * v1[2] - v0[2] * v1[1]; n[1] += v0[2] * v1[0] - v0[0] * v1[2]; n[2] += v0[0] * v1[1] - v0[1] * v1[0]; @@ -845,7 +845,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { if (inverted) { n = -n; } - normal.add_data3f(n); + normal.add_data3(n); } } } @@ -859,10 +859,10 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { for (int xi = x_begin; xi < x_end - 1; ++xi) { if (_zero_special) { - if (get_point(xi, yi) == LPoint3f::zero() || - get_point(xi, yi + 1) == LPoint3f::zero() || - get_point(xi + 1, yi + 1) == LPoint3f::zero() || - get_point(xi + 1, yi) == LPoint3f::zero()) { + if (get_point(xi, yi) == LPoint3::zero() || + get_point(xi, yi + 1) == LPoint3::zero() || + get_point(xi + 1, yi + 1) == LPoint3::zero() || + get_point(xi + 1, yi) == LPoint3::zero()) { continue; } } @@ -908,7 +908,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { // in UV space, in the range 0..1. //////////////////////////////////////////////////////////////////// void PfmFile:: -compute_sample_point(LPoint3f &result, +compute_sample_point(LPoint3 &result, double x, double y, double sample_radius) const { x *= _x_size; y *= _y_size; @@ -928,9 +928,9 @@ compute_sample_point(LPoint3f &result, // included point. //////////////////////////////////////////////////////////////////// void PfmFile:: -box_filter_region(LPoint3f &result, +box_filter_region(LPoint3 &result, double x0, double y0, double x1, double y1) const { - result = LPoint3f::zero(); + result = LPoint3::zero(); double coverage = 0.0; assert(y0 >= 0.0 && y1 >= 0.0); @@ -966,7 +966,7 @@ box_filter_region(LPoint3f &result, // Description: //////////////////////////////////////////////////////////////////// void PfmFile:: -box_filter_line(LPoint3f &result, double &coverage, +box_filter_line(LPoint3 &result, double &coverage, double x0, int y, double x1, double y_contrib) const { int x = (int)x0; // Get the first (partial) xel @@ -995,10 +995,10 @@ box_filter_line(LPoint3f &result, double &coverage, // Description: //////////////////////////////////////////////////////////////////// void PfmFile:: -box_filter_point(LPoint3f &result, double &coverage, +box_filter_point(LPoint3 &result, double &coverage, int x, int y, double x_contrib, double y_contrib) const { - const LPoint3f &point = get_point(x, y); - if (_zero_special && point == LPoint3f::zero()) { + const LPoint3 &point = get_point(x, y); + if (_zero_special && point == LPoint3::zero()) { return; } diff --git a/panda/src/grutil/pfmFile.h b/panda/src/grutil/pfmFile.h index d69c88c046..1c97f316b9 100755 --- a/panda/src/grutil/pfmFile.h +++ b/panda/src/grutil/pfmFile.h @@ -45,23 +45,23 @@ PUBLISHED: INLINE int get_x_size() const; INLINE int get_y_size() const; - INLINE float get_scale() const; + INLINE PN_stdfloat get_scale() const; INLINE int get_num_channels() const; INLINE bool has_point(int x, int y) const; - INLINE const LPoint3f &get_point(int x, int y) const; - INLINE void set_point(int x, int y, const LVecBase3f &point); - INLINE LPoint3f &modify_point(int x, int y); + INLINE const LPoint3 &get_point(int x, int y) const; + INLINE void set_point(int x, int y, const LVecBase3 &point); + INLINE LPoint3 &modify_point(int x, int y); - bool calc_average_point(LPoint3f &result, double x, double y, double radius) const; - bool calc_min_max(LVecBase3f &min_points, LVecBase3f &max_points) const; + bool calc_average_point(LPoint3 &result, double x, double y, double radius) const; + bool calc_min_max(LVecBase3 &min_points, LVecBase3 &max_points) const; INLINE void set_zero_special(bool zero_special); INLINE bool get_zero_special() const; void resize(int new_x_size, int new_y_size); void reverse_rows(); - void xform(const LMatrix4f &transform); + void xform(const LMatrix4 &transform); PT(BoundingHexahedron) compute_planar_bounds(double point_dist, double sample_radius) const; @@ -76,13 +76,13 @@ PUBLISHED: private: void make_vis_mesh_geom(GeomNode *gnode, bool inverted) const; - void compute_sample_point(LPoint3f &result, + void compute_sample_point(LPoint3 &result, double x, double y, double sample_radius) const; - void box_filter_region(LPoint3f &result, + void box_filter_region(LPoint3 &result, double x0, double y0, double x1, double y1) const; - void box_filter_line(LPoint3f &result, double &coverage, + void box_filter_line(LPoint3 &result, double &coverage, double x0, int y, double x1, double y_contrib) const; - void box_filter_point(LPoint3f &result, double &coverage, + void box_filter_point(LPoint3 &result, double &coverage, int x, int y, double x_contrib, double y_contrib) const; class MiniGridCell { @@ -96,12 +96,12 @@ private: int xi, int yi, int dist, int ti) const; private: - typedef pvector Table; + typedef pvector Table; Table _table; int _x_size; int _y_size; - float _scale; + PN_stdfloat _scale; int _num_channels; bool _zero_special; diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.cxx b/panda/src/grutil/pipeOcclusionCullTraverser.cxx index e8b5684909..9a6216fb34 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.cxx +++ b/panda/src/grutil/pipeOcclusionCullTraverser.cxx @@ -440,15 +440,15 @@ make_sphere() { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_stream); for (int sl = 0; sl < num_slices; ++sl) { - float longitude0 = (float)sl / (float)num_slices; - float longitude1 = (float)(sl + 1) / (float)num_slices; - vertex.add_data3f(compute_sphere_point(0.0, longitude0)); + PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; + PN_stdfloat longitude1 = (PN_stdfloat)(sl + 1) / (PN_stdfloat)num_slices; + vertex.add_data3(compute_sphere_point(0.0, longitude0)); for (int st = 1; st < num_stacks; ++st) { - float latitude = (float)st / (float)num_stacks; - vertex.add_data3f(compute_sphere_point(latitude, longitude0)); - vertex.add_data3f(compute_sphere_point(latitude, longitude1)); + PN_stdfloat latitude = (PN_stdfloat)st / (PN_stdfloat)num_stacks; + vertex.add_data3(compute_sphere_point(latitude, longitude0)); + vertex.add_data3(compute_sphere_point(latitude, longitude1)); } - vertex.add_data3f(compute_sphere_point(1.0, longitude0)); + vertex.add_data3(compute_sphere_point(1.0, longitude0)); strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); @@ -464,15 +464,15 @@ make_sphere() { // Description: Returns a point on the surface of the unit sphere. // latitude and longitude range from 0.0 to 1.0. //////////////////////////////////////////////////////////////////// -Vertexf PipeOcclusionCullTraverser:: -compute_sphere_point(float latitude, float longitude) { - float s1, c1; - csincos(latitude * MathNumbers::pi_f, &s1, &c1); +LVertex PipeOcclusionCullTraverser:: +compute_sphere_point(PN_stdfloat latitude, PN_stdfloat longitude) { + PN_stdfloat s1, c1; + csincos(latitude * MathNumbers::pi, &s1, &c1); - float s2, c2; - csincos(longitude * 2.0f * MathNumbers::pi_f, &s2, &c2); + PN_stdfloat s2, c2; + csincos(longitude * 2.0f * MathNumbers::pi, &s2, &c2); - Vertexf p(s1 * c2, s1 * s2, c1); + LVertex p(s1 * c2, s1 * s2, c1); return p; } @@ -488,14 +488,14 @@ make_box() { ("occlusion_box", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(0.0f, 0.0f, 0.0f); - vertex.add_data3f(0.0f, 0.0f, 1.0f); - vertex.add_data3f(0.0f, 1.0f, 0.0f); - vertex.add_data3f(0.0f, 1.0f, 1.0f); - vertex.add_data3f(1.0f, 0.0f, 0.0f); - vertex.add_data3f(1.0f, 0.0f, 1.0f); - vertex.add_data3f(1.0f, 1.0f, 0.0f); - vertex.add_data3f(1.0f, 1.0f, 1.0f); + vertex.add_data3(0.0f, 0.0f, 0.0f); + vertex.add_data3(0.0f, 0.0f, 1.0f); + vertex.add_data3(0.0f, 1.0f, 0.0f); + vertex.add_data3(0.0f, 1.0f, 1.0f); + vertex.add_data3(1.0f, 0.0f, 0.0f); + vertex.add_data3(1.0f, 0.0f, 1.0f); + vertex.add_data3(1.0f, 1.0f, 0.0f); + vertex.add_data3(1.0f, 1.0f, 1.0f); PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); tris->add_vertices(0, 4, 5); @@ -571,7 +571,7 @@ get_volume_viz(const BoundingVolume *vol, const BoundingSphere *sphere = DCAST(BoundingSphere, vol); CPT(TransformState) local_transform = TransformState::make_pos_hpr_scale(sphere->get_center(), - LVecBase3f(0, 0, 0), + LVecBase3(0, 0, 0), sphere->get_radius()); net_transform = net_transform->compose(local_transform); @@ -581,8 +581,8 @@ get_volume_viz(const BoundingVolume *vol, // is, the occlusion test may fail, so we won't bother performing // it for this object. Anyway, it's not occluded by anything, // since it's intersecting the near plane. - const LPoint3f ¢er = modelview_transform->get_pos(); - const LVecBase3f &radius = modelview_transform->get_scale(); + const LPoint3 ¢er = modelview_transform->get_pos(); + const LVecBase3 &radius = modelview_transform->get_scale(); if (center[1] - radius[1] < 0.0f) { return false; } @@ -595,7 +595,7 @@ get_volume_viz(const BoundingVolume *vol, const BoundingBox *box = DCAST(BoundingBox, vol); CPT(TransformState) local_transform = TransformState::make_pos_hpr_scale(box->get_minq(), - LVecBase3f(0, 0, 0), + LVecBase3(0, 0, 0), box->get_maxq() - box->get_minq()); net_transform = net_transform->compose(local_transform); @@ -605,19 +605,19 @@ get_volume_viz(const BoundingVolume *vol, // is, the occlusion test may fail, so we won't bother performing // it for this object. Anyway, it's not occluded by anything, // since it's intersecting the near plane. - static const LPoint3f points[8] = { - LPoint3f(0.0f, 0.0f, 0.0f), - LPoint3f(0.0f, 0.0f, 1.0f), - LPoint3f(0.0f, 1.0f, 0.0f), - LPoint3f(0.0f, 1.0f, 1.0f), - LPoint3f(1.0f, 0.0f, 0.0f), - LPoint3f(1.0f, 0.0f, 1.0f), - LPoint3f(1.0f, 1.0f, 0.0f), - LPoint3f(1.0f, 1.0f, 1.0f), + static const LPoint3 points[8] = { + LPoint3(0.0f, 0.0f, 0.0f), + LPoint3(0.0f, 0.0f, 1.0f), + LPoint3(0.0f, 1.0f, 0.0f), + LPoint3(0.0f, 1.0f, 1.0f), + LPoint3(1.0f, 0.0f, 0.0f), + LPoint3(1.0f, 0.0f, 1.0f), + LPoint3(1.0f, 1.0f, 0.0f), + LPoint3(1.0f, 1.0f, 1.0f), }; - const LMatrix4f &mat = modelview_transform->get_mat(); + const LMatrix4 &mat = modelview_transform->get_mat(); for (int i = 0; i < 8; ++i) { - LPoint3f p = points[i] * mat; + LPoint3 p = points[i] * mat; if (p[1] < 0.0f) { return false; } @@ -683,13 +683,13 @@ void PipeOcclusionCullTraverser:: show_results(int num_fragments, const Geom *geom, const TransformState *net_transform, const TransformState *modelview_transform) { - Colorf color; + LColor color; if (num_fragments == 0) { // Magenta: culled - color.set(0.8f, 0.0f, 1.0f, 0.4f); + color.set(0.8f, 0.0f, 1.0f, 0.4); } else { // Yellow: visible - color.set(1.0f, 1.0f, 0.5f, 0.4f); + color.set(1.0f, 1.0f, 0.5f, 0.4); } CPT(RenderState) state = RenderState::make diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.h b/panda/src/grutil/pipeOcclusionCullTraverser.h index 076e972f39..fb8636c79d 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.h +++ b/panda/src/grutil/pipeOcclusionCullTraverser.h @@ -70,7 +70,7 @@ protected: private: void make_sphere(); - static Vertexf compute_sphere_point(float latitude, float longitude); + static LVertex compute_sphere_point(PN_stdfloat latitude, PN_stdfloat longitude); void make_box(); void make_solid_test_state(); diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index 5db016f969..d59e9e347a 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -43,9 +43,9 @@ SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { _clock_object = ClockObject::get_global_clock(); set_align(A_left); - set_transform(LMatrix4f::scale_mat(scene_graph_analyzer_meter_scale) * - LMatrix4f::translate_mat(LVector3f::rfu(-1.0f + scene_graph_analyzer_meter_side_margins * scene_graph_analyzer_meter_scale, 0.0f, 1.0f - scene_graph_analyzer_meter_scale))); - set_card_color(0.0f, 0.0f, 0.0f, 0.4f); + set_transform(LMatrix4::scale_mat(scene_graph_analyzer_meter_scale) * + LMatrix4::translate_mat(LVector3::rfu(-1.0f + scene_graph_analyzer_meter_side_margins * scene_graph_analyzer_meter_scale, 0.0f, 1.0f - scene_graph_analyzer_meter_scale))); + set_card_color(0.0f, 0.0f, 0.0f, 0.4); set_card_as_margin(scene_graph_analyzer_meter_side_margins, scene_graph_analyzer_meter_side_margins, 0.1f, 0.0f); set_usage_hint(Geom::UH_client); @@ -95,10 +95,10 @@ setup_window(GraphicsOutput *window) { PT(Lens) lens = new OrthographicLens; - static const float left = -1.0f; - static const float right = 1.0f; - static const float bottom = -1.0f; - static const float top = 1.0f; + static const PN_stdfloat left = -1.0f; + static const PN_stdfloat right = 1.0f; + static const PN_stdfloat bottom = -1.0f; + static const PN_stdfloat top = 1.0f; lens->set_film_size(right - left, top - bottom); lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5); lens->set_near_far(-1000, 1000); diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index 0ae5fa0476..f3fb5a2b75 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -173,7 +173,7 @@ public: // in eye coordinates, from the camera plane. This is a virtual // function because different GSG's may define the eye coordinate // space differently. - virtual float compute_distance_to(const LPoint3f &point) const=0; + virtual PN_stdfloat compute_distance_to(const LPoint3 &point) const=0; // These are used to implement decals. If depth_offset_decals() // returns true, none of the remaining functions will be called, diff --git a/panda/src/iphone/Sources.pp b/panda/src/iphone/Sources.pp index f8a646521f..6872c582ef 100644 --- a/panda/src/iphone/Sources.pp +++ b/panda/src/iphone/Sources.pp @@ -12,7 +12,7 @@ #define LOCAL_LIBS \ iphonedisplay \ framework putil collide pgraph chan text \ - pnmimage pnmimagetypes event effects gobj display \ + pnmimage pnmimagetypes event gobj display \ mathutil putil express dgraph device tform \ linmath pstatclient panda glstuff diff --git a/panda/src/iphonedisplay/Sources.pp b/panda/src/iphonedisplay/Sources.pp index f4bf264cd5..61b3d364c8 100644 --- a/panda/src/iphonedisplay/Sources.pp +++ b/panda/src/iphonedisplay/Sources.pp @@ -10,7 +10,7 @@ #define LOCAL_LIBS \ framework putil collide pgraph chan text \ - pnmimage pnmimagetypes event effects gobj display \ + pnmimage pnmimagetypes event gobj display \ mathutil putil express dgraph device tform \ linmath pstatclient panda glstuff glesgsg diff --git a/panda/src/lerp/config_lerp.cxx b/panda/src/lerp/config_lerp.cxx index d9e251b2c4..5397ff3ee2 100644 --- a/panda/src/lerp/config_lerp.cxx +++ b/panda/src/lerp/config_lerp.cxx @@ -27,27 +27,27 @@ ConfigureFn(config_lerp) { LerpFunctor::init_type(); SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); - SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); + SimpleLerpFunctor::init_type(); SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); - SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); + SimpleQueryLerpFunctor::init_type(); MultiLerpFunctor::init_type(); LerpBlendType::init_type(); diff --git a/panda/src/lerp/lerp.cxx b/panda/src/lerp/lerp.cxx index dde33ccf12..872d6b9037 100644 --- a/panda/src/lerp/lerp.cxx +++ b/panda/src/lerp/lerp.cxx @@ -21,8 +21,8 @@ TypeHandle Lerp::_type_handle; TypeHandle AutonomousLerp::_type_handle; -static INLINE float scale_t(float t, float start, float end) { - float ret = t; +static INLINE PN_stdfloat scale_t(PN_stdfloat t, PN_stdfloat start, PN_stdfloat end) { + PN_stdfloat ret = t; if (ret < start) ret = start; if (ret > end) @@ -33,11 +33,11 @@ static INLINE float scale_t(float t, float start, float end) { return ret / end; } -Lerp::Lerp(LerpFunctor* func, float endt, LerpBlendType* blend) +Lerp::Lerp(LerpFunctor* func, PN_stdfloat endt, LerpBlendType* blend) : _blend(blend), _func(func), _startt(0.), _endt(endt), _delta(1.), _t(0.) {} -Lerp::Lerp(LerpFunctor* func, float startt, float endt, +Lerp::Lerp(LerpFunctor* func, PN_stdfloat startt, PN_stdfloat endt, LerpBlendType* blend) : _blend(blend), _func(func), _startt(startt), _endt(endt), @@ -69,28 +69,28 @@ void Lerp::step() { throw_event(_event); } } else { - float t = scale_t(_t, _startt, _endt); + PN_stdfloat t = scale_t(_t, _startt, _endt); t = (_blend==(LerpBlendType*)0L)?t:(*_blend)(t); (*_func)(t); } } -void Lerp::set_step_size(float delta) { +void Lerp::set_step_size(PN_stdfloat delta) { _delta = delta; } -float Lerp::get_step_size() const { +PN_stdfloat Lerp::get_step_size() const { return _delta; } -void Lerp::set_t(float t) { +void Lerp::set_t(PN_stdfloat t) { _t = t; - float x = scale_t(_t, _startt, _endt); + PN_stdfloat x = scale_t(_t, _startt, _endt); x = (_blend==(LerpBlendType*)0L)?x:(*_blend)(x); (*_func)(x); } -float Lerp::get_t() const { +PN_stdfloat Lerp::get_t() const { return _t; } @@ -110,12 +110,12 @@ std::string Lerp::get_end_event() const { return _event; } -AutonomousLerp::AutonomousLerp(LerpFunctor* func, float endt, +AutonomousLerp::AutonomousLerp(LerpFunctor* func, PN_stdfloat endt, LerpBlendType* blend, EventHandler* handler) : _blend(blend), _func(func), _handler(handler), _startt(0.), _endt(endt), _t(0.) {} -AutonomousLerp::AutonomousLerp(LerpFunctor* func, float startt, float endt, +AutonomousLerp::AutonomousLerp(LerpFunctor* func, PN_stdfloat startt, PN_stdfloat endt, LerpBlendType* blend, EventHandler* handler) : _blend(blend), _func(func), _handler(handler), _startt(startt), _endt(endt), _t(startt) {} @@ -162,14 +162,14 @@ LerpFunctor* AutonomousLerp::get_functor() const { return _func; } -void AutonomousLerp::set_t(float t) { +void AutonomousLerp::set_t(PN_stdfloat t) { _t = t; - float x = scale_t(_t, _startt, _endt); + PN_stdfloat x = scale_t(_t, _startt, _endt); x = (_blend==(LerpBlendType*)0L)?x:(*_blend)(x); (*_func)(x); } -float AutonomousLerp::get_t() const { +PN_stdfloat AutonomousLerp::get_t() const { return _t; } @@ -188,9 +188,9 @@ void AutonomousLerp::step() { stop(); return; } - float delta = ClockObject::get_global_clock()->get_dt(); + PN_stdfloat delta = ClockObject::get_global_clock()->get_dt(); _t += delta; - float t = scale_t(_t, _startt, _endt); + PN_stdfloat t = scale_t(_t, _startt, _endt); t = (_blend==(LerpBlendType*)0L)?t:(*_blend)(t); (*_func)(t); if (is_done() && !_event.empty()) diff --git a/panda/src/lerp/lerp.h b/panda/src/lerp/lerp.h index 5ca9e044df..3469796dcc 100644 --- a/panda/src/lerp/lerp.h +++ b/panda/src/lerp/lerp.h @@ -28,22 +28,22 @@ private: PT(LerpBlendType) _blend; PT(LerpFunctor) _func; std::string _event; - float _startt; - float _endt; - float _delta; - float _t; + PN_stdfloat _startt; + PN_stdfloat _endt; + PN_stdfloat _delta; + PN_stdfloat _t; PUBLISHED: - Lerp(LerpFunctor* func, float endt, LerpBlendType* blend); - Lerp(LerpFunctor* func, float startt, float endt, LerpBlendType* blend); + Lerp(LerpFunctor* func, PN_stdfloat endt, LerpBlendType* blend); + Lerp(LerpFunctor* func, PN_stdfloat startt, PN_stdfloat endt, LerpBlendType* blend); Lerp(const Lerp&); virtual ~Lerp(); Lerp& operator=(const Lerp&); void step(); - void set_step_size(float); - float get_step_size() const; - void set_t(float); - float get_t() const; + void set_step_size(PN_stdfloat); + PN_stdfloat get_step_size() const; + void set_t(PN_stdfloat); + PN_stdfloat get_t() const; bool is_done() const; LerpFunctor* get_functor() const; void set_end_event(const std::string&); @@ -75,17 +75,17 @@ private: PT(LerpFunctor) _func; EventHandler* _handler; std::string _event; - float _startt; - float _endt; - float _t; + PN_stdfloat _startt; + PN_stdfloat _endt; + PN_stdfloat _t; virtual void step(); static void handle_event(const Event *, void*); PUBLISHED: - AutonomousLerp(LerpFunctor* func, float endt, LerpBlendType* blend, + AutonomousLerp(LerpFunctor* func, PN_stdfloat endt, LerpBlendType* blend, EventHandler* handler); - AutonomousLerp(LerpFunctor* func, float startt, float endt, + AutonomousLerp(LerpFunctor* func, PN_stdfloat startt, PN_stdfloat endt, LerpBlendType* blend, EventHandler* handler); AutonomousLerp(const AutonomousLerp&); virtual ~AutonomousLerp(); @@ -95,8 +95,8 @@ PUBLISHED: void resume(); bool is_done() const; LerpFunctor* get_functor() const; - void set_t(float); - float get_t() const; + void set_t(PN_stdfloat); + PN_stdfloat get_t() const; void set_end_event(const std::string&); std::string get_end_event() const; diff --git a/panda/src/lerp/lerpblend.cxx b/panda/src/lerp/lerpblend.cxx index 32fde6155e..6cf72e521b 100644 --- a/panda/src/lerp/lerpblend.cxx +++ b/panda/src/lerp/lerpblend.cxx @@ -28,7 +28,7 @@ LerpBlendType& LerpBlendType::operator=(const LerpBlendType&) { return *this; } -float LerpBlendType::operator()(float t) { +PN_stdfloat LerpBlendType::operator()(PN_stdfloat t) { return t; } @@ -43,8 +43,8 @@ EaseInBlendType& EaseInBlendType::operator=(const EaseInBlendType& c) { return *this; } -float EaseInBlendType::operator()(float t) { - float x = t*t; +PN_stdfloat EaseInBlendType::operator()(PN_stdfloat t) { + PN_stdfloat x = t*t; return ((3.0f * x) - (t * x)) * 0.5f; } @@ -58,7 +58,7 @@ EaseOutBlendType& EaseOutBlendType::operator=(const EaseOutBlendType& c) { return *this; } -float EaseOutBlendType::operator()(float t) { +PN_stdfloat EaseOutBlendType::operator()(PN_stdfloat t) { return ((3.0f * t) - (t * t * t)) * 0.5f; } @@ -73,8 +73,8 @@ EaseInOutBlendType& EaseInOutBlendType::operator=(const EaseInOutBlendType& c) return *this; } -float EaseInOutBlendType::operator()(float t) { - float x = t*t; +PN_stdfloat EaseInOutBlendType::operator()(PN_stdfloat t) { + PN_stdfloat x = t*t; return (3.0f * x) - (2.0f * t * x); } @@ -87,7 +87,7 @@ NoBlendType& NoBlendType::operator=(const NoBlendType& c) { return *this; } -float NoBlendType::operator()(float t) { +PN_stdfloat NoBlendType::operator()(PN_stdfloat t) { return t; } diff --git a/panda/src/lerp/lerpblend.h b/panda/src/lerp/lerpblend.h index c4a4a452c1..788448cc58 100644 --- a/panda/src/lerp/lerpblend.h +++ b/panda/src/lerp/lerpblend.h @@ -22,7 +22,7 @@ class EXPCL_PANDA_LERP LerpBlendType : public TypedReferenceCount { PUBLISHED: LerpBlendType() {} virtual ~LerpBlendType(); - virtual float operator()(float) = 0; + virtual PN_stdfloat operator()(PN_stdfloat) = 0; public: LerpBlendType(const LerpBlendType&); @@ -52,7 +52,7 @@ class EXPCL_PANDA_LERP EaseInBlendType : public LerpBlendType { PUBLISHED: EaseInBlendType() {} virtual ~EaseInBlendType(); - virtual float operator()(float); + virtual PN_stdfloat operator()(PN_stdfloat); public: EaseInBlendType(const EaseInBlendType&); @@ -82,7 +82,7 @@ class EXPCL_PANDA_LERP EaseOutBlendType : public LerpBlendType { PUBLISHED: EaseOutBlendType() {} virtual ~EaseOutBlendType(); - virtual float operator()(float); + virtual PN_stdfloat operator()(PN_stdfloat); public: EaseOutBlendType(const EaseOutBlendType&); @@ -112,7 +112,7 @@ class EXPCL_PANDA_LERP EaseInOutBlendType : public LerpBlendType { PUBLISHED: EaseInOutBlendType() {} virtual ~EaseInOutBlendType(); - virtual float operator()(float); + virtual PN_stdfloat operator()(PN_stdfloat); public: EaseInOutBlendType(const EaseInOutBlendType&); EaseInOutBlendType& operator=(const EaseInOutBlendType&); @@ -141,7 +141,7 @@ class EXPCL_PANDA_LERP NoBlendType : public LerpBlendType { PUBLISHED: NoBlendType() {} virtual ~NoBlendType(); - virtual float operator()(float); + virtual PN_stdfloat operator()(PN_stdfloat); public: NoBlendType(const NoBlendType&); NoBlendType& operator=(const NoBlendType&); diff --git a/panda/src/lerp/lerpchans.h b/panda/src/lerp/lerpchans.h index fabae2bf2a..e1d3e2eab5 100644 --- a/panda/src/lerp/lerpchans.h +++ b/panda/src/lerp/lerpchans.h @@ -27,9 +27,9 @@ class LerpChannelRange { private: - float _low, _high; + PN_stdfloat _low, _high; public: - INLINE LerpChannelRange(float low, float high) : _low(low), _high(high) { + INLINE LerpChannelRange(PN_stdfloat low, PN_stdfloat high) : _low(low), _high(high) { if (low > high) { _low = high; _high = low; @@ -38,23 +38,23 @@ public: INLINE LerpChannelRange(const LerpChannelRange& c) : _low(c._low), _high(c._high) {} INLINE ~LerpChannelRange() {} - INLINE float GetLow() { return _low; } - INLINE float GetHigh() { return _high; } - INLINE void SetLow(float l) { + INLINE PN_stdfloat GetLow() { return _low; } + INLINE PN_stdfloat GetHigh() { return _high; } + INLINE void SetLow(PN_stdfloat l) { if (l > _high) { _low = _high; _high = l; } else _low = l; } - INLINE void SetHigh(float h) { + INLINE void SetHigh(PN_stdfloat h) { if (h < _low) { _high = _low; _low = h; } else _high = h; } - INLINE void SetRange(float l, float h) { + INLINE void SetRange(PN_stdfloat l, PN_stdfloat h) { if (l > h) { _low = h; _high = l; @@ -73,7 +73,7 @@ public: template class LerpChannel { public: - virtual GetValue(float p); + virtual GetValue(PN_stdfloat p); }; template diff --git a/panda/src/lerp/lerpfunctor.cxx b/panda/src/lerp/lerpfunctor.cxx index 7f9189d142..be26632736 100644 --- a/panda/src/lerp/lerpfunctor.cxx +++ b/panda/src/lerp/lerpfunctor.cxx @@ -29,7 +29,7 @@ LerpFunctor& LerpFunctor::operator=(const LerpFunctor&) { return *this; } -void LerpFunctor::operator()(float) { +void LerpFunctor::operator()(PN_stdfloat) { // should not be here } @@ -44,7 +44,7 @@ MultiLerpFunctor& MultiLerpFunctor::operator=(const MultiLerpFunctor& c) { return *this; } -void MultiLerpFunctor::operator()(float f) { +void MultiLerpFunctor::operator()(PN_stdfloat f) { for (Functors::iterator i=_funcs.begin(); i!=_funcs.end(); ++i) (*(*i))(f); } diff --git a/panda/src/lerp/lerpfunctor.h b/panda/src/lerp/lerpfunctor.h index f1dc1b0cac..6e37aff5aa 100644 --- a/panda/src/lerp/lerpfunctor.h +++ b/panda/src/lerp/lerpfunctor.h @@ -24,7 +24,7 @@ public: LerpFunctor(const LerpFunctor&); virtual ~LerpFunctor(); LerpFunctor& operator=(const LerpFunctor&); - virtual void operator()(float) = 0; + virtual void operator()(PN_stdfloat) = 0; PUBLISHED: static TypeHandle get_class_type() { @@ -62,10 +62,10 @@ protected: public: virtual ~SimpleLerpFunctor(); SimpleLerpFunctor& operator=(const SimpleLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); PUBLISHED: - value interpolate(float); + value interpolate(PN_stdfloat); INLINE const value &get_start() const { return _start; } INLINE const value &get_end() const { return _end; } @@ -107,7 +107,7 @@ public: : SimpleLerpFunctor(start, end) {} virtual ~SimpleQueryLerpFunctor(); SimpleQueryLerpFunctor& operator=(const SimpleQueryLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); PUBLISHED: value get_value(); @@ -140,52 +140,52 @@ TypeHandle SimpleQueryLerpFunctor::_type_handle; #include "luse.h" EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleLerpFunctor) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_LERP, EXPTP_PANDA_LERP, SimpleQueryLerpFunctor) typedef SimpleLerpFunctor IntLerpFunctor; -typedef SimpleLerpFunctor FloatLerpFunctor; -typedef SimpleLerpFunctor LPoint2fLerpFunctor; -typedef SimpleLerpFunctor LPoint3fLerpFunctor; -typedef SimpleLerpFunctor LPoint4fLerpFunctor; -typedef SimpleLerpFunctor LVecBase2fLerpFunctor; -typedef SimpleLerpFunctor LVecBase3fLerpFunctor; -typedef SimpleLerpFunctor LVecBase4fLerpFunctor; -typedef SimpleLerpFunctor LVector2fLerpFunctor; -typedef SimpleLerpFunctor LVector3fLerpFunctor; -typedef SimpleLerpFunctor LVector4fLerpFunctor; +typedef SimpleLerpFunctor StdfloatLerpFunctor; +typedef SimpleLerpFunctor LPoint2LerpFunctor; +typedef SimpleLerpFunctor LPoint3LerpFunctor; +typedef SimpleLerpFunctor LPoint4LerpFunctor; +typedef SimpleLerpFunctor LVecBase2LerpFunctor; +typedef SimpleLerpFunctor LVecBase3LerpFunctor; +typedef SimpleLerpFunctor LVecBase4LerpFunctor; +typedef SimpleLerpFunctor LVector2LerpFunctor; +typedef SimpleLerpFunctor LVector3LerpFunctor; +typedef SimpleLerpFunctor LVector4LerpFunctor; typedef SimpleQueryLerpFunctor IntQueryLerpFunctor; -typedef SimpleQueryLerpFunctor FloatQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LPoint2fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LPoint3fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LPoint4fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVecBase2fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVecBase3fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVecBase4fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVector2fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVector3fQueryLerpFunctor; -typedef SimpleQueryLerpFunctor LVector4fQueryLerpFunctor; +typedef SimpleQueryLerpFunctor StdfloatQueryLerpFunctor; +typedef SimpleQueryLerpFunctor LPoint2QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LPoint3QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LPoint4QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVecBase2QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVecBase3QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVecBase4QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVector2QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVector3QueryLerpFunctor; +typedef SimpleQueryLerpFunctor LVector4QueryLerpFunctor; #include "pset.h" #include "pointerTo.h" @@ -199,7 +199,7 @@ public: MultiLerpFunctor(const MultiLerpFunctor&); virtual ~MultiLerpFunctor(); MultiLerpFunctor& operator=(const MultiLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); void add_functor(LerpFunctor*); void remove_functor(LerpFunctor*); @@ -250,12 +250,12 @@ SimpleLerpFunctor::operator=(const SimpleLerpFunctor& c) { } template -void SimpleLerpFunctor::operator()(float) { +void SimpleLerpFunctor::operator()(PN_stdfloat) { // should not be here } template -value SimpleLerpFunctor::interpolate(float t) { +value SimpleLerpFunctor::interpolate(PN_stdfloat t) { return ((t * _diff_cache) + _start); } @@ -278,7 +278,7 @@ SimpleQueryLerpFunctor::operator=(const SimpleQueryLerpFunctor& c) { } template -void SimpleQueryLerpFunctor::operator()(float t) { +void SimpleQueryLerpFunctor::operator()(PN_stdfloat t) { _save = this->interpolate(t); } diff --git a/panda/src/linmath/aa_luse.h b/panda/src/linmath/aa_luse.h index fae3a5c17d..771c19714c 100644 --- a/panda/src/linmath/aa_luse.h +++ b/panda/src/linmath/aa_luse.h @@ -60,6 +60,61 @@ typedef LPoint3d TexCoord3d; typedef LVecBase4d Colord; typedef LVecBase3d RGBColord; +// And finally, we define the unqualified "standard" float type, which +// is based on the setting of STDFLOAT_DOUBLE. This is the type that +// is used for graphics-specific operations such as vertex and pos +// value. The default is single-precision floats, which is almost +// always what you really want. +#ifndef STDFLOAT_DOUBLE +// The default setting--single-precision floats. + +typedef LVecBase2f LVecBase2; +typedef LPoint2f LPoint2; +typedef LVector2f LVector2; +typedef LVecBase3f LVecBase3; +typedef LPoint3f LPoint3; +typedef LVector3f LVector3; +typedef LVecBase4f LVecBase4; +typedef LPoint4f LPoint4; +typedef LVector4f LVector4; +typedef LQuaternionf LQuaternion; +typedef LRotationf LRotation; +typedef LOrientationf LOrientation; +typedef LMatrix3f LMatrix3; +typedef LMatrix4f LMatrix4; + +typedef Vertexf LVertex; +typedef Normalf LNormal; +typedef TexCoordf LTexCoord; +typedef TexCoord3f LTexCoord3; +typedef Colorf LColor; +typedef RGBColorf LRGBColor; + +#else // STDFLOAT_DOUBLE +// The specialty setting--double-precision floats. + +typedef LVecBase2d LVecBase2; +typedef LPoint2d LPoint2; +typedef LVector2d LVector2; +typedef LVecBase3d LVecBase3; +typedef LPoint3d LPoint3; +typedef LVector3d LVector3; +typedef LVecBase4d LVecBase4; +typedef LPoint4d LPoint4; +typedef LVector4d LVector4; +typedef LQuaterniond LQuaternion; +typedef LRotationd LRotation; +typedef LOrientationd LOrientation; +typedef LMatrix3d LMatrix3; +typedef LMatrix4d LMatrix4; + +typedef Vertexd LVertex; +typedef Normald LNormal; +typedef TexCoordd LTexCoord; +typedef TexCoord3d LTexCoord3; +typedef Colord LColor; +typedef RGBColord LRGBColor; + +#endif // STDFLOAT_DOUBLE #endif - diff --git a/panda/src/linmath/lcast_to_src.I b/panda/src/linmath/lcast_to_src.I index fd09b503a6..acfcad19d5 100644 --- a/panda/src/linmath/lcast_to_src.I +++ b/panda/src/linmath/lcast_to_src.I @@ -12,6 +12,66 @@ // //////////////////////////////////////////////////////////////////// +INLINE_LINMATH const FLOATNAME(LVecBase2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase2) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LVecBase3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase3) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LVecBase4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase4) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LVector2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector2) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LVector3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector3) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LVector4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector4) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LPoint2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint2) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LPoint3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint3) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LPoint4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint4) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LQuaternion) & +lcast_to(FLOATTYPE *, const FLOATNAME(LQuaternion) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LMatrix3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LMatrix3) &source) { + return source; +} + +INLINE_LINMATH const FLOATNAME(LMatrix4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LMatrix4) &source) { + return source; +} + INLINE_LINMATH FLOATNAME2(LVecBase2) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVecBase2) &source) { return FLOATNAME2(LVecBase2)(source[0], source[1]); diff --git a/panda/src/linmath/lcast_to_src.h b/panda/src/linmath/lcast_to_src.h index 69706266be..55d2a3446f 100644 --- a/panda/src/linmath/lcast_to_src.h +++ b/panda/src/linmath/lcast_to_src.h @@ -12,6 +12,42 @@ // //////////////////////////////////////////////////////////////////// +INLINE_LINMATH const FLOATNAME(LVecBase2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase2) &source); + +INLINE_LINMATH const FLOATNAME(LVecBase3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase3) &source); + +INLINE_LINMATH const FLOATNAME(LVecBase4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase4) &source); + +INLINE_LINMATH const FLOATNAME(LVector2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector2) &source); + +INLINE_LINMATH const FLOATNAME(LVector3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector3) &source); + +INLINE_LINMATH const FLOATNAME(LVector4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LVector4) &source); + +INLINE_LINMATH const FLOATNAME(LPoint2) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint2) &source); + +INLINE_LINMATH const FLOATNAME(LPoint3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint3) &source); + +INLINE_LINMATH const FLOATNAME(LPoint4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LPoint4) &source); + +INLINE_LINMATH const FLOATNAME(LQuaternion) & +lcast_to(FLOATTYPE *, const FLOATNAME(LQuaternion) &c); + +INLINE_LINMATH const FLOATNAME(LMatrix3) & +lcast_to(FLOATTYPE *, const FLOATNAME(LMatrix3) &source); + +INLINE_LINMATH const FLOATNAME(LMatrix4) & +lcast_to(FLOATTYPE *, const FLOATNAME(LMatrix4) &source); + INLINE_LINMATH FLOATNAME2(LVecBase2) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVecBase2) &source); diff --git a/panda/src/linmath/mathNumbers.cxx b/panda/src/linmath/mathNumbers.cxx index 0f0b390ba4..bf1adb23a7 100644 --- a/panda/src/linmath/mathNumbers.cxx +++ b/panda/src/linmath/mathNumbers.cxx @@ -15,13 +15,18 @@ #include "mathNumbers.h" #include -const double MathNumbers::pi = 4.0 * atan(1.0); -const double MathNumbers::ln2 = log(2.0); -const double MathNumbers::rad_2_deg = 180.0 / MathNumbers::pi; -const double MathNumbers::deg_2_rad = MathNumbers::pi / 180.0; +const double MathNumbers::pi_d = 4.0 * atan(1.0); +const double MathNumbers::ln2_d = log(2.0); +const double MathNumbers::rad_2_deg_d = 180.0 / MathNumbers::pi_d; +const double MathNumbers::deg_2_rad_d = MathNumbers::pi_d / 180.0; const float MathNumbers::pi_f = 4.0 * atan(1.0); const float MathNumbers::ln2_f = log(2.0); -const float MathNumbers::rad_2_deg_f = 180.0 / MathNumbers::pi; -const float MathNumbers::deg_2_rad_f = MathNumbers::pi / 180.0; +const float MathNumbers::rad_2_deg_f = 180.0 / MathNumbers::pi_d; +const float MathNumbers::deg_2_rad_f = MathNumbers::pi_d / 180.0; + +const PN_stdfloat MathNumbers::pi = 4.0 * atan(1.0); +const PN_stdfloat MathNumbers::ln2 = log(2.0); +const PN_stdfloat MathNumbers::rad_2_deg = 180.0 / MathNumbers::pi_d; +const PN_stdfloat MathNumbers::deg_2_rad = MathNumbers::pi_d / 180.0; diff --git a/panda/src/linmath/mathNumbers.h b/panda/src/linmath/mathNumbers.h index 582c296bcd..a481f65302 100644 --- a/panda/src/linmath/mathNumbers.h +++ b/panda/src/linmath/mathNumbers.h @@ -15,18 +15,24 @@ #define MATHNUMBERS_H #include "pandabase.h" +#include "numeric_types.h" class EXPCL_PANDA_LINMATH MathNumbers { PUBLISHED: + static const double pi_d; + static const double ln2_d; + static const double rad_2_deg_d; + static const double deg_2_rad_d; + static const float pi_f; + static const float ln2_f; static const float rad_2_deg_f; static const float deg_2_rad_f; - static const float ln2_f; - static const double pi; - static const double ln2; - static const double rad_2_deg; - static const double deg_2_rad; + static const PN_stdfloat pi; + static const PN_stdfloat ln2; + static const PN_stdfloat rad_2_deg; + static const PN_stdfloat deg_2_rad; public: INLINE static float cpi(float); diff --git a/panda/src/mathutil/Sources.pp b/panda/src/mathutil/Sources.pp index 0bf2471fd4..009ada5651 100644 --- a/panda/src/mathutil/Sources.pp +++ b/panda/src/mathutil/Sources.pp @@ -32,8 +32,8 @@ perlinNoise2.h perlinNoise2.I \ perlinNoise3.h perlinNoise3.I \ plane.h plane_src.I plane_src.cxx plane_src.h \ - pta_LMatrix4f.h pta_LMatrix3f.h pta_LVecBase3f.h \ - pta_LVecBase4f.h pta_LVecBase2f.h \ + pta_LMatrix4.h pta_LMatrix3.h pta_LVecBase3.h \ + pta_LVecBase4.h pta_LVecBase2.h \ randomizer.h randomizer.I \ rotate_to.h rotate_to_src.cxx \ stackedPerlinNoise2.h stackedPerlinNoise2.I \ @@ -56,8 +56,8 @@ perlinNoise2.cxx \ perlinNoise3.cxx \ plane.cxx \ - pta_LMatrix4f.cxx pta_LMatrix3f.cxx pta_LVecBase3f.cxx \ - pta_LVecBase4f.cxx pta_LVecBase2f.cxx \ + pta_LMatrix4.cxx pta_LMatrix3.cxx pta_LVecBase3.cxx \ + pta_LVecBase4.cxx pta_LVecBase2.cxx \ randomizer.cxx \ rotate_to.cxx \ stackedPerlinNoise2.cxx \ @@ -71,8 +71,8 @@ boundingPlane.I boundingPlane.h \ boundingSphere.I boundingSphere.h boundingVolume.I \ boundingVolume.h config_mathutil.h fftCompressor.h \ - pta_LMatrix4f.h pta_LMatrix3f.h pta_LVecBase3f.h \ - pta_LVecBase4f.h pta_LVecBase2f.h \ + pta_LMatrix4.h pta_LMatrix3.h pta_LVecBase3.h \ + pta_LVecBase4.h pta_LVecBase2.h \ finiteBoundingVolume.h frustum.h frustum_src.I frustum_src.h \ geometricBoundingVolume.I geometricBoundingVolume.h look_at.h \ look_at_src.I look_at_src.h \ diff --git a/panda/src/mathutil/boundingBox.I b/panda/src/mathutil/boundingBox.I index d81f5f37dc..2b595b5794 100644 --- a/panda/src/mathutil/boundingBox.I +++ b/panda/src/mathutil/boundingBox.I @@ -28,7 +28,7 @@ BoundingBox() { // Description: Constructs a specific box object. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL BoundingBox:: -BoundingBox(const LPoint3f &min, const LPoint3f &max) : +BoundingBox(const LPoint3 &min, const LPoint3 &max) : _min(min), _max(max) { #ifdef NDEBUG @@ -46,7 +46,7 @@ BoundingBox(const LPoint3f &min, const LPoint3f &max) : // would also work, but it is a virtual non-inline // method. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL const LPoint3f &BoundingBox:: +INLINE_MATHUTIL const LPoint3 &BoundingBox:: get_minq() const { nassertr(!is_empty(), _min); nassertr(!is_infinite(), _min); @@ -60,7 +60,7 @@ get_minq() const { // would also work, but it is a virtual non-inline // method. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL const LPoint3f &BoundingBox:: +INLINE_MATHUTIL const LPoint3 &BoundingBox:: get_maxq() const { nassertr(!is_empty(), _max); nassertr(!is_infinite(), _max); @@ -82,14 +82,14 @@ get_num_points() const { // Access: Published // Description: Returns the nth vertex of the rectangular solid. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f BoundingBox:: +INLINE_MATHUTIL LPoint3 BoundingBox:: get_point(int n) const { - nassertr(n >= 0 && n < 8, LPoint3f::zero()); + nassertr(n >= 0 && n < 8, LPoint3::zero()); // We do some trickery assuming that _min and _max are consecutive // in memory. - const LPoint3f *a = &_min; - return LPoint3f(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); + const LPoint3 *a = &_min; + return LPoint3(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); } //////////////////////////////////////////////////////////////////// @@ -107,10 +107,10 @@ get_num_planes() const { // Access: Published // Description: Returns the nth face of the rectangular solid. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL Planef BoundingBox:: +INLINE_MATHUTIL LPlane BoundingBox:: get_plane(int n) const { - nassertr(n >= 0 && n < 6, Planef()); - return Planef(get_point(plane_def[n][0]), + nassertr(n >= 0 && n < 6, LPlane()); + return LPlane(get_point(plane_def[n][0]), get_point(plane_def[n][1]), get_point(plane_def[n][2])); } diff --git a/panda/src/mathutil/boundingBox.cxx b/panda/src/mathutil/boundingBox.cxx index 0b34beb8de..ceb3ef6756 100644 --- a/panda/src/mathutil/boundingBox.cxx +++ b/panda/src/mathutil/boundingBox.cxx @@ -49,7 +49,7 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingBox:: +LPoint3 BoundingBox:: get_min() const { nassertr(!is_empty(), _min); nassertr(!is_infinite(), _min); @@ -61,7 +61,7 @@ get_min() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingBox:: +LPoint3 BoundingBox:: get_max() const { nassertr(!is_empty(), _max); nassertr(!is_infinite(), _max); @@ -73,7 +73,7 @@ get_max() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float BoundingBox:: +PN_stdfloat BoundingBox:: get_volume() const { nassertr(!is_infinite(), 0.0f); if (is_empty()) { @@ -89,10 +89,10 @@ get_volume() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingBox:: +LPoint3 BoundingBox:: get_approx_center() const { - nassertr(!is_empty(), LPoint3f::zero()); - nassertr(!is_infinite(), LPoint3f::zero()); + nassertr(!is_empty(), LPoint3::zero()); + nassertr(!is_infinite(), LPoint3::zero()); return (_min + _max) * 0.5f; } @@ -102,16 +102,16 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void BoundingBox:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { // We need to transform the eight corners of the cube, and then // determine the new box. - LPoint3f x = get_point(0) * mat; - LPoint3f n = x; + LPoint3 x = get_point(0) * mat; + LPoint3 n = x; for (int i = 1; i < 8; ++i) { - LPoint3f p = get_point(i) * mat; + LPoint3 p = get_point(i) * mat; n.set(min(n[0], p[0]), min(n[1], p[1]), min(n[2], p[2])); x.set(max(x[0], p[0]), max(x[1], p[1]), max(x[2], p[2])); } @@ -187,7 +187,7 @@ contains_other(const BoundingVolume *other) const { // Description: //////////////////////////////////////////////////////////////////// bool BoundingBox:: -extend_by_point(const LPoint3f &point) { +extend_by_point(const LPoint3 &point) { nassertr(!point.is_nan(), false); if (is_empty()) { @@ -258,8 +258,8 @@ bool BoundingBox:: extend_by_finite(const FiniteBoundingVolume *volume) { nassertr(!volume->is_empty(), false); - LVector3f min1 = volume->get_min(); - LVector3f max1 = volume->get_max(); + LVector3 min1 = volume->get_min(); + LVector3 max1 = volume->get_max(); if (is_empty()) { _min = min1; @@ -284,11 +284,11 @@ extend_by_finite(const FiniteBoundingVolume *volume) { // Description: //////////////////////////////////////////////////////////////////// bool BoundingBox:: -around_points(const LPoint3f *first, const LPoint3f *last) { +around_points(const LPoint3 *first, const LPoint3 *last) { nassertr(first != last, false); // Get the minmax of all the points to construct a bounding box. - const LPoint3f *p = first; + const LPoint3 *p = first; #ifndef NDEBUG // Skip any NaN points. @@ -406,8 +406,8 @@ around_finite(const BoundingVolume **first, nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { const FiniteBoundingVolume *vol = DCAST(FiniteBoundingVolume, *p); - LPoint3f min1 = vol->get_min(); - LPoint3f max1 = vol->get_max(); + LPoint3 min1 = vol->get_min(); + LPoint3 max1 = vol->get_max(); _min.set(min(_min[0], min1[0]), min(_min[1], min1[1]), min(_min[2], min1[2])); @@ -427,7 +427,7 @@ around_finite(const BoundingVolume **first, // Description: //////////////////////////////////////////////////////////////////// int BoundingBox:: -contains_point(const LPoint3f &point) const { +contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); if (is_empty()) { @@ -453,7 +453,7 @@ contains_point(const LPoint3f &point) const { // Description: //////////////////////////////////////////////////////////////////// int BoundingBox:: -contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { +contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); if (a == b) { @@ -562,8 +562,8 @@ contains_box(const BoundingBox *box) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!box->is_empty() && !box->is_infinite(), 0); - const LPoint3f &min1 = box->get_minq(); - const LPoint3f &max1 = box->get_maxq(); + const LPoint3 &min1 = box->get_minq(); + const LPoint3 &max1 = box->get_maxq(); if (min1[0] >= _min[0] && max1[0] <= _max[0] && min1[1] >= _min[1] && max1[1] <= _max[1] && @@ -638,8 +638,8 @@ contains_finite(const FiniteBoundingVolume *volume) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!volume->is_empty() && !volume->is_infinite(), 0); - LPoint3f min1 = volume->get_min(); - LPoint3f max1 = volume->get_max(); + LPoint3 min1 = volume->get_min(); + LPoint3 max1 = volume->get_max(); if (min1[0] >= _min[0] && max1[0] <= _max[0] && min1[1] >= _min[1] && max1[1] <= _max[1] && diff --git a/panda/src/mathutil/boundingBox.h b/panda/src/mathutil/boundingBox.h index cd6754621e..f166de283c 100644 --- a/panda/src/mathutil/boundingBox.h +++ b/panda/src/mathutil/boundingBox.h @@ -31,33 +31,33 @@ class EXPCL_PANDA_MATHUTIL BoundingBox : public FiniteBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingBox(); - INLINE_MATHUTIL BoundingBox(const LPoint3f &min, const LPoint3f &max); + INLINE_MATHUTIL BoundingBox(const LPoint3 &min, const LPoint3 &max); ALLOC_DELETED_CHAIN(BoundingBox); public: virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_min() const; - virtual LPoint3f get_max() const; - virtual float get_volume() const; + virtual LPoint3 get_min() const; + virtual LPoint3 get_max() const; + virtual PN_stdfloat get_volume() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: INLINE_MATHUTIL int get_num_points() const; - INLINE_MATHUTIL LPoint3f get_point(int n) const; + INLINE_MATHUTIL LPoint3 get_point(int n) const; MAKE_SEQ(get_points, get_num_points, get_point); INLINE_MATHUTIL int get_num_planes() const; - INLINE_MATHUTIL Planef get_plane(int n) const; + INLINE_MATHUTIL LPlane get_plane(int n) const; MAKE_SEQ(get_planes, get_num_planes, get_plane); public: // Inline accessors for speed. - INLINE_MATHUTIL const LPoint3f &get_minq() const; - INLINE_MATHUTIL const LPoint3f &get_maxq() const; + INLINE_MATHUTIL const LPoint3 &get_minq() const; + INLINE_MATHUTIL const LPoint3 &get_maxq() const; public: virtual const BoundingBox *as_bounding_box() const; @@ -70,14 +70,14 @@ protected: virtual int contains_other(const BoundingVolume *other) const; - virtual bool extend_by_point(const LPoint3f &point); + virtual bool extend_by_point(const LPoint3 &point); virtual bool extend_by_sphere(const BoundingSphere *sphere); virtual bool extend_by_box(const BoundingBox *box); virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron); bool extend_by_finite(const FiniteBoundingVolume *volume); - virtual bool around_points(const LPoint3f *first, - const LPoint3f *last); + virtual bool around_points(const LPoint3 *first, + const LPoint3 *last); virtual bool around_spheres(const BoundingVolume **first, const BoundingVolume **last); virtual bool around_boxes(const BoundingVolume **first, @@ -87,8 +87,8 @@ protected: bool around_finite(const BoundingVolume **first, const BoundingVolume **last); - virtual int contains_point(const LPoint3f &point) const; - virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; + virtual int contains_point(const LPoint3 &point) const; + virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; @@ -97,8 +97,8 @@ protected: int contains_finite(const FiniteBoundingVolume *volume) const; private: - LPoint3f _min; - LPoint3f _max; + LPoint3 _min; + LPoint3 _max; static const int plane_def[6][3]; diff --git a/panda/src/mathutil/boundingHexahedron.I b/panda/src/mathutil/boundingHexahedron.I index e36fc7822c..4c0f17f441 100644 --- a/panda/src/mathutil/boundingHexahedron.I +++ b/panda/src/mathutil/boundingHexahedron.I @@ -37,9 +37,9 @@ get_num_points() const { // Access: Published // Description: Returns the nth vertex of the hexahedron. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f BoundingHexahedron:: +INLINE_MATHUTIL LPoint3 BoundingHexahedron:: get_point(int n) const { - nassertr(n >= 0 && n < num_points, LPoint3f::zero()); + nassertr(n >= 0 && n < num_points, LPoint3::zero()); return _points[n]; } @@ -58,8 +58,8 @@ get_num_planes() const { // Access: Published // Description: Returns the nth face of the hexahedron. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL Planef BoundingHexahedron:: +INLINE_MATHUTIL LPlane BoundingHexahedron:: get_plane(int n) const { - nassertr(n >= 0 && n < num_planes, Planef()); + nassertr(n >= 0 && n < num_planes, LPlane()); return _planes[n]; } diff --git a/panda/src/mathutil/boundingHexahedron.cxx b/panda/src/mathutil/boundingHexahedron.cxx index a8d140a1cf..cc2ef03e70 100644 --- a/panda/src/mathutil/boundingHexahedron.cxx +++ b/panda/src/mathutil/boundingHexahedron.cxx @@ -34,7 +34,7 @@ BoundingHexahedron(const Frustumf &frustum, bool is_ortho, cs = get_default_coordinate_system(); } - float fs = 1.0f; + PN_stdfloat fs = 1.0f; if (!is_ortho) { fs = frustum._ffar / frustum._fnear; } @@ -58,7 +58,7 @@ BoundingHexahedron(const Frustumf &frustum, bool is_ortho, set_centroid(); set_planes(); } else { - xform(LMatrix4f::convert_mat(CS_zup_right, cs)); + xform(LMatrix4::convert_mat(CS_zup_right, cs)); } } @@ -68,10 +68,10 @@ BoundingHexahedron(const Frustumf &frustum, bool is_ortho, // Description: //////////////////////////////////////////////////////////////////// BoundingHexahedron:: -BoundingHexahedron(const LPoint3f &fll, const LPoint3f &flr, - const LPoint3f &fur, const LPoint3f &ful, - const LPoint3f &nll, const LPoint3f &nlr, - const LPoint3f &nur, const LPoint3f &nul) { +BoundingHexahedron(const LPoint3 &fll, const LPoint3 &flr, + const LPoint3 &fur, const LPoint3 &ful, + const LPoint3 &nll, const LPoint3 &nlr, + const LPoint3 &nur, const LPoint3 &nul) { _points[0] = fll; _points[1] = flr; _points[2] = fur; @@ -101,12 +101,12 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingHexahedron:: +LPoint3 BoundingHexahedron:: get_min() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); int i; - LPoint3f m = _points[0]; + LPoint3 m = _points[0]; for (i = 1; i < num_points; i++) { m.set(min(m[0], _points[i][0]), min(m[1], _points[i][1]), @@ -120,12 +120,12 @@ get_min() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingHexahedron:: +LPoint3 BoundingHexahedron:: get_max() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); int i; - LPoint3f m = _points[0]; + LPoint3 m = _points[0]; for (i = 1; i < num_points; i++) { m.set(max(m[0], _points[i][0]), max(m[1], _points[i][1]), @@ -139,10 +139,10 @@ get_max() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingHexahedron:: +LPoint3 BoundingHexahedron:: get_approx_center() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); return _centroid; } @@ -152,7 +152,7 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void BoundingHexahedron:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { if (!is_empty() && !is_infinite()) { for (int i = 0; i < num_points; i++) { _points[i] = _points[i] * mat; @@ -250,7 +250,7 @@ contains_other(const BoundingVolume *other) const { // Description: //////////////////////////////////////////////////////////////////// int BoundingHexahedron:: -contains_point(const LPoint3f &point) const { +contains_point(const LPoint3 &point) const { if (is_empty()) { return IF_no_intersection; @@ -261,7 +261,7 @@ contains_point(const LPoint3f &point) const { // The hexahedron contains the point iff the point is behind all of // the planes. for (int i = 0; i < num_planes; i++) { - const Planef &p = _planes[i]; + const LPlane &p = _planes[i]; if (p.dist_to_plane(point) > 0.0f) { return IF_no_intersection; } @@ -276,7 +276,7 @@ contains_point(const LPoint3f &point) const { // Description: //////////////////////////////////////////////////////////////////// int BoundingHexahedron:: -contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { +contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { if (is_empty()) { return IF_no_intersection; @@ -287,7 +287,7 @@ contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { // The hexahedron does not contains the line segment if both points // are in front of any one plane. for (int i = 0; i < num_planes; i++) { - const Planef &p = _planes[i]; + const LPlane &p = _planes[i]; if (p.dist_to_plane(a) > 0.0f || p.dist_to_plane(b) > 0.0f) { return IF_no_intersection; @@ -312,14 +312,14 @@ contains_sphere(const BoundingSphere *sphere) const { // The hexahedron contains the sphere iff the sphere is at least // partly behind all of the planes. - const LPoint3f ¢er = sphere->get_center(); - float radius = sphere->get_radius(); + const LPoint3 ¢er = sphere->get_center(); + PN_stdfloat radius = sphere->get_radius(); int result = IF_possible | IF_some | IF_all; for (int i = 0; i < num_planes; i++) { - const Planef &p = _planes[i]; - float dist = p.dist_to_plane(center); + const LPlane &p = _planes[i]; + PN_stdfloat dist = p.dist_to_plane(center); if (dist > radius) { // The sphere is completely in front of this plane; it's thus @@ -347,17 +347,17 @@ contains_box(const BoundingBox *box) const { nassertr(!box->is_empty(), 0); // Put the box inside a sphere for the purpose of this test. - const LPoint3f &min = box->get_minq(); - const LPoint3f &max = box->get_maxq(); - LPoint3f center = (min + max) * 0.5f; - float radius2 = (max - center).length_squared(); + const LPoint3 &min = box->get_minq(); + const LPoint3 &max = box->get_maxq(); + LPoint3 center = (min + max) * 0.5f; + PN_stdfloat radius2 = (max - center).length_squared(); int result = IF_possible | IF_some | IF_all; for (int i = 0; i < num_planes; i++) { - const Planef &p = _planes[i]; - float dist = p.dist_to_plane(center); - float dist2 = dist * dist; + const LPlane &p = _planes[i]; + PN_stdfloat dist = p.dist_to_plane(center); + PN_stdfloat dist2 = dist * dist; if (dist2 <= radius2) { // The sphere is not completely behind this plane, but some of @@ -402,17 +402,17 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { nassertr(!hexahedron->is_empty(), 0); // Put the hexahedron inside a sphere for the purposes of this test. - LPoint3f min = hexahedron->get_min(); - LPoint3f max = hexahedron->get_max(); - LPoint3f center = (min + max) * 0.5f; - float radius2 = (max - center).length_squared(); + LPoint3 min = hexahedron->get_min(); + LPoint3 max = hexahedron->get_max(); + LPoint3 center = (min + max) * 0.5f; + PN_stdfloat radius2 = (max - center).length_squared(); int result = IF_possible | IF_some | IF_all; for (int i = 0; i < num_planes; i++) { - const Planef &p = _planes[i]; - float dist = p.dist_to_plane(center); - float dist2 = dist * dist; + const LPlane &p = _planes[i]; + PN_stdfloat dist = p.dist_to_plane(center); + PN_stdfloat dist2 = dist * dist; if (dist >= 0.0f && dist2 > radius2) { // The sphere is completely in front of this plane; it's thus @@ -451,7 +451,7 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { //////////////////////////////////////////////////////////////////// void BoundingHexahedron:: set_planes() { - _planes[0] = Planef(_points[0], _points[3], _points[2]); + _planes[0] = LPlane(_points[0], _points[3], _points[2]); // Test to see if we have accidentally inverted our frustum by // transforming it with a -1 matrix. We do this by ensuring that @@ -460,20 +460,20 @@ set_planes() { if (_planes[0].dist_to_plane(_centroid) > 0) { // Oops! We're flipped! Rebuild the planes in the opposite // direction. - _planes[0] = Planef(_points[0], _points[2], _points[3]); - _planes[1] = Planef(_points[0], _points[5], _points[1]); - _planes[2] = Planef(_points[1], _points[6], _points[2]); - _planes[3] = Planef(_points[2], _points[7], _points[3]); - _planes[4] = Planef(_points[3], _points[4], _points[0]); - _planes[5] = Planef(_points[4], _points[7], _points[6]); + _planes[0] = LPlane(_points[0], _points[2], _points[3]); + _planes[1] = LPlane(_points[0], _points[5], _points[1]); + _planes[2] = LPlane(_points[1], _points[6], _points[2]); + _planes[3] = LPlane(_points[2], _points[7], _points[3]); + _planes[4] = LPlane(_points[3], _points[4], _points[0]); + _planes[5] = LPlane(_points[4], _points[7], _points[6]); } else { // No, a perfectly sane universe. - _planes[1] = Planef(_points[0], _points[1], _points[5]); - _planes[2] = Planef(_points[1], _points[2], _points[6]); - _planes[3] = Planef(_points[2], _points[3], _points[7]); - _planes[4] = Planef(_points[3], _points[0], _points[4]); - _planes[5] = Planef(_points[4], _points[6], _points[7]); + _planes[1] = LPlane(_points[0], _points[1], _points[5]); + _planes[2] = LPlane(_points[1], _points[2], _points[6]); + _planes[3] = LPlane(_points[2], _points[3], _points[7]); + _planes[4] = LPlane(_points[3], _points[0], _points[4]); + _planes[5] = LPlane(_points[4], _points[6], _points[7]); } // Still not entirely sure why some code keeps triggering these, but @@ -495,9 +495,9 @@ set_planes() { //////////////////////////////////////////////////////////////////// void BoundingHexahedron:: set_centroid() { - LPoint3f net = _points[0]; + LPoint3 net = _points[0]; for (int i = 1; i < num_points; i++) { net += _points[i]; } - _centroid = net / (float)num_points; + _centroid = net / (PN_stdfloat)num_points; } diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index 458a4bbad9..034922e9ed 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -40,30 +40,30 @@ public: PUBLISHED: BoundingHexahedron(const Frustumf &frustum, bool is_ortho, CoordinateSystem cs = CS_default); - BoundingHexahedron(const LPoint3f &fll, const LPoint3f &flr, - const LPoint3f &fur, const LPoint3f &ful, - const LPoint3f &nll, const LPoint3f &nlr, - const LPoint3f &nur, const LPoint3f &nul); + BoundingHexahedron(const LPoint3 &fll, const LPoint3 &flr, + const LPoint3 &fur, const LPoint3 &ful, + const LPoint3 &nll, const LPoint3 &nlr, + const LPoint3 &nur, const LPoint3 &nul); public: ALLOC_DELETED_CHAIN(BoundingHexahedron); virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_min() const; - virtual LPoint3f get_max() const; + virtual LPoint3 get_min() const; + virtual LPoint3 get_max() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; PUBLISHED: INLINE_MATHUTIL int get_num_points() const; - INLINE_MATHUTIL LPoint3f get_point(int n) const; + INLINE_MATHUTIL LPoint3 get_point(int n) const; MAKE_SEQ(get_points, get_num_points, get_point); INLINE_MATHUTIL int get_num_planes() const; - INLINE_MATHUTIL Planef get_plane(int n) const; + INLINE_MATHUTIL LPlane get_plane(int n) const; MAKE_SEQ(get_planes, get_num_planes, get_plane); public: @@ -76,8 +76,8 @@ protected: const BoundingVolume **last) const; virtual int contains_other(const BoundingVolume *other) const; - virtual int contains_point(const LPoint3f &point) const; - virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; + virtual int contains_point(const LPoint3 &point) const; + virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; @@ -91,9 +91,9 @@ private: num_points = 8, num_planes = 6 }; - LPoint3f _points[num_points]; - Planef _planes[num_planes]; - LPoint3f _centroid; + LPoint3 _points[num_points]; + LPlane _planes[num_planes]; + LPoint3 _centroid; public: diff --git a/panda/src/mathutil/boundingLine.I b/panda/src/mathutil/boundingLine.I index dd8cfdccac..4623088a0a 100644 --- a/panda/src/mathutil/boundingLine.I +++ b/panda/src/mathutil/boundingLine.I @@ -28,7 +28,7 @@ BoundingLine() { // Description: //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL BoundingLine:: -BoundingLine(const LPoint3f &a, const LPoint3f &b) : +BoundingLine(const LPoint3 &a, const LPoint3 &b) : _origin(a), _vector(b - a) { _vector.normalize(); @@ -43,7 +43,7 @@ BoundingLine(const LPoint3f &a, const LPoint3f &b) : // Access: Published // Description: Returns the first point that defines the line. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL const LPoint3f &BoundingLine:: +INLINE_MATHUTIL const LPoint3 &BoundingLine:: get_point_a() const { nassertr(!is_empty(), _origin); nassertr(!is_infinite(), _origin); @@ -55,7 +55,7 @@ get_point_a() const { // Access: Published // Description: Returns the second point that defines the line. //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f BoundingLine:: +INLINE_MATHUTIL LPoint3 BoundingLine:: get_point_b() const { nassertr(!is_empty(), _origin); nassertr(!is_infinite(), _origin); diff --git a/panda/src/mathutil/boundingLine.cxx b/panda/src/mathutil/boundingLine.cxx index 5352764321..afc66b857e 100644 --- a/panda/src/mathutil/boundingLine.cxx +++ b/panda/src/mathutil/boundingLine.cxx @@ -35,10 +35,10 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingLine:: +LPoint3 BoundingLine:: get_approx_center() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); return (get_point_a() + get_point_b()) / 2.0; } @@ -48,7 +48,7 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void BoundingLine:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { @@ -152,7 +152,7 @@ contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!sphere->is_empty() && !sphere->is_infinite(), 0); - float r = sphere->get_radius(); + PN_stdfloat r = sphere->get_radius(); if (r * r >= sqr_dist_to_line(sphere->get_center())) { return IF_possible | IF_some; @@ -171,8 +171,8 @@ contains_box(const BoundingBox *box) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!box->is_empty() && !box->is_infinite(), 0); - LPoint3f center = (box->get_minq() + box->get_maxq()) * 0.5f; - float r2 = (box->get_maxq() - box->get_minq()).length_squared() * 0.25f; + LPoint3 center = (box->get_minq() + box->get_maxq()) * 0.5f; + PN_stdfloat r2 = (box->get_maxq() - box->get_minq()).length_squared() * 0.25f; if (r2 >= sqr_dist_to_line(center)) { return IF_possible; @@ -186,22 +186,22 @@ contains_box(const BoundingBox *box) const { // Access: Protected // Description: //////////////////////////////////////////////////////////////////// -float BoundingLine:: -sqr_dist_to_line(const LPoint3f &point) const { +PN_stdfloat BoundingLine:: +sqr_dist_to_line(const LPoint3 &point) const { nassertr(!point.is_nan(), 0.0f); nassertr(!is_empty() && !is_infinite(), 0.0f); - nassertr(!_vector.almost_equal(LVector3f(0.0f, 0.0f, 0.0f)), 0.0f); + nassertr(!_vector.almost_equal(LVector3(0.0f, 0.0f, 0.0f)), 0.0f); // The formula for the distance from a point to the line based on // the quadratic equation. - float A = dot(_vector, _vector); + PN_stdfloat A = dot(_vector, _vector); nassertr(A != 0.0f, 0.0f); - LVector3f fc = _origin - point; - float B = 2.0 * dot(_vector, fc); - float fc_d2 = dot(fc, fc); + LVector3 fc = _origin - point; + PN_stdfloat B = 2.0 * dot(_vector, fc); + PN_stdfloat fc_d2 = dot(fc, fc); - float r2 = fc_d2 - B*B / 4.0*A; + PN_stdfloat r2 = fc_d2 - B*B / 4.0*A; nassertr(!cnan(r2), 0.0f); return r2; diff --git a/panda/src/mathutil/boundingLine.h b/panda/src/mathutil/boundingLine.h index e81408ed4c..a9bb26ea46 100644 --- a/panda/src/mathutil/boundingLine.h +++ b/panda/src/mathutil/boundingLine.h @@ -35,20 +35,20 @@ public: INLINE_MATHUTIL BoundingLine(); PUBLISHED: - INLINE_MATHUTIL BoundingLine(const LPoint3f &a, const LPoint3f &b); + INLINE_MATHUTIL BoundingLine(const LPoint3 &a, const LPoint3 &b); ALLOC_DELETED_CHAIN(BoundingLine); public: virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: - INLINE_MATHUTIL const LPoint3f &get_point_a() const; - INLINE_MATHUTIL LPoint3f get_point_b() const; + INLINE_MATHUTIL const LPoint3 &get_point_a() const; + INLINE_MATHUTIL LPoint3 get_point_b() const; public: virtual const BoundingLine *as_bounding_line() const; @@ -65,11 +65,11 @@ protected: virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; - float sqr_dist_to_line(const LPoint3f &point) const; + PN_stdfloat sqr_dist_to_line(const LPoint3 &point) const; private: - LPoint3f _origin; - LVector3f _vector; + LPoint3 _origin; + LVector3 _vector; public: diff --git a/panda/src/mathutil/boundingPlane.I b/panda/src/mathutil/boundingPlane.I index 92aaf461ed..57f23826f3 100644 --- a/panda/src/mathutil/boundingPlane.I +++ b/panda/src/mathutil/boundingPlane.I @@ -29,7 +29,7 @@ BoundingPlane() { // Description: //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL BoundingPlane:: -BoundingPlane(const Planef &plane) : +BoundingPlane(const LPlane &plane) : _plane(plane) { _flags = 0; @@ -40,7 +40,7 @@ BoundingPlane(const Planef &plane) : // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL const Planef &BoundingPlane:: +INLINE_MATHUTIL const LPlane &BoundingPlane:: get_plane() const { nassertr(!is_empty(), _plane); nassertr(!is_infinite(), _plane); diff --git a/panda/src/mathutil/boundingPlane.cxx b/panda/src/mathutil/boundingPlane.cxx index 86d3f83725..01a8bc5076 100644 --- a/panda/src/mathutil/boundingPlane.cxx +++ b/panda/src/mathutil/boundingPlane.cxx @@ -33,10 +33,10 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingPlane:: +LPoint3 BoundingPlane:: get_approx_center() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); return _plane.get_point(); } @@ -46,7 +46,7 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void BoundingPlane:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { @@ -143,8 +143,8 @@ contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!sphere->is_empty() && !sphere->is_infinite(), 0); - float r = sphere->get_radius(); - float d = _plane.dist_to_plane(sphere->get_center()); + PN_stdfloat r = sphere->get_radius(); + PN_stdfloat d = _plane.dist_to_plane(sphere->get_center()); if (d <= -r) { // The sphere is completely behind the plane. @@ -171,15 +171,15 @@ contains_box(const BoundingBox *box) const { nassertr(!box->is_empty() && !box->is_infinite(), 0); // Put the box inside a sphere for the purpose of this test. - const LPoint3f &min = box->get_minq(); - const LPoint3f &max = box->get_maxq(); - LPoint3f center = (min + max) * 0.5f; - float radius2 = (max - center).length_squared(); + const LPoint3 &min = box->get_minq(); + const LPoint3 &max = box->get_maxq(); + LPoint3 center = (min + max) * 0.5f; + PN_stdfloat radius2 = (max - center).length_squared(); int result = IF_possible | IF_some | IF_all; - float dist = _plane.dist_to_plane(center); - float dist2 = dist * dist; + PN_stdfloat dist = _plane.dist_to_plane(center); + PN_stdfloat dist2 = dist * dist; if (dist2 <= radius2) { // The sphere is not completely behind this plane, but some of diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index 30e9d8da6f..0ee5821f83 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -31,19 +31,19 @@ class EXPCL_PANDA_MATHUTIL BoundingPlane : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingPlane(); - INLINE_MATHUTIL BoundingPlane(const Planef &plane); + INLINE_MATHUTIL BoundingPlane(const LPlane &plane); ALLOC_DELETED_CHAIN(BoundingPlane); public: virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: - INLINE_MATHUTIL const Planef &get_plane() const; + INLINE_MATHUTIL const LPlane &get_plane() const; public: virtual const BoundingPlane *as_bounding_plane() const; @@ -64,7 +64,7 @@ protected: virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; private: - Planef _plane; + LPlane _plane; public: static TypeHandle get_class_type() { diff --git a/panda/src/mathutil/boundingSphere.I b/panda/src/mathutil/boundingSphere.I index 1ae1c30925..c42c7a40e4 100644 --- a/panda/src/mathutil/boundingSphere.I +++ b/panda/src/mathutil/boundingSphere.I @@ -28,7 +28,7 @@ BoundingSphere() { // Description: Constructs a specific sphere. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL BoundingSphere:: -BoundingSphere(const LPoint3f ¢er, float radius) : +BoundingSphere(const LPoint3 ¢er, PN_stdfloat radius) : _center(center), _radius(radius) { _flags = 0; @@ -42,10 +42,10 @@ BoundingSphere(const LPoint3f ¢er, float radius) : // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL LPoint3f BoundingSphere:: +INLINE_MATHUTIL LPoint3 BoundingSphere:: get_center() const { - nassertr(!is_empty(), LPoint3f::zero()); - nassertr(!is_infinite(), LPoint3f::zero()); + nassertr(!is_empty(), LPoint3::zero()); + nassertr(!is_infinite(), LPoint3::zero()); return _center; } @@ -54,7 +54,7 @@ get_center() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE_MATHUTIL float BoundingSphere:: +INLINE_MATHUTIL PN_stdfloat BoundingSphere:: get_radius() const { nassertr(!is_empty(), 0.0f); nassertr(!is_infinite(), 0.0f); diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index 5347ae0b64..0745c50b25 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -40,11 +40,11 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingSphere:: +LPoint3 BoundingSphere:: get_min() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); - return LPoint3f(_center[0] - _radius, + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); + return LPoint3(_center[0] - _radius, _center[1] - _radius, _center[2] - _radius); } @@ -54,11 +54,11 @@ get_min() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingSphere:: +LPoint3 BoundingSphere:: get_max() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); - return LPoint3f(_center[0] + _radius, + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); + return LPoint3(_center[0] + _radius, _center[1] + _radius, _center[2] + _radius); } @@ -68,7 +68,7 @@ get_max() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float BoundingSphere:: +PN_stdfloat BoundingSphere:: get_volume() const { nassertr(!is_infinite(), 0.0f); if (is_empty()) { @@ -84,10 +84,10 @@ get_volume() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f BoundingSphere:: +LPoint3 BoundingSphere:: get_approx_center() const { - nassertr(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); - nassertr(!is_infinite(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); + nassertr(!is_infinite(), LPoint3(0.0f, 0.0f, 0.0f)); return get_center(); } @@ -97,7 +97,7 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void BoundingSphere:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { @@ -105,16 +105,16 @@ xform(const LMatrix4f &mat) { // contains a non-uniform scale. /* - LVector3f x,y,z; + LVector3 x,y,z; mat.get_row3(x,0); mat.get_row3(y,1); mat.get_row3(z,2); - float xd = dot(x, x); - float yd = dot(y, y); - float zd = dot(z, z); + PN_stdfloat xd = dot(x, x); + PN_stdfloat yd = dot(y, y); + PN_stdfloat zd = dot(z, z); */ - float xd,yd,zd,scale; + PN_stdfloat xd,yd,zd,scale; #define ROW_DOTTED(mat,ROWNUM) \ (mat._m.m._##ROWNUM##0*mat._m.m._##ROWNUM##0 + \ @@ -204,7 +204,7 @@ contains_other(const BoundingVolume *other) const { // Description: //////////////////////////////////////////////////////////////////// bool BoundingSphere:: -extend_by_point(const LPoint3f &point) { +extend_by_point(const LPoint3 &point) { nassertr(!point.is_nan(), false); if (is_empty()) { @@ -212,8 +212,8 @@ extend_by_point(const LPoint3f &point) { _radius = 0.0f; _flags = 0; } else if (!is_infinite()) { - LVector3f v = point - _center; - float dist2 = dot(v, v); + LVector3 v = point - _center; + PN_stdfloat dist2 = dot(v, v); if (dist2 > _radius * _radius) { _radius = sqrtf(dist2); } @@ -236,7 +236,7 @@ extend_by_sphere(const BoundingSphere *sphere) { _radius = sphere->_radius; _flags = 0; } else { - float dist = length(sphere->_center - _center); + PN_stdfloat dist = length(sphere->_center - _center); _radius = max(_radius, dist + sphere->_radius); } @@ -250,19 +250,19 @@ extend_by_sphere(const BoundingSphere *sphere) { //////////////////////////////////////////////////////////////////// bool BoundingSphere:: extend_by_box(const BoundingBox *box) { - const LVector3f &min1 = box->get_minq(); - const LVector3f &max1 = box->get_maxq(); + const LVector3 &min1 = box->get_minq(); + const LVector3 &max1 = box->get_maxq(); if (is_empty()) { _center = (min1 + max1) * 0.5f; - _radius = length(LVector3f(max1 - _center)); + _radius = length(LVector3(max1 - _center)); _flags = 0; } else { // Find the minimum radius necessary to reach the corner. - float max_dist2 = -1.0; + PN_stdfloat max_dist2 = -1.0; for (int i = 0; i < 8; ++i) { - float dist2 = (box->get_point(i) - _center).length_squared(); + PN_stdfloat dist2 = (box->get_point(i) - _center).length_squared(); if (dist2 > max_dist2) { max_dist2 = dist2; } @@ -309,12 +309,12 @@ extend_by_finite(const FiniteBoundingVolume *volume) { // Description: //////////////////////////////////////////////////////////////////// bool BoundingSphere:: -around_points(const LPoint3f *first, const LPoint3f *last) { +around_points(const LPoint3 *first, const LPoint3 *last) { nassertr(first != last, false); // First, get the box of all the points to construct a bounding // box. - const LPoint3f *p = first; + const LPoint3 *p = first; #ifndef NDEBUG // Skip any NaN points. @@ -330,8 +330,8 @@ around_points(const LPoint3f *first, const LPoint3f *last) { } #endif - LPoint3f min_box = *p; - LPoint3f max_box = *p; + LPoint3 min_box = *p; + LPoint3 max_box = *p; ++p; #ifndef NDEBUG @@ -373,10 +373,10 @@ around_points(const LPoint3f *first, const LPoint3f *last) { _center = (min_box + max_box) * 0.5f; // Now walk back through to get the max distance from center. - float max_dist2 = 0.0f; + PN_stdfloat max_dist2 = 0.0f; for (p = first; p != last; ++p) { - LVector3f v = (*p) - _center; - float dist2 = dot(v, v); + LVector3 v = (*p) - _center; + PN_stdfloat dist2 = dot(v, v); max_dist2 = max(max_dist2, dist2); } @@ -449,8 +449,8 @@ around_finite(const BoundingVolume **first, nassertr(!(*p)->is_empty() && !(*p)->is_infinite(), false); const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); nassertr(vol != (FiniteBoundingVolume *)NULL, false); - LPoint3f min_box = vol->get_min(); - LPoint3f max_box = vol->get_max(); + LPoint3 min_box = vol->get_min(); + LPoint3 max_box = vol->get_max(); bool any_spheres = (vol->as_bounding_sphere() != NULL); @@ -462,8 +462,8 @@ around_finite(const BoundingVolume **first, set_infinite(); return true; } - LPoint3f min1 = vol->get_min(); - LPoint3f max1 = vol->get_max(); + LPoint3 min1 = vol->get_min(); + LPoint3 max1 = vol->get_max(); min_box.set(min(min_box[0], min1[0]), min(min_box[1], min1[1]), min(min_box[2], min1[2])); @@ -494,7 +494,7 @@ around_finite(const BoundingVolume **first, const BoundingSphere *sphere = (*p)->as_bounding_sphere(); if (sphere != (BoundingSphere *)NULL) { // This is a sphere; consider its corner. - float dist = length(sphere->_center - _center); + PN_stdfloat dist = length(sphere->_center - _center); _radius = max(_radius, dist + sphere->_radius); } else { @@ -506,9 +506,9 @@ around_finite(const BoundingVolume **first, box.local_object(); // Find the minimum radius necessary to reach the corner. - float max_dist2 = -1.0; + PN_stdfloat max_dist2 = -1.0; for (int i = 0; i < 8; ++i) { - float dist2 = (box.get_point(i) - _center).length_squared(); + PN_stdfloat dist2 = (box.get_point(i) - _center).length_squared(); if (dist2 > max_dist2) { max_dist2 = dist2; } @@ -529,7 +529,7 @@ around_finite(const BoundingVolume **first, // Description: //////////////////////////////////////////////////////////////////// int BoundingSphere:: -contains_point(const LPoint3f &point) const { +contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); if (is_empty()) { @@ -539,8 +539,8 @@ contains_point(const LPoint3f &point) const { return IF_possible | IF_some | IF_all; } else { - LVector3f v = point - _center; - float dist2 = dot(v, v); + LVector3 v = point - _center; + PN_stdfloat dist2 = dot(v, v); return (dist2 <= _radius * _radius) ? IF_possible | IF_some | IF_all : IF_no_intersection; } @@ -552,7 +552,7 @@ contains_point(const LPoint3f &point) const { // Description: //////////////////////////////////////////////////////////////////// int BoundingSphere:: -contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { +contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); if (a == b) { @@ -565,21 +565,21 @@ contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { return IF_possible | IF_some | IF_all; } else { - LPoint3f from = a; - LVector3f delta = b - a; - float t1, t2; + LPoint3 from = a; + LVector3 delta = b - a; + PN_stdfloat t1, t2; // Solve the equation for the intersection of a line with a sphere // using the quadratic equation. - float A = dot(delta, delta); + PN_stdfloat A = dot(delta, delta); nassertr(A != 0.0f, 0); // Trivial line segment. - LVector3f fc = from - _center; - float B = 2.0f * dot(delta, fc); - float C = dot(fc, fc) - _radius * _radius; + LVector3 fc = from - _center; + PN_stdfloat B = 2.0f * dot(delta, fc); + PN_stdfloat C = dot(fc, fc) - _radius * _radius; - float radical = B*B - 4.0f*A*C; + PN_stdfloat radical = B*B - 4.0f*A*C; if (IS_NEARLY_ZERO(radical)) { // Tangent. @@ -593,8 +593,8 @@ contains_lineseg(const LPoint3f &a, const LPoint3f &b) const { return IF_no_intersection; } - float reciprocal_2A = 1.0f/(2.0f*A); - float sqrt_radical = sqrtf(radical); + PN_stdfloat reciprocal_2A = 1.0f/(2.0f*A); + PN_stdfloat sqrt_radical = sqrtf(radical); t1 = ( -B - sqrt_radical ) * reciprocal_2A; t2 = ( -B + sqrt_radical ) * reciprocal_2A; @@ -621,8 +621,8 @@ contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); nassertr(!sphere->is_empty() && !sphere->is_infinite(), 0); - LVector3f v = sphere->_center - _center; - float dist2 = dot(v, v); + LVector3 v = sphere->_center - _center; + PN_stdfloat dist2 = dot(v, v); if (_radius >= sphere->_radius && dist2 <= (_radius - sphere->_radius) * (_radius - sphere->_radius)) { diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index 875c83b47a..c75c156944 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -28,24 +28,24 @@ class EXPCL_PANDA_MATHUTIL BoundingSphere : public FiniteBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingSphere(); - INLINE_MATHUTIL BoundingSphere(const LPoint3f ¢er, float radius); + INLINE_MATHUTIL BoundingSphere(const LPoint3 ¢er, PN_stdfloat radius); ALLOC_DELETED_CHAIN(BoundingSphere); public: virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_min() const; - virtual LPoint3f get_max() const; - virtual float get_volume() const; + virtual LPoint3 get_min() const; + virtual LPoint3 get_max() const; + virtual PN_stdfloat get_volume() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; PUBLISHED: - INLINE_MATHUTIL LPoint3f get_center() const; - INLINE_MATHUTIL float get_radius() const; + INLINE_MATHUTIL LPoint3 get_center() const; + INLINE_MATHUTIL PN_stdfloat get_radius() const; public: virtual const BoundingSphere *as_bounding_sphere() const; @@ -58,14 +58,14 @@ protected: virtual int contains_other(const BoundingVolume *other) const; - virtual bool extend_by_point(const LPoint3f &point); + virtual bool extend_by_point(const LPoint3 &point); virtual bool extend_by_sphere(const BoundingSphere *sphere); virtual bool extend_by_box(const BoundingBox *box); virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron); bool extend_by_finite(const FiniteBoundingVolume *volume); - virtual bool around_points(const LPoint3f *first, - const LPoint3f *last); + virtual bool around_points(const LPoint3 *first, + const LPoint3 *last); virtual bool around_spheres(const BoundingVolume **first, const BoundingVolume **last); virtual bool around_boxes(const BoundingVolume **first, @@ -75,8 +75,8 @@ protected: bool around_finite(const BoundingVolume **first, const BoundingVolume **last); - virtual int contains_point(const LPoint3f &point) const; - virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; + virtual int contains_point(const LPoint3 &point) const; + virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; @@ -84,8 +84,8 @@ protected: virtual int contains_plane(const BoundingPlane *plane) const; private: - LPoint3f _center; - float _radius; + LPoint3 _center; + PN_stdfloat _radius; public: diff --git a/panda/src/mathutil/config_mathutil.N b/panda/src/mathutil/config_mathutil.N index 035a8729df..948b48af9e 100644 --- a/panda/src/mathutil/config_mathutil.N +++ b/panda/src/mathutil/config_mathutil.N @@ -16,34 +16,69 @@ forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray -renametype PointerToArray PTAMat4 -renametype ConstPointerToArray CPTAMat4 +renametype PointerToArray PTAMat4f +renametype ConstPointerToArray CPTAMat4f forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray -renametype PointerToArray PTAMat3 -renametype ConstPointerToArray CPTAMat3 +renametype PointerToArray PTAMat3f +renametype ConstPointerToArray CPTAMat3f forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray -renametype PointerToArray PTAVecBase4 -renametype ConstPointerToArray PTAVecBase4 +renametype PointerToArray PTAVecBase4f +renametype ConstPointerToArray PTAVecBase4f forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray -renametype PointerToArray PTAVecBase3 -renametype ConstPointerToArray PTAVecBase3 +renametype PointerToArray PTAVecBase3f +renametype ConstPointerToArray PTAVecBase3f forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray -renametype PointerToArray PTAVecBase2 -renametype ConstPointerToArray PTAVecBase2 +renametype PointerToArray PTAVecBase2f +renametype ConstPointerToArray PTAVecBase2f + +forcetype PointerToBase > +forcetype PointerToArrayBase +forcetype PointerToArray +forcetype ConstPointerToArray +renametype PointerToArray PTAMat4d +renametype ConstPointerToArray CPTAMat4d + +forcetype PointerToBase > +forcetype PointerToArrayBase +forcetype PointerToArray +forcetype ConstPointerToArray +renametype PointerToArray PTAMat3d +renametype ConstPointerToArray CPTAMat3d + +forcetype PointerToBase > +forcetype PointerToArrayBase +forcetype PointerToArray +forcetype ConstPointerToArray +renametype PointerToArray PTAVecBase4d +renametype ConstPointerToArray PTAVecBase4d + +forcetype PointerToBase > +forcetype PointerToArrayBase +forcetype PointerToArray +forcetype ConstPointerToArray +renametype PointerToArray PTAVecBase3d +renametype ConstPointerToArray PTAVecBase3d + +forcetype PointerToBase > +forcetype PointerToArrayBase +forcetype PointerToArray +forcetype ConstPointerToArray +renametype PointerToArray PTAVecBase2d +renametype ConstPointerToArray PTAVecBase2d diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index bb0ed29732..84bb08a510 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -251,13 +251,13 @@ write_header(Datagram &datagram) { // indicated datagram. //////////////////////////////////////////////////////////////////// void FFTCompressor:: -write_reals(Datagram &datagram, const float *array, int length) { +write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { datagram.add_int32(length); if (_quality > 100) { // Special case: lossless output. for (int i = 0; i < length; i++) { - datagram.add_float32(array[i]); + datagram.add_stdfloat(array[i]); } return; } @@ -275,7 +275,7 @@ write_reals(Datagram &datagram, const float *array, int length) { if (length == 1) { // Special case: just write out the one number. - datagram.add_float32(array[0]); + datagram.add_stdfloat(array[0]); return; } @@ -289,7 +289,7 @@ write_reals(Datagram &datagram, const float *array, int length) { /* if (_use_error_threshold) { // Don't encode the data if it moves too erratically. - float error = get_compressability(array, length); + PN_stdfloat error = get_compressability(array, length); if (error > fft_error_threshold) { // No good: the data probably won't compress well. Just write // out lossless data. @@ -305,7 +305,7 @@ write_reals(Datagram &datagram, const float *array, int length) { << "Writing stream of " << length << " numbers uncompressed.\n"; } for (int i = 0; i < length; i++) { - datagram.add_float32(array[i]); + datagram.add_stdfloat(array[i]); } return; } @@ -389,12 +389,12 @@ write_reals(Datagram &datagram, const float *array, int length) { // datagram. //////////////////////////////////////////////////////////////////// void FFTCompressor:: -write_hprs(Datagram &datagram, const LVecBase3f *array, int length) { +write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { #ifndef NDEBUG if (_quality >= 104) { // If quality level is at least 104, we don't even convert hpr at // all. This is just for debugging. - vector_float h, p, r; + vector_stdfloat h, p, r; h.reserve(length); p.reserve(length); @@ -420,13 +420,13 @@ write_hprs(Datagram &datagram, const LVecBase3f *array, int length) { if (_quality >= 103) { // If quality level is 103, we convert hpr to a table of matrices. // This is just for debugging. - vector_float + vector_stdfloat m00, m01, m02, m10, m11, m12, m20, m21, m22; for (int i = 0; i < length; i++) { - LMatrix3f mat; - compose_matrix(mat, LVecBase3f(1.0, 1.0, 1.0), LVecBase3f(0.0, 0.0, 0.0), + LMatrix3 mat; + compose_matrix(mat, LVecBase3(1.0, 1.0, 1.0), LVecBase3(0.0, 0.0, 0.0), array[i]); m00.push_back(mat(0, 0)); m01.push_back(mat(0, 1)); @@ -472,7 +472,7 @@ write_hprs(Datagram &datagram, const LVecBase3f *array, int length) { // have to write out all three components; any three can be used to // determine the fourth (provided we ensure consistency of sign). - vector_float qr, qi, qj, qk; + vector_stdfloat qr, qi, qj, qk; qr.reserve(length); qi.reserve(length); @@ -480,14 +480,14 @@ write_hprs(Datagram &datagram, const LVecBase3f *array, int length) { qk.reserve(length); for (int i = 0; i < length; i++) { - LMatrix3f mat; - compose_matrix(mat, LVecBase3f(1.0, 1.0, 1.0), LVecBase3f(0.0, 0.0, 0.0), + LMatrix3 mat; + compose_matrix(mat, LVecBase3(1.0, 1.0, 1.0), LVecBase3(0.0, 0.0, 0.0), array[i]); if (_transpose_quats) { mat.transpose_in_place(); } - LOrientationf rot(mat); + LOrientation rot(mat); rot.normalize(); // This may not be necessary, but let's not take chances. if (rot.get_r() < 0) { @@ -506,11 +506,11 @@ write_hprs(Datagram &datagram, const LVecBase3f *array, int length) { #ifdef NOTIFY_DEBUG if (mathutil_cat.is_warning()) { - LMatrix3f mat2; + LMatrix3 mat2; rot.extract_to_matrix(mat2); if (!mat.almost_equal(mat2, 0.0001)) { - LVecBase3f hpr1, hpr2; - LVecBase3f scale, shear; + LVecBase3 hpr1, hpr2; + LVecBase3 scale, shear; decompose_matrix(mat, scale, shear, hpr1); decompose_matrix(mat2, scale, shear, hpr2); mathutil_cat.warning() @@ -602,7 +602,7 @@ read_header(DatagramIterator &di, int bam_minor_version) { // an error. //////////////////////////////////////////////////////////////////// bool FFTCompressor:: -read_reals(DatagramIterator &di, vector_float &array) { +read_reals(DatagramIterator &di, vector_stdfloat &array) { int length = di.get_int32(); if (_quality > 100) { @@ -610,7 +610,7 @@ read_reals(DatagramIterator &di, vector_float &array) { // Special case: lossless output. for (int i = 0; i < length; i++) { - array.push_back(di.get_float32()); + array.push_back(di.get_stdfloat()); } return true; } @@ -628,7 +628,7 @@ read_reals(DatagramIterator &di, vector_float &array) { if (length == 1) { // Special case: just read in the one number. - array.push_back(di.get_float32()); + array.push_back(di.get_stdfloat()); return true; } @@ -641,7 +641,7 @@ read_reals(DatagramIterator &di, vector_float &array) { if (reject_compression) { array.reserve(array.size() + length); for (int i = 0; i < length; i++) { - array.push_back(di.get_float32()); + array.push_back(di.get_stdfloat()); } return true; } @@ -689,12 +689,12 @@ read_reals(DatagramIterator &di, vector_float &array) { // calculation. See temp_hpr_fix. //////////////////////////////////////////////////////////////////// bool FFTCompressor:: -read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { +read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { #ifndef NDEBUG if (_quality >= 104) { // If quality level is at least 104, we don't even convert hpr to // quat. This is just for debugging. - vector_float h, p, r; + vector_stdfloat h, p, r; bool okflag = true; okflag = read_reals(di, h) && @@ -704,7 +704,7 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { if (okflag) { nassertr(h.size() == p.size() && p.size() == r.size(), false); for (int i = 0; i < (int)h.size(); i++) { - array.push_back(LVecBase3f(h[i], p[i], r[i])); + array.push_back(LVecBase3(h[i], p[i], r[i])); } } @@ -713,7 +713,7 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { if (_quality >= 103) { // If quality level is 103, we read in a table of 3x3 rotation // matrices. This is just for debugging. - vector_float + vector_stdfloat m00, m01, m02, m10, m11, m12, m20, m21, m22; @@ -731,10 +731,10 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { if (okflag) { for (int i = 0; i < (int)m00.size(); i++) { - LMatrix3f mat(m00[i], m01[i], m02[i], + LMatrix3 mat(m00[i], m01[i], m02[i], m10[i], m11[i], m12[i], m20[i], m21[i], m22[i]); - LVecBase3f scale, shear, hpr; + LVecBase3 scale, shear, hpr; if (new_hpr) { decompose_matrix_new_hpr(mat, scale, shear, hpr); } else { @@ -748,7 +748,7 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { } #endif - vector_float qr, qi, qj, qk; + vector_stdfloat qr, qi, qj, qk; bool okflag = true; @@ -769,11 +769,11 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { array.reserve(array.size() + qi.size()); for (int i = 0; i < (int)qi.size(); i++) { - LOrientationf rot; + LOrientation rot; // Infer the r component from the remaining three. - float qr2 = 1.0 - (qi[i] * qi[i] + qj[i] * qj[i] + qk[i] * qk[i]); - float qr1 = qr2 < 0.0 ? 0.0 : sqrtf(qr2); + PN_stdfloat qr2 = 1.0 - (qi[i] * qi[i] + qj[i] * qj[i] + qk[i] * qk[i]); + PN_stdfloat qr1 = qr2 < 0.0 ? 0.0 : sqrtf(qr2); rot.set(qr1, qi[i], qj[i], qk[i]); @@ -792,12 +792,12 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { rot.normalize(); // Just for good measure. - LMatrix3f mat; + LMatrix3 mat; rot.extract_to_matrix(mat); if (_transpose_quats) { mat.transpose_in_place(); } - LVecBase3f scale, shear, hpr; + LVecBase3 scale, shear, hpr; if (new_hpr) { decompose_matrix_new_hpr(mat, scale, shear, hpr); } else { @@ -819,7 +819,7 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { // ensure that the array is initially empty. //////////////////////////////////////////////////////////////////// bool FFTCompressor:: -read_hprs(DatagramIterator &di, pvector &array) { +read_hprs(DatagramIterator &di, pvector &array) { return read_hprs(di, array, temp_hpr_fix); } @@ -1046,8 +1046,8 @@ interpolate(double t, double a, double b) { // calmer the numbers, and the greater its likelihood of // being successfully compressed. //////////////////////////////////////////////////////////////////// -float FFTCompressor:: -get_compressability(const float *data, int length) const { +PN_stdfloat FFTCompressor:: +get_compressability(const PN_stdfloat *data, int length) const { // The result returned is actually the standard deviation of the // table of deltas between consecutive frames. This number is // larger if the frames have wildly different values. @@ -1056,21 +1056,21 @@ get_compressability(const float *data, int length) const { return 0.0; } - float sum = 0.0; - float sum2 = 0.0; + PN_stdfloat sum = 0.0; + PN_stdfloat sum2 = 0.0; for (int i = 1; i < length; i++) { - float delta = data[i] - data[i - 1]; + PN_stdfloat delta = data[i] - data[i - 1]; sum += delta; sum2 += delta * delta; } - float variance = (sum2 - (sum * sum) / (length - 1)) / (length - 2); + PN_stdfloat variance = (sum2 - (sum * sum) / (length - 1)) / (length - 2); if (variance < 0.0) { // This can only happen due to tiny roundoff error. return 0.0; } - float std_deviation = csqrt(variance); + PN_stdfloat std_deviation = csqrt(variance); return std_deviation; } diff --git a/panda/src/mathutil/fftCompressor.h b/panda/src/mathutil/fftCompressor.h index 065f42cc45..ccc693501a 100644 --- a/panda/src/mathutil/fftCompressor.h +++ b/panda/src/mathutil/fftCompressor.h @@ -19,7 +19,7 @@ #include "pvector.h" #include "pointerToArray.h" -#include "vector_float.h" +#include "vector_stdfloat.h" #include "vector_double.h" #include "luse.h" @@ -58,14 +58,14 @@ public: bool get_transpose_quats() const; void write_header(Datagram &datagram); - void write_reals(Datagram &datagram, const float *array, int length); - void write_hprs(Datagram &datagram, const LVecBase3f *array, int length); + void write_reals(Datagram &datagram, const PN_stdfloat *array, int length); + void write_hprs(Datagram &datagram, const LVecBase3 *array, int length); bool read_header(DatagramIterator &di, int bam_minor_version); - bool read_reals(DatagramIterator &di, vector_float &array); - bool read_hprs(DatagramIterator &di, pvector &array, + bool read_reals(DatagramIterator &di, vector_stdfloat &array); + bool read_hprs(DatagramIterator &di, pvector &array, bool new_hpr); - bool read_hprs(DatagramIterator &di, pvector &array); + bool read_hprs(DatagramIterator &di, pvector &array); static void free_storage(); @@ -91,7 +91,7 @@ private: double get_scale_factor(int i, int length) const; static double interpolate(double t, double a, double b); - float get_compressability(const float *data, int length) const; + PN_stdfloat get_compressability(const PN_stdfloat *data, int length) const; int _bam_minor_version; int _quality; diff --git a/panda/src/mathutil/finiteBoundingVolume.cxx b/panda/src/mathutil/finiteBoundingVolume.cxx index b2c7250107..08adf02ddd 100644 --- a/panda/src/mathutil/finiteBoundingVolume.cxx +++ b/panda/src/mathutil/finiteBoundingVolume.cxx @@ -22,7 +22,7 @@ TypeHandle FiniteBoundingVolume::_type_handle; // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -float FiniteBoundingVolume:: +PN_stdfloat FiniteBoundingVolume:: get_volume() const { nassertr(!is_infinite(), 0.0f); if (is_empty()) { diff --git a/panda/src/mathutil/finiteBoundingVolume.h b/panda/src/mathutil/finiteBoundingVolume.h index b6921a2bbc..32e1d513e2 100644 --- a/panda/src/mathutil/finiteBoundingVolume.h +++ b/panda/src/mathutil/finiteBoundingVolume.h @@ -28,9 +28,9 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_MATHUTIL FiniteBoundingVolume : public GeometricBoundingVolume { PUBLISHED: - virtual LPoint3f get_min() const=0; - virtual LPoint3f get_max() const=0; - virtual float get_volume() const; + virtual LPoint3 get_min() const=0; + virtual LPoint3 get_max() const=0; + virtual PN_stdfloat get_volume() const; public: virtual const FiniteBoundingVolume *as_finite_bounding_volume() const; diff --git a/panda/src/mathutil/frustum.h b/panda/src/mathutil/frustum.h index daa43746ea..3cab4f539d 100644 --- a/panda/src/mathutil/frustum.h +++ b/panda/src/mathutil/frustum.h @@ -28,4 +28,10 @@ #include "dblnames.h" #include "frustum_src.h" +#ifndef STDFLOAT_DOUBLE +typedef Frustumf LFrustum; +#else +typedef Frustumd LFrustum; +#endif + #endif diff --git a/panda/src/mathutil/geometricBoundingVolume.I b/panda/src/mathutil/geometricBoundingVolume.I index 6fa83fa1c9..3bce5116be 100644 --- a/panda/src/mathutil/geometricBoundingVolume.I +++ b/panda/src/mathutil/geometricBoundingVolume.I @@ -39,7 +39,7 @@ extend_by(const GeometricBoundingVolume *vol) { // point. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL bool GeometricBoundingVolume:: -extend_by(const LPoint3f &point) { +extend_by(const LPoint3 &point) { return extend_by_point(point); } @@ -63,7 +63,7 @@ around(const GeometricBoundingVolume **first, // indicated. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL bool GeometricBoundingVolume:: -around(const LPoint3f *first, const LPoint3f *last) { +around(const LPoint3 *first, const LPoint3 *last) { _flags = F_empty; if (first != last) { return around_points(first, last); @@ -92,7 +92,7 @@ contains(const GeometricBoundingVolume *vol) const { // indicated point. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL int GeometricBoundingVolume:: -contains(const LPoint3f &point) const { +contains(const LPoint3 &point) const { if (is_empty()) { return IF_no_intersection; } @@ -108,7 +108,7 @@ contains(const LPoint3f &point) const { // indicated line segment. //////////////////////////////////////////////////////////////////// INLINE_MATHUTIL int GeometricBoundingVolume:: -contains(const LPoint3f &a, const LPoint3f &b) const { +contains(const LPoint3 &a, const LPoint3 &b) const { if (is_empty()) { return IF_no_intersection; } diff --git a/panda/src/mathutil/geometricBoundingVolume.cxx b/panda/src/mathutil/geometricBoundingVolume.cxx index 240b0e2c2a..756f86dca0 100644 --- a/panda/src/mathutil/geometricBoundingVolume.cxx +++ b/panda/src/mathutil/geometricBoundingVolume.cxx @@ -36,7 +36,7 @@ as_geometric_bounding_volume() const { // Returns true if possible, false if not. //////////////////////////////////////////////////////////////////// bool GeometricBoundingVolume:: -extend_by_point(const LPoint3f &) { +extend_by_point(const LPoint3 &) { return false; } @@ -47,7 +47,7 @@ extend_by_point(const LPoint3f &) { // identified by an STL-style begin/end list. //////////////////////////////////////////////////////////////////// bool GeometricBoundingVolume:: -around_points(const LPoint3f *, const LPoint3f *) { +around_points(const LPoint3 *, const LPoint3 *) { _flags = F_empty; return false; } @@ -59,7 +59,7 @@ around_points(const LPoint3f *, const LPoint3f *) { // point. //////////////////////////////////////////////////////////////////// int GeometricBoundingVolume:: -contains_point(const LPoint3f &) const { +contains_point(const LPoint3 &) const { return IF_dont_understand; } @@ -70,6 +70,6 @@ contains_point(const LPoint3f &) const { // segment. //////////////////////////////////////////////////////////////////// int GeometricBoundingVolume:: -contains_lineseg(const LPoint3f &, const LPoint3f &) const { +contains_lineseg(const LPoint3 &, const LPoint3 &) const { return IF_dont_understand; } diff --git a/panda/src/mathutil/geometricBoundingVolume.h b/panda/src/mathutil/geometricBoundingVolume.h index 6a72dad391..4f028ddc5f 100644 --- a/panda/src/mathutil/geometricBoundingVolume.h +++ b/panda/src/mathutil/geometricBoundingVolume.h @@ -34,22 +34,22 @@ public: PUBLISHED: INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol); - INLINE_MATHUTIL bool extend_by(const LPoint3f &point); + INLINE_MATHUTIL bool extend_by(const LPoint3 &point); // It might be nice to make these template member functions so we // could have true STL-style first/last iterators, but that's // impossible for virtual functions. INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last); - INLINE_MATHUTIL bool around(const LPoint3f *first, - const LPoint3f *last); + INLINE_MATHUTIL bool around(const LPoint3 *first, + const LPoint3 *last); INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const; - INLINE_MATHUTIL int contains(const LPoint3f &point) const; - INLINE_MATHUTIL int contains(const LPoint3f &a, const LPoint3f &b) const; + INLINE_MATHUTIL int contains(const LPoint3 &point) const; + INLINE_MATHUTIL int contains(const LPoint3 &a, const LPoint3 &b) const; - virtual LPoint3f get_approx_center() const=0; - virtual void xform(const LMatrix4f &mat)=0; + virtual LPoint3 get_approx_center() const=0; + virtual void xform(const LMatrix4 &mat)=0; public: virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const; @@ -58,11 +58,11 @@ protected: // Some virtual functions to implement fundamental bounding // operations on points in 3-d space. - virtual bool extend_by_point(const LPoint3f &point); - virtual bool around_points(const LPoint3f *first, - const LPoint3f *last); - virtual int contains_point(const LPoint3f &point) const; - virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; + virtual bool extend_by_point(const LPoint3 &point); + virtual bool around_points(const LPoint3 *first, + const LPoint3 *last); + virtual int contains_point(const LPoint3 &point) const; + virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; public: diff --git a/panda/src/mathutil/linmath_events.h b/panda/src/mathutil/linmath_events.h index 97557e6ecf..2e24b302ea 100644 --- a/panda/src/mathutil/linmath_events.h +++ b/panda/src/mathutil/linmath_events.h @@ -32,13 +32,13 @@ //////////////////////////////////////////////////////////////////// -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); -typedef EventStoreValue EventStoreVec2; -typedef EventStoreValue EventStoreVec3; -typedef EventStoreValue EventStoreMat4; +typedef EventStoreValue EventStoreVec2; +typedef EventStoreValue EventStoreVec3; +typedef EventStoreValue EventStoreMat4; // Tell GCC that we'll take care of the instantiation explicitly here. diff --git a/panda/src/mathutil/mathutil_composite2.cxx b/panda/src/mathutil/mathutil_composite2.cxx index 4cccde372a..0ebf6516d8 100644 --- a/panda/src/mathutil/mathutil_composite2.cxx +++ b/panda/src/mathutil/mathutil_composite2.cxx @@ -6,11 +6,11 @@ #include "perlinNoise2.cxx" #include "perlinNoise3.cxx" #include "plane.cxx" -#include "pta_LMatrix4f.cxx" -#include "pta_LMatrix3f.cxx" -#include "pta_LVecBase4f.cxx" -#include "pta_LVecBase3f.cxx" -#include "pta_LVecBase2f.cxx" +#include "pta_LMatrix4.cxx" +#include "pta_LMatrix3.cxx" +#include "pta_LVecBase4.cxx" +#include "pta_LVecBase3.cxx" +#include "pta_LVecBase2.cxx" #include "randomizer.cxx" #include "rotate_to.cxx" #include "stackedPerlinNoise2.cxx" diff --git a/panda/src/mathutil/omniBoundingVolume.cxx b/panda/src/mathutil/omniBoundingVolume.cxx index 0f46e194f5..9a406909e8 100644 --- a/panda/src/mathutil/omniBoundingVolume.cxx +++ b/panda/src/mathutil/omniBoundingVolume.cxx @@ -35,9 +35,9 @@ make_copy() const { // Access: Public, Virtual // Description: //////////////////////////////////////////////////////////////////// -LPoint3f OmniBoundingVolume:: +LPoint3 OmniBoundingVolume:: get_approx_center() const { - return LPoint3f(0.0f, 0.0f, 0.0f); + return LPoint3(0.0f, 0.0f, 0.0f); } //////////////////////////////////////////////////////////////////// @@ -46,7 +46,7 @@ get_approx_center() const { // Description: //////////////////////////////////////////////////////////////////// void OmniBoundingVolume:: -xform(const LMatrix4f &) { +xform(const LMatrix4 &) { } //////////////////////////////////////////////////////////////////// @@ -99,7 +99,7 @@ contains_other(const BoundingVolume *) const { // Description: //////////////////////////////////////////////////////////////////// bool OmniBoundingVolume:: -extend_by_point(const LPoint3f &) { +extend_by_point(const LPoint3 &) { return true; } @@ -139,7 +139,7 @@ extend_by_hexahedron(const BoundingHexahedron *) { // Description: //////////////////////////////////////////////////////////////////// bool OmniBoundingVolume:: -around_points(const LPoint3f *, const LPoint3f *) { +around_points(const LPoint3 *, const LPoint3 *) { return true; } @@ -182,7 +182,7 @@ around_hexahedrons(const BoundingVolume **, // Description: //////////////////////////////////////////////////////////////////// int OmniBoundingVolume:: -contains_point(const LPoint3f &) const { +contains_point(const LPoint3 &) const { return IF_possible | IF_some | IF_all; } @@ -192,7 +192,7 @@ contains_point(const LPoint3f &) const { // Description: //////////////////////////////////////////////////////////////////// int OmniBoundingVolume:: -contains_lineseg(const LPoint3f &, const LPoint3f &) const { +contains_lineseg(const LPoint3 &, const LPoint3 &) const { return IF_possible | IF_some | IF_all; } diff --git a/panda/src/mathutil/omniBoundingVolume.h b/panda/src/mathutil/omniBoundingVolume.h index 1a609325c7..e6d1e69e06 100644 --- a/panda/src/mathutil/omniBoundingVolume.h +++ b/panda/src/mathutil/omniBoundingVolume.h @@ -31,8 +31,8 @@ PUBLISHED: public: virtual BoundingVolume *make_copy() const; - virtual LPoint3f get_approx_center() const; - virtual void xform(const LMatrix4f &mat); + virtual LPoint3 get_approx_center() const; + virtual void xform(const LMatrix4 &mat); virtual void output(ostream &out) const; @@ -44,13 +44,13 @@ protected: virtual int contains_other(const BoundingVolume *other) const; - virtual bool extend_by_point(const LPoint3f &point); + virtual bool extend_by_point(const LPoint3 &point); virtual bool extend_by_sphere(const BoundingSphere *sphere); virtual bool extend_by_box(const BoundingBox *box); virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron); - virtual bool around_points(const LPoint3f *first, - const LPoint3f *last); + virtual bool around_points(const LPoint3 *first, + const LPoint3 *last); virtual bool around_spheres(const BoundingVolume **first, const BoundingVolume **last); virtual bool around_boxes(const BoundingVolume **first, @@ -58,8 +58,8 @@ protected: virtual bool around_hexahedrons(const BoundingVolume **first, const BoundingVolume **last); - virtual int contains_point(const LPoint3f &point) const; - virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; + virtual int contains_point(const LPoint3 &point) const; + virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; diff --git a/panda/src/mathutil/parabola.h b/panda/src/mathutil/parabola.h index 774c4b7c58..09473fc810 100644 --- a/panda/src/mathutil/parabola.h +++ b/panda/src/mathutil/parabola.h @@ -26,4 +26,10 @@ #include "dblnames.h" #include "parabola_src.h" +#ifndef STDFLOAT_DOUBLE +typedef Parabolaf LParabola; +#else +typedef Parabolad LParabola; +#endif + #endif diff --git a/panda/src/mathutil/plane.h b/panda/src/mathutil/plane.h index ad1a8d3558..0ed759789a 100644 --- a/panda/src/mathutil/plane.h +++ b/panda/src/mathutil/plane.h @@ -32,4 +32,10 @@ class DatagramIterator; #include "dblnames.h" #include "plane_src.h" +#ifndef STDFLOAT_DOUBLE +typedef Planef LPlane; +#else +typedef Planed LPlane; +#endif + #endif diff --git a/panda/src/mathutil/pta_LMatrix3f.cxx b/panda/src/mathutil/pta_LMatrix3.cxx similarity index 90% rename from panda/src/mathutil/pta_LMatrix3f.cxx rename to panda/src/mathutil/pta_LMatrix3.cxx index 2232ce3a2a..7e71a7a8ac 100644 --- a/panda/src/mathutil/pta_LMatrix3f.cxx +++ b/panda/src/mathutil/pta_LMatrix3.cxx @@ -1,4 +1,4 @@ -// Filename: pta_LMatrix3f.cxx +// Filename: pta_LMatrix3.cxx // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,7 +12,7 @@ // //////////////////////////////////////////////////////////////////// -#include "pta_LMatrix3f.h" +#include "pta_LMatrix3.h" // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/mathutil/pta_LMatrix3f.h b/panda/src/mathutil/pta_LMatrix3.h similarity index 56% rename from panda/src/mathutil/pta_LMatrix3f.h rename to panda/src/mathutil/pta_LMatrix3.h index 0f6368d2ff..816afef033 100644 --- a/panda/src/mathutil/pta_LMatrix3f.h +++ b/panda/src/mathutil/pta_LMatrix3.h @@ -1,4 +1,4 @@ -// Filename: pta_lmatrix3f.h +// Filename: pta_LMatrix3.h // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PTA_LMATRIX3F_H -#define PTA_LMATRIX3F_H +#ifndef PTA_LMATRIX3_H +#define PTA_LMATRIX3_H #include "pandabase.h" #include "luse.h" @@ -36,6 +36,31 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LMatrix3f; typedef ConstPointerToArray CPTA_LMatrix3f; +//////////////////////////////////////////////////////////////////// +// Class : PTA_LMatrix3d +// Description : A pta of LMatrix3ds. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a pta of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the pta again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray) + +typedef PointerToArray PTA_LMatrix3d; +typedef ConstPointerToArray CPTA_LMatrix3d; + +#ifndef STDFLOAT_DOUBLE +typedef PTA_LMatrix3f PTA_LMatrix3; +typedef CPTA_LMatrix3f CPTA_LMatrix3; +#else +typedef PTA_LMatrix3d PTA_LMatrix3; +typedef CPTA_LMatrix3d CPTA_LMatrix3; +#endif // STDFLOAT_DOUBLE + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma interface diff --git a/panda/src/mathutil/pta_LMatrix4f.cxx b/panda/src/mathutil/pta_LMatrix4.cxx similarity index 90% rename from panda/src/mathutil/pta_LMatrix4f.cxx rename to panda/src/mathutil/pta_LMatrix4.cxx index 0f5e137ac6..a171eb7e35 100644 --- a/panda/src/mathutil/pta_LMatrix4f.cxx +++ b/panda/src/mathutil/pta_LMatrix4.cxx @@ -1,4 +1,4 @@ -// Filename: pta_LMatrix4f.cxx +// Filename: pta_LMatrix4.cxx // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,7 +12,7 @@ // //////////////////////////////////////////////////////////////////// -#include "pta_LMatrix4f.h" +#include "pta_LMatrix4.h" // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/mathutil/pta_LMatrix4f.h b/panda/src/mathutil/pta_LMatrix4.h similarity index 56% rename from panda/src/mathutil/pta_LMatrix4f.h rename to panda/src/mathutil/pta_LMatrix4.h index f43de2231e..5e0032ef2d 100644 --- a/panda/src/mathutil/pta_LMatrix4f.h +++ b/panda/src/mathutil/pta_LMatrix4.h @@ -1,4 +1,4 @@ -// Filename: pta_lmatrix4f.h +// Filename: pta_LMatrix4.h // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PTA_LMATRIX4F_H -#define PTA_LMATRIX4F_H +#ifndef PTA_LMATRIX4_H +#define PTA_LMATRIX4_H #include "pandabase.h" #include "luse.h" @@ -36,6 +36,31 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LMatrix4f; typedef ConstPointerToArray CPTA_LMatrix4f; +//////////////////////////////////////////////////////////////////// +// Class : PTA_LMatrix4d +// Description : A pta of LMatrix4ds. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a pta of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the pta again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray) + +typedef PointerToArray PTA_LMatrix4d; +typedef ConstPointerToArray CPTA_LMatrix4d; + +#ifndef STDFLOAT_DOUBLE +typedef PTA_LMatrix4f PTA_LMatrix4; +typedef CPTA_LMatrix4f CPTA_LMatrix4; +#else +typedef PTA_LMatrix4d PTA_LMatrix4; +typedef CPTA_LMatrix4d CPTA_LMatrix4; +#endif // STDFLOAT_DOUBLE + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma interface diff --git a/panda/src/mathutil/pta_LVecBase3f.cxx b/panda/src/mathutil/pta_LVecBase2.cxx similarity index 90% rename from panda/src/mathutil/pta_LVecBase3f.cxx rename to panda/src/mathutil/pta_LVecBase2.cxx index ebbe6e5e56..4e60170a8d 100644 --- a/panda/src/mathutil/pta_LVecBase3f.cxx +++ b/panda/src/mathutil/pta_LVecBase2.cxx @@ -1,4 +1,4 @@ -// Filename: pta_LVecBase3f.cxx +// Filename: pta_LVecBase2.cxx // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,7 +12,7 @@ // //////////////////////////////////////////////////////////////////// -#include "pta_LVecBase3f.h" +#include "pta_LVecBase2.h" // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/mathutil/pta_LVecBase2f.h b/panda/src/mathutil/pta_LVecBase2.h similarity index 56% rename from panda/src/mathutil/pta_LVecBase2f.h rename to panda/src/mathutil/pta_LVecBase2.h index 7a62f13a34..82468ba01c 100644 --- a/panda/src/mathutil/pta_LVecBase2f.h +++ b/panda/src/mathutil/pta_LVecBase2.h @@ -1,4 +1,4 @@ -// Filename: pta_LVecBase2f.h +// Filename: pta_LVecBase2.h // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PTA_LVECBASE2F_H -#define PTA_LVECBASE2F_H +#ifndef PTA_LVECBASE2_H +#define PTA_LVECBASE2_H #include "pandabase.h" #include "luse.h" @@ -36,6 +36,31 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase2f; typedef ConstPointerToArray CPTA_LVecBase2f; +//////////////////////////////////////////////////////////////////// +// Class : PTA_LVecBase2d +// Description : A pta of LVecBase2ds. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a pta of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the pta again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray) + +typedef PointerToArray PTA_LVecBase2d; +typedef ConstPointerToArray CPTA_LVecBase2d; + +#ifndef STDFLOAT_DOUBLE +typedef PTA_LVecBase2f PTA_LVecBase2; +typedef CPTA_LVecBase2f CPTA_LVecBase2; +#else +typedef PTA_LVecBase2d PTA_LVecBase2; +typedef CPTA_LVecBase2d CPTA_LVecBase2; +#endif // STDFLOAT_DOUBLE + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma interface diff --git a/panda/src/mathutil/pta_LVecBase2f.cxx b/panda/src/mathutil/pta_LVecBase3.cxx similarity index 90% rename from panda/src/mathutil/pta_LVecBase2f.cxx rename to panda/src/mathutil/pta_LVecBase3.cxx index 7db9595052..ab535d218f 100644 --- a/panda/src/mathutil/pta_LVecBase2f.cxx +++ b/panda/src/mathutil/pta_LVecBase3.cxx @@ -1,4 +1,4 @@ -// Filename: pta_LVecBase2f.cxx +// Filename: pta_LVecBase3.cxx // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,7 +12,7 @@ // //////////////////////////////////////////////////////////////////// -#include "pta_LVecBase2f.h" +#include "pta_LVecBase3.h" // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/mathutil/pta_LVecBase3f.h b/panda/src/mathutil/pta_LVecBase3.h similarity index 56% rename from panda/src/mathutil/pta_LVecBase3f.h rename to panda/src/mathutil/pta_LVecBase3.h index 16c83a6aa7..0fc46a92cb 100644 --- a/panda/src/mathutil/pta_LVecBase3f.h +++ b/panda/src/mathutil/pta_LVecBase3.h @@ -1,4 +1,4 @@ -// Filename: pta_LVecBase3f.h +// Filename: pta_LVecBase3.h // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PTA_LVECBASE3F_H -#define PTA_LVECBASE3F_H +#ifndef PTA_LVECBASE3_H +#define PTA_LVECBASE3_H #include "pandabase.h" #include "luse.h" @@ -36,6 +36,31 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase3f; typedef ConstPointerToArray CPTA_LVecBase3f; +//////////////////////////////////////////////////////////////////// +// Class : PTA_LVecBase3d +// Description : A pta of LVecBase3ds. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a pta of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the pta again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray) + +typedef PointerToArray PTA_LVecBase3d; +typedef ConstPointerToArray CPTA_LVecBase3d; + +#ifndef STDFLOAT_DOUBLE +typedef PTA_LVecBase3f PTA_LVecBase3; +typedef CPTA_LVecBase3f CPTA_LVecBase3; +#else +typedef PTA_LVecBase3d PTA_LVecBase3; +typedef CPTA_LVecBase3d CPTA_LVecBase3; +#endif // STDFLOAT_DOUBLE + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma interface diff --git a/panda/src/mathutil/pta_LVecBase4.cxx b/panda/src/mathutil/pta_LVecBase4.cxx new file mode 100644 index 0000000000..8f133e36de --- /dev/null +++ b/panda/src/mathutil/pta_LVecBase4.cxx @@ -0,0 +1,20 @@ +// Filename: pta_LVecBase4.cxx +// Created by: drose (27Feb10) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "pta_LVecBase4.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif diff --git a/panda/src/mathutil/pta_LVecBase4f.h b/panda/src/mathutil/pta_LVecBase4.h similarity index 56% rename from panda/src/mathutil/pta_LVecBase4f.h rename to panda/src/mathutil/pta_LVecBase4.h index 4ba49d5a95..4a86afcc28 100644 --- a/panda/src/mathutil/pta_LVecBase4f.h +++ b/panda/src/mathutil/pta_LVecBase4.h @@ -1,4 +1,4 @@ -// Filename: pta_LVecBase4f.h +// Filename: pta_LVecBase4.h // Created by: drose (27Feb10) // //////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef PTA_LVECBASE4F_H -#define PTA_LVECBASE4F_H +#ifndef PTA_LVECBASE4_H +#define PTA_LVECBASE4_H #include "pandabase.h" #include "luse.h" @@ -36,6 +36,31 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase4f; typedef ConstPointerToArray CPTA_LVecBase4f; +//////////////////////////////////////////////////////////////////// +// Class : PTA_LVecBase4d +// Description : A pta of LVecBase4ds. This class is defined once here, +// and exported to PANDA.DLL; other packages that want +// to use a pta of this type (whether they need to +// export it or not) should include this header file, +// rather than defining the pta again. +//////////////////////////////////////////////////////////////////// + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArray) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerToArray) + +typedef PointerToArray PTA_LVecBase4d; +typedef ConstPointerToArray CPTA_LVecBase4d; + +#ifndef STDFLOAT_DOUBLE +typedef PTA_LVecBase4f PTA_LVecBase4; +typedef CPTA_LVecBase4f CPTA_LVecBase4; +#else +typedef PTA_LVecBase4d PTA_LVecBase4; +typedef CPTA_LVecBase4d CPTA_LVecBase4; +#endif // STDFLOAT_DOUBLE + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ #pragma interface diff --git a/panda/src/mathutil/pta_LVecBase4f.cxx b/panda/src/mathutil/pta_LVecBase4f.cxx deleted file mode 100644 index 2df05bf042..0000000000 --- a/panda/src/mathutil/pta_LVecBase4f.cxx +++ /dev/null @@ -1,20 +0,0 @@ -// Filename: pta_LVecBase4f.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// 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 "pta_LVecBase4f.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/mathutil/test_mathutil.cxx b/panda/src/mathutil/test_mathutil.cxx index 120d40a91b..86c3ed92fa 100644 --- a/panda/src/mathutil/test_mathutil.cxx +++ b/panda/src/mathutil/test_mathutil.cxx @@ -21,11 +21,11 @@ int main() { - Planef p1(LVector3f(1, 0, 0), LPoint3f(1, 0, 0)); - Planef p2(LVector3f(0, 0, 1), LPoint3f(1, 0, 0)); + LPlane p1(LVector3(1, 0, 0), LPoint3(1, 0, 0)); + LPlane p2(LVector3(0, 0, 1), LPoint3(1, 0, 0)); - LPoint3f from; - LVector3f delta; + LPoint3 from; + LVector3 delta; if (p1.intersects_plane(from, delta, p2)) { nout << "intersects, " << from << " to " << delta << "\n"; @@ -54,12 +54,12 @@ main() { */ /* - BoundingLine line(LPoint3f(0, 0, 1), LPoint3f(0, 0, 0)); + BoundingLine line(LPoint3(0, 0, 1), LPoint3(0, 0, 0)); - BoundingSphere s1(LPoint3f(0, 0, 10), 1); - BoundingSphere s2(LPoint3f(10, 0, 10), 1); - BoundingSphere s3(LPoint3f(1, 0, 0), 1); - BoundingSphere s4(LPoint3f(-1, -1, -1), 1); + BoundingSphere s1(LPoint3(0, 0, 10), 1); + BoundingSphere s2(LPoint3(10, 0, 10), 1); + BoundingSphere s3(LPoint3(1, 0, 0), 1); + BoundingSphere s4(LPoint3(-1, -1, -1), 1); line.contains(&s1); line.contains(&s2); @@ -68,10 +68,10 @@ main() { */ /* - s1.contains(LPoint3f(0, 0, 1), LPoint3f(0, 0, 0)); - s2.contains(LPoint3f(0, 0, 1), LPoint3f(0, 0, 0)); - s3.contains(LPoint3f(0, 0, 1), LPoint3f(0, 0, 0)); - s4.contains(LPoint3f(0, 0, 1), LPoint3f(0, 0, 0)); + s1.contains(LPoint3(0, 0, 1), LPoint3(0, 0, 0)); + s2.contains(LPoint3(0, 0, 1), LPoint3(0, 0, 0)); + s3.contains(LPoint3(0, 0, 1), LPoint3(0, 0, 0)); + s4.contains(LPoint3(0, 0, 1), LPoint3(0, 0, 0)); */ return (0); diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index e2da17a86e..dcc5027812 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/panda/src/mathutil/triangulator.cxx @@ -2187,7 +2187,7 @@ triangulate_single_polygon(int nvert, int posmax, int side) { } if (ri > 0) /* reflex chain is non-empty */ { - float crossResult = CROSS(vert[v].pt, vert[rc[ri - 1]].pt, + PN_stdfloat crossResult = CROSS(vert[v].pt, vert[rc[ri - 1]].pt, vert[rc[ri]].pt); if ( crossResult >= 0 ) /* could be convex corner or straight */ { diff --git a/panda/src/mesadisplay/mesagsg.h b/panda/src/mesadisplay/mesagsg.h index e6c4d0ffb6..dcdb6205c4 100644 --- a/panda/src/mesadisplay/mesagsg.h +++ b/panda/src/mesadisplay/mesagsg.h @@ -28,12 +28,33 @@ #ifdef MESA_MGL #define GLP(name) mgl##name + +#ifndef STDFLOAT_DOUBLE +#define GLPf(name) mgl ## name ## f +#define GLPfv(name) mgl ## name ## fv +#else // STDFLOAT_DOUBLE +#define GLPf(name) mgl ## name ## d +#define GLPfv(name) mgl ## name ## dv +#endif // STDFLOAT_DOUBLE + #define GLPREFIX_QUOTED "mgl" #define USE_MGL_NAMESPACE 1 -#else + +#else // MESA_MGL + +#ifndef STDFLOAT_DOUBLE +#define GLPf(name) gl ## name ## f +#define GLPfv(name) gl ## name ## fv +#else // STDFLOAT_DOUBLE +#define GLPf(name) gl ## name ## d +#define GLPfv(name) gl ## name ## dv +#endif // STDFLOAT_DOUBLE + #define GLP(name) gl##name #define GLPREFIX_QUOTED "gl" -#endif + +#endif // MESA_MGL + #define CLP(name) Mesa##name #define CLASSPREFIX_QUOTED "Mesa" #define GLSYSTEM_NAME "Mesa" diff --git a/panda/src/nativenet/buffered_datagramconnection.h b/panda/src/nativenet/buffered_datagramconnection.h index 4dc440e364..2aada81b5b 100755 --- a/panda/src/nativenet/buffered_datagramconnection.h +++ b/panda/src/nativenet/buffered_datagramconnection.h @@ -79,7 +79,7 @@ PUBLISHED: // int WaitFor_Read_Error(const Socket_fdset & fd, const Time_Span & timeout); - inline void WaitForNetworkReadEvent(float MaxTime) + inline void WaitForNetworkReadEvent(PN_stdfloat MaxTime) { Socket_fdset fdset; fdset.setForSocket(*this); diff --git a/panda/src/nativenet/time_span.h b/panda/src/nativenet/time_span.h index d703b838ad..7c7a1062ec 100755 --- a/panda/src/nativenet/time_span.h +++ b/panda/src/nativenet/time_span.h @@ -23,7 +23,7 @@ public: Time_Span(long seconds, int usecs ) ; Time_Span(const Time_Span& Time_SpanSrc); Time_Span(const Time_Clock& Time_SpanSrc); - Time_Span(float Seconds); + Time_Span(PN_stdfloat Seconds); /////////////////// @@ -88,7 +88,7 @@ inline Time_Span::Time_Span(time_t time) // Function name : Time_Span::Time_Span // Description : ////////////////////////////////////////////////////////////// -inline Time_Span::Time_Span(float Seconds) +inline Time_Span::Time_Span(PN_stdfloat Seconds) { _my_time.tv_sec = (long)Seconds; // this truncats .. desired result.. _my_time.tv_usec = (long)((Seconds - (double)_my_time.tv_sec) * (double)USEC); diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 54e2acaaca..693bb1af02 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -149,8 +149,8 @@ draw_resize_box() { // Now determine the inner corner of the quad, choosing a 15x15 // pixel square in the lower-right corner, computed from the // viewport size. - float inner_x = 1.0f - (15.0f * 2.0f / _viewport_width); - float inner_y = (15.0f * 2.0f / _viewport_height) - 1.0f; + PN_stdfloat inner_x = 1.0f - (15.0f * 2.0f / _viewport_width); + PN_stdfloat inner_y = (15.0f * 2.0f / _viewport_height) - 1.0f; // Draw the quad. We just use the slow, simple immediate mode calls // here. It's just one quad, after all. @@ -401,7 +401,7 @@ get_gamma_table() { // for atexit. //////////////////////////////////////////////////////////////////// bool osxGraphicsStateGuardian:: -static_set_gamma(bool restore, float gamma) { +static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; set = false; @@ -458,7 +458,7 @@ static_set_gamma(bool restore, float gamma) { // on success. //////////////////////////////////////////////////////////////////// bool osxGraphicsStateGuardian:: -set_gamma(float gamma) { +set_gamma(PN_stdfloat gamma) { bool set; set = static_set_gamma(false, gamma); diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.h b/panda/src/osxdisplay/osxGraphicsStateGuardian.h index f8fb9ad60b..cb901fa1bc 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.h +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.h @@ -40,8 +40,8 @@ public: void draw_resize_box(); bool get_gamma_table(); - bool static_set_gamma(bool restore, float gamma); - bool set_gamma(float gamma); + bool static_set_gamma(bool restore, PN_stdfloat gamma); + bool set_gamma(PN_stdfloat gamma); void atexit_function(); void restore_gamma(); diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index 741cc22d57..5c53b6717d 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -409,8 +409,8 @@ do_resize() { }; GetWindowPortBounds(_osx_window, &rectPort); - viewRect.size.width = (float)(rectPort.right - rectPort.left); - viewRect.size.height = (float)(rectPort.bottom - rectPort.top); + viewRect.size.width = (PN_stdfloat)(rectPort.right - rectPort.left); + viewRect.size.height = (PN_stdfloat)(rectPort.bottom - rectPort.top); // tell panda WindowProperties properties; diff --git a/panda/src/parametrics/cubicCurveseg.cxx b/panda/src/parametrics/cubicCurveseg.cxx index e93f8b59b8..3451277685 100644 --- a/panda/src/parametrics/cubicCurveseg.cxx +++ b/panda/src/parametrics/cubicCurveseg.cxx @@ -40,7 +40,7 @@ CubicCurveseg() { // (the columns of the matrix) explicitly. //////////////////////////////////////////////////////////////////// CubicCurveseg:: -CubicCurveseg(const LMatrix4f &basis) { +CubicCurveseg(const LMatrix4 &basis) { Bx = basis.get_col(0); By = basis.get_col(1); Bz = basis.get_col(2); @@ -67,7 +67,7 @@ CubicCurveseg(const BezierSeg &seg) { // nurbs_basis for a description of the parameters. //////////////////////////////////////////////////////////////////// CubicCurveseg:: -CubicCurveseg(int order, const float knots[], const LVecBase4f cvs[]) { +CubicCurveseg(int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) { nurbs_basis(order, knots, cvs); } @@ -89,9 +89,9 @@ CubicCurveseg:: // point t. //////////////////////////////////////////////////////////////////// bool CubicCurveseg:: -get_point(float t, LVecBase3f &point) const { - float t_sqrd = t*t; - evaluate_point(LVecBase4f(t*t_sqrd, t_sqrd, t, 1.0f), point); +get_point(PN_stdfloat t, LVecBase3 &point) const { + PN_stdfloat t_sqrd = t*t; + evaluate_point(LVecBase4(t*t_sqrd, t_sqrd, t, 1.0f), point); return true; } @@ -102,8 +102,8 @@ get_point(float t, LVecBase3f &point) const { // point t. //////////////////////////////////////////////////////////////////// bool CubicCurveseg:: -get_tangent(float t, LVecBase3f &tangent) const { - evaluate_vector(LVecBase4f(3.0f*t*t, 2.0f*t, 1.0f, 0.0f), tangent); +get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { + evaluate_vector(LVecBase4(3.0f*t*t, 2.0f*t, 1.0f, 0.0f), tangent); return true; } @@ -114,10 +114,10 @@ get_tangent(float t, LVecBase3f &tangent) const { // the given parametric point. //////////////////////////////////////////////////////////////////// bool CubicCurveseg:: -get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const { - float t_sqrd=t*t; - evaluate_point(LVecBase4f(t*t_sqrd, t_sqrd, t, 1.0f), point); - evaluate_vector(LVecBase4f(3.0f*t_sqrd, /*2.0f*t*/t+t, 1.0f, 0.0f), tangent); +get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { + PN_stdfloat t_sqrd=t*t; + evaluate_point(LVecBase4(t*t_sqrd, t_sqrd, t, 1.0f), point); + evaluate_vector(LVecBase4(3.0f*t_sqrd, /*2.0f*t*/t+t, 1.0f, 0.0f), tangent); return true; } @@ -128,8 +128,8 @@ get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const { // parametric point t. //////////////////////////////////////////////////////////////////// bool CubicCurveseg:: -get_2ndtangent(float t, LVecBase3f &tangent2) const { - evaluate_vector(LVecBase4f(6.0f*t, 2.0f, 0.0f, 0.0f), tangent2); +get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { + evaluate_vector(LVecBase4(6.0f*t, 2.0f, 0.0f, 0.0f), tangent2); return true; } @@ -144,18 +144,18 @@ get_2ndtangent(float t, LVecBase3f &tangent2) const { void CubicCurveseg:: hermite_basis(const HermiteCurveCV &cv0, const HermiteCurveCV &cv1, - float tlength) { - static LMatrix4f + PN_stdfloat tlength) { + static LMatrix4 Mh( 2.0f, -3.0f, 0.0f, 1.0f, -2.0f, 3.0f, 0.0f, 0.0f, 1.0f, -2.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f); - LVecBase4f Gx(cv0._p[0], cv1._p[0], + LVecBase4 Gx(cv0._p[0], cv1._p[0], cv0._out[0]*tlength, cv1._in[0]*tlength); - LVecBase4f Gy(cv0._p[1], cv1._p[1], + LVecBase4 Gy(cv0._p[1], cv1._p[1], cv0._out[1]*tlength, cv1._in[1]*tlength); - LVecBase4f Gz(cv0._p[2], cv1._p[2], + LVecBase4 Gz(cv0._p[2], cv1._p[2], cv0._out[2]*tlength, cv1._in[2]*tlength); Bx = Gx * Mh; @@ -173,15 +173,15 @@ hermite_basis(const HermiteCurveCV &cv0, //////////////////////////////////////////////////////////////////// void CubicCurveseg:: bezier_basis(const BezierSeg &seg) { - static LMatrix4f + static LMatrix4 Mb(-1.0f, 3.0f, -3.0f, 1.0f, 3.0f, -6.0f, 3.0f, 0.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f); - LVecBase4f Gx(seg._v[0][0], seg._v[1][0], seg._v[2][0], seg._v[3][0]); - LVecBase4f Gy(seg._v[0][1], seg._v[1][1], seg._v[2][1], seg._v[3][1]); - LVecBase4f Gz(seg._v[0][2], seg._v[1][2], seg._v[2][2], seg._v[3][2]); + LVecBase4 Gx(seg._v[0][0], seg._v[1][0], seg._v[2][0], seg._v[3][0]); + LVecBase4 Gy(seg._v[0][1], seg._v[1][1], seg._v[2][1], seg._v[3][1]); + LVecBase4 Gz(seg._v[0][2], seg._v[1][2], seg._v[2][2], seg._v[3][2]); Bx = Gx * Mb; By = Gy * Mb; @@ -189,11 +189,11 @@ bezier_basis(const BezierSeg &seg) { rational = false; } -static LVecBase4f +static LVecBase4 nurbs_blending_function(int order, int i, int j, - const float knots[]) { + const PN_stdfloat knots[]) { // This is doubly recursive. Ick. - LVecBase4f r; + LVecBase4 r; if (j==1) { if (i==order-1 && knots[i] < knots[i+1]) { @@ -203,11 +203,11 @@ nurbs_blending_function(int order, int i, int j, } } else { - LVecBase4f bi0 = nurbs_blending_function(order, i, j-1, knots); - LVecBase4f bi1 = nurbs_blending_function(order, i+1, j-1, knots); + LVecBase4 bi0 = nurbs_blending_function(order, i, j-1, knots); + LVecBase4 bi1 = nurbs_blending_function(order, i+1, j-1, knots); - float d0 = knots[i+j-1] - knots[i]; - float d1 = knots[i+j] - knots[i+1]; + PN_stdfloat d0 = knots[i+j-1] - knots[i]; + PN_stdfloat d1 = knots[i+j] - knots[i+1]; // First term. Division by zero is defined to equal zero. if (d0 != 0.0f) { @@ -248,20 +248,20 @@ nurbs_blending_function(int order, int i, int j, void compute_nurbs_basis(int order, - const float knots_in[], - LMatrix4f &basis) { + const PN_stdfloat knots_in[], + LMatrix4 &basis) { int i; // Scale the supplied knots to the range 0..1. - float knots[8]; - float mink = knots_in[order-1]; - float maxk = knots_in[order]; + PN_stdfloat knots[8]; + PN_stdfloat mink = knots_in[order-1]; + PN_stdfloat maxk = knots_in[order]; if (mink==maxk) { // Huh. What were you thinking? This is a trivial NURBS. parametrics_cat->warning() << "Trivial NURBS curve specified." << endl; - memset((void *)&basis, 0, sizeof(LMatrix4f)); + memset((void *)&basis, 0, sizeof(LMatrix4)); return; } @@ -270,7 +270,7 @@ compute_nurbs_basis(int order, } - LVecBase4f b[4]; + LVecBase4 b[4]; for (i = 0; i=1 && order<=4); - LMatrix4f B; + LMatrix4 B; compute_nurbs_basis(order, knots, B); // Create a local copy of our CV's, so we can zero out the unused // elements. - LVecBase4f c[4]; + LVecBase4 c[4]; for (int i = 0; i < 4; i++) { - c[i] = (i= 0 && n < (int)_data.size(), 0.0f); return _data[n]._t; @@ -126,9 +126,9 @@ get_sample_t(int n) const { // Access: Public // Description: Returns the point in space of the nth sample added. //////////////////////////////////////////////////////////////////// -LVecBase3f CurveFitter:: +LVecBase3 CurveFitter:: get_sample_xyz(int n) const { - nassertr(n >= 0 && n < (int)_data.size(), LVecBase3f::zero()); + nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._xyz; } @@ -137,9 +137,9 @@ get_sample_xyz(int n) const { // Access: Public // Description: Returns the orientation of the nth sample added. //////////////////////////////////////////////////////////////////// -LVecBase3f CurveFitter:: +LVecBase3 CurveFitter:: get_sample_hpr(int n) const { - nassertr(n >= 0 && n < (int)_data.size(), LVecBase3f::zero()); + nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._hpr; } @@ -150,9 +150,9 @@ get_sample_hpr(int n) const { // added. This is only meaningful if compute_tangents() // has already been called. //////////////////////////////////////////////////////////////////// -LVecBase3f CurveFitter:: +LVecBase3 CurveFitter:: get_sample_tangent(int n) const { - nassertr(n >= 0 && n < (int)_data.size(), LVecBase3f::zero()); + nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._tangent; } @@ -183,15 +183,15 @@ remove_samples(int begin, int end) { void CurveFitter:: sample(ParametricCurveCollection *curves, int count) { nassertv(curves != (ParametricCurveCollection *)NULL); - float max_t = curves->get_max_t(); - float t, last_t, d; + PN_stdfloat max_t = curves->get_max_t(); + PN_stdfloat t, last_t, d; DataPoint dp; last_t = 0.0f; d = 0.0f; int i; for (i = 0; i < count; i++) { - t = max_t * (float)i / (float)(count-1); + t = max_t * (PN_stdfloat)i / (PN_stdfloat)(count-1); if (curves->evaluate(t, dp._xyz, dp._hpr)) { dp._t = t; _data.push_back(dp); @@ -218,8 +218,8 @@ sample(ParametricCurveCollection *curves, int count) { void CurveFitter:: wrap_hpr() { Data::iterator di; - LVecBase3f last(0.0f, 0.0f, 0.0f); - LVecBase3f net(0.0f, 0.0f, 0.0f); + LVecBase3 last(0.0f, 0.0f, 0.0f); + LVecBase3 net(0.0f, 0.0f, 0.0f); for (di = _data.begin(); di != _data.end(); ++di) { int i; @@ -261,9 +261,9 @@ sort_points() { // last samples. //////////////////////////////////////////////////////////////////// void CurveFitter:: -desample(float factor) { +desample(PN_stdfloat factor) { int in, out; - float count = factor; + PN_stdfloat count = factor; out = 0; for (in = 0; in < (int)_data.size()-1; in++) { @@ -291,7 +291,7 @@ desample(float factor) { // as the points were added). //////////////////////////////////////////////////////////////////// void CurveFitter:: -compute_tangents(float scale) { +compute_tangents(PN_stdfloat scale) { // If the head and tail points match up, close the curve. bool closed = false; @@ -438,8 +438,8 @@ make_nurbs() const { // between their two neighbors. int i; - float k1, k2 = nc->get_knot(num_knots-1); - const float one_third = 1.0f/3.0f; + PN_stdfloat k1, k2 = nc->get_knot(num_knots-1); + const PN_stdfloat one_third = 1.0f/3.0f; for (i = 3; i < num_knots - 4; i += 3) { k1 = nc->get_knot(i-1); k2 = nc->get_knot(i+2); diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index d01dc4a900..c5c67138f3 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -38,23 +38,23 @@ PUBLISHED: ~CurveFitter(); void reset(); - void add_xyz(float t, const LVecBase3f &xyz); - void add_hpr(float t, const LVecBase3f &hpr); - void add_xyz_hpr(float t, const LVecBase3f &xyz, const LVecBase3f &hpr); + void add_xyz(PN_stdfloat t, const LVecBase3 &xyz); + void add_hpr(PN_stdfloat t, const LVecBase3 &hpr); + void add_xyz_hpr(PN_stdfloat t, const LVecBase3 &xyz, const LVecBase3 &hpr); int get_num_samples() const; - float get_sample_t(int n) const; - LVecBase3f get_sample_xyz(int n) const; - LVecBase3f get_sample_hpr(int n) const; - LVecBase3f get_sample_tangent(int n) const; + PN_stdfloat get_sample_t(int n) const; + LVecBase3 get_sample_xyz(int n) const; + LVecBase3 get_sample_hpr(int n) const; + LVecBase3 get_sample_tangent(int n) const; void remove_samples(int begin, int end); void sample(ParametricCurveCollection *curves, int count); void wrap_hpr(); void sort_points(); - void desample(float factor); + void desample(PN_stdfloat factor); - void compute_tangents(float scale); + void compute_tangents(PN_stdfloat scale); PT(ParametricCurveCollection) make_hermite() const; PT(ParametricCurveCollection) make_nurbs() const; @@ -68,11 +68,11 @@ public: INLINE void output(ostream &out) const; INLINE bool operator < (const DataPoint &other) const; - float _t; - LVecBase3f _xyz; - LVecBase3f _hpr; - LVecBase3f _tangent; - LVecBase3f _hpr_tangent; + PN_stdfloat _t; + LVecBase3 _xyz; + LVecBase3 _hpr; + LVecBase3 _tangent; + LVecBase3 _hpr_tangent; }; typedef pvector Data; diff --git a/panda/src/parametrics/hermiteCurve.cxx b/panda/src/parametrics/hermiteCurve.cxx index 9679d03239..447cdbfedc 100644 --- a/panda/src/parametrics/hermiteCurve.cxx +++ b/panda/src/parametrics/hermiteCurve.cxx @@ -27,18 +27,18 @@ TypeHandle HermiteCurve::_type_handle; -static const LVecBase3f zerovec_3f = LVecBase3f(0.0f, 0.0f, 0.0f); +static const LVecBase3 zerovec_3 = LVecBase3(0.0f, 0.0f, 0.0f); // This is returned occasionally from some of the functions, and is // used from time to time as an initializer. //////////////////////////////////////////////////////////////////// // Function: show_vec3 -// Description: This function writes a LVecBase3f, with a specified +// Description: This function writes a LVecBase3, with a specified // number of significant dimensions. //////////////////////////////////////////////////////////////////// static ostream & -show_vec3(ostream &out, int indent_level, const LVecBase3f &v, +show_vec3(ostream &out, int indent_level, const LVecBase3 &v, int num_dimensions) { indent(out, indent_level) << v[0]; for (int i = 1; i {\n"; show_vec3(out, indent_level + 2, _p - scale_in * _in / 3.0, @@ -323,20 +323,20 @@ get_num_cvs() const { // The index number of the new CV is returned. //////////////////////////////////////////////////////////////////// int HermiteCurve:: -insert_cv(float t) { +insert_cv(PN_stdfloat t) { if (!is_valid() || t >= get_max_t()) { int n = append_cv(HC_SMOOTH, 0.0f, 0.0f, 0.0f); set_cv_tstart(n, t); return n; } - t = min(max(t, 0.0f), get_max_t()); + t = min(max(t, (PN_stdfloat)0.0), get_max_t()); int n = find_cv(t); nassertr(n+11) { bool result = @@ -461,11 +461,11 @@ set_cv_type(int n, int type) { // Description: Changes the given CV's position. //////////////////////////////////////////////////////////////////// bool HermiteCurve:: -set_cv_point(int n, float x, float y, float z) { +set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { return false; } - _points[n].set_point(LVecBase3f(x, y, z)); + _points[n].set_point(LVecBase3(x, y, z)); invalidate_cv(n, false); return true; } @@ -478,11 +478,11 @@ set_cv_point(int n, float x, float y, float z) { // tangent. //////////////////////////////////////////////////////////////////// bool HermiteCurve:: -set_cv_in(int n, float x, float y, float z) { +set_cv_in(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { return false; } - _points[n].set_in(LVecBase3f(x, y, z)); + _points[n].set_in(LVecBase3(x, y, z)); invalidate_cv(n, false); return true; } @@ -495,11 +495,11 @@ set_cv_in(int n, float x, float y, float z) { // tangent. //////////////////////////////////////////////////////////////////// bool HermiteCurve:: -set_cv_out(int n, float x, float y, float z) { +set_cv_out(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { return false; } - _points[n].set_out(LVecBase3f(x, y, z)); + _points[n].set_out(LVecBase3(x, y, z)); invalidate_cv(n, false); return true; } @@ -511,7 +511,7 @@ set_cv_out(int n, float x, float y, float z) { // This may affect the shape of the curve. //////////////////////////////////////////////////////////////////// bool HermiteCurve:: -set_cv_tstart(int n, float tstart) { +set_cv_tstart(int n, PN_stdfloat tstart) { if (n <= 0 || n >= (int)_points.size()) { return false; } @@ -562,16 +562,16 @@ get_cv_type(int n) const { // Access: Published // Description: Returns the position of the given CV. //////////////////////////////////////////////////////////////////// -const LVecBase3f &HermiteCurve:: +const LVecBase3 &HermiteCurve:: get_cv_point(int n) const { if (n < 0 || n >= (int)_points.size()) { - return zerovec_3f; + return zerovec_3; } return _points[n]._p; } void HermiteCurve:: -get_cv_point(int n, LVecBase3f &v) const { +get_cv_point(int n, LVecBase3 &v) const { v = get_cv_point(n); } @@ -581,16 +581,16 @@ get_cv_point(int n, LVecBase3f &v) const { // Access: Published // Description: Returns the in tangent of the given CV. //////////////////////////////////////////////////////////////////// -const LVecBase3f &HermiteCurve:: +const LVecBase3 &HermiteCurve:: get_cv_in(int n) const { if (n < 0 || n >= (int)_points.size() || _points[n-1]._type==HC_CUT) { - return zerovec_3f; + return zerovec_3; } return _points[n]._in; } void HermiteCurve:: -get_cv_in(int n, LVecBase3f &v) const { +get_cv_in(int n, LVecBase3 &v) const { v = get_cv_in(n); } @@ -600,16 +600,16 @@ get_cv_in(int n, LVecBase3f &v) const { // Access: Published // Description: Returns the out tangent of the given CV. //////////////////////////////////////////////////////////////////// -const LVecBase3f &HermiteCurve:: +const LVecBase3 &HermiteCurve:: get_cv_out(int n) const { if (n < 0 || n >= (int)_points.size() || _points[n]._type==HC_CUT) { - return zerovec_3f; + return zerovec_3; } return _points[n]._out; } void HermiteCurve:: -get_cv_out(int n, LVecBase3f &v) const { +get_cv_out(int n, LVecBase3 &v) const { v = get_cv_out(n); } @@ -620,7 +620,7 @@ get_cv_out(int n, LVecBase3f &v) const { // Description: Returns the starting point in parametric space of the // given CV. //////////////////////////////////////////////////////////////////// -float HermiteCurve:: +PN_stdfloat HermiteCurve:: get_cv_tstart(int n) const { if (n<0) { return 0.0f; @@ -728,10 +728,10 @@ write_cv(ostream &out, int n) const { // possible, false if something goes horribly wrong. //////////////////////////////////////////////////////////////////// bool HermiteCurve:: -rebuild_curveseg(int, float, const LVecBase4f &, - int, float, const LVecBase4f &, - int, float, const LVecBase4f &, - int, float, const LVecBase4f &) { +rebuild_curveseg(int, PN_stdfloat, const LVecBase4 &, + int, PN_stdfloat, const LVecBase4 &, + int, PN_stdfloat, const LVecBase4 &, + int, PN_stdfloat, const LVecBase4 &) { cerr << "rebuild_curveseg not implemented for this curve type.\n"; return false; } @@ -797,7 +797,7 @@ format_egg(ostream &out, const string &name, const string &curve_type, static void -wrap_hpr(const LVecBase3f &hpr1, LVecBase3f &hpr2) { +wrap_hpr(const LVecBase3 &hpr1, LVecBase3 &hpr2) { for (int i = 0; i < 3; i++) { while ((hpr2[i] - hpr1[i]) > 180.0) { hpr2[i] -= 360.0; @@ -817,7 +817,7 @@ wrap_hpr(const LVecBase3f &hpr1, LVecBase3f &hpr2) { //////////////////////////////////////////////////////////////////// void HermiteCurve:: invalidate_cv(int n, bool redo_all) { - float t1 = 0.0f, t2 = get_max_t(); + PN_stdfloat t1 = 0.0f, t2 = get_max_t(); if (n>0 && _points[n-1]._type!=HC_CUT) { const HermiteCurveCV &p1 = _points[n-1]; HermiteCurveCV p2(_points[n]); @@ -862,7 +862,7 @@ invalidate_cv(int n, bool redo_all) { // t. //////////////////////////////////////////////////////////////////// int HermiteCurve:: -find_cv(float t) { +find_cv(PN_stdfloat t) { nassertr(is_valid(), 0); int n; diff --git a/panda/src/parametrics/hermiteCurve.h b/panda/src/parametrics/hermiteCurve.h index 1c0925576a..124913fb23 100644 --- a/panda/src/parametrics/hermiteCurve.h +++ b/panda/src/parametrics/hermiteCurve.h @@ -55,20 +55,20 @@ public: HermiteCurveCV(const HermiteCurveCV &c); ~HermiteCurveCV(); - void set_point(const LVecBase3f &point) { _p = point; } - void set_in(const LVecBase3f &in); - void set_out(const LVecBase3f &out); + void set_point(const LVecBase3 &point) { _p = point; } + void set_in(const LVecBase3 &in); + void set_out(const LVecBase3 &out); void set_type(int type); void set_name(const string &name); void format_egg(ostream &out, int indent, int num_dimensions, bool show_in, bool show_out, - float scale_in, float scale_out) const; + PN_stdfloat scale_in, PN_stdfloat scale_out) const; void write_datagram(BamWriter *manager, Datagram &me) const; void fillin(DatagramIterator &scan, BamReader *manager); - LVecBase3f _p, _in, _out; + LVecBase3 _p, _in, _out; int _type; string _name; }; @@ -93,9 +93,9 @@ PUBLISHED: int get_num_cvs() const; - int insert_cv(float t); - int append_cv(int type, float x, float y, float z); - inline int append_cv(int type, const LVecBase3f &v) { + int insert_cv(PN_stdfloat t); + int append_cv(int type, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + inline int append_cv(int type, const LVecBase3 &v) { return append_cv(type, v[0], v[1], v[2]); } @@ -103,30 +103,30 @@ PUBLISHED: void remove_all_cvs(); bool set_cv_type(int n, int type); - bool set_cv_point(int n, float x, float y, float z); - inline bool set_cv_point(int n, const LVecBase3f &v) { + bool set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + inline bool set_cv_point(int n, const LVecBase3 &v) { return set_cv_point(n, v[0], v[1], v[2]); } - bool set_cv_in(int n, float x, float y, float z); - inline bool set_cv_in(int n, const LVecBase3f &v) { + bool set_cv_in(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + inline bool set_cv_in(int n, const LVecBase3 &v) { return set_cv_in(n, v[0], v[1], v[2]); } - bool set_cv_out(int n, float x, float y, float z); - inline bool set_cv_out(int n, const LVecBase3f &v) { + bool set_cv_out(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + inline bool set_cv_out(int n, const LVecBase3 &v) { return set_cv_out(n, v[0], v[1], v[2]); } - bool set_cv_tstart(int n, float tstart); + bool set_cv_tstart(int n, PN_stdfloat tstart); bool set_cv_name(int n, const char *name); int get_cv_type(int n) const; - const LVecBase3f &get_cv_point(int n) const; - void get_cv_point(int n, LVecBase3f &v) const; - const LVecBase3f &get_cv_in(int n) const; - void get_cv_in(int n, LVecBase3f &v) const; - const LVecBase3f &get_cv_out(int n) const; - void get_cv_out(int n, LVecBase3f &v) const; - float get_cv_tstart(int n) const; + const LVecBase3 &get_cv_point(int n) const; + void get_cv_point(int n, LVecBase3 &v) const; + const LVecBase3 &get_cv_in(int n) const; + void get_cv_in(int n, LVecBase3 &v) const; + const LVecBase3 &get_cv_out(int n) const; + void get_cv_out(int n, LVecBase3 &v) const; + PN_stdfloat get_cv_tstart(int n) const; string get_cv_name(int n) const; virtual void output(ostream &out) const; @@ -139,17 +139,17 @@ public: } virtual bool - rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, - int rtype1, float t1, const LVecBase4f &v1, - int rtype2, float t2, const LVecBase4f &v2, - int rtype3, float t3, const LVecBase4f &v3); + rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, + int rtype1, PN_stdfloat t1, const LVecBase4 &v1, + int rtype2, PN_stdfloat t2, const LVecBase4 &v2, + int rtype3, PN_stdfloat t3, const LVecBase4 &v3); protected: virtual bool format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const; void invalidate_cv(int n, bool redo_all); - int find_cv(float t); + int find_cv(PN_stdfloat t); void recompute_basis(); pvector _points; diff --git a/panda/src/parametrics/nurbsBasisVector.I b/panda/src/parametrics/nurbsBasisVector.I index cbb6209a76..93873044c5 100644 --- a/panda/src/parametrics/nurbsBasisVector.I +++ b/panda/src/parametrics/nurbsBasisVector.I @@ -59,7 +59,7 @@ get_num_segments() const { // Description: Returns the first legal value of t on the curve. // Usually this is 0.0. //////////////////////////////////////////////////////////////////// -INLINE float NurbsBasisVector:: +INLINE PN_stdfloat NurbsBasisVector:: get_start_t() const { nassertr(!_segments.empty(), 0.0f); return _segments.front()._from; @@ -70,7 +70,7 @@ get_start_t() const { // Access: Public // Description: Returns the last legal value of t on the curve. //////////////////////////////////////////////////////////////////// -INLINE float NurbsBasisVector:: +INLINE PN_stdfloat NurbsBasisVector:: get_end_t() const { nassertr(!_segments.empty(), 0.0f); return _segments.back()._to; @@ -94,7 +94,7 @@ get_vertex_index(int segment) const { // Access: Public // Description: Returns the t value of the beginning of this segment. //////////////////////////////////////////////////////////////////// -INLINE float NurbsBasisVector:: +INLINE PN_stdfloat NurbsBasisVector:: get_from(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); return _segments[segment]._from; @@ -105,7 +105,7 @@ get_from(int segment) const { // Access: Public // Description: Returns the t value of the end of this segment. //////////////////////////////////////////////////////////////////// -INLINE float NurbsBasisVector:: +INLINE PN_stdfloat NurbsBasisVector:: get_to(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); return _segments[segment]._to; @@ -119,9 +119,9 @@ get_to(int segment) const { // vector over the segment; it does not depend on the // control vertices. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &NurbsBasisVector:: +INLINE const LMatrix4 &NurbsBasisVector:: get_basis(int segment) const { - nassertr(segment >= 0 && segment < (int)_segments.size(), LMatrix4f::ident_mat()); + nassertr(segment >= 0 && segment < (int)_segments.size(), LMatrix4::ident_mat()); return _segments[segment]._basis; } @@ -132,11 +132,11 @@ get_basis(int segment) const { // corresponding to [from, to]. Returns the scaled // value. //////////////////////////////////////////////////////////////////// -INLINE float NurbsBasisVector:: -scale_t(int segment, float t) const { +INLINE PN_stdfloat NurbsBasisVector:: +scale_t(int segment, PN_stdfloat t) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); - float from = _segments[segment]._from; - float to = _segments[segment]._to; + PN_stdfloat from = _segments[segment]._from; + PN_stdfloat to = _segments[segment]._to; t = (t - from) / (to - from); - return min(max(t, 0.0f), 1.0f); + return min(max(t, (PN_stdfloat)0.0), (PN_stdfloat)1.0); } diff --git a/panda/src/parametrics/nurbsBasisVector.cxx b/panda/src/parametrics/nurbsBasisVector.cxx index 390094b886..294e89a09e 100644 --- a/panda/src/parametrics/nurbsBasisVector.cxx +++ b/panda/src/parametrics/nurbsBasisVector.cxx @@ -32,13 +32,13 @@ clear(int order) { // and appends it to the set of basis matrices. //////////////////////////////////////////////////////////////////// void NurbsBasisVector:: -append_segment(int vertex_index, const float knots[]) { +append_segment(int vertex_index, const PN_stdfloat knots[]) { int i; // Scale the supplied knots to the range 0..1. - float scaled_knots[8]; - float min_k = knots[_order - 1]; - float max_k = knots[_order]; + PN_stdfloat scaled_knots[8]; + PN_stdfloat min_k = knots[_order - 1]; + PN_stdfloat max_k = knots[_order]; nassertv(min_k != max_k); for (i = 0; i < _order + _order; i++) { @@ -51,12 +51,12 @@ append_segment(int vertex_index, const float knots[]) { segment._to = max_k; for (i = 0; i < _order; i++) { - LVecBase4f b = nurbs_blending_function(_order, i, _order, scaled_knots); + LVecBase4 b = nurbs_blending_function(_order, i, _order, scaled_knots); segment._basis.set_col(i, b); } for (i = _order; i < 4; i++) { - segment._basis.set_col(i, LVecBase4f::zero()); + segment._basis.set_col(i, LVecBase4::zero()); } _segments.push_back(segment); @@ -81,10 +81,10 @@ transpose() { // Description: Recursively computes the appropriate blending // function for the indicated knot vector. //////////////////////////////////////////////////////////////////// -LVecBase4f NurbsBasisVector:: -nurbs_blending_function(int order, int i, int j, const float knots[]) { +LVecBase4 NurbsBasisVector:: +nurbs_blending_function(int order, int i, int j, const PN_stdfloat knots[]) { // This is doubly recursive. Ick. - LVecBase4f r; + LVecBase4 r; if (j == 1) { if (i == order - 1 && knots[i] < knots[i + 1]) { @@ -94,11 +94,11 @@ nurbs_blending_function(int order, int i, int j, const float knots[]) { } } else { - LVecBase4f bi0 = nurbs_blending_function(order, i, j - 1, knots); - LVecBase4f bi1 = nurbs_blending_function(order, i + 1, j - 1, knots); + LVecBase4 bi0 = nurbs_blending_function(order, i, j - 1, knots); + LVecBase4 bi1 = nurbs_blending_function(order, i + 1, j - 1, knots); - float d0 = knots[i + j - 1] - knots[i]; - float d1 = knots[i + j] - knots[i + 1]; + PN_stdfloat d0 = knots[i + j - 1] - knots[i]; + PN_stdfloat d1 = knots[i + j] - knots[i + 1]; // First term. Division by zero is defined to equal zero. if (d0 != 0.0f) { diff --git a/panda/src/parametrics/nurbsBasisVector.h b/panda/src/parametrics/nurbsBasisVector.h index d7cee57631..a63a152087 100644 --- a/panda/src/parametrics/nurbsBasisVector.h +++ b/panda/src/parametrics/nurbsBasisVector.h @@ -42,23 +42,23 @@ public: INLINE int get_order() const; INLINE int get_num_segments() const; - INLINE float get_start_t() const; - INLINE float get_end_t() const; + INLINE PN_stdfloat get_start_t() const; + INLINE PN_stdfloat get_end_t() const; INLINE int get_vertex_index(int segment) const; - INLINE float get_from(int segment) const; - INLINE float get_to(int segment) const; - INLINE const LMatrix4f &get_basis(int segment) const; - INLINE float scale_t(int segment, float t) const; + INLINE PN_stdfloat get_from(int segment) const; + INLINE PN_stdfloat get_to(int segment) const; + INLINE const LMatrix4 &get_basis(int segment) const; + INLINE PN_stdfloat scale_t(int segment, PN_stdfloat t) const; void clear(int order); - void append_segment(int vertex_index, const float knots[]); + void append_segment(int vertex_index, const PN_stdfloat knots[]); void transpose(); private: - static LVecBase4f nurbs_blending_function(int order, int i, int j, - const float knots[]); + static LVecBase4 nurbs_blending_function(int order, int i, int j, + const PN_stdfloat knots[]); private: int _order; @@ -66,9 +66,9 @@ private: class Segment { public: int _vertex_index; - float _from; - float _to; - LMatrix4f _basis; + PN_stdfloat _from; + PN_stdfloat _to; + LMatrix4 _basis; }; typedef pvector Segments; diff --git a/panda/src/parametrics/nurbsCurve.cxx b/panda/src/parametrics/nurbsCurve.cxx index 987e56a79d..d3f679a02c 100644 --- a/panda/src/parametrics/nurbsCurve.cxx +++ b/panda/src/parametrics/nurbsCurve.cxx @@ -58,7 +58,7 @@ NurbsCurve(const ParametricCurve &pc) { //////////////////////////////////////////////////////////////////// NurbsCurve:: NurbsCurve(int order, int num_cvs, - const float knots[], const LVecBase4f cvs[]) { + const PN_stdfloat knots[], const LVecBase4 cvs[]) { _order = order; int i; @@ -155,7 +155,7 @@ get_num_knots() const { // successful, false otherwise. //////////////////////////////////////////////////////////////////// bool NurbsCurve:: -insert_cv(float t) { +insert_cv(PN_stdfloat t) { if (_cvs.empty()) { append_cv(0.0f, 0.0f, 0.0f); return true; @@ -177,16 +177,16 @@ insert_cv(float t) { // First, get the new values of all the CV's that will change. // These are the CV's in the range [k - (_order-1), k-1]. - LVecBase4f new_cvs[3]; + LVecBase4 new_cvs[3]; int i; for (i = 0; i < _order-1; i++) { int nk = i + k - (_order-1); - float ti = get_knot(nk); - float d = get_knot(nk + _order-1) - ti; + PN_stdfloat ti = get_knot(nk); + PN_stdfloat d = get_knot(nk + _order-1) - ti; if (d == 0.0f) { new_cvs[i] = _cvs[nk-1]._p; } else { - float a = (t - ti) / d; + PN_stdfloat a = (t - ti) / d; new_cvs[i] = (1.0f-a)*_cvs[nk-1]._p + a*_cvs[nk]._p; } } @@ -240,7 +240,7 @@ remove_all_cvs() { // successful, false otherwise. //////////////////////////////////////////////////////////////////// bool NurbsCurve:: -set_cv(int n, const LVecBase4f &v) { +set_cv(int n, const LVecBase4 &v) { nassertr(n >= 0 && n < get_num_cvs(), false); _cvs[n]._p = v; @@ -253,9 +253,9 @@ set_cv(int n, const LVecBase4f &v) { // Description: Returns the position in homogeneous space of the // indicated CV. //////////////////////////////////////////////////////////////////// -LVecBase4f NurbsCurve:: +LVecBase4 NurbsCurve:: get_cv(int n) const { - nassertr(n >= 0 && n < get_num_cvs(), LVecBase4f::zero()); + nassertr(n >= 0 && n < get_num_cvs(), LVecBase4::zero()); return _cvs[n]._p; } @@ -271,7 +271,7 @@ get_cv(int n) const { // outside the range of its neighbors. //////////////////////////////////////////////////////////////////// bool NurbsCurve:: -set_knot(int n, float t) { +set_knot(int n, PN_stdfloat t) { nassertr(n >= 0 && n < get_num_knots(), false); if (n < _order || n-1 >= (int)_cvs.size()) { @@ -286,7 +286,7 @@ set_knot(int n, float t) { // Access: Published, Virtual // Description: Retrieves the value of the indicated knot. //////////////////////////////////////////////////////////////////// -float NurbsCurve:: +PN_stdfloat NurbsCurve:: get_knot(int n) const { if (n < _order || _cvs.empty()) { return 0.0f; @@ -312,8 +312,8 @@ bool NurbsCurve:: recompute() { _segs.erase(_segs.begin(), _segs.end()); - float knots[8]; - LVecBase4f cvs[4]; + PN_stdfloat knots[8]; + LVecBase4 cvs[4]; if ((int)_cvs.size() > _order-1) { for (int cv = 0; cv < (int)_cvs.size()-(_order-1); cv++) { @@ -348,10 +348,10 @@ recompute() { // possible, false if something goes horribly wrong. //////////////////////////////////////////////////////////////////// bool NurbsCurve:: -rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, - int rtype1, float t1, const LVecBase4f &v1, - int rtype2, float t2, const LVecBase4f &v2, - int rtype3, float t3, const LVecBase4f &v3) { +rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, + int rtype1, PN_stdfloat t1, const LVecBase4 &v1, + int rtype2, PN_stdfloat t2, const LVecBase4 &v2, + int rtype3, PN_stdfloat t3, const LVecBase4 &v3) { // Figure out which CV's contributed to this segment. int seg = 0; @@ -368,8 +368,8 @@ rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, } // Now copy the cvs and knots in question. - LMatrix4f G; - float knots[8]; + LMatrix4 G; + PN_stdfloat knots[8]; int c; @@ -377,7 +377,7 @@ rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, // properties depends on the original value. if ((rtype0 | rtype1 | rtype2 | rtype3) & RT_KEEP_ORIG) { for (c = 0; c < 4; c++) { - const LVecBase4f &s = (c < _order) ? _cvs[c+cv]._p : LVecBase4f::zero(); + const LVecBase4 &s = (c < _order) ? _cvs[c+cv]._p : LVecBase4::zero(); G.set_col(c, s); } @@ -388,10 +388,10 @@ rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, knots[c] = get_knot(c+cv); } - LMatrix4f B; + LMatrix4 B; compute_nurbs_basis(_order, knots, B); - LMatrix4f Bi; + LMatrix4 Bi; Bi = invert(B); if (!CubicCurveseg::compute_seg(rtype0, t0, v0, @@ -441,7 +441,7 @@ stitch(const ParametricCurve *a, const ParametricCurve *b) { // First, translate curve B to move its first CV to curve A's last // CV. - LVecBase3f point_offset = + LVecBase3 point_offset = na->get_cv_point(na->get_num_cvs() - 1) - nb->get_cv_point(0); int num_b_cvs = nb->get_num_cvs(); for (int i = 0; i < num_b_cvs; i++) { @@ -454,7 +454,7 @@ stitch(const ParametricCurve *a, const ParametricCurve *b) { _cvs.pop_back(); } - float t = na->get_max_t(); + PN_stdfloat t = na->get_max_t(); // Now add all the new CV's. pvector::iterator ci; @@ -512,7 +512,7 @@ write(ostream &out, int indent_level) const { // Returns the index of the new CV. //////////////////////////////////////////////////////////////////// int NurbsCurve:: -append_cv_impl(const LVecBase4f &v) { +append_cv_impl(const LVecBase4 &v) { _cvs.push_back(CV(v, get_knot(_cvs.size())+1.0f)); return _cvs.size()-1; } @@ -537,7 +537,7 @@ format_egg(ostream &out, const string &name, const string &curve_type, // is beyond the end of the curve. //////////////////////////////////////////////////////////////////// int NurbsCurve:: -find_cv(float t) { +find_cv(PN_stdfloat t) { int i; for (i = _order-1; i < (int)_cvs.size(); i++) { if (_cvs[i]._t >= t) { diff --git a/panda/src/parametrics/nurbsCurve.h b/panda/src/parametrics/nurbsCurve.h index 4952b01571..152e7e1f20 100644 --- a/panda/src/parametrics/nurbsCurve.h +++ b/panda/src/parametrics/nurbsCurve.h @@ -50,7 +50,7 @@ PUBLISHED: NurbsCurve(const ParametricCurve &pc); public: NurbsCurve(int order, int num_cvs, - const float knots[], const LVecBase4f cvs[]); + const PN_stdfloat knots[], const LVecBase4 cvs[]); PUBLISHED: virtual ~NurbsCurve(); @@ -65,25 +65,25 @@ public: virtual int get_num_cvs() const; virtual int get_num_knots() const; - virtual bool insert_cv(float t); + virtual bool insert_cv(PN_stdfloat t); virtual bool remove_cv(int n); virtual void remove_all_cvs(); - virtual bool set_cv(int n, const LVecBase4f &v); - virtual LVecBase4f get_cv(int n) const; + virtual bool set_cv(int n, const LVecBase4 &v); + virtual LVecBase4 get_cv(int n) const; - virtual bool set_knot(int n, float t); - virtual float get_knot(int n) const; + virtual bool set_knot(int n, PN_stdfloat t); + virtual PN_stdfloat get_knot(int n) const; virtual bool recompute(); public: virtual bool - rebuild_curveseg(int rtype0, float t0, const LVecBase4f &v0, - int rtype1, float t1, const LVecBase4f &v1, - int rtype2, float t2, const LVecBase4f &v2, - int rtype3, float t3, const LVecBase4f &v3); + rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, + int rtype1, PN_stdfloat t1, const LVecBase4 &v1, + int rtype2, PN_stdfloat t2, const LVecBase4 &v2, + int rtype3, PN_stdfloat t3, const LVecBase4 &v3); virtual bool stitch(const ParametricCurve *a, const ParametricCurve *b); @@ -94,20 +94,20 @@ public: virtual void write(ostream &out, int indent_level = 0) const; protected: - virtual int append_cv_impl(const LVecBase4f &v); + virtual int append_cv_impl(const LVecBase4 &v); virtual bool format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const; - int find_cv(float t); + int find_cv(PN_stdfloat t); int _order; class CV { public: CV() {} - CV(const LVecBase4f &p, float t) : _p(p), _t(t) {} - LVecBase4f _p; - float _t; + CV(const LVecBase4 &p, PN_stdfloat t) : _p(p), _t(t) {} + LVecBase4 _p; + PN_stdfloat _t; }; pvector _cvs; diff --git a/panda/src/parametrics/nurbsCurveEvaluator.I b/panda/src/parametrics/nurbsCurveEvaluator.I index 48ec6a328f..71fd9b1a48 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.I +++ b/panda/src/parametrics/nurbsCurveEvaluator.I @@ -63,7 +63,7 @@ get_num_vertices() const { // homogeneous weight. //////////////////////////////////////////////////////////////////// INLINE void NurbsCurveEvaluator:: -set_vertex(int i, const LVecBase4f &vertex) { +set_vertex(int i, const LVecBase4 &vertex) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_vertex(vertex); } @@ -77,9 +77,9 @@ set_vertex(int i, const LVecBase4f &vertex) { // scaled up by the weight factor. //////////////////////////////////////////////////////////////////// INLINE void NurbsCurveEvaluator:: -set_vertex(int i, const LVecBase3f &vertex, float weight) { +set_vertex(int i, const LVecBase3 &vertex, PN_stdfloat weight) { nassertv(i >= 0 && i < (int)_vertices.size()); - _vertices[i].set_vertex(LVecBase4f(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); + _vertices[i].set_vertex(LVecBase4(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); } //////////////////////////////////////////////////////////////////// @@ -88,9 +88,9 @@ set_vertex(int i, const LVecBase3f &vertex, float weight) { // Description: Returns the nth control vertex of the curve, relative // to its indicated coordinate space. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &NurbsCurveEvaluator:: +INLINE const LVecBase4 &NurbsCurveEvaluator:: get_vertex(int i) const { - nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4f::zero()); + nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4::zero()); return _vertices[i].get_vertex(); } @@ -100,16 +100,16 @@ get_vertex(int i) const { // Description: Returns the nth control vertex of the curve, relative // to the given coordinate space. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f NurbsCurveEvaluator:: +INLINE LVecBase4 NurbsCurveEvaluator:: get_vertex(int i, const NodePath &rel_to) const { - nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4f::zero()); + nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4::zero()); NodePath space = _vertices[i].get_space(rel_to); - const LVecBase4f &vertex = _vertices[i].get_vertex(); + const LVecBase4 &vertex = _vertices[i].get_vertex(); if (space.is_empty()) { return vertex; } else { - const LMatrix4f &mat = space.get_mat(rel_to); + const LMatrix4 &mat = space.get_mat(rel_to); return vertex * mat; } } @@ -174,20 +174,20 @@ set_vertex_space(int i, const string &space) { // extended vertices can be set. //////////////////////////////////////////////////////////////////// INLINE void NurbsCurveEvaluator:: -set_extended_vertex(int i, int d, float value) { +set_extended_vertex(int i, int d, PN_stdfloat value) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_extended_vertex(d, value); } //////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::float_extended_vertex +// Function: NurbsCurveEvaluator::get_extended_vertex // Access: Public // Description: Returns an n-dimensional vertex value. See // set_extended_vertex(). This returns the value set // for the indicated dimension, or 0.0 if nothing has // been set. //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveEvaluator:: +INLINE PN_stdfloat NurbsCurveEvaluator:: get_extended_vertex(int i, int d) const { nassertr(i >= 0 && i < (int)_vertices.size(), 0.0f); return _vertices[i].get_extended_vertex(d); diff --git a/panda/src/parametrics/nurbsCurveEvaluator.cxx b/panda/src/parametrics/nurbsCurveEvaluator.cxx index 9f09cbdad2..6c2615e233 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.cxx +++ b/panda/src/parametrics/nurbsCurveEvaluator.cxx @@ -81,7 +81,7 @@ get_vertex_space(int i, const NodePath &rel_to) const { // num_values times. See set_extended_vertex(). //////////////////////////////////////////////////////////////////// void NurbsCurveEvaluator:: -set_extended_vertices(int i, int d, const float values[], int num_values) { +set_extended_vertices(int i, int d, const PN_stdfloat values[], int num_values) { nassertv(i >= 0 && i < (int)_vertices.size()); NurbsVertex &vertex = _vertices[i]; @@ -99,7 +99,7 @@ set_extended_vertices(int i, int d, const float values[], int num_values) { // vector is supplied. //////////////////////////////////////////////////////////////////// void NurbsCurveEvaluator:: -set_knot(int i, float knot) { +set_knot(int i, PN_stdfloat knot) { if (_knots_dirty) { recompute_knots(); } @@ -112,7 +112,7 @@ set_knot(int i, float knot) { // Access: Published // Description: Returns the value of the nth knot. //////////////////////////////////////////////////////////////////// -float NurbsCurveEvaluator:: +PN_stdfloat NurbsCurveEvaluator:: get_knot(int i) const { if (_knots_dirty) { ((NurbsCurveEvaluator *)this)->recompute_knots(); @@ -160,7 +160,7 @@ evaluate(const NodePath &rel_to) const { } // First, transform the vertices as appropriate. - pvector vecs; + pvector vecs; get_vertices(vecs, rel_to); // And apply those transformed vertices to the basis matrices to @@ -179,17 +179,17 @@ evaluate(const NodePath &rel_to) const { // transformed by the indicated matrix. //////////////////////////////////////////////////////////////////// PT(NurbsCurveResult) NurbsCurveEvaluator:: -evaluate(const NodePath &rel_to, const LMatrix4f &mat) const { +evaluate(const NodePath &rel_to, const LMatrix4 &mat) const { if (_basis_dirty) { ((NurbsCurveEvaluator *)this)->recompute_basis(); } // First, transform the vertices as appropriate. - pvector vecs; + pvector vecs; get_vertices(vecs, rel_to); // And then apply the indicated matrix. - pvector::iterator vi; + pvector::iterator vi; for (vi = vecs.begin(); vi != vecs.end(); ++vi) { (*vi) = (*vi) * mat; } @@ -220,7 +220,7 @@ output(ostream &out) const { // homogenous space. //////////////////////////////////////////////////////////////////// void NurbsCurveEvaluator:: -get_vertices(pvector &verts, const NodePath &rel_to) const { +get_vertices(pvector &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); verts.reserve(verts.size() + num_vertices); int vi; @@ -238,13 +238,13 @@ get_vertices(pvector &verts, const NodePath &rel_to) const { // space. //////////////////////////////////////////////////////////////////// void NurbsCurveEvaluator:: -get_vertices(pvector &verts, const NodePath &rel_to) const { +get_vertices(pvector &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); verts.reserve(verts.size() + num_vertices); int vi; for (vi = 0; vi < num_vertices; vi++) { - LVecBase4f vertex = get_vertex(vi, rel_to); - LPoint3f v3(vertex[0] / vertex[3], vertex[1] / vertex[3], vertex[2] / vertex[3]); + LVecBase4 vertex = get_vertex(vi, rel_to); + LPoint3 v3(vertex[0] / vertex[3], vertex[1] / vertex[3], vertex[2] / vertex[3]); verts.push_back(v3); } } @@ -260,7 +260,7 @@ recompute_knots() { int num_knots = get_num_knots(); _knots.reserve(num_knots); - float value = 0.0f; + PN_stdfloat value = 0.0f; int i = 0; while (i < _order) { diff --git a/panda/src/parametrics/nurbsCurveEvaluator.h b/panda/src/parametrics/nurbsCurveEvaluator.h index c15a7151dc..46a0b43942 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.h +++ b/panda/src/parametrics/nurbsCurveEvaluator.h @@ -20,7 +20,7 @@ #include "nurbsCurveResult.h" #include "nurbsVertex.h" #include "pointerTo.h" -#include "vector_float.h" +#include "vector_stdfloat.h" #include "pvector.h" #include "nodePath.h" #include "referenceCount.h" @@ -51,24 +51,24 @@ PUBLISHED: void reset(int num_vertices); INLINE int get_num_vertices() const; - INLINE void set_vertex(int i, const LVecBase4f &vertex); - INLINE void set_vertex(int i, const LVecBase3f &vertex, float weight = 1.0); - INLINE const LVecBase4f &get_vertex(int i) const; - INLINE LVecBase4f get_vertex(int i, const NodePath &rel_to) const; + INLINE void set_vertex(int i, const LVecBase4 &vertex); + INLINE void set_vertex(int i, const LVecBase3 &vertex, PN_stdfloat weight = 1.0); + INLINE const LVecBase4 &get_vertex(int i) const; + INLINE LVecBase4 get_vertex(int i, const NodePath &rel_to) const; MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); INLINE void set_vertex_space(int i, const NodePath &space); INLINE void set_vertex_space(int i, const string &space); NodePath get_vertex_space(int i, const NodePath &rel_to) const; - INLINE void set_extended_vertex(int i, int d, float value); - INLINE float get_extended_vertex(int i, int d) const; + INLINE void set_extended_vertex(int i, int d, PN_stdfloat value); + INLINE PN_stdfloat get_extended_vertex(int i, int d) const; void set_extended_vertices(int i, int d, - const float values[], int num_values); + const PN_stdfloat values[], int num_values); INLINE int get_num_knots() const; - void set_knot(int i, float knot); - float get_knot(int i) const; + void set_knot(int i, PN_stdfloat knot); + PN_stdfloat get_knot(int i) const; MAKE_SEQ(get_knots, get_num_knots, get_knot); void normalize_knots(); @@ -76,13 +76,13 @@ PUBLISHED: PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const; PT(NurbsCurveResult) evaluate(const NodePath &rel_to, - const LMatrix4f &mat) const; + const LMatrix4 &mat) const; void output(ostream &out) const; public: - void get_vertices(pvector &verts, const NodePath &rel_to) const; - void get_vertices(pvector &verts, const NodePath &rel_to) const; + void get_vertices(pvector &verts, const NodePath &rel_to) const; + void get_vertices(pvector &verts, const NodePath &rel_to) const; private: void recompute_knots(); @@ -94,7 +94,7 @@ private: Vertices _vertices; bool _knots_dirty; - typedef vector_float Knots; + typedef vector_stdfloat Knots; Knots _knots; bool _basis_dirty; diff --git a/panda/src/parametrics/nurbsCurveInterface.I b/panda/src/parametrics/nurbsCurveInterface.I index 9ac2e52e0e..00045d7e88 100644 --- a/panda/src/parametrics/nurbsCurveInterface.I +++ b/panda/src/parametrics/nurbsCurveInterface.I @@ -19,8 +19,8 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE int NurbsCurveInterface:: -append_cv(float x, float y, float z) { - return append_cv(LVecBase3f(x, y, z)); +append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + return append_cv(LVecBase3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -29,8 +29,8 @@ append_cv(float x, float y, float z) { // Description: //////////////////////////////////////////////////////////////////// INLINE int NurbsCurveInterface:: -append_cv(const LVecBase3f &v) { - return append_cv(LVecBase4f(v[0], v[1], v[2], 1.0f)); +append_cv(const LVecBase3 &v) { + return append_cv(LVecBase4(v[0], v[1], v[2], 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ append_cv(const LVecBase3f &v) { // Description: //////////////////////////////////////////////////////////////////// INLINE int NurbsCurveInterface:: -append_cv(const LVecBase4f &v) { +append_cv(const LVecBase4 &v) { return append_cv_impl(v); } @@ -50,8 +50,8 @@ append_cv(const LVecBase4f &v) { // successful, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool NurbsCurveInterface:: -set_cv_point(int n, float x, float y, float z) { - return set_cv_point(n, LVecBase3f(x, y, z)); +set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + return set_cv_point(n, LVecBase3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -61,9 +61,9 @@ set_cv_point(int n, float x, float y, float z) { // successful, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool NurbsCurveInterface:: -set_cv_point(int n, const LVecBase3f &v) { +set_cv_point(int n, const LVecBase3 &v) { nassertr(n >= 0 && n < get_num_cvs(), false); - return set_cv(n, LVecBase4f(v[0], v[1], v[2], 1.0f) * get_cv_weight(n)); + return set_cv(n, LVecBase4(v[0], v[1], v[2], 1.0f) * get_cv_weight(n)); } //////////////////////////////////////////////////////////////////// @@ -71,12 +71,12 @@ set_cv_point(int n, const LVecBase3f &v) { // Access: Public, Scheme // Description: Returns the position of the indicated CV. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NurbsCurveInterface:: +INLINE LVecBase3 NurbsCurveInterface:: get_cv_point(int n) const { - nassertr(n >= 0 && n < get_num_cvs(), LVecBase3f::zero()); - LVecBase4f p = get_cv(n); - nassertr(p[3] != 0.0f, LVecBase3f::zero()); - return LVecBase3f(p[0], p[1], p[2]) / p[3]; + nassertr(n >= 0 && n < get_num_cvs(), LVecBase3::zero()); + LVecBase4 p = get_cv(n); + nassertr(p[3] != 0.0f, LVecBase3::zero()); + return LVecBase3(p[0], p[1], p[2]) / p[3]; } //////////////////////////////////////////////////////////////////// @@ -84,7 +84,7 @@ get_cv_point(int n) const { // Access: Published // Description: Returns the weight of the indicated CV. //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveInterface:: +INLINE PN_stdfloat NurbsCurveInterface:: get_cv_weight(int n) const { return get_cv(n)[3]; } diff --git a/panda/src/parametrics/nurbsCurveInterface.cxx b/panda/src/parametrics/nurbsCurveInterface.cxx index 66333aaf80..fd87c0a7b1 100644 --- a/panda/src/parametrics/nurbsCurveInterface.cxx +++ b/panda/src/parametrics/nurbsCurveInterface.cxx @@ -34,9 +34,9 @@ NurbsCurveInterface:: // its position in 3-d space. //////////////////////////////////////////////////////////////////// bool NurbsCurveInterface:: -set_cv_weight(int n, float w) { +set_cv_weight(int n, PN_stdfloat w) { nassertr(n >= 0 && n < get_num_cvs(), false); - LVecBase4f cv = get_cv(n); + LVecBase4 cv = get_cv(n); if (cv[3] == 0.0f) { cv.set(0.0f, 0.0f, 0.0f, w); } else { @@ -67,8 +67,8 @@ void NurbsCurveInterface:: write(ostream &out, int indent_level) const { indent(out, indent_level); - float min_t = 0.0f; - float max_t = 0.0f; + PN_stdfloat min_t = 0.0f; + PN_stdfloat max_t = 0.0f; if (get_num_knots() > 0) { min_t = get_knot(0); diff --git a/panda/src/parametrics/nurbsCurveInterface.h b/panda/src/parametrics/nurbsCurveInterface.h index b7b694ff2c..ec110c1a55 100644 --- a/panda/src/parametrics/nurbsCurveInterface.h +++ b/panda/src/parametrics/nurbsCurveInterface.h @@ -40,33 +40,33 @@ PUBLISHED: virtual int get_num_cvs() const=0; virtual int get_num_knots() const=0; - virtual bool insert_cv(float t)=0; + virtual bool insert_cv(PN_stdfloat t)=0; - INLINE int append_cv(float x, float y, float z); - INLINE int append_cv(const LVecBase3f &v); - INLINE int append_cv(const LVecBase4f &v); + INLINE int append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE int append_cv(const LVecBase3 &v); + INLINE int append_cv(const LVecBase4 &v); virtual bool remove_cv(int n)=0; virtual void remove_all_cvs()=0; - INLINE bool set_cv_point(int n, float x, float y, float z); - INLINE bool set_cv_point(int n, const LVecBase3f &v); - INLINE LVecBase3f get_cv_point(int n) const; + INLINE bool set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE bool set_cv_point(int n, const LVecBase3 &v); + INLINE LVecBase3 get_cv_point(int n) const; - bool set_cv_weight(int n, float w); - INLINE float get_cv_weight(int n) const; + bool set_cv_weight(int n, PN_stdfloat w); + INLINE PN_stdfloat get_cv_weight(int n) const; - virtual bool set_cv(int n, const LVecBase4f &v)=0; - virtual LVecBase4f get_cv(int n) const=0; + virtual bool set_cv(int n, const LVecBase4 &v)=0; + virtual LVecBase4 get_cv(int n) const=0; - virtual bool set_knot(int n, float t)=0; - virtual float get_knot(int n) const=0; + virtual bool set_knot(int n, PN_stdfloat t)=0; + virtual PN_stdfloat get_knot(int n) const=0; void write_cv(ostream &out, int n) const; protected: - virtual int append_cv_impl(const LVecBase4f &v)=0; + virtual int append_cv_impl(const LVecBase4 &v)=0; void write(ostream &out, int indent_level) const; bool format_egg(ostream &out, const string &name, diff --git a/panda/src/parametrics/nurbsCurveResult.I b/panda/src/parametrics/nurbsCurveResult.I index cb2c227922..ebe4c848e6 100644 --- a/panda/src/parametrics/nurbsCurveResult.I +++ b/panda/src/parametrics/nurbsCurveResult.I @@ -28,7 +28,7 @@ INLINE NurbsCurveResult:: // Description: Returns the first legal value of t on the curve. // Usually this is 0.0. //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveResult:: +INLINE PN_stdfloat NurbsCurveResult:: get_start_t() const { return _basis.get_start_t(); } @@ -38,7 +38,7 @@ get_start_t() const { // Access: Published // Description: Returns the last legal value of t on the curve. //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveResult:: +INLINE PN_stdfloat NurbsCurveResult:: get_end_t() const { return _basis.get_end_t(); } @@ -51,7 +51,7 @@ get_end_t() const { // the t value is valid, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool NurbsCurveResult:: -eval_point(float t, LVecBase3f &point) { +eval_point(PN_stdfloat t, LVecBase3 &point) { int segment = find_segment(t); if (segment == -1) { return false; @@ -70,7 +70,7 @@ eval_point(float t, LVecBase3f &point) { // See also eval_point(). //////////////////////////////////////////////////////////////////// INLINE bool NurbsCurveResult:: -eval_tangent(float t, LVecBase3f &tangent) { +eval_tangent(PN_stdfloat t, LVecBase3 &tangent) { int segment = find_segment(t); if (segment == -1) { return false; @@ -87,8 +87,8 @@ eval_tangent(float t, LVecBase3f &tangent) { // to the extended vertices associated with the curve in // the indicated dimension. //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveResult:: -eval_extended_point(float t, int d) { +INLINE PN_stdfloat NurbsCurveResult:: +eval_extended_point(PN_stdfloat t, int d) { int segment = find_segment(t); if (segment == -1) { return 0.0f; @@ -107,7 +107,7 @@ eval_extended_point(float t, int d) { // the indicated result array. //////////////////////////////////////////////////////////////////// INLINE bool NurbsCurveResult:: -eval_extended_points(float t, int d, float result[], int num_values) { +eval_extended_points(PN_stdfloat t, int d, PN_stdfloat result[], int num_values) { int segment = find_segment(t); if (segment == -1) { return false; @@ -139,8 +139,8 @@ get_num_segments() const { // eval_segment_point()), and returns the corresponding // t value in the entire curve (as in eval_point()). //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveResult:: -get_segment_t(int segment, float t) const { +INLINE PN_stdfloat NurbsCurveResult:: +get_segment_t(int segment, PN_stdfloat t) const { return t * (_basis.get_to(segment) - _basis.get_from(segment)) + _basis.get_from(segment); } @@ -161,7 +161,7 @@ get_num_samples() const { // Description: Returns the t value of the nth sample point generated // by the previous call to adaptive_sample(). //////////////////////////////////////////////////////////////////// -INLINE float NurbsCurveResult:: +INLINE PN_stdfloat NurbsCurveResult:: get_sample_t(int n) const { nassertr(n >= 0 && n < (int)_adaptive_result.size(), 0.0f); return _adaptive_result[n]._t; @@ -178,9 +178,9 @@ get_sample_t(int n) const { // get_sample_t() and pass it into eval_tangent() or // eval_extended_point(). //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &NurbsCurveResult:: +INLINE const LPoint3 &NurbsCurveResult:: get_sample_point(int n) const { - nassertr(n >= 0 && n < (int)_adaptive_result.size(), LPoint3f::zero()); + nassertr(n >= 0 && n < (int)_adaptive_result.size(), LPoint3::zero()); return _adaptive_result[n]._point; } @@ -193,7 +193,7 @@ get_sample_point(int n) const { // t value in the entire curve (as in eval_point()). //////////////////////////////////////////////////////////////////// INLINE NurbsCurveResult::AdaptiveSample:: -AdaptiveSample(float t, const LPoint3f &point) : +AdaptiveSample(PN_stdfloat t, const LPoint3 &point) : _t(t), _point(point) { diff --git a/panda/src/parametrics/nurbsCurveResult.cxx b/panda/src/parametrics/nurbsCurveResult.cxx index aac1f05b19..85b16a334b 100644 --- a/panda/src/parametrics/nurbsCurveResult.cxx +++ b/panda/src/parametrics/nurbsCurveResult.cxx @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////// NurbsCurveResult:: NurbsCurveResult(const NurbsBasisVector &basis, - const LVecBase4f vecs[], const NurbsVertex *verts, + const LVecBase4 vecs[], const NurbsVertex *verts, int num_vertices) : _basis(basis), _verts(verts) @@ -40,20 +40,20 @@ NurbsCurveResult(const NurbsBasisVector &basis, nassertv(vi >= 0 && vi + order - 1 < num_vertices); // Create a geometry matrix from our (up to) four involved vertices. - LMatrix4f geom; + LMatrix4 geom; int ci = 0; while (ci < order) { geom.set_row(ci, vecs[vi + ci]); ci++; } while (ci < 4) { - geom.set_row(ci, LVecBase4f::zero()); + geom.set_row(ci, LVecBase4::zero()); ci++; } // And compose this geometry matrix with the basis matrix to // produce a new matrix, which will be used to evaluate the curve. - LMatrix4f result; + LMatrix4 result; result.multiply(_basis.get_basis(i), geom); _composed.push_back(result); } @@ -78,11 +78,11 @@ NurbsCurveResult(const NurbsBasisVector &basis, // evaluate the points along each segment. //////////////////////////////////////////////////////////////////// void NurbsCurveResult:: -eval_segment_point(int segment, float t, LVecBase3f &point) const { - float t2 = t*t; - LVecBase4f tvec(t*t2, t2, t, 1.0f); +eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const { + PN_stdfloat t2 = t*t; + LVecBase4 tvec(t*t2, t2, t, 1.0f); - float weight = tvec.dot(_composed[segment].get_col(3)); + PN_stdfloat weight = tvec.dot(_composed[segment].get_col(3)); point.set(tvec.dot(_composed[segment].get_col(0)) / weight, tvec.dot(_composed[segment].get_col(1)) / weight, @@ -98,9 +98,9 @@ eval_segment_point(int segment, float t, LVecBase3f &point) const { // zero, particularly at the endpoints. //////////////////////////////////////////////////////////////////// void NurbsCurveResult:: -eval_segment_tangent(int segment, float t, LVecBase3f &tangent) const { - float t2 = t*t; - LVecBase4f tvec(3.0 * t2, 2.0 * t, 1.0f, 0.0f); +eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const { + PN_stdfloat t2 = t*t; + LVecBase4 tvec(3.0 * t2, 2.0 * t, 1.0f, 0.0f); tangent.set(tvec.dot(_composed[segment].get_col(0)), tvec.dot(_composed[segment].get_col(1)), @@ -114,21 +114,21 @@ eval_segment_tangent(int segment, float t, LVecBase3f &tangent) const { // to the extended vertices associated with the curve in // the indicated dimension. //////////////////////////////////////////////////////////////////// -float NurbsCurveResult:: -eval_segment_extended_point(int segment, float t, int d) const { +PN_stdfloat NurbsCurveResult:: +eval_segment_extended_point(int segment, PN_stdfloat t, int d) const { nassertr(segment >= 0 && segment < _basis.get_num_segments(), 0.0f); - float t2 = t*t; - LVecBase4f tvec(t*t2, t2, t, 1.0f); + PN_stdfloat t2 = t*t; + LVecBase4 tvec(t*t2, t2, t, 1.0f); - float weight = tvec.dot(_composed[segment].get_col(3)); + PN_stdfloat weight = tvec.dot(_composed[segment].get_col(3)); // Calculate the composition of the basis matrix and the geometry // matrix on-the-fly. int order = _basis.get_order(); int vi = _basis.get_vertex_index(segment); - LVecBase4f geom; + LVecBase4 geom; int ci = 0; while (ci < order) { geom[ci] = _verts[vi + ci].get_extended_vertex(d); @@ -139,10 +139,10 @@ eval_segment_extended_point(int segment, float t, int d) const { ci++; } - const LMatrix4f &basis = _basis.get_basis(segment); + const LMatrix4 &basis = _basis.get_basis(segment); // Compute matrix * column vector. - LVecBase4f composed_geom(basis.get_row(0).dot(geom), + LVecBase4 composed_geom(basis.get_row(0).dot(geom), basis.get_row(1).dot(geom), basis.get_row(2).dot(geom), basis.get_row(3).dot(geom)); @@ -159,23 +159,23 @@ eval_segment_extended_point(int segment, float t, int d) const { // the indicated result array. //////////////////////////////////////////////////////////////////// void NurbsCurveResult:: -eval_segment_extended_points(int segment, float t, int d, - float result[], int num_values) const { +eval_segment_extended_points(int segment, PN_stdfloat t, int d, + PN_stdfloat result[], int num_values) const { nassertv(segment >= 0 && segment < _basis.get_num_segments()); - float t2 = t*t; - LVecBase4f tvec(t*t2, t2, t, 1.0f); + PN_stdfloat t2 = t*t; + LVecBase4 tvec(t*t2, t2, t, 1.0f); - float weight = tvec.dot(_composed[segment].get_col(3)); + PN_stdfloat weight = tvec.dot(_composed[segment].get_col(3)); // Calculate the composition of the basis matrix and the geometry // matrix on-the-fly. - const LMatrix4f &basis = _basis.get_basis(segment); + const LMatrix4 &basis = _basis.get_basis(segment); int order = _basis.get_order(); int vi = _basis.get_vertex_index(segment); for (int n = 0; n < num_values; n++) { - LVecBase4f geom; + LVecBase4 geom; int ci = 0; while (ci < order) { geom[ci] = _verts[vi + ci].get_extended_vertex(d + n); @@ -187,7 +187,7 @@ eval_segment_extended_points(int segment, float t, int d, } // Compute matrix * column vector. - LVecBase4f composed_geom(basis.get_row(0).dot(geom), + LVecBase4 composed_geom(basis.get_row(0).dot(geom), basis.get_row(1).dot(geom), basis.get_row(2).dot(geom), basis.get_row(3).dot(geom)); @@ -208,11 +208,11 @@ eval_segment_extended_points(int segment, float t, int d, // get_sample_t(), and get_sample_point(). //////////////////////////////////////////////////////////////////// void NurbsCurveResult:: -adaptive_sample(float tolerance) { - float tolerance_2 = tolerance * tolerance; +adaptive_sample(PN_stdfloat tolerance) { + PN_stdfloat tolerance_2 = tolerance * tolerance; _adaptive_result.clear(); - LPoint3f p0, p1; + LPoint3 p0, p1; int num_segments = _basis.get_num_segments(); for (int segment = 0; segment < num_segments; ++segment) { @@ -238,7 +238,7 @@ adaptive_sample(float tolerance) { // this value. //////////////////////////////////////////////////////////////////// int NurbsCurveResult:: -find_segment(float t) { +find_segment(PN_stdfloat t) { // Trivially check the endpoints of the curve. if (t >= get_end_t()) { return _basis.get_num_segments() - 1; @@ -271,7 +271,7 @@ find_segment(float t) { // increasing order of t, and they don't overlap. //////////////////////////////////////////////////////////////////// int NurbsCurveResult:: -r_find_segment(float t, int top, int bot) const { +r_find_segment(PN_stdfloat t, int top, int bot) const { if (bot < top) { // Not found. return -1; @@ -279,8 +279,8 @@ r_find_segment(float t, int top, int bot) const { int mid = (top + bot) / 2; nassertr(mid >= 0 && mid < _basis.get_num_segments(), -1); - float from = _basis.get_from(mid); - float to = _basis.get_to(mid); + PN_stdfloat from = _basis.get_from(mid); + PN_stdfloat to = _basis.get_to(mid); if (from > t) { // Too high, try lower. return r_find_segment(t, top, mid - 1); @@ -304,10 +304,10 @@ r_find_segment(float t, int top, int bot) const { // excluding t0. //////////////////////////////////////////////////////////////////// void NurbsCurveResult:: -r_adaptive_sample(int segment, float t0, const LPoint3f &p0, - float t1, const LPoint3f &p1, float tolerance_2) { - float tmid = (t0 + t1) * 0.5f; - LPoint3f pmid; +r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0, + PN_stdfloat t1, const LPoint3 &p1, PN_stdfloat tolerance_2) { + PN_stdfloat tmid = (t0 + t1) * 0.5f; + LPoint3 pmid; eval_segment_point(segment, tmid, pmid); if (sqr_dist_to_line(pmid, p0, p1 - p0) > tolerance_2) { @@ -328,13 +328,13 @@ r_adaptive_sample(int segment, float t0, const LPoint3f &p0, // computes the minimum distance from a point to a line, // and returns the distance squared. //////////////////////////////////////////////////////////////////// -float NurbsCurveResult:: -sqr_dist_to_line(const LPoint3f &point, const LPoint3f &origin, - const LVector3f &vec) { - LVector3f norm = vec; +PN_stdfloat NurbsCurveResult:: +sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, + const LVector3 &vec) { + LVector3 norm = vec; norm.normalize(); - LVector3f d = point - origin; - float hyp_2 = d.length_squared(); - float leg = d.dot(norm); + LVector3 d = point - origin; + PN_stdfloat hyp_2 = d.length_squared(); + PN_stdfloat leg = d.dot(norm); return hyp_2 - leg * leg; } diff --git a/panda/src/parametrics/nurbsCurveResult.h b/panda/src/parametrics/nurbsCurveResult.h index e55efff829..fff4cd34a0 100644 --- a/panda/src/parametrics/nurbsCurveResult.h +++ b/panda/src/parametrics/nurbsCurveResult.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "referenceCount.h" #include "nurbsBasisVector.h" -#include "vector_float.h" +#include "vector_stdfloat.h" class NurbsVertex; @@ -38,44 +38,44 @@ class NurbsVertex; class EXPCL_PANDA_PARAMETRICS NurbsCurveResult : public ReferenceCount { public: NurbsCurveResult(const NurbsBasisVector &basis, - const LVecBase4f vecs[], const NurbsVertex *verts, + const LVecBase4 vecs[], const NurbsVertex *verts, int num_vertices); PUBLISHED: INLINE ~NurbsCurveResult(); - INLINE float get_start_t() const; - INLINE float get_end_t() const; + INLINE PN_stdfloat get_start_t() const; + INLINE PN_stdfloat get_end_t() const; - INLINE bool eval_point(float t, LVecBase3f &point); - INLINE bool eval_tangent(float t, LVecBase3f &tangent); - INLINE float eval_extended_point(float t, int d); - INLINE bool eval_extended_points(float t, int d, - float result[], int num_values); + INLINE bool eval_point(PN_stdfloat t, LVecBase3 &point); + INLINE bool eval_tangent(PN_stdfloat t, LVecBase3 &tangent); + INLINE PN_stdfloat eval_extended_point(PN_stdfloat t, int d); + INLINE bool eval_extended_points(PN_stdfloat t, int d, + PN_stdfloat result[], int num_values); INLINE int get_num_segments() const; - void eval_segment_point(int segment, float t, LVecBase3f &point) const; - void eval_segment_tangent(int segment, float t, LVecBase3f &tangent) const; - float eval_segment_extended_point(int segment, float t, int d) const; - void eval_segment_extended_points(int segment, float t, int d, - float result[], int num_values) const; - INLINE float get_segment_t(int segment, float t) const; + void eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const; + void eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const; + PN_stdfloat eval_segment_extended_point(int segment, PN_stdfloat t, int d) const; + void eval_segment_extended_points(int segment, PN_stdfloat t, int d, + PN_stdfloat result[], int num_values) const; + INLINE PN_stdfloat get_segment_t(int segment, PN_stdfloat t) const; - void adaptive_sample(float tolerance); + void adaptive_sample(PN_stdfloat tolerance); INLINE int get_num_samples() const; - INLINE float get_sample_t(int n) const; - INLINE const LPoint3f &get_sample_point(int n) const; + INLINE PN_stdfloat get_sample_t(int n) const; + INLINE const LPoint3 &get_sample_point(int n) const; MAKE_SEQ(get_sample_ts, get_num_samples, get_sample_t); MAKE_SEQ(get_sample_points, get_num_samples, get_sample_points); private: - int find_segment(float t); - int r_find_segment(float t, int top, int bot) const; + int find_segment(PN_stdfloat t); + int r_find_segment(PN_stdfloat t, int top, int bot) const; - void r_adaptive_sample(int segment, float t0, const LPoint3f &p0, - float t1, const LPoint3f &p1, float tolerance_2); - static float sqr_dist_to_line(const LPoint3f &point, const LPoint3f &origin, - const LVector3f &vec); + void r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0, + PN_stdfloat t1, const LPoint3 &p1, PN_stdfloat tolerance_2); + static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, + const LVector3 &vec); NurbsBasisVector _basis; const NurbsVertex *_verts; @@ -83,18 +83,18 @@ private: // We pre-compose the basis matrix and the geometry vectors, so we // have these handy for evaluation. There is one entry in the // _composed for each entry in basis._segments. - typedef pvector ComposedGeom; + typedef pvector ComposedGeom; ComposedGeom _composed; int _last_segment; - float _last_from; - float _last_to; + PN_stdfloat _last_from; + PN_stdfloat _last_to; class AdaptiveSample { public: - INLINE AdaptiveSample(float t, const LPoint3f &point); - float _t; - LPoint3f _point; + INLINE AdaptiveSample(PN_stdfloat t, const LPoint3 &point); + PN_stdfloat _t; + LPoint3 _point; }; typedef pvector AdaptiveResult; AdaptiveResult _adaptive_result; diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.I b/panda/src/parametrics/nurbsSurfaceEvaluator.I index 90f6a9ee59..7e2a6ac1b0 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.I +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.I @@ -103,7 +103,7 @@ get_num_v_vertices() const { // homogeneous weight. //////////////////////////////////////////////////////////////////// INLINE void NurbsSurfaceEvaluator:: -set_vertex(int ui, int vi, const LVecBase4f &vertex) { +set_vertex(int ui, int vi, const LVecBase4 &vertex) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); vert(ui, vi).set_vertex(vertex); @@ -118,10 +118,10 @@ set_vertex(int ui, int vi, const LVecBase4f &vertex) { // scaled up by the weight factor. //////////////////////////////////////////////////////////////////// INLINE void NurbsSurfaceEvaluator:: -set_vertex(int ui, int vi, const LVecBase3f &vertex, float weight) { +set_vertex(int ui, int vi, const LVecBase3 &vertex, PN_stdfloat weight) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); - vert(ui, vi).set_vertex(LVecBase4f(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); + vert(ui, vi).set_vertex(LVecBase4(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); } //////////////////////////////////////////////////////////////////// @@ -130,10 +130,10 @@ set_vertex(int ui, int vi, const LVecBase3f &vertex, float weight) { // Description: Returns the nth control vertex of the surface, relative // to its indicated coordinate space. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &NurbsSurfaceEvaluator:: +INLINE const LVecBase4 &NurbsSurfaceEvaluator:: get_vertex(int ui, int vi) const { nassertr(ui >= 0 && ui < _num_u_vertices && - vi >= 0 && vi < _num_v_vertices, LVecBase4f::zero()); + vi >= 0 && vi < _num_v_vertices, LVecBase4::zero()); return vert(ui, vi).get_vertex(); } @@ -143,17 +143,17 @@ get_vertex(int ui, int vi) const { // Description: Returns the nth control vertex of the surface, relative // to the given coordinate space. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f NurbsSurfaceEvaluator:: +INLINE LVecBase4 NurbsSurfaceEvaluator:: get_vertex(int ui, int vi, const NodePath &rel_to) const { nassertr(ui >= 0 && ui < _num_u_vertices && - vi >= 0 && vi < _num_v_vertices, LVecBase4f::zero()); + vi >= 0 && vi < _num_v_vertices, LVecBase4::zero()); NodePath space = vert(ui, vi).get_space(rel_to); - const LVecBase4f &vertex = vert(ui, vi).get_vertex(); + const LVecBase4 &vertex = vert(ui, vi).get_vertex(); if (space.is_empty()) { return vertex; } else { - const LMatrix4f &mat = space.get_mat(rel_to); + const LMatrix4 &mat = space.get_mat(rel_to); return vertex * mat; } } @@ -220,21 +220,21 @@ set_vertex_space(int ui, int vi, const string &space) { // extended vertices can be set. //////////////////////////////////////////////////////////////////// INLINE void NurbsSurfaceEvaluator:: -set_extended_vertex(int ui, int vi, int d, float value) { +set_extended_vertex(int ui, int vi, int d, PN_stdfloat value) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); vert(ui, vi).set_extended_vertex(d, value); } //////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::float_extended_vertex +// Function: NurbsSurfaceEvaluator::get_extended_vertex // Access: Public // Description: Returns an n-dimensional vertex value. See // set_extended_vertex(). This returns the value set // for the indicated dimension, or 0.0 if nothing has // been set. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceEvaluator:: +INLINE PN_stdfloat NurbsSurfaceEvaluator:: get_extended_vertex(int ui, int vi, int d) const { nassertr(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices, 0.0f); diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx index 716e2d8bf9..fba59019c9 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx @@ -91,7 +91,7 @@ get_vertex_space(int ui, int vi, const NodePath &rel_to) const { //////////////////////////////////////////////////////////////////// void NurbsSurfaceEvaluator:: set_extended_vertices(int ui, int vi, int d, - const float values[], int num_values) { + const PN_stdfloat values[], int num_values) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); @@ -110,7 +110,7 @@ set_extended_vertices(int ui, int vi, int d, // vector is supplied. //////////////////////////////////////////////////////////////////// void NurbsSurfaceEvaluator:: -set_u_knot(int i, float knot) { +set_u_knot(int i, PN_stdfloat knot) { if (_u_knots_dirty) { recompute_u_knots(); } @@ -123,7 +123,7 @@ set_u_knot(int i, float knot) { // Access: Published // Description: Returns the value of the nth knot. //////////////////////////////////////////////////////////////////// -float NurbsSurfaceEvaluator:: +PN_stdfloat NurbsSurfaceEvaluator:: get_u_knot(int i) const { if (_u_knots_dirty) { ((NurbsSurfaceEvaluator *)this)->recompute_u_knots(); @@ -165,7 +165,7 @@ normalize_u_knots() { // vector is supplied. //////////////////////////////////////////////////////////////////// void NurbsSurfaceEvaluator:: -set_v_knot(int i, float knot) { +set_v_knot(int i, PN_stdfloat knot) { if (_v_knots_dirty) { recompute_v_knots(); } @@ -178,7 +178,7 @@ set_v_knot(int i, float knot) { // Access: Published // Description: Returns the value of the nth knot. //////////////////////////////////////////////////////////////////// -float NurbsSurfaceEvaluator:: +PN_stdfloat NurbsSurfaceEvaluator:: get_v_knot(int i) const { if (_v_knots_dirty) { ((NurbsSurfaceEvaluator *)this)->recompute_v_knots(); @@ -229,7 +229,7 @@ evaluate(const NodePath &rel_to) const { } // First, transform the vertices as appropriate. - pvector vecs; + pvector vecs; get_vertices(vecs, rel_to); // And apply those transformed vertices to the basis matrices to @@ -262,18 +262,18 @@ output(ostream &out) const { // coordinate changing more rapidly. //////////////////////////////////////////////////////////////////// void NurbsSurfaceEvaluator:: -get_vertices(pvector &verts, const NodePath &rel_to) const { +get_vertices(pvector &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); verts.reserve(verts.size() + num_vertices); int vi; for (vi = 0; vi < num_vertices; vi++) { NodePath space = _vertices[vi].get_space(rel_to); - const LVecBase4f &vertex = _vertices[vi].get_vertex(); + const LVecBase4 &vertex = _vertices[vi].get_vertex(); if (space.is_empty()) { verts.push_back(vertex); } else { CPT(TransformState) transform = space.get_transform(rel_to); - const LMatrix4f &mat = transform->get_mat(); + const LMatrix4 &mat = transform->get_mat(); verts.push_back(vertex * mat); } } @@ -291,19 +291,19 @@ get_vertices(pvector &verts, const NodePath &rel_to) const { // coordinate changing more rapidly. //////////////////////////////////////////////////////////////////// void NurbsSurfaceEvaluator:: -get_vertices(pvector &verts, const NodePath &rel_to) const { +get_vertices(pvector &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); verts.reserve(verts.size() + num_vertices); int vi; for (vi = 0; vi < num_vertices; vi++) { const NodePath &space = _vertices[vi].get_space(rel_to); - LVecBase4f vertex = _vertices[vi].get_vertex(); + LVecBase4 vertex = _vertices[vi].get_vertex(); if (!space.is_empty()) { CPT(TransformState) transform = space.get_transform(rel_to); - const LMatrix4f &mat = transform->get_mat(); + const LMatrix4 &mat = transform->get_mat(); vertex = vertex * mat; } - LPoint3f v3(vertex[0] / vertex[3], vertex[1] / vertex[3], vertex[2] / vertex[3]); + LPoint3 v3(vertex[0] / vertex[3], vertex[1] / vertex[3], vertex[2] / vertex[3]); verts.push_back(v3); } } @@ -319,7 +319,7 @@ recompute_u_knots() { int num_knots = get_num_u_knots(); _u_knots.reserve(num_knots); - float value = 0.0f; + PN_stdfloat value = 0.0f; int i = 0; while (i < _u_order) { @@ -351,7 +351,7 @@ recompute_v_knots() { int num_knots = get_num_v_knots(); _v_knots.reserve(num_knots); - float value = 0.0f; + PN_stdfloat value = 0.0f; int i = 0; while (i < _v_order) { diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.h b/panda/src/parametrics/nurbsSurfaceEvaluator.h index fec94d9c4f..d87e9020d7 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.h +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.h @@ -20,7 +20,7 @@ #include "nurbsSurfaceResult.h" #include "nurbsVertex.h" #include "pointerTo.h" -#include "vector_float.h" +#include "vector_stdfloat.h" #include "pvector.h" #include "nodePath.h" #include "referenceCount.h" @@ -49,29 +49,29 @@ PUBLISHED: INLINE int get_num_u_vertices() const; INLINE int get_num_v_vertices() const; - INLINE void set_vertex(int ui, int vi, const LVecBase4f &vertex); - INLINE void set_vertex(int ui, int vi, const LVecBase3f &vertex, float weight = 1.0); - INLINE const LVecBase4f &get_vertex(int ui, int vi) const; - INLINE LVecBase4f get_vertex(int ui, int vi, const NodePath &rel_to) const; + INLINE void set_vertex(int ui, int vi, const LVecBase4 &vertex); + INLINE void set_vertex(int ui, int vi, const LVecBase3 &vertex, PN_stdfloat weight = 1.0); + INLINE const LVecBase4 &get_vertex(int ui, int vi) const; + INLINE LVecBase4 get_vertex(int ui, int vi, const NodePath &rel_to) const; INLINE void set_vertex_space(int ui, int vi, const NodePath &space); INLINE void set_vertex_space(int ui, int vi, const string &space); NodePath get_vertex_space(int ui, int vi, const NodePath &rel_to) const; - INLINE void set_extended_vertex(int ui, int vi, int d, float value); - INLINE float get_extended_vertex(int ui, int vi, int d) const; + INLINE void set_extended_vertex(int ui, int vi, int d, PN_stdfloat value); + INLINE PN_stdfloat get_extended_vertex(int ui, int vi, int d) const; void set_extended_vertices(int ui, int vi, int d, - const float values[], int num_values); + const PN_stdfloat values[], int num_values); INLINE int get_num_u_knots() const; - void set_u_knot(int i, float knot); - float get_u_knot(int i) const; + void set_u_knot(int i, PN_stdfloat knot); + PN_stdfloat get_u_knot(int i) const; MAKE_SEQ(get_u_knots, get_num_u_knots, get_u_knot); void normalize_u_knots(); INLINE int get_num_v_knots() const; - void set_v_knot(int i, float knot); - float get_v_knot(int i) const; + void set_v_knot(int i, PN_stdfloat knot); + PN_stdfloat get_v_knot(int i) const; MAKE_SEQ(get_v_knots, get_num_v_knots, get_v_knot); void normalize_v_knots(); @@ -83,8 +83,8 @@ PUBLISHED: void output(ostream &out) const; public: - void get_vertices(pvector &verts, const NodePath &rel_to) const; - void get_vertices(pvector &verts, const NodePath &rel_to) const; + void get_vertices(pvector &verts, const NodePath &rel_to) const; + void get_vertices(pvector &verts, const NodePath &rel_to) const; private: INLINE NurbsVertex &vert(int ui, int vi); @@ -105,7 +105,7 @@ private: bool _u_knots_dirty; bool _v_knots_dirty; - typedef vector_float Knots; + typedef vector_stdfloat Knots; Knots _u_knots; Knots _v_knots; diff --git a/panda/src/parametrics/nurbsSurfaceResult.I b/panda/src/parametrics/nurbsSurfaceResult.I index f606e1a8b9..45e6302e97 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.I +++ b/panda/src/parametrics/nurbsSurfaceResult.I @@ -28,7 +28,7 @@ INLINE NurbsSurfaceResult:: // Description: Returns the first legal value of u on the surface. // Usually this is 0.0. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: +INLINE PN_stdfloat NurbsSurfaceResult:: get_start_u() const { return _u_basis.get_start_t(); } @@ -38,7 +38,7 @@ get_start_u() const { // Access: Public // Description: Returns the last legal value of u on the surface. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: +INLINE PN_stdfloat NurbsSurfaceResult:: get_end_u() const { return _u_basis.get_end_t(); } @@ -49,7 +49,7 @@ get_end_u() const { // Description: Returns the first legal value of v on the surface. // Usually this is 0.0. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: +INLINE PN_stdfloat NurbsSurfaceResult:: get_start_v() const { return _v_basis.get_start_t(); } @@ -59,7 +59,7 @@ get_start_v() const { // Access: Public // Description: Returns the last legal value of v on the surface. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: +INLINE PN_stdfloat NurbsSurfaceResult:: get_end_v() const { return _v_basis.get_end_t(); } @@ -72,7 +72,7 @@ get_end_v() const { // the u, v values are valid, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool NurbsSurfaceResult:: -eval_point(float u, float v, LVecBase3f &point) { +eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) { int ui = find_u_segment(u); int vi = find_v_segment(v); if (ui == -1 || vi == -1) { @@ -93,7 +93,7 @@ eval_point(float u, float v, LVecBase3f &point) { // See also eval_point(). //////////////////////////////////////////////////////////////////// INLINE bool NurbsSurfaceResult:: -eval_normal(float u, float v, LVecBase3f &normal) { +eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) { int ui = find_u_segment(u); int vi = find_v_segment(v); if (ui == -1 || vi == -1) { @@ -112,8 +112,8 @@ eval_normal(float u, float v, LVecBase3f &normal) { // to the extended vertices associated with the surface in // the indicated dimension. //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: -eval_extended_point(float u, float v, int d) { +INLINE PN_stdfloat NurbsSurfaceResult:: +eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d) { int ui = find_u_segment(u); int vi = find_v_segment(v); if (ui == -1 || vi == -1) { @@ -134,7 +134,7 @@ eval_extended_point(float u, float v, int d) { // the indicated result array. //////////////////////////////////////////////////////////////////// INLINE bool NurbsSurfaceResult:: -eval_extended_points(float u, float v, int d, float result[], +eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d, PN_stdfloat result[], int num_values) { int ui = find_u_segment(u); int vi = find_v_segment(v); @@ -182,8 +182,8 @@ get_num_v_segments() const { // eval_segment_point()), and returns the corresponding // u value in the entire surface (as in eval_point()). //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: -get_segment_u(int ui, float u) const { +INLINE PN_stdfloat NurbsSurfaceResult:: +get_segment_u(int ui, PN_stdfloat u) const { return u * (_u_basis.get_to(ui) - _u_basis.get_from(ui)) + _u_basis.get_from(ui); } @@ -195,8 +195,8 @@ get_segment_u(int ui, float u) const { // eval_segment_point()), and returns the corresponding // v value in the entire surface (as in eval_point()). //////////////////////////////////////////////////////////////////// -INLINE float NurbsSurfaceResult:: -get_segment_v(int vi, float v) const { +INLINE PN_stdfloat NurbsSurfaceResult:: +get_segment_v(int vi, PN_stdfloat v) const { return v * (_v_basis.get_to(vi) - _v_basis.get_from(vi)) + _v_basis.get_from(vi); } diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index cb97521e34..913ab8a410 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -26,7 +26,7 @@ NurbsSurfaceResult:: NurbsSurfaceResult(const NurbsBasisVector &u_basis, const NurbsBasisVector &v_basis, - const LVecBase4f vecs[], const NurbsVertex *verts, + const LVecBase4 vecs[], const NurbsVertex *verts, int num_u_vertices, int num_v_vertices) : _u_basis(u_basis), _v_basis(v_basis), @@ -51,20 +51,20 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, } for (int vi = 0; vi < num_v_segments; vi++) { - const LMatrix4f &v_basis_transpose = _v_basis.get_basis(vi); + const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); int vn = _v_basis.get_vertex_index(vi); nassertv(vn >= 0 && vn + v_order - 1 < _num_v_vertices); for (int ui = 0; ui < num_u_segments; ui++) { - const LMatrix4f &u_basis_mat = _u_basis.get_basis(ui); + const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); int un = _u_basis.get_vertex_index(ui); nassertv(un >= 0 && un + u_order - 1 < _num_u_vertices); // Create four geometry matrices from our (up to) sixteen // involved vertices. - LMatrix4f geom_x, geom_y, geom_z, geom_w; + LMatrix4 geom_x, geom_y, geom_z, geom_w; memset(&geom_x, 0, sizeof(geom_x)); memset(&geom_y, 0, sizeof(geom_y)); memset(&geom_z, 0, sizeof(geom_z)); @@ -73,7 +73,7 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { if (uni < u_order && vni < v_order) { - const LVecBase4f &vec = vecs[verti(un + uni, vn + vni)]; + const LVecBase4 &vec = vecs[verti(un + uni, vn + vni)]; geom_x(uni, vni) = vec[0]; geom_y(uni, vni) = vec[1]; geom_z(uni, vni) = vec[2]; @@ -115,16 +115,16 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, // evaluate the points along each segment. //////////////////////////////////////////////////////////////////// void NurbsSurfaceResult:: -eval_segment_point(int ui, int vi, float u, float v, LVecBase3f &point) const { +eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const { int i = segi(ui, vi); nassertv(i >= 0 && i < (int)_composed.size()); - float u2 = u*u; - LVecBase4f uvec(u*u2, u2, u, 1.0f); - float v2 = v*v; - LVecBase4f vvec(v*v2, v2, v, 1.0f); + PN_stdfloat u2 = u*u; + LVecBase4 uvec(u*u2, u2, u, 1.0f); + PN_stdfloat v2 = v*v; + LVecBase4 vvec(v*v2, v2, v, 1.0f); - float weight = vvec.dot(uvec * _composed[i]._w); + PN_stdfloat weight = vvec.dot(uvec * _composed[i]._w); point.set(vvec.dot(uvec * _composed[i]._x) / weight, vvec.dot(uvec * _composed[i]._y) / weight, @@ -140,22 +140,22 @@ eval_segment_point(int ui, int vi, float u, float v, LVecBase3f &point) const { // zero. //////////////////////////////////////////////////////////////////// void NurbsSurfaceResult:: -eval_segment_normal(int ui, int vi, float u, float v, LVecBase3f &normal) const { +eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const { int i = segi(ui, vi); nassertv(i >= 0 && i < (int)_composed.size()); - float u2 = u*u; - LVecBase4f uvec(u*u2, u2, u, 1.0f); - LVecBase4f duvec(3.0f * u2, 2.0f * u, 1.0f, 0.0f); - float v2 = v*v; - LVecBase4f vvec(v*v2, v2, v, 1.0f); - LVecBase4f dvvec(3.0f * v2, 2.0f * v, 1.0f, 0.0f); + PN_stdfloat u2 = u*u; + LVecBase4 uvec(u*u2, u2, u, 1.0f); + LVecBase4 duvec(3.0f * u2, 2.0f * u, 1.0f, 0.0f); + PN_stdfloat v2 = v*v; + LVecBase4 vvec(v*v2, v2, v, 1.0f); + LVecBase4 dvvec(3.0f * v2, 2.0f * v, 1.0f, 0.0f); - LVector3f utan(vvec.dot(duvec * _composed[i]._x), + LVector3 utan(vvec.dot(duvec * _composed[i]._x), vvec.dot(duvec * _composed[i]._y), vvec.dot(duvec * _composed[i]._z)); - LVector3f vtan(dvvec.dot(uvec * _composed[i]._x), + LVector3 vtan(dvvec.dot(uvec * _composed[i]._x), dvvec.dot(uvec * _composed[i]._y), dvvec.dot(uvec * _composed[i]._z)); @@ -169,29 +169,29 @@ eval_segment_normal(int ui, int vi, float u, float v, LVecBase3f &normal) const // to the extended vertices associated with the surface in // the indicated dimension. //////////////////////////////////////////////////////////////////// -float NurbsSurfaceResult:: -eval_segment_extended_point(int ui, int vi, float u, float v, int d) const { +PN_stdfloat NurbsSurfaceResult:: +eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) const { int i = segi(ui, vi); nassertr(i >= 0 && i < (int)_composed.size(), 0.0f); - float u2 = u*u; - LVecBase4f uvec(u*u2, u2, u, 1.0f); - float v2 = v*v; - LVecBase4f vvec(v*v2, v2, v, 1.0f); + PN_stdfloat u2 = u*u; + LVecBase4 uvec(u*u2, u2, u, 1.0f); + PN_stdfloat v2 = v*v; + LVecBase4 vvec(v*v2, v2, v, 1.0f); - float weight = vvec.dot(uvec * _composed[i]._w); + PN_stdfloat weight = vvec.dot(uvec * _composed[i]._w); // Calculate the composition of the basis matrices and the geometry // matrix on-the-fly. - const LMatrix4f &v_basis_transpose = _v_basis.get_basis(vi); - const LMatrix4f &u_basis_mat = _u_basis.get_basis(ui); + const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); + const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); int u_order = _u_basis.get_order(); int v_order = _v_basis.get_order(); int un = _u_basis.get_vertex_index(ui); int vn = _v_basis.get_vertex_index(vi); - LMatrix4f geom; + LMatrix4 geom; memset(&geom, 0, sizeof(geom)); for (int uni = 0; uni < 4; uni++) { @@ -202,7 +202,7 @@ eval_segment_extended_point(int ui, int vi, float u, float v, int d) const { } } - LMatrix4f composed = u_basis_mat * geom * v_basis_transpose; + LMatrix4 composed = u_basis_mat * geom * v_basis_transpose; return vvec.dot(uvec * composed) / weight; } @@ -216,22 +216,22 @@ eval_segment_extended_point(int ui, int vi, float u, float v, int d) const { // the indicated result array. //////////////////////////////////////////////////////////////////// void NurbsSurfaceResult:: -eval_segment_extended_points(int ui, int vi, float u, float v, int d, - float result[], int num_values) const { +eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d, + PN_stdfloat result[], int num_values) const { int i = segi(ui, vi); nassertv(i >= 0 && i < (int)_composed.size()); - float u2 = u*u; - LVecBase4f uvec(u*u2, u2, u, 1.0f); - float v2 = v*v; - LVecBase4f vvec(v*v2, v2, v, 1.0f); + PN_stdfloat u2 = u*u; + LVecBase4 uvec(u*u2, u2, u, 1.0f); + PN_stdfloat v2 = v*v; + LVecBase4 vvec(v*v2, v2, v, 1.0f); - float weight = vvec.dot(uvec * _composed[i]._w); + PN_stdfloat weight = vvec.dot(uvec * _composed[i]._w); // Calculate the composition of the basis matrices and the geometry // matrix on-the-fly. - const LMatrix4f &v_basis_transpose = _v_basis.get_basis(vi); - const LMatrix4f &u_basis_mat = _u_basis.get_basis(ui); + const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); + const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); int u_order = _u_basis.get_order(); int v_order = _v_basis.get_order(); @@ -239,7 +239,7 @@ eval_segment_extended_points(int ui, int vi, float u, float v, int d, int vn = _v_basis.get_vertex_index(vi); for (int n = 0; n < num_values; n++) { - LMatrix4f geom; + LMatrix4 geom; memset(&geom, 0, sizeof(geom)); for (int uni = 0; uni < 4; uni++) { @@ -251,7 +251,7 @@ eval_segment_extended_points(int ui, int vi, float u, float v, int d, } } - LMatrix4f composed = u_basis_mat * geom * v_basis_transpose; + LMatrix4 composed = u_basis_mat * geom * v_basis_transpose; result[n] = vvec.dot(uvec * composed) / weight; } } @@ -264,7 +264,7 @@ eval_segment_extended_points(int ui, int vi, float u, float v, int d, // this value. //////////////////////////////////////////////////////////////////// int NurbsSurfaceResult:: -find_u_segment(float u) { +find_u_segment(PN_stdfloat u) { // Trivially check the endpoints of the surface. if (u >= get_end_u()) { return _u_basis.get_num_segments() - 1; @@ -297,7 +297,7 @@ find_u_segment(float u) { // increasing order of t, and they don't overlap. //////////////////////////////////////////////////////////////////// int NurbsSurfaceResult:: -r_find_u_segment(float u, int top, int bot) const { +r_find_u_segment(PN_stdfloat u, int top, int bot) const { if (bot < top) { // Not found. return -1; @@ -305,8 +305,8 @@ r_find_u_segment(float u, int top, int bot) const { int mid = (top + bot) / 2; nassertr(mid >= 0 && mid < _u_basis.get_num_segments(), -1); - float from = _u_basis.get_from(mid); - float to = _u_basis.get_to(mid); + PN_stdfloat from = _u_basis.get_from(mid); + PN_stdfloat to = _u_basis.get_to(mid); if (from > u) { // Too high, try lower. return r_find_u_segment(u, top, mid - 1); @@ -330,7 +330,7 @@ r_find_u_segment(float u, int top, int bot) const { // this value. //////////////////////////////////////////////////////////////////// int NurbsSurfaceResult:: -find_v_segment(float v) { +find_v_segment(PN_stdfloat v) { // Trivially check the endpoints of the surface. if (v >= get_end_v()) { return _v_basis.get_num_segments() - 1; @@ -363,7 +363,7 @@ find_v_segment(float v) { // increasing order of t, and they don't overlap. //////////////////////////////////////////////////////////////////// int NurbsSurfaceResult:: -r_find_v_segment(float v, int top, int bot) const { +r_find_v_segment(PN_stdfloat v, int top, int bot) const { if (bot < top) { // Not found. return -1; @@ -371,8 +371,8 @@ r_find_v_segment(float v, int top, int bot) const { int mid = (top + bot) / 2; nassertr(mid >= 0 && mid < _v_basis.get_num_segments(), -1); - float from = _v_basis.get_from(mid); - float to = _v_basis.get_to(mid); + PN_stdfloat from = _v_basis.get_from(mid); + PN_stdfloat to = _v_basis.get_to(mid); if (from > v) { // Too high, try lower. return r_find_v_segment(v, top, mid - 1); diff --git a/panda/src/parametrics/nurbsSurfaceResult.h b/panda/src/parametrics/nurbsSurfaceResult.h index 0fcfa5cbc9..7c421c92d4 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.h +++ b/panda/src/parametrics/nurbsSurfaceResult.h @@ -32,42 +32,42 @@ class EXPCL_PANDA_PARAMETRICS NurbsSurfaceResult : public ReferenceCount { public: NurbsSurfaceResult(const NurbsBasisVector &u_basis, const NurbsBasisVector &v_basis, - const LVecBase4f vecs[], const NurbsVertex *verts, + const LVecBase4 vecs[], const NurbsVertex *verts, int num_u_vertices, int num_v_vertices); PUBLISHED: INLINE ~NurbsSurfaceResult(); - INLINE float get_start_u() const; - INLINE float get_end_u() const; + INLINE PN_stdfloat get_start_u() const; + INLINE PN_stdfloat get_end_u() const; - INLINE float get_start_v() const; - INLINE float get_end_v() const; + INLINE PN_stdfloat get_start_v() const; + INLINE PN_stdfloat get_end_v() const; - INLINE bool eval_point(float u, float v, LVecBase3f &point); - INLINE bool eval_normal(float u, float v, LVecBase3f &normal); - INLINE float eval_extended_point(float u, float v, int d); - INLINE bool eval_extended_points(float u, float v, int d, - float result[], int num_values); + INLINE bool eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point); + INLINE bool eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal); + INLINE PN_stdfloat eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d); + INLINE bool eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d, + PN_stdfloat result[], int num_values); INLINE int get_num_u_segments() const; INLINE int get_num_v_segments() const; - void eval_segment_point(int ui, int vi, float u, float v, LVecBase3f &point) const; - void eval_segment_normal(int ui, int vi, float u, float v, LVecBase3f &normal) const; - float eval_segment_extended_point(int ui, int vi, float u, float v, int d) const; - void eval_segment_extended_points(int ui, int vi, float u, float v, int d, - float result[], int num_values) const; - INLINE float get_segment_u(int ui, float u) const; - INLINE float get_segment_v(int vi, float v) const; + void eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const; + void eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const; + PN_stdfloat eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) const; + void eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d, + PN_stdfloat result[], int num_values) const; + INLINE PN_stdfloat get_segment_u(int ui, PN_stdfloat u) const; + INLINE PN_stdfloat get_segment_v(int vi, PN_stdfloat v) const; private: INLINE int verti(int ui, int vi) const; INLINE int segi(int ui, int vi) const; - int find_u_segment(float u); - int r_find_u_segment(float u, int top, int bot) const; - int find_v_segment(float v); - int r_find_v_segment(float v, int top, int bot) const; + int find_u_segment(PN_stdfloat u); + int r_find_u_segment(PN_stdfloat u, int top, int bot) const; + int find_v_segment(PN_stdfloat v); + int r_find_v_segment(PN_stdfloat v, int top, int bot) const; NurbsBasisVector _u_basis; NurbsBasisVector _v_basis; @@ -81,18 +81,18 @@ private: // v_basis._segments. class ComposedMats { public: - LMatrix4f _x, _y, _z, _w; + LMatrix4 _x, _y, _z, _w; }; typedef pvector ComposedGeom; ComposedGeom _composed; int _last_u_segment; - float _last_u_from; - float _last_u_to; + PN_stdfloat _last_u_from; + PN_stdfloat _last_u_to; int _last_v_segment; - float _last_v_from; - float _last_v_to; + PN_stdfloat _last_v_from; + PN_stdfloat _last_v_to; }; #include "nurbsSurfaceResult.I" diff --git a/panda/src/parametrics/nurbsVertex.I b/panda/src/parametrics/nurbsVertex.I index 18f2b20135..8370cf20f3 100644 --- a/panda/src/parametrics/nurbsVertex.I +++ b/panda/src/parametrics/nurbsVertex.I @@ -62,7 +62,7 @@ INLINE NurbsVertex:: // Description: //////////////////////////////////////////////////////////////////// INLINE void NurbsVertex:: -set_vertex(const LVecBase4f &vertex) { +set_vertex(const LVecBase4 &vertex) { _vertex = vertex; } @@ -71,7 +71,7 @@ set_vertex(const LVecBase4f &vertex) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &NurbsVertex:: +INLINE const LVecBase4 &NurbsVertex:: get_vertex() const { return _vertex; } diff --git a/panda/src/parametrics/nurbsVertex.cxx b/panda/src/parametrics/nurbsVertex.cxx index 425282ec09..68483cc952 100644 --- a/panda/src/parametrics/nurbsVertex.cxx +++ b/panda/src/parametrics/nurbsVertex.cxx @@ -38,19 +38,19 @@ // extended vertices can be set. //////////////////////////////////////////////////////////////////// void NurbsVertex:: -set_extended_vertex(int d, float value) { +set_extended_vertex(int d, PN_stdfloat value) { _extended[d] = value * _vertex[3]; } //////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::float_extended_vertex +// Function: NurbsVertex::get_extended_vertex // Access: Public // Description: Returns an n-dimensional vertex value. See // set_extended_vertex(). This returns the value set // for the indicated dimension, or 0.0 if nothing has // been set. //////////////////////////////////////////////////////////////////// -float NurbsVertex:: +PN_stdfloat NurbsVertex:: get_extended_vertex(int d) const { Extended::const_iterator ei; ei = _extended.find(d); diff --git a/panda/src/parametrics/nurbsVertex.h b/panda/src/parametrics/nurbsVertex.h index 539cab150a..10948022c4 100644 --- a/panda/src/parametrics/nurbsVertex.h +++ b/panda/src/parametrics/nurbsVertex.h @@ -40,21 +40,21 @@ public: INLINE void operator = (const NurbsVertex ©); INLINE ~NurbsVertex(); - INLINE void set_vertex(const LVecBase4f &vertex); - INLINE const LVecBase4f &get_vertex() const; + INLINE void set_vertex(const LVecBase4 &vertex); + INLINE const LVecBase4 &get_vertex() const; INLINE void set_space(const NodePath &space); INLINE void set_space(const string &space); INLINE NodePath get_space(const NodePath &rel_to) const; - void set_extended_vertex(int d, float value); - float get_extended_vertex(int d) const; + void set_extended_vertex(int d, PN_stdfloat value); + PN_stdfloat get_extended_vertex(int d) const; private: - LVecBase4f _vertex; + LVecBase4 _vertex; NodePath _space; string _space_path; - typedef pmap Extended; + typedef pmap Extended; Extended _extended; }; diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 258b90e2b5..149bd11c08 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -23,7 +23,7 @@ #include "bamReader.h" #include "omniBoundingVolume.h" -static const float tolerance_divisor = 100000.0f; +static const PN_stdfloat tolerance_divisor = 100000.0f; TypeHandle ParametricCurve::_type_handle; @@ -103,7 +103,7 @@ is_valid() const { // 1.0f; derived classes might override this to return // something else. //////////////////////////////////////////////////////////////////// -float ParametricCurve:: +PN_stdfloat ParametricCurve:: get_max_t() const { return 1.0f; } @@ -190,7 +190,7 @@ get_num_dimensions() const { // Description: Approximates the length of the entire curve to within // a few decimal places. //////////////////////////////////////////////////////////////////// -float ParametricCurve:: +PN_stdfloat ParametricCurve:: calc_length() const { return calc_length(0.0f, get_max_t()); } @@ -201,17 +201,17 @@ calc_length() const { // Description: Approximates the length of the curve segment from // parametric time 'from' to time 'to'. //////////////////////////////////////////////////////////////////// -float ParametricCurve:: -calc_length(float from, float to) const { - float t1, t2; - LPoint3f p1, p2; +PN_stdfloat ParametricCurve:: +calc_length(PN_stdfloat from, PN_stdfloat to) const { + PN_stdfloat t1, t2; + LPoint3 p1, p2; // Normally we expect from < to. If they came in backwards, reverse // them. - float to_minus_from = to - from; + PN_stdfloat to_minus_from = to - from; if (to_minus_from < 0.0f) { - float temp = to; + PN_stdfloat temp = to; to = from; from = temp; to_minus_from=-to_minus_from; @@ -221,13 +221,13 @@ calc_length(float from, float to) const { int num_segs = (int)(to_minus_from) + 1; t2 = from; get_point(t2, p2); - float net = 0.0f; + PN_stdfloat net = 0.0f; for (int i = 1; i <= num_segs; i++) { t1 = t2; p1 = p2; - t2 = (to - from) * (float)i / (float)num_segs + from; + t2 = (to - from) * (PN_stdfloat)i / (PN_stdfloat)num_segs + from; get_point(t2, p2); net += r_calc_length(t1, t2, p1, p2, (p1 - p2).length()); @@ -249,20 +249,20 @@ calc_length(float from, float to) const { // // The search distance must not be negative. //////////////////////////////////////////////////////////////////// -float ParametricCurve:: -find_length(float start_t, float length_offset) const { +PN_stdfloat ParametricCurve:: +find_length(PN_stdfloat start_t, PN_stdfloat length_offset) const { nassertr(length_offset >= 0.0f, start_t); nassertr(start_t >= 0.0f && start_t <= get_max_t(), start_t); - float t1, t2; - LPoint3f p1, p2; + PN_stdfloat t1, t2; + LPoint3 p1, p2; // Start with a segment for each unit of t. - float max_t = get_max_t(); + PN_stdfloat max_t = get_max_t(); int num_segs = (int)cfloor(max_t - start_t + 1); t2 = start_t; get_point(t2, p2); - float net = 0.0f; + PN_stdfloat net = 0.0f; for (int i = 1; i <= num_segs; i++) { assert(net <= length_offset); @@ -270,11 +270,11 @@ find_length(float start_t, float length_offset) const { t1 = t2; p1 = p2; - t2 = start_t + (((max_t - start_t) * (float)i) / (float)num_segs); + t2 = start_t + (((max_t - start_t) * (PN_stdfloat)i) / (PN_stdfloat)num_segs); get_point(t2, p2); - float seglength = (p1 - p2).length(); - float result; + PN_stdfloat seglength = (p1 - p2).length(); + PN_stdfloat result; if (r_find_length(length_offset - net, result, t1, t2, p1, p2, seglength)) { @@ -297,7 +297,7 @@ find_length(float start_t, float length_offset) const { // tangent value at that point. //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -adjust_point(float, float, float, float) { +adjust_point(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } @@ -309,7 +309,7 @@ adjust_point(float, float, float, float) { // at the point. //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -adjust_tangent(float, float, float, float) { +adjust_tangent(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } @@ -320,7 +320,7 @@ adjust_tangent(float, float, float, float) { // point (px, py, pz) with the tangent (tx, ty, tz). //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -adjust_pt(float, float, float, float, float, float, float) { +adjust_pt(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } @@ -515,8 +515,8 @@ convert_to_hermite(HermiteCurve *hc) const { int i, n; if (!bz_segs.empty()) { - float scale_in = 0.0f; - float scale_out = bz_segs[0]._t; + PN_stdfloat scale_in = 0.0f; + PN_stdfloat scale_out = bz_segs[0]._t; n = hc->append_cv(HC_SMOOTH, bz_segs[0]._v[0]); hc->set_cv_out(n, 3.0f * (bz_segs[0]._v[1] - bz_segs[0]._v[0]) / scale_out); @@ -548,8 +548,8 @@ convert_to_hermite(HermiteCurve *hc) const { int num_cvs = hc->get_num_cvs(); for (n = 1; n < num_cvs-1; n++) { if (hc->get_cv_type(n)!=HC_CUT) { - LVector3f in = hc->get_cv_in(n); - LVector3f out = hc->get_cv_out(n); + LVector3 in = hc->get_cv_in(n); + LVector3 out = hc->get_cv_out(n); if (in.almost_equal(out, 0.0001f)) { hc->set_cv_type(n, HC_SMOOTH); @@ -598,7 +598,7 @@ convert_to_nurbs(ParametricCurve *nc) const { } } - float t; + PN_stdfloat t; int ki = 4; nurbs->set_knot(0, 0.0f); nurbs->set_knot(1, 0.0f); @@ -664,7 +664,7 @@ unregister_drawer(ParametricCurveDrawer *drawer) { // recomputed in some way. //////////////////////////////////////////////////////////////////// void ParametricCurve:: -invalidate(float, float) { +invalidate(PN_stdfloat, PN_stdfloat) { invalidate_all(); } @@ -709,11 +709,11 @@ format_egg(ostream &, const string &, const string &, int) const { // evaluate to the endpoints p1 and p2, and the segment // has the length seglength. //////////////////////////////////////////////////////////////////// -float ParametricCurve:: -r_calc_length(float t1, float t2, const LPoint3f &p1, const LPoint3f &p2, - float seglength) const { - static const float length_tolerance = 0.0000001f; - static const float t_tolerance = 0.000001f; +PN_stdfloat ParametricCurve:: +r_calc_length(PN_stdfloat t1, PN_stdfloat t2, const LPoint3 &p1, const LPoint3 &p2, + PN_stdfloat seglength) const { + static const PN_stdfloat length_tolerance = 0.0000001f; + static const PN_stdfloat t_tolerance = 0.000001f; if (t2 - t1 < t_tolerance) { // Stop recursing--we've just walked off the limit for @@ -721,9 +721,9 @@ r_calc_length(float t1, float t2, const LPoint3f &p1, const LPoint3f &p2, return 0.0f; } - float tmid; - LPoint3f pmid; - float left, right; + PN_stdfloat tmid; + LPoint3 pmid; + PN_stdfloat left, right; // Calculate the point on the curve midway between the two // endpoints. @@ -757,12 +757,12 @@ r_calc_length(float t1, float t2, const LPoint3f &p1, const LPoint3f &p2, // segment and returns false. //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -r_find_length(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2, - float &seglength) const { - static const float length_tolerance = 0.0000001f; - static const float t_tolerance = 0.000001f; +r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2, + PN_stdfloat &seglength) const { + static const PN_stdfloat length_tolerance = 0.0000001f; + static const PN_stdfloat t_tolerance = 0.000001f; if (target_length < t_tolerance) { // Stop recursing--we've just walked off the limit for @@ -772,9 +772,9 @@ r_find_length(float target_length, float &found_t, } - float tmid; - LPoint3f pmid; - float left, right; + PN_stdfloat tmid; + LPoint3 pmid; + PN_stdfloat left, right; // Calculate the point on the curve midway between the two // endpoints. @@ -835,11 +835,11 @@ r_find_length(float target_length, float &found_t, // found_t to the point along the segment. //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -r_find_t(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2) const { - static const float length_tolerance = 0.0001f; - static const float t_tolerance = 0.0001f; +r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2) const { + static const PN_stdfloat length_tolerance = 0.0001f; + static const PN_stdfloat t_tolerance = 0.0001f; if (parametrics_cat.is_spam()) { parametrics_cat.spam() @@ -853,7 +853,7 @@ r_find_t(float target_length, float &found_t, } // No, compute distance between two endpoints - float point_dist; + PN_stdfloat point_dist; point_dist = (p2 - p1).length(); // Is the target point past the far endpoint? @@ -874,9 +874,9 @@ r_find_t(float target_length, float &found_t, } // No, subdivide and continue - float tmid; - LPoint3f pmid; - float left; + PN_stdfloat tmid; + LPoint3 pmid; + PN_stdfloat left; // Calculate the point on the curve midway between the two // endpoints. @@ -904,11 +904,11 @@ r_find_t(float target_length, float &found_t, // Description: non-recursive version of r_find_t (see above) //////////////////////////////////////////////////////////////////// bool ParametricCurve:: -find_t_linear(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2) const { - const float length_tolerance = (p1-p2).length()/tolerance_divisor; - const float t_tolerance = (t1+t2)/tolerance_divisor; +find_t_linear(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2) const { + const PN_stdfloat length_tolerance = (p1-p2).length()/tolerance_divisor; + const PN_stdfloat t_tolerance = (t1+t2)/tolerance_divisor; if (parametrics_cat.is_spam()) { parametrics_cat.spam() @@ -922,11 +922,11 @@ find_t_linear(float target_length, float &found_t, return false; } - float tleft = t1; - float tright = t2; - float tmid; - LPoint3f pmid; - float len; + PN_stdfloat tleft = t1; + PN_stdfloat tright = t2; + PN_stdfloat tmid; + LPoint3 pmid; + PN_stdfloat len; while (1) { tmid = (tleft + tright) * 0.5f; diff --git a/panda/src/parametrics/parametricCurve.h b/panda/src/parametrics/parametricCurve.h index 420d8e8a1b..a90e79780c 100644 --- a/panda/src/parametrics/parametricCurve.h +++ b/panda/src/parametrics/parametricCurve.h @@ -69,7 +69,7 @@ public: PUBLISHED: virtual bool is_valid() const; - virtual float get_max_t() const; + virtual PN_stdfloat get_max_t() const; void set_curve_type(int type); int get_curve_type() const; @@ -77,20 +77,20 @@ PUBLISHED: void set_num_dimensions(int num); int get_num_dimensions() const; - float calc_length() const; - float calc_length(float from, float to) const; - float find_length(float start_t, float length_offset) const; + PN_stdfloat calc_length() const; + PN_stdfloat calc_length(PN_stdfloat from, PN_stdfloat to) const; + PN_stdfloat find_length(PN_stdfloat start_t, PN_stdfloat length_offset) const; - virtual bool get_point(float t, LVecBase3f &point) const=0; - virtual bool get_tangent(float t, LVecBase3f &tangent) const=0; - virtual bool get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const=0; - virtual bool get_2ndtangent(float t, LVecBase3f &tangent2) const=0; + virtual bool get_point(PN_stdfloat t, LVecBase3 &point) const=0; + virtual bool get_tangent(PN_stdfloat t, LVecBase3 &tangent) const=0; + virtual bool get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const=0; + virtual bool get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const=0; - virtual bool adjust_point(float t, float px, float py, float pz); - virtual bool adjust_tangent(float t, float tx, float ty, float tz); - virtual bool adjust_pt(float t, - float px, float py, float pz, - float tx, float ty, float tz); + virtual bool adjust_point(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz); + virtual bool adjust_tangent(PN_stdfloat t, PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz); + virtual bool adjust_pt(PN_stdfloat t, + PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz); virtual bool recompute(); @@ -102,8 +102,8 @@ PUBLISHED: public: struct BezierSeg { public: - LVecBase3f _v[4]; - float _t; + LVecBase3 _v[4]; + PN_stdfloat _t; }; typedef pvector BezierSegs; @@ -118,26 +118,26 @@ public: void unregister_drawer(ParametricCurveDrawer *drawer); protected: - void invalidate(float t1, float t2); + void invalidate(PN_stdfloat t1, PN_stdfloat t2); void invalidate_all(); virtual bool format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const; private: - float r_calc_length(float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2, - float seglength) const; - bool r_find_length(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2, - float &seglength) const; - bool r_find_t(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2) const; - bool find_t_linear(float target_length, float &found_t, - float t1, float t2, - const LPoint3f &p1, const LPoint3f &p2) const; + PN_stdfloat r_calc_length(PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2, + PN_stdfloat seglength) const; + bool r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2, + PN_stdfloat &seglength) const; + bool r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2) const; + bool find_t_linear(PN_stdfloat target_length, PN_stdfloat &found_t, + PN_stdfloat t1, PN_stdfloat t2, + const LPoint3 &p1, const LPoint3 &p2) const; protected: int _curve_type; diff --git a/panda/src/parametrics/parametricCurveCollection.I b/panda/src/parametrics/parametricCurveCollection.I index d524c32c0e..fed97ba83f 100644 --- a/panda/src/parametrics/parametricCurveCollection.I +++ b/panda/src/parametrics/parametricCurveCollection.I @@ -51,7 +51,7 @@ get_curve(int index) const { // *last* curve in the collection. Normally, this will // be either the XYZ or HPR curve, or a timewarp curve. //////////////////////////////////////////////////////////////////// -INLINE float ParametricCurveCollection:: +INLINE PN_stdfloat ParametricCurveCollection:: get_max_t() const { if (_curves.empty()) { return 0.0f; @@ -66,8 +66,8 @@ get_max_t() const { // evaluate(). //////////////////////////////////////////////////////////////////// INLINE bool ParametricCurveCollection:: -evaluate_xyz(float t, LVecBase3f &xyz) const { - LVecBase3f hpr; +evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const { + LVecBase3 hpr; return evaluate(t, xyz, hpr); } @@ -78,8 +78,8 @@ evaluate_xyz(float t, LVecBase3f &xyz) const { // evaluate(). //////////////////////////////////////////////////////////////////// INLINE bool ParametricCurveCollection:: -evaluate_hpr(float t, LVecBase3f &hpr) const { - LVecBase3f xyz; +evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const { + LVecBase3 xyz; return evaluate(t, xyz, hpr); } @@ -92,8 +92,8 @@ evaluate_hpr(float t, LVecBase3f &hpr) const { // the adjustment for some reason. //////////////////////////////////////////////////////////////////// INLINE bool ParametricCurveCollection:: -adjust_xyz(float t, float x, float y, float z) { - return adjust_xyz(t, LVecBase3f(x, y, z)); +adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + return adjust_xyz(t, LVecBase3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -105,6 +105,6 @@ adjust_xyz(float t, float x, float y, float z) { // the adjustment for some reason. //////////////////////////////////////////////////////////////////// INLINE bool ParametricCurveCollection:: -adjust_hpr(float t, float h, float p, float r) { - return adjust_hpr(t, LVecBase3f(h, p, r)); +adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + return adjust_hpr(t, LVecBase3(h, p, r)); } diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 0ed6ade549..00701b2fb6 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -317,7 +317,7 @@ get_timewarp_curve(int n) const { // of the collection) will range from 0 to max_t. //////////////////////////////////////////////////////////////////// void ParametricCurveCollection:: -make_even(float max_t, float segments_per_unit) { +make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); if (xyz_curve == (ParametricCurve *)NULL) { parametrics_cat.error() @@ -338,8 +338,8 @@ make_even(float max_t, float segments_per_unit) { << "Calculating length of curve.\n"; } - float net_length = xyz_curve->calc_length(); - float segment_length = net_length / (float)num_segments; + PN_stdfloat net_length = xyz_curve->calc_length(); + PN_stdfloat segment_length = net_length / (PN_stdfloat)num_segments; if (parametrics_cat.is_debug()) { parametrics_cat.debug() @@ -347,15 +347,15 @@ make_even(float max_t, float segments_per_unit) { << num_segments << " segments of " << segment_length << " units each.\n"; } - float last_t = 0.0f; - fitter.add_xyz(0.0f, LVecBase3f(last_t, 0.0f, 0.0f)); - float val_inc= max_t/num_segments; - float val=val_inc; + PN_stdfloat last_t = 0.0f; + fitter.add_xyz(0.0f, LVecBase3(last_t, 0.0f, 0.0f)); + PN_stdfloat val_inc= max_t/num_segments; + PN_stdfloat val=val_inc; for (int i = 0; i < num_segments; i++,val+=val_inc) { - float next_t = xyz_curve->find_length(last_t, segment_length); - fitter.add_xyz(/*(float)(i + 1)/num_segments * max_t,*/ - val, LVecBase3f(next_t, 0.0f, 0.0f)); + PN_stdfloat next_t = xyz_curve->find_length(last_t, segment_length); + fitter.add_xyz(/*(PN_stdfloat)(i + 1)/num_segments * max_t,*/ + val, LVecBase3(next_t, 0.0f, 0.0f)); if (parametrics_cat.is_spam()) { parametrics_cat.spam() @@ -387,7 +387,7 @@ make_even(float max_t, float segments_per_unit) { // point. //////////////////////////////////////////////////////////////////// void ParametricCurveCollection:: -face_forward(float segments_per_unit) { +face_forward(PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); if (xyz_curve == (ParametricCurve *)NULL) { parametrics_cat.error() @@ -418,10 +418,10 @@ face_forward(float segments_per_unit) { // length in parametric time (based on the timewarp curves). CurveFitter fitter; - float max_t = get_max_t(); + PN_stdfloat max_t = get_max_t(); int num_segments = (int)cfloor(segments_per_unit * max_t + 0.5); - LVecBase3f hpr(0.0f, 0.0f, 0.0f); + LVecBase3 hpr(0.0f, 0.0f, 0.0f); // We compute the first HPR point a little point into the beginning // of the curve, instead of at 0.0f, because the tangent at 0.0f is @@ -430,7 +430,7 @@ face_forward(float segments_per_unit) { fitter.add_hpr(0.0f, hpr); for (int i = 0; i < num_segments; i++) { - float t = (float)(i + 1) / num_segments * max_t; + PN_stdfloat t = (PN_stdfloat)(i + 1) / num_segments * max_t; determine_hpr(t, xyz_curve, hpr); fitter.add_hpr(t, hpr); } @@ -453,13 +453,13 @@ face_forward(float segments_per_unit) { // get_max_t() will return the given max_t value. //////////////////////////////////////////////////////////////////// void ParametricCurveCollection:: -reset_max_t(float max_t) { +reset_max_t(PN_stdfloat max_t) { // Define a linear NURBS curve. PT(NurbsCurve) nurbs = new NurbsCurve; nurbs->set_curve_type(PCT_T); nurbs->set_order(2); - nurbs->append_cv(LVecBase3f(0.0f, 0.0f, 0.0f)); - nurbs->append_cv(LVecBase3f(get_max_t(), 0.0f, 0.0f)); + nurbs->append_cv(LVecBase3(0.0f, 0.0f, 0.0f)); + nurbs->append_cv(LVecBase3(get_max_t(), 0.0f, 0.0f)); nurbs->set_knot(0, 0.0f); nurbs->set_knot(1, 0.0f); nurbs->set_knot(2, max_t); @@ -483,15 +483,15 @@ reset_max_t(float max_t) { // otherwise. //////////////////////////////////////////////////////////////////// bool ParametricCurveCollection:: -evaluate(float t, LVecBase3f &xyz, LVecBase3f &hpr) const { +evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { // First, apply all the timewarps in sequence, from back to front. // Also take note of the XYZ and HPR curves. ParametricCurve *xyz_curve = (ParametricCurve *)NULL; ParametricCurve *hpr_curve = (ParametricCurve *)NULL; ParametricCurve *default_curve = (ParametricCurve *)NULL; - float t0 = t; - LVecBase3f point; + PN_stdfloat t0 = t; + LVecBase3 point; ParametricCurves::const_reverse_iterator ci; for (ci = _curves.rbegin(); ci != _curves.rend(); ++ci) { @@ -555,17 +555,17 @@ evaluate(float t, LVecBase3f &xyz, LVecBase3f &hpr) const { // otherwise. //////////////////////////////////////////////////////////////////// bool ParametricCurveCollection:: -evaluate(float t, LMatrix4f &result, CoordinateSystem cs) const { - LVecBase3f xyz(0.0f, 0.0f, 0.0f); - LVecBase3f hpr(0.0f, 0.0f, 0.0f); +evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs) const { + LVecBase3 xyz(0.0f, 0.0f, 0.0f); + LVecBase3 hpr(0.0f, 0.0f, 0.0f); if (!evaluate(t, xyz, hpr)) { return false; } compose_matrix(result, - LVecBase3f(1.0f, 1.0f, 1.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), + LVecBase3(1.0f, 1.0f, 1.0f), + LVecBase3(0.0f, 0.0f, 0.0f), hpr, xyz, cs); return true; } @@ -578,10 +578,10 @@ evaluate(float t, LMatrix4f &result, CoordinateSystem cs) const { // value of t to all the timewarps. Return -1.0f if the // value of t exceeds one of the timewarps' ranges. //////////////////////////////////////////////////////////////////// -float ParametricCurveCollection:: -evaluate_t(float t) const { - float t0 = t; - LVecBase3f point; +PN_stdfloat ParametricCurveCollection:: +evaluate_t(PN_stdfloat t) const { + PN_stdfloat t0 = t; + LVecBase3 point; ParametricCurves::const_iterator ci; for (ci = _curves.begin(); ci != _curves.end(); ++ci) { @@ -607,13 +607,13 @@ evaluate_t(float t) const { // the adjustment for some reason. //////////////////////////////////////////////////////////////////// bool ParametricCurveCollection:: -adjust_xyz(float t, const LVecBase3f &xyz) { +adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { ParametricCurve *xyz_curve = get_xyz_curve(); if (xyz_curve == (ParametricCurve *)NULL) { return false; } - float t0 = evaluate_t(t); + PN_stdfloat t0 = evaluate_t(t); if (t0 >= 0.0f && t < xyz_curve->get_max_t()) { return xyz_curve->adjust_point(t, xyz[0], xyz[1], xyz[2]); } @@ -629,13 +629,13 @@ adjust_xyz(float t, const LVecBase3f &xyz) { // the adjustment for some reason. //////////////////////////////////////////////////////////////////// bool ParametricCurveCollection:: -adjust_hpr(float t, const LVecBase3f &hpr) { +adjust_hpr(PN_stdfloat t, const LVecBase3 &hpr) { ParametricCurve *hpr_curve = get_hpr_curve(); if (hpr_curve == (ParametricCurve *)NULL) { return false; } - float t0 = evaluate_t(t); + PN_stdfloat t0 = evaluate_t(t); if (t0 >= 0.0f && t < hpr_curve->get_max_t()) { return hpr_curve->adjust_point(t, hpr[0], hpr[1], hpr[2]); } @@ -918,10 +918,10 @@ unregister_drawer(ParametricCurveDrawer *drawer) { // cannot (in which case hpr is left unchanged). //////////////////////////////////////////////////////////////////// bool ParametricCurveCollection:: -determine_hpr(float t, ParametricCurve *xyz_curve, LVecBase3f &hpr) const { - float t0 = evaluate_t(t); +determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const { + PN_stdfloat t0 = evaluate_t(t); - LVector3f tangent; + LVector3 tangent; if (!xyz_curve->get_tangent(t0, tangent)) { return false; } @@ -930,10 +930,10 @@ determine_hpr(float t, ParametricCurve *xyz_curve, LVecBase3f &hpr) const { return false; } - LMatrix3f mat; + LMatrix3 mat; look_at(mat, tangent); - LVecBase3f scale, shear; + LVecBase3 scale, shear; return decompose_matrix(mat, scale, shear, hpr); } diff --git a/panda/src/parametrics/parametricCurveCollection.h b/panda/src/parametrics/parametricCurveCollection.h index b8612d5054..01d505234b 100644 --- a/panda/src/parametrics/parametricCurveCollection.h +++ b/panda/src/parametrics/parametricCurveCollection.h @@ -63,23 +63,23 @@ PUBLISHED: ParametricCurve *get_timewarp_curve(int n) const; MAKE_SEQ(get_timewarp_curves, get_num_timewarps, get_timewarp_curve); - INLINE float get_max_t() const; + INLINE PN_stdfloat get_max_t() const; - void make_even(float max_t, float segments_per_unit); - void face_forward(float segments_per_unit); - void reset_max_t(float max_t); + void make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit); + void face_forward(PN_stdfloat segments_per_unit); + void reset_max_t(PN_stdfloat max_t); - bool evaluate(float t, LVecBase3f &xyz, LVecBase3f &hpr) const; - bool evaluate(float t, LMatrix4f &result, CoordinateSystem cs = CS_default) const; + bool evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const; + bool evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs = CS_default) const; - float evaluate_t(float t) const; - INLINE bool evaluate_xyz(float t, LVecBase3f &xyz) const; - INLINE bool evaluate_hpr(float t, LVecBase3f &hpr) const; + PN_stdfloat evaluate_t(PN_stdfloat t) const; + INLINE bool evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const; + INLINE bool evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const; - INLINE bool adjust_xyz(float t, float x, float y, float z); - bool adjust_xyz(float t, const LVecBase3f &xyz); - INLINE bool adjust_hpr(float t, float h, float p, float r); - bool adjust_hpr(float t, const LVecBase3f &xyz); + INLINE bool adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + bool adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz); + INLINE bool adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + bool adjust_hpr(PN_stdfloat t, const LVecBase3 &xyz); bool recompute(); @@ -98,7 +98,7 @@ public: void unregister_drawer(ParametricCurveDrawer *drawer); private: - bool determine_hpr(float t, ParametricCurve *xyz_curve, LVecBase3f &hpr) const; + bool determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const; void prepare_add_curve(ParametricCurve *curve); void prepare_remove_curve(ParametricCurve *curve); void redraw(); diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index 89d90feccf..3e412ba8e3 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -63,7 +63,7 @@ is_valid() const { // The curve is defined in the range 0.0f <= t <= // get_max_t(). //////////////////////////////////////////////////////////////////// -float PiecewiseCurve:: +PN_stdfloat PiecewiseCurve:: get_max_t() const { return _segs.empty() ? 0.0f : _segs.back()._tend; } @@ -79,7 +79,7 @@ get_max_t() const { // end (whichever is nearer) and returns false. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -get_point(float t, LVecBase3f &point) const { +get_point(PN_stdfloat t, LVecBase3 &point) const { const ParametricCurve *curve; bool result = find_curve(curve, t); if (curve == NULL){ @@ -97,7 +97,7 @@ get_point(float t, LVecBase3f &point) const { // point t. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -get_tangent(float t, LVecBase3f &tangent) const { +get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { const ParametricCurve *curve; bool result = find_curve(curve, t); @@ -113,7 +113,7 @@ get_tangent(float t, LVecBase3f &tangent) const { // curve at the point t. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -get_2ndtangent(float t, LVecBase3f &tangent2) const { +get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { const ParametricCurve *curve; bool result = find_curve(curve, t); @@ -129,8 +129,8 @@ get_2ndtangent(float t, LVecBase3f &tangent2) const { // tangent value at that point. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -adjust_point(float t, - float px, float py, float pz) { +adjust_point(PN_stdfloat t, + PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz) { if (parametrics_cat.is_debug()) { parametrics_cat.debug() << "Adjusting point at " << t << " to " << px << " " << py << " " @@ -145,10 +145,10 @@ adjust_point(float t, return false; } - rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(), - RT_POINT, t, LVecBase4f(px, py, pz, 1.0f), - RT_TANGENT | RT_KEEP_ORIG, t, LVecBase4f(), - RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f()); + rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4(), + RT_POINT, t, LVecBase4(px, py, pz, 1.0f), + RT_TANGENT | RT_KEEP_ORIG, t, LVecBase4(), + RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4()); return true; } @@ -160,8 +160,8 @@ adjust_point(float t, // at the point. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -adjust_tangent(float t, - float tx, float ty, float tz) { +adjust_tangent(PN_stdfloat t, + PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz) { const ParametricCurve *curve; bool result = find_curve(curve, t); @@ -170,10 +170,10 @@ adjust_tangent(float t, return false; } - rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(), - RT_POINT | RT_KEEP_ORIG, t, LVecBase4f(), - RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0f), - RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f()); + rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4(), + RT_POINT | RT_KEEP_ORIG, t, LVecBase4(), + RT_TANGENT, t, LVecBase4(tx, ty, tz, 0.0f), + RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4()); return true; } @@ -184,9 +184,9 @@ adjust_tangent(float t, // point (px, py, pz) with the tangent (tx, ty, tz). //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -adjust_pt(float t, - float px, float py, float pz, - float tx, float ty, float tz) { +adjust_pt(PN_stdfloat t, + PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, + PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz) { const ParametricCurve *curve; bool result = find_curve(curve, t); @@ -195,10 +195,10 @@ adjust_pt(float t, return false; } - rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(), - RT_POINT, t, LVecBase4f(px, py, pz, 1.0f), - RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0f), - RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f()); + rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4(), + RT_POINT, t, LVecBase4(px, py, pz, 1.0f), + RT_TANGENT, t, LVecBase4(tx, ty, tz, 0.0f), + RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4()); return true; } @@ -210,7 +210,7 @@ adjust_pt(float t, // curve at a given parametric point t. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const { +get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { const ParametricCurve *curve; bool result = find_curve(curve, t); @@ -257,7 +257,7 @@ get_curveseg(int ti) { // not changed. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -insert_curveseg(int ti, ParametricCurve *seg, float tlength) { +insert_curveseg(int ti, ParametricCurve *seg, PN_stdfloat tlength) { if (ti < 0 || ti > (int)_segs.size()) { return false; } @@ -291,7 +291,7 @@ remove_curveseg(int ti) { return false; } - float tlength = get_tlength(ti); + PN_stdfloat tlength = get_tlength(ti); _segs.erase(_segs.begin() + ti); // Now update the _tend figures for everything after the one we @@ -322,7 +322,7 @@ remove_all_curvesegs() { // Description: Returns the parametric length of the given segment of // the curve. //////////////////////////////////////////////////////////////////// -float PiecewiseCurve:: +PN_stdfloat PiecewiseCurve:: get_tlength(int ti) const { assert(ti >= 0 && ti < (int)_segs.size()); return (ti==0) ? _segs[ti]._tend : _segs[ti]._tend - _segs[ti-1]._tend; @@ -334,7 +334,7 @@ get_tlength(int ti) const { // Description: Returns the parametric start of the given segment of // the curve. //////////////////////////////////////////////////////////////////// -float PiecewiseCurve:: +PN_stdfloat PiecewiseCurve:: get_tstart(int ti) const { assert(ti >= 0 && ti <= (int)_segs.size()); return (ti==0) ? 0.0f : _segs[ti-1]._tend; @@ -346,7 +346,7 @@ get_tstart(int ti) const { // Description: Returns the parametric end of the given segment of // the curve. //////////////////////////////////////////////////////////////////// -float PiecewiseCurve:: +PN_stdfloat PiecewiseCurve:: get_tend(int ti) const { assert(ti >= 0 && ti < (int)_segs.size()); return _segs[ti]._tend; @@ -362,7 +362,7 @@ get_tend(int ti) const { // overall length of the curve the same. //////////////////////////////////////////////////////////////////// bool PiecewiseCurve:: -set_tlength(int ti, float tlength) { +set_tlength(int ti, PN_stdfloat tlength) { if (ti < 0 || ti >= (int)_segs.size()) { return false; } @@ -389,7 +389,7 @@ set_tlength(int ti, float tlength) { //////////////////////////////////////////////////////////////////// void PiecewiseCurve:: make_nurbs(int order, int num_cvs, - const float knots[], const LVecBase4f cvs[]) { + const PN_stdfloat knots[], const LVecBase4 cvs[]) { remove_all_curvesegs(); for (int i=0; i _segs; diff --git a/panda/src/parametrics/ropeNode.I b/panda/src/parametrics/ropeNode.I index 57b35f204d..3b0a97b309 100644 --- a/panda/src/parametrics/ropeNode.I +++ b/panda/src/parametrics/ropeNode.I @@ -26,8 +26,8 @@ CData() { _u_dominant = true; _uv_scale = 1.0f; _normal_mode = RopeNode::NM_none; - _tube_up = LVector3f::up(); - _matrix = LMatrix4f::ident_mat(); + _tube_up = LVector3::up(); + _matrix = LMatrix4::ident_mat(); _has_matrix = false; _use_vertex_color = false; _num_subdiv = 10; @@ -166,7 +166,7 @@ get_uv_direction() const { // specified by set_uv_direction(). //////////////////////////////////////////////////////////////////// INLINE void RopeNode:: -set_uv_scale(float uv_scale) { +set_uv_scale(PN_stdfloat uv_scale) { CDWriter cdata(_cycler); cdata->_uv_scale = uv_scale; } @@ -177,7 +177,7 @@ set_uv_scale(float uv_scale) { // Description: Returns the scaling factor to apply to generated UV's // for the rope. //////////////////////////////////////////////////////////////////// -INLINE float RopeNode:: +INLINE PN_stdfloat RopeNode:: get_uv_scale() const { CDReader cdata(_cycler); return cdata->_uv_scale; @@ -223,7 +223,7 @@ get_normal_mode() const { // gimble-lock around its primary axis. //////////////////////////////////////////////////////////////////// INLINE void RopeNode:: -set_tube_up(const LVector3f &tube_up) { +set_tube_up(const LVector3 &tube_up) { CDWriter cdata(_cycler); cdata->_tube_up = tube_up; } @@ -235,7 +235,7 @@ set_tube_up(const LVector3f &tube_up) { // of the curve, when RenderMode is RM_tube. See // set_tube_up(). //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &RopeNode:: +INLINE const LVector3 &RopeNode:: get_tube_up() const { CDReader cdata(_cycler); return cdata->_tube_up; @@ -400,7 +400,7 @@ get_vertex_thickness_dimension() { // basis. See set_use_vertex_thickness(). //////////////////////////////////////////////////////////////////// INLINE void RopeNode:: -set_thickness(float thickness) { +set_thickness(PN_stdfloat thickness) { nassertv(thickness >= 0); CDWriter cdata(_cycler); cdata->_thickness = thickness; @@ -412,7 +412,7 @@ set_thickness(float thickness) { // Description: Returns the thickness of the rope. See // set_thickness(). //////////////////////////////////////////////////////////////////// -INLINE float RopeNode:: +INLINE PN_stdfloat RopeNode:: get_thickness() const { CDReader cdata(_cycler); return cdata->_thickness; @@ -427,7 +427,7 @@ get_thickness() const { // before the polygon vertices are generated. //////////////////////////////////////////////////////////////////// INLINE void RopeNode:: -set_matrix(const LMatrix4f &matrix) { +set_matrix(const LMatrix4 &matrix) { CDWriter cdata(_cycler); cdata->_matrix = matrix; cdata->_has_matrix = true; @@ -442,7 +442,7 @@ set_matrix(const LMatrix4f &matrix) { INLINE void RopeNode:: clear_matrix() { CDWriter cdata(_cycler); - cdata->_matrix = LMatrix4f::ident_mat(); + cdata->_matrix = LMatrix4::ident_mat(); cdata->_has_matrix = false; } @@ -466,7 +466,7 @@ has_matrix() const { // transformed into the RopeNode's coordinate space, but // before the polygon vertices are generated. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &RopeNode:: +INLINE const LMatrix4 &RopeNode:: get_matrix() const { CDReader cdata(_cycler); return cdata->_matrix; diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index c5b71752d3..68a83ca268 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -276,12 +276,12 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, CPT(GeomVertexFormat) RopeNode:: get_format(bool support_normals) const { PT(GeomVertexArrayFormat) array_format = new GeomVertexArrayFormat - (InternalName::get_vertex(), 3, Geom::NT_float32, + (InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point); if (support_normals && get_normal_mode() == NM_vertex) { array_format->add_column - (InternalName::get_normal(), 3, Geom::NT_float32, + (InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_vector); } if (get_use_vertex_color()) { @@ -291,7 +291,7 @@ get_format(bool support_normals) const { } if (get_uv_mode() != UV_none) { array_format->add_column - (InternalName::get_texcoord(), 2, Geom::NT_float32, + (InternalName::get_texcoord(), 2, Geom::NT_stdfloat, Geom::C_texcoord); } @@ -315,13 +315,13 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, NurbsCurveEvaluator *curve = get_curve(); if (curve != (NurbsCurveEvaluator *)NULL) { - pvector verts; + pvector verts; get_curve()->get_vertices(verts, rel_to); if (has_matrix()) { // And then apply the indicated matrix. - const LMatrix4f &mat = get_matrix(); - pvector::iterator vi; + const LMatrix4 &mat = get_matrix(); + pvector::iterator vi; for (vi = verts.begin(); vi != verts.end(); ++vi) { (*vi) = (*vi) * mat; } @@ -458,7 +458,7 @@ render_billboard(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) rel_transform = net_transform->invert_compose(camera_transform); - LVector3f camera_vec = LVector3f::forward() * rel_transform->get_mat(); + LVector3 camera_vec = LVector3::forward() * rel_transform->get_mat(); CurveSegments curve_segments; int num_curve_verts = get_connected_segments(curve_segments, result); @@ -592,10 +592,10 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, bool use_vertex_thickness = get_use_vertex_thickness(); CurveSegment *curve_segment = NULL; - LPoint3f last_point; + LPoint3 last_point; for (int segment = 0; segment < num_segments; ++segment) { - LPoint3f point; + LPoint3 point; result->eval_segment_point(segment, 0.0f, point); if (curve_segment == (CurveSegment *)NULL || @@ -626,7 +626,7 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, // Store all the remaining points in this segment. for (int i = 1; i < num_verts; ++i) { - float t = (float)i / (float)(num_verts - 1); + PN_stdfloat t = (PN_stdfloat)i / (PN_stdfloat)(num_verts - 1); CurveVertex vtx; result->eval_segment_point(segment, t, vtx._p); @@ -670,28 +670,28 @@ compute_thread_vertices(GeomVertexData *vdata, GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); UVMode uv_mode = get_uv_mode(); - float uv_scale = get_uv_scale(); + PN_stdfloat uv_scale = get_uv_scale(); bool u_dominant = get_uv_direction(); bool use_vertex_color = get_use_vertex_color(); - float dist = 0.0f; + PN_stdfloat dist = 0.0f; CurveSegments::const_iterator si; for (si = curve_segments.begin(); si != curve_segments.end(); ++si) { const CurveSegment &segment = (*si); for (size_t j = 0; j < segment.size(); ++j) { - vertex.add_data3f(segment[j]._p); + vertex.add_data3(segment[j]._p); if (use_vertex_color) { - color.add_data4f(segment[j]._c); + color.add_data4(segment[j]._c); } - float uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); + PN_stdfloat uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); if (uv_mode != UV_none) { if (u_dominant) { - texcoord.add_data2f(uv_t, 0.0f); + texcoord.add_data2(uv_t, 0.0f); } else { - texcoord.add_data2f(0.0f, uv_t); + texcoord.add_data2(0.0f, uv_t); } } } @@ -709,7 +709,7 @@ compute_thread_vertices(GeomVertexData *vdata, //////////////////////////////////////////////////////////////////// void RopeNode:: compute_billboard_vertices(GeomVertexData *vdata, - const LVector3f &camera_vec, + const LVector3 &camera_vec, const RopeNode::CurveSegments &curve_segments, int num_curve_verts, NurbsCurveResult *result) const { @@ -720,47 +720,47 @@ compute_billboard_vertices(GeomVertexData *vdata, GeomVertexWriter color(vdata, InternalName::get_color()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - float thickness = get_thickness(); - float overall_radius = thickness * 0.5f; - float radius = overall_radius; + PN_stdfloat thickness = get_thickness(); + PN_stdfloat overall_radius = thickness * 0.5f; + PN_stdfloat radius = overall_radius; UVMode uv_mode = get_uv_mode(); - float uv_scale = get_uv_scale(); + PN_stdfloat uv_scale = get_uv_scale(); bool u_dominant = get_uv_direction(); bool use_vertex_color = get_use_vertex_color(); bool use_vertex_thickness = get_use_vertex_thickness(); - float dist = 0.0f; + PN_stdfloat dist = 0.0f; CurveSegments::const_iterator si; for (si = curve_segments.begin(); si != curve_segments.end(); ++si) { const CurveSegment &segment = (*si); for (size_t j = 0; j < segment.size(); ++j) { - LVector3f tangent; + LVector3 tangent; compute_tangent(tangent, segment, j, result); - LVector3f norm = cross(tangent, camera_vec); + LVector3 norm = cross(tangent, camera_vec); norm.normalize(); if (use_vertex_thickness) { radius = overall_radius * segment[j]._thickness; } - vertex.add_data3f(segment[j]._p + norm * radius); - vertex.add_data3f(segment[j]._p - norm * radius); + vertex.add_data3(segment[j]._p + norm * radius); + vertex.add_data3(segment[j]._p - norm * radius); if (use_vertex_color) { - color.add_data4f(segment[j]._c); - color.add_data4f(segment[j]._c); + color.add_data4(segment[j]._c); + color.add_data4(segment[j]._c); } - float uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); + PN_stdfloat uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); if (uv_mode != UV_none) { if (u_dominant) { - texcoord.add_data2f(uv_t, 1.0f); - texcoord.add_data2f(uv_t, 0.0f); + texcoord.add_data2(uv_t, 1.0f); + texcoord.add_data2(uv_t, 0.0f); } else { - texcoord.add_data2f(1.0f, uv_t); - texcoord.add_data2f(0.0f, uv_t); + texcoord.add_data2(1.0f, uv_t); + texcoord.add_data2(0.0f, uv_t); } } } @@ -785,11 +785,11 @@ compute_tube_vertices(GeomVertexData *vdata, int num_slices = get_num_slices(); num_verts_per_slice = num_slices; - float thickness = get_thickness(); - float overall_radius = thickness * 0.5f; - float radius = overall_radius; + PN_stdfloat thickness = get_thickness(); + PN_stdfloat overall_radius = thickness * 0.5f; + PN_stdfloat radius = overall_radius; UVMode uv_mode = get_uv_mode(); - float uv_scale = get_uv_scale(); + PN_stdfloat uv_scale = get_uv_scale(); bool u_dominant = get_uv_direction(); NormalMode normal_mode = get_normal_mode(); bool use_vertex_color = get_use_vertex_color(); @@ -810,48 +810,48 @@ compute_tube_vertices(GeomVertexData *vdata, GeomVertexWriter color(vdata, InternalName::get_color()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - LVector3f up = get_tube_up(); + LVector3 up = get_tube_up(); - float dist = 0.0f; + PN_stdfloat dist = 0.0f; CurveSegments::const_iterator si; for (si = curve_segments.begin(); si != curve_segments.end(); ++si) { const CurveSegment &segment = (*si); for (size_t j = 0; j < segment.size(); ++j) { - LVector3f tangent; + LVector3 tangent; compute_tangent(tangent, segment, j, result); - LVector3f norm = cross(tangent, up); + LVector3 norm = cross(tangent, up); norm.normalize(); up = cross(norm, tangent); - LMatrix3f rotate = LMatrix3f::rotate_mat(360.0f / (float)num_slices, + LMatrix3 rotate = LMatrix3::rotate_mat(360.0f / (PN_stdfloat)num_slices, tangent); - float uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); + PN_stdfloat uv_t = compute_uv_t(dist, uv_mode, uv_scale, segment, j); for (int s = 0; s < num_verts_per_slice; ++s) { if (use_vertex_thickness) { radius = overall_radius * segment[j]._thickness; } - vertex.add_data3f(segment[j]._p + norm * radius); + vertex.add_data3(segment[j]._p + norm * radius); if (normal_mode == NM_vertex) { - normal.add_data3f(norm); + normal.add_data3(norm); } if (use_vertex_color) { - color.add_data4f(segment[j]._c); + color.add_data4(segment[j]._c); } norm = norm * rotate; if (uv_mode != UV_none) { - float uv_s = (float)s / (float)num_slices; + PN_stdfloat uv_s = (PN_stdfloat)s / (PN_stdfloat)num_slices; if (u_dominant) { - texcoord.add_data2f(uv_t, uv_s); + texcoord.add_data2(uv_t, uv_s); } else { - texcoord.add_data2f(uv_s, uv_t); + texcoord.add_data2(uv_s, uv_t); } } } @@ -868,7 +868,7 @@ compute_tube_vertices(GeomVertexData *vdata, // point in the segment. //////////////////////////////////////////////////////////////////// void RopeNode:: -compute_tangent(LVector3f &tangent, const RopeNode::CurveSegment &segment, +compute_tangent(LVector3 &tangent, const RopeNode::CurveSegment &segment, size_t j, NurbsCurveResult *result) { // First, try to evaluate the tangent at the curve. This gives // better results at the ends at the endpoints where the tangent @@ -878,7 +878,7 @@ compute_tangent(LVector3f &tangent, const RopeNode::CurveSegment &segment, Actually, on second thought this looks terrible. if (result->eval_tangent(segment[j]._t, tangent)) { - if (!tangent.almost_equal(LVector3f::zero())) { + if (!tangent.almost_equal(LVector3::zero())) { return; } } @@ -901,9 +901,9 @@ compute_tangent(LVector3f &tangent, const RopeNode::CurveSegment &segment, // Description: Computes the texture coordinate along the curve for // the indicated point in the segment. //////////////////////////////////////////////////////////////////// -float RopeNode:: -compute_uv_t(float &dist, const RopeNode::UVMode &uv_mode, - float uv_scale, const RopeNode::CurveSegment &segment, +PN_stdfloat RopeNode:: +compute_uv_t(PN_stdfloat &dist, const RopeNode::UVMode &uv_mode, + PN_stdfloat uv_scale, const RopeNode::CurveSegment &segment, size_t j) { switch (uv_mode) { case UV_none: @@ -914,14 +914,14 @@ compute_uv_t(float &dist, const RopeNode::UVMode &uv_mode, case UV_distance: if (j != 0) { - LVector3f vec = segment[j]._p - segment[j - 1]._p; + LVector3 vec = segment[j]._p - segment[j - 1]._p; dist += vec.length(); } return dist * uv_scale; case UV_distance2: if (j != 0) { - LVector3f vec = segment[j]._p - segment[j - 1]._p; + LVector3 vec = segment[j]._p - segment[j - 1]._p; dist += vec.length_squared(); } return dist * uv_scale; diff --git a/panda/src/parametrics/ropeNode.h b/panda/src/parametrics/ropeNode.h index ad6cebd71a..6028af5d52 100644 --- a/panda/src/parametrics/ropeNode.h +++ b/panda/src/parametrics/ropeNode.h @@ -109,14 +109,14 @@ PUBLISHED: INLINE void set_uv_direction(bool u_dominant); INLINE bool get_uv_direction() const; - INLINE void set_uv_scale(float scale); - INLINE float get_uv_scale() const; + INLINE void set_uv_scale(PN_stdfloat scale); + INLINE PN_stdfloat get_uv_scale() const; INLINE void set_normal_mode(NormalMode normal_mode); INLINE NormalMode get_normal_mode() const; - INLINE void set_tube_up(const LVector3f &tube_up); - INLINE const LVector3f &get_tube_up() const; + INLINE void set_tube_up(const LVector3 &tube_up); + INLINE const LVector3 &get_tube_up() const; INLINE void set_use_vertex_color(bool flag); INLINE bool get_use_vertex_color() const; @@ -132,13 +132,13 @@ PUBLISHED: INLINE bool get_use_vertex_thickness() const; INLINE static int get_vertex_thickness_dimension(); - INLINE void set_thickness(float thickness); - INLINE float get_thickness() const; + INLINE void set_thickness(PN_stdfloat thickness); + INLINE PN_stdfloat get_thickness() const; - INLINE void set_matrix(const LMatrix4f &matrix); + INLINE void set_matrix(const LMatrix4 &matrix); INLINE void clear_matrix(); INLINE bool has_matrix() const; - INLINE const LMatrix4f &get_matrix() const; + INLINE const LMatrix4 &get_matrix() const; void reset_bound(const NodePath &rel_to); @@ -165,10 +165,10 @@ private: class CurveVertex { public: - LPoint3f _p; - Colorf _c; - float _thickness; - float _t; + LPoint3 _p; + LColor _c; + PN_stdfloat _thickness; + PN_stdfloat _t; }; typedef pvector CurveSegment; typedef pvector CurveSegments; @@ -180,7 +180,7 @@ private: const CurveSegments &curve_segments, int num_curve_verts) const; void compute_billboard_vertices(GeomVertexData *vdata, - const LVector3f &camera_vec, + const LVector3 &camera_vec, const CurveSegments &curve_segments, int num_curve_verts, NurbsCurveResult *result) const; @@ -190,10 +190,10 @@ private: int num_curve_verts, NurbsCurveResult *result) const; - static void compute_tangent(LVector3f &tangent, const CurveSegment &segment, + static void compute_tangent(LVector3 &tangent, const CurveSegment &segment, size_t j, NurbsCurveResult *result); - static float compute_uv_t(float &dist, const UVMode &uv_mode, - float uv_scale, const CurveSegment &segment, + static PN_stdfloat compute_uv_t(PN_stdfloat &dist, const UVMode &uv_mode, + PN_stdfloat uv_scale, const CurveSegment &segment, size_t j); @@ -214,16 +214,16 @@ private: RenderMode _render_mode; UVMode _uv_mode; bool _u_dominant; - float _uv_scale; + PN_stdfloat _uv_scale; NormalMode _normal_mode; - LVector3f _tube_up; - LMatrix4f _matrix; + LVector3 _tube_up; + LMatrix4 _matrix; bool _has_matrix; bool _use_vertex_color; int _num_subdiv; int _num_slices; bool _use_vertex_thickness; - float _thickness; + PN_stdfloat _thickness; }; PipelineCycler _cycler; diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index 1a7d7a9d7d..b22466dadc 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -266,7 +266,7 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, NurbsSurfaceEvaluator *surface = get_surface(); if (surface != (NurbsSurfaceEvaluator *)NULL) { - pvector verts; + pvector verts; get_surface()->get_vertices(verts, rel_to); GeometricBoundingVolume *gbv; @@ -310,26 +310,26 @@ render_sheet(CullTraverser *trav, CullTraverserData &data, for (int ui = 0; ui < num_u_segments; ui++) { for (int uni = 0; uni <= num_u_verts; uni++) { - float u0 = (float)uni / (float)num_u_verts; - float u0_tc = result->get_segment_u(ui, u0); + PN_stdfloat u0 = (PN_stdfloat)uni / (PN_stdfloat)num_u_verts; + PN_stdfloat u0_tc = result->get_segment_u(ui, u0); for (int vi = 0; vi < num_v_segments; vi++) { for (int vni = 0; vni < num_v_verts; vni++) { - float v = (float)vni / (float)(num_v_verts - 1); - float v_tc = result->get_segment_v(vi, v); + PN_stdfloat v = (PN_stdfloat)vni / (PN_stdfloat)(num_v_verts - 1); + PN_stdfloat v_tc = result->get_segment_v(vi, v); - LPoint3f point; - LVector3f norm; + LPoint3 point; + LVector3 norm; result->eval_segment_point(ui, vi, u0, v, point); result->eval_segment_normal(ui, vi, u0, v, norm); - vertex.add_data3f(point); - normal.add_data3f(norm); - texcoord.add_data2f(u0_tc, v_tc); + vertex.add_data3(point); + normal.add_data3(norm); + texcoord.add_data2(u0_tc, v_tc); if (use_vertex_color) { - Colorf c0; + LColor c0; result->eval_segment_extended_points(ui, vi, u0, v, 0, &c0[0], 4); - color.add_data4f(c0); + color.add_data4(c0); } } } diff --git a/panda/src/particlesystem/arcEmitter.I b/panda/src/particlesystem/arcEmitter.I index 37e19e2056..b49520554f 100644 --- a/panda/src/particlesystem/arcEmitter.I +++ b/panda/src/particlesystem/arcEmitter.I @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////// INLINE void ArcEmitter:: -set_start_angle(float angle) { +set_start_angle(PN_stdfloat angle) { _start_theta = deg_2_rad(angle); } @@ -30,7 +30,7 @@ set_start_angle(float angle) { //////////////////////////////////////////////////////////////////// INLINE void ArcEmitter:: -set_end_angle(float angle) { +set_end_angle(PN_stdfloat angle) { _end_theta = deg_2_rad(angle); } @@ -41,7 +41,7 @@ set_end_angle(float angle) { //////////////////////////////////////////////////////////////////// INLINE void ArcEmitter:: -set_arc(float startAngle, float endAngle) { +set_arc(PN_stdfloat startAngle, PN_stdfloat endAngle) { _start_theta = deg_2_rad(startAngle); _end_theta = deg_2_rad(endAngle); } @@ -52,7 +52,7 @@ set_arc(float startAngle, float endAngle) { // Description : get start angle //////////////////////////////////////////////////////////////////// -INLINE float ArcEmitter:: +INLINE PN_stdfloat ArcEmitter:: get_start_angle() { return rad_2_deg(_start_theta); } @@ -63,7 +63,7 @@ get_start_angle() { // Description : get end angle //////////////////////////////////////////////////////////////////// -INLINE float ArcEmitter:: +INLINE PN_stdfloat ArcEmitter:: get_end_angle() { return rad_2_deg(_end_theta); } diff --git a/panda/src/particlesystem/arcEmitter.cxx b/panda/src/particlesystem/arcEmitter.cxx index b7715582bd..fd46d120f0 100755 --- a/panda/src/particlesystem/arcEmitter.cxx +++ b/panda/src/particlesystem/arcEmitter.cxx @@ -62,8 +62,8 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void ArcEmitter:: -assign_initial_position(LPoint3f& pos) { - float theta; +assign_initial_position(LPoint3& pos) { + PN_stdfloat theta; if ( _start_theta < _end_theta ) { theta = LERP(NORMALIZED_RAND(), _start_theta, _end_theta); } else { @@ -74,9 +74,9 @@ assign_initial_position(LPoint3f& pos) { this->_cos_theta = cosf(theta); this->_sin_theta = sinf(theta); - float new_radius_spread = SPREAD(_radius_spread); - float new_x = _cos_theta * (_radius + new_radius_spread); - float new_y = _sin_theta * (_radius + new_radius_spread); + PN_stdfloat new_radius_spread = SPREAD(_radius_spread); + PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread); + PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread); pos.set(new_x, new_y, 0.0f); } diff --git a/panda/src/particlesystem/arcEmitter.h b/panda/src/particlesystem/arcEmitter.h index 45a1903247..25fcc6a369 100755 --- a/panda/src/particlesystem/arcEmitter.h +++ b/panda/src/particlesystem/arcEmitter.h @@ -30,23 +30,23 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_start_angle(float angle); - INLINE void set_end_angle(float angle); - INLINE void set_arc(float startAngle, float endAngle); + INLINE void set_start_angle(PN_stdfloat angle); + INLINE void set_end_angle(PN_stdfloat angle); + INLINE void set_arc(PN_stdfloat startAngle, PN_stdfloat endAngle); - INLINE float get_start_angle(); - INLINE float get_end_angle(); + INLINE PN_stdfloat get_start_angle(); + INLINE PN_stdfloat get_end_angle(); virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: // our emitter limits - float _start_theta; - float _end_theta; + PN_stdfloat _start_theta; + PN_stdfloat _end_theta; /////////////////////////////// - virtual void assign_initial_position(LPoint3f& pos); + virtual void assign_initial_position(LPoint3& pos); }; #include "arcEmitter.I" diff --git a/panda/src/particlesystem/baseParticle.I b/panda/src/particlesystem/baseParticle.I index 429e5ffd9c..fdd5060640 100644 --- a/panda/src/particlesystem/baseParticle.I +++ b/panda/src/particlesystem/baseParticle.I @@ -12,11 +12,11 @@ // //////////////////////////////////////////////////////////////////// -INLINE void BaseParticle::set_age(float age) { +INLINE void BaseParticle::set_age(PN_stdfloat age) { _age = age; } -INLINE void BaseParticle::set_lifespan(float lifespan) { +INLINE void BaseParticle::set_lifespan(PN_stdfloat lifespan) { _lifespan = lifespan; } @@ -28,11 +28,11 @@ INLINE void BaseParticle::set_index(int index) { _index = index; } -INLINE float BaseParticle::get_age() const { +INLINE PN_stdfloat BaseParticle::get_age() const { return _age; } -INLINE float BaseParticle::get_lifespan() const { +INLINE PN_stdfloat BaseParticle::get_lifespan() const { return _lifespan; } @@ -44,12 +44,12 @@ INLINE int BaseParticle::get_index() const { return _index; } -INLINE float BaseParticle::get_parameterized_age() const { +INLINE PN_stdfloat BaseParticle::get_parameterized_age() const { if (_lifespan <= 0) return 1.0; return _age / _lifespan; } -INLINE float BaseParticle::get_parameterized_vel() const { +INLINE PN_stdfloat BaseParticle::get_parameterized_vel() const { if (IS_NEARLY_ZERO(get_terminal_velocity())) return 0.0; return (get_velocity().length()) / get_terminal_velocity(); } diff --git a/panda/src/particlesystem/baseParticle.cxx b/panda/src/particlesystem/baseParticle.cxx index 2fc219197e..2824b64b48 100644 --- a/panda/src/particlesystem/baseParticle.cxx +++ b/panda/src/particlesystem/baseParticle.cxx @@ -20,7 +20,7 @@ // Description : Default Constructor //////////////////////////////////////////////////////////////////// BaseParticle:: -BaseParticle(float lifespan, bool alive) : +BaseParticle(PN_stdfloat lifespan, bool alive) : _age(0.0f), _lifespan(lifespan), _alive(alive), _index(0){ } @@ -51,7 +51,7 @@ BaseParticle:: // Access : Public // Description : for spriteParticleRenderer //////////////////////////////////////////////////////////////////// -float BaseParticle:: +PN_stdfloat BaseParticle:: get_theta() const { return 0.0f; } diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index 6208fd32c9..84fc240959 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -26,19 +26,19 @@ class EXPCL_PANDAPHYSICS BaseParticle : public PhysicsObject { public: // local methods - INLINE void set_age(float age); - INLINE void set_lifespan(float lifespan); + INLINE void set_age(PN_stdfloat age); + INLINE void set_lifespan(PN_stdfloat lifespan); INLINE void set_alive(bool alive); INLINE void set_index(int index); - INLINE float get_age() const; - INLINE float get_lifespan() const; + INLINE PN_stdfloat get_age() const; + INLINE PN_stdfloat get_lifespan() const; INLINE bool get_alive() const; INLINE int get_index() const; - INLINE float get_parameterized_age() const; - INLINE float get_parameterized_vel() const; + INLINE PN_stdfloat get_parameterized_age() const; + INLINE PN_stdfloat get_parameterized_vel() const; // child methods virtual void init() = 0; @@ -46,7 +46,7 @@ public: virtual void update() = 0; // for spriteParticleRenderer - virtual float get_theta() const; + virtual PN_stdfloat get_theta() const; // from PhysicsObject virtual PhysicsObject *make_copy() const = 0; @@ -55,18 +55,18 @@ public: virtual void write(ostream &out, int indent=0) const; protected: - BaseParticle(float lifespan = 1.0f, bool alive = false); + BaseParticle(PN_stdfloat lifespan = 1.0f, bool alive = false); BaseParticle(const BaseParticle ©); virtual ~BaseParticle(); private: // NOTE: age and lifespan are in seconds. - float _age; - float _lifespan; + PN_stdfloat _age; + PN_stdfloat _lifespan; bool _alive; int _index; - LPoint3f _last_position; + LPoint3 _last_position; }; #include "baseParticle.I" diff --git a/panda/src/particlesystem/baseParticleEmitter.I b/panda/src/particlesystem/baseParticleEmitter.I index 9606651e59..22116c1def 100644 --- a/panda/src/particlesystem/baseParticleEmitter.I +++ b/panda/src/particlesystem/baseParticleEmitter.I @@ -38,7 +38,7 @@ get_emission_type() const { // Description : assignment of explicit emission launch vector //////////////////////////////////////////////////////////////////// INLINE void BaseParticleEmitter:: -set_explicit_launch_vector(const LVector3f& elv) { +set_explicit_launch_vector(const LVector3& elv) { _explicit_launch_vector = elv; } @@ -47,7 +47,7 @@ set_explicit_launch_vector(const LVector3f& elv) { // Access : Public // Description : query for explicit emission launch vector //////////////////////////////////////////////////////////////////// -INLINE LVector3f BaseParticleEmitter:: +INLINE LVector3 BaseParticleEmitter:: get_explicit_launch_vector() const { return _explicit_launch_vector; } @@ -58,7 +58,7 @@ get_explicit_launch_vector() const { // Description : assignment of radiate emission origin point //////////////////////////////////////////////////////////////////// INLINE void BaseParticleEmitter:: -set_radiate_origin(const LPoint3f& ro) { +set_radiate_origin(const LPoint3& ro) { _radiate_origin = ro; } @@ -67,7 +67,7 @@ set_radiate_origin(const LPoint3f& ro) { // Access : Public // Description : query for explicit emission launch vector //////////////////////////////////////////////////////////////////// -INLINE LPoint3f BaseParticleEmitter:: +INLINE LPoint3 BaseParticleEmitter:: get_radiate_origin() const { return _radiate_origin; } @@ -78,7 +78,7 @@ get_radiate_origin() const { // Description : amplitude assignment //////////////////////////////////////////////////////////////////// INLINE void BaseParticleEmitter:: -set_amplitude(float a) { +set_amplitude(PN_stdfloat a) { _amplitude = a; } @@ -87,7 +87,7 @@ set_amplitude(float a) { // Access : Public // Description : amplitude query //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleEmitter:: +INLINE PN_stdfloat BaseParticleEmitter:: get_amplitude() const { return _amplitude; } @@ -98,7 +98,7 @@ get_amplitude() const { // Description : amplitude spread assignment //////////////////////////////////////////////////////////////////// INLINE void BaseParticleEmitter:: -set_amplitude_spread(float as) { +set_amplitude_spread(PN_stdfloat as) { _amplitude_spread = as; } @@ -107,7 +107,7 @@ set_amplitude_spread(float as) { // Access : Public // Description : amplitude spread query //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleEmitter:: +INLINE PN_stdfloat BaseParticleEmitter:: get_amplitude_spread() const { return _amplitude_spread; } @@ -118,7 +118,7 @@ get_amplitude_spread() const { // Description : user-defined force //////////////////////////////////////////////////////////////////// INLINE void BaseParticleEmitter:: -set_offset_force(const LVector3f& of) { +set_offset_force(const LVector3& of) { _offset_force = of; } @@ -127,7 +127,7 @@ set_offset_force(const LVector3f& of) { // Access : Public // Description : user-defined force //////////////////////////////////////////////////////////////////// -INLINE LVector3f BaseParticleEmitter:: +INLINE LVector3 BaseParticleEmitter:: get_offset_force() const { return _offset_force; } diff --git a/panda/src/particlesystem/baseParticleEmitter.cxx b/panda/src/particlesystem/baseParticleEmitter.cxx index 20faf9f954..d5c8a2153f 100644 --- a/panda/src/particlesystem/baseParticleEmitter.cxx +++ b/panda/src/particlesystem/baseParticleEmitter.cxx @@ -61,7 +61,7 @@ BaseParticleEmitter:: // Description : parent generation function //////////////////////////////////////////////////////////////////// void BaseParticleEmitter:: -generate(LPoint3f& pos, LVector3f& vel) { +generate(LPoint3& pos, LVector3& vel) { assign_initial_position(pos); switch(_emission_type) diff --git a/panda/src/particlesystem/baseParticleEmitter.h b/panda/src/particlesystem/baseParticleEmitter.h index 73e545aeb7..d8e8eac719 100644 --- a/panda/src/particlesystem/baseParticleEmitter.h +++ b/panda/src/particlesystem/baseParticleEmitter.h @@ -39,21 +39,21 @@ PUBLISHED: virtual ~BaseParticleEmitter(); virtual BaseParticleEmitter *make_copy() = 0; - void generate(LPoint3f& pos, LVector3f& vel); + void generate(LPoint3& pos, LVector3& vel); INLINE void set_emission_type(emissionType et); - INLINE void set_amplitude(float a); - INLINE void set_amplitude_spread(float as); - INLINE void set_offset_force(const LVector3f& of); // this is a constant force applied to all particles - INLINE void set_explicit_launch_vector(const LVector3f& elv); - INLINE void set_radiate_origin(const LPoint3f& ro); + INLINE void set_amplitude(PN_stdfloat a); + INLINE void set_amplitude_spread(PN_stdfloat as); + INLINE void set_offset_force(const LVector3& of); // this is a constant force applied to all particles + INLINE void set_explicit_launch_vector(const LVector3& elv); + INLINE void set_radiate_origin(const LPoint3& ro); INLINE emissionType get_emission_type() const; - INLINE float get_amplitude() const; - INLINE float get_amplitude_spread() const; - INLINE LVector3f get_offset_force() const; - INLINE LVector3f get_explicit_launch_vector() const; - INLINE LPoint3f get_radiate_origin() const; + INLINE PN_stdfloat get_amplitude() const; + INLINE PN_stdfloat get_amplitude_spread() const; + INLINE LVector3 get_offset_force() const; + INLINE LVector3 get_explicit_launch_vector() const; + INLINE LPoint3 get_radiate_origin() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; @@ -63,18 +63,18 @@ protected: BaseParticleEmitter(const BaseParticleEmitter ©); emissionType _emission_type; - LVector3f _explicit_launch_vector; - LPoint3f _radiate_origin; + LVector3 _explicit_launch_vector; + LPoint3 _radiate_origin; - float _amplitude; - float _amplitude_spread; + PN_stdfloat _amplitude; + PN_stdfloat _amplitude_spread; private: // these should be called in sequence (pos, then vel) - virtual void assign_initial_position(LPoint3f& pos) = 0; - virtual void assign_initial_velocity(LVector3f& vel) = 0; + virtual void assign_initial_position(LPoint3& pos) = 0; + virtual void assign_initial_velocity(LVector3& vel) = 0; - LVector3f _offset_force; + LVector3 _offset_force; }; #include "baseParticleEmitter.I" diff --git a/panda/src/particlesystem/baseParticleFactory.I b/panda/src/particlesystem/baseParticleFactory.I index 7d825554e5..4a01d9d706 100644 --- a/panda/src/particlesystem/baseParticleFactory.I +++ b/panda/src/particlesystem/baseParticleFactory.I @@ -17,7 +17,7 @@ // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_lifespan_base(float lb) { +set_lifespan_base(PN_stdfloat lb) { _lifespan_base = lb; } @@ -26,7 +26,7 @@ set_lifespan_base(float lb) { // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_lifespan_spread(float ld) { +set_lifespan_spread(PN_stdfloat ld) { _lifespan_spread = ld; } @@ -35,7 +35,7 @@ set_lifespan_spread(float ld) { // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_mass_base(float mb) { +set_mass_base(PN_stdfloat mb) { nassertv(mb >= _mass_spread); _mass_base = mb; } @@ -45,7 +45,7 @@ set_mass_base(float mb) { // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_mass_spread(float md) { +set_mass_spread(PN_stdfloat md) { nassertv(md < _mass_base); _mass_spread = md; } @@ -55,7 +55,7 @@ set_mass_spread(float md) { // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_terminal_velocity_base(float tvb) { +set_terminal_velocity_base(PN_stdfloat tvb) { _terminal_velocity_base = tvb; } @@ -64,7 +64,7 @@ set_terminal_velocity_base(float tvb) { // Description : public //////////////////////////////////////////////////////////////////// INLINE void BaseParticleFactory:: -set_terminal_velocity_spread(float tvd) { +set_terminal_velocity_spread(PN_stdfloat tvd) { _terminal_velocity_spread = tvd; } @@ -72,7 +72,7 @@ set_terminal_velocity_spread(float tvd) { // Function : get_lifespan_base // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_lifespan_base() const { return _lifespan_base; } @@ -81,7 +81,7 @@ get_lifespan_base() const { // Function : get_lifespan_spread // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_lifespan_spread() const { return _lifespan_spread; } @@ -90,7 +90,7 @@ get_lifespan_spread() const { // Function : get_mass_base // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_mass_base() const { return _mass_base; } @@ -99,7 +99,7 @@ get_mass_base() const { // Function : get_mass_spread // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_mass_spread() const { return _mass_spread; } @@ -108,7 +108,7 @@ get_mass_spread() const { // Function : get_terminal_velocity_base // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_terminal_velocity_base() const { return _terminal_velocity_base; } @@ -117,7 +117,7 @@ get_terminal_velocity_base() const { // Function : get_terminal_velocity_spread // Description : public //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleFactory:: +INLINE PN_stdfloat BaseParticleFactory:: get_terminal_velocity_spread() const { return _terminal_velocity_spread; } diff --git a/panda/src/particlesystem/baseParticleFactory.h b/panda/src/particlesystem/baseParticleFactory.h index 9a1c15c3b7..cafad15f6d 100644 --- a/panda/src/particlesystem/baseParticleFactory.h +++ b/panda/src/particlesystem/baseParticleFactory.h @@ -31,19 +31,19 @@ class EXPCL_PANDAPHYSICS BaseParticleFactory : public ReferenceCount { PUBLISHED: virtual ~BaseParticleFactory(); - INLINE void set_lifespan_base(float lb); - INLINE void set_lifespan_spread(float ls); - INLINE void set_mass_base(float mb); - INLINE void set_mass_spread(float ms); - INLINE void set_terminal_velocity_base(float tvb); - INLINE void set_terminal_velocity_spread(float tvs); + INLINE void set_lifespan_base(PN_stdfloat lb); + INLINE void set_lifespan_spread(PN_stdfloat ls); + INLINE void set_mass_base(PN_stdfloat mb); + INLINE void set_mass_spread(PN_stdfloat ms); + INLINE void set_terminal_velocity_base(PN_stdfloat tvb); + INLINE void set_terminal_velocity_spread(PN_stdfloat tvs); - INLINE float get_lifespan_base() const; - INLINE float get_lifespan_spread() const; - INLINE float get_mass_base() const; - INLINE float get_mass_spread() const; - INLINE float get_terminal_velocity_base() const; - INLINE float get_terminal_velocity_spread() const; + INLINE PN_stdfloat get_lifespan_base() const; + INLINE PN_stdfloat get_lifespan_spread() const; + INLINE PN_stdfloat get_mass_base() const; + INLINE PN_stdfloat get_mass_spread() const; + INLINE PN_stdfloat get_terminal_velocity_base() const; + INLINE PN_stdfloat get_terminal_velocity_spread() const; virtual BaseParticle *alloc_particle() const = 0; @@ -57,14 +57,14 @@ protected: BaseParticleFactory(const BaseParticleFactory ©); private: - float _lifespan_base; - float _lifespan_spread; + PN_stdfloat _lifespan_base; + PN_stdfloat _lifespan_spread; - float _mass_base; - float _mass_spread; + PN_stdfloat _mass_base; + PN_stdfloat _mass_spread; - float _terminal_velocity_base; - float _terminal_velocity_spread; + PN_stdfloat _terminal_velocity_base; + PN_stdfloat _terminal_velocity_spread; virtual void populate_child_particle(BaseParticle *bp) const = 0; }; diff --git a/panda/src/particlesystem/baseParticleRenderer.I b/panda/src/particlesystem/baseParticleRenderer.I index 147d111254..24a2f59403 100644 --- a/panda/src/particlesystem/baseParticleRenderer.I +++ b/panda/src/particlesystem/baseParticleRenderer.I @@ -57,7 +57,7 @@ get_alpha_mode() const { // Description : sets alpha for "user" alpha mode //////////////////////////////////////////////////////////////////// INLINE void BaseParticleRenderer:: -set_user_alpha(float ua) { +set_user_alpha(PN_stdfloat ua) { _user_alpha = ua; } @@ -66,7 +66,7 @@ set_user_alpha(float ua) { // Access : Published // Description : gets alpha for "user" alpha mode //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleRenderer:: +INLINE PN_stdfloat BaseParticleRenderer:: get_user_alpha() const { return _user_alpha; } @@ -105,7 +105,7 @@ get_ignore_scale() const { // Access : Published // Description : gets current alpha for a particle //////////////////////////////////////////////////////////////////// -INLINE float BaseParticleRenderer:: +INLINE PN_stdfloat BaseParticleRenderer:: get_cur_alpha(BaseParticle* bp) { switch(_alpha_mode) { case PR_ALPHA_OUT: diff --git a/panda/src/particlesystem/baseParticleRenderer.h b/panda/src/particlesystem/baseParticleRenderer.h index 49ee4f1b94..1bab12dc27 100644 --- a/panda/src/particlesystem/baseParticleRenderer.h +++ b/panda/src/particlesystem/baseParticleRenderer.h @@ -56,8 +56,8 @@ PUBLISHED: INLINE void set_alpha_mode(ParticleRendererAlphaMode am); INLINE ParticleRendererAlphaMode get_alpha_mode() const; - INLINE void set_user_alpha(float ua); - INLINE float get_user_alpha() const; + INLINE void set_user_alpha(PN_stdfloat ua); + INLINE PN_stdfloat get_user_alpha() const; INLINE void set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa = ColorBlendAttrib::O_zero, ColorBlendAttrib::Operand ob = ColorBlendAttrib::O_zero); @@ -81,7 +81,7 @@ protected: void enable_alpha(); void disable_alpha(); - INLINE float get_cur_alpha(BaseParticle* bp); + INLINE PN_stdfloat get_cur_alpha(BaseParticle* bp); virtual void resize_pool(int new_size) = 0; @@ -91,7 +91,7 @@ private: PT(GeomNode) _render_node; NodePath _render_node_path; - float _user_alpha; + PN_stdfloat _user_alpha; bool _ignore_scale; // birth and kill particle are for renderers that might do maintenance diff --git a/panda/src/particlesystem/boxEmitter.I b/panda/src/particlesystem/boxEmitter.I index bac4f03733..d580118669 100644 --- a/panda/src/particlesystem/boxEmitter.I +++ b/panda/src/particlesystem/boxEmitter.I @@ -18,7 +18,7 @@ // Description : boundary assignment //////////////////////////////////////////////////////////////////// INLINE void BoxEmitter:: -set_min_bound(const LPoint3f& vmin) { +set_min_bound(const LPoint3& vmin) { _vmin = vmin; } @@ -28,7 +28,7 @@ set_min_bound(const LPoint3f& vmin) { // Description : boundary assignment //////////////////////////////////////////////////////////////////// INLINE void BoxEmitter:: -set_max_bound(const LPoint3f& vmax) { +set_max_bound(const LPoint3& vmax) { _vmax = vmax; } @@ -37,7 +37,7 @@ set_max_bound(const LPoint3f& vmax) { // Access : Public // Description : boundary accessor //////////////////////////////////////////////////////////////////// -INLINE LPoint3f BoxEmitter:: +INLINE LPoint3 BoxEmitter:: get_min_bound() const { return _vmin; } @@ -47,7 +47,7 @@ get_min_bound() const { // Access : Public // Description : boundary accessor //////////////////////////////////////////////////////////////////// -INLINE LPoint3f BoxEmitter:: +INLINE LPoint3 BoxEmitter:: get_max_bound() const { return _vmax; } diff --git a/panda/src/particlesystem/boxEmitter.cxx b/panda/src/particlesystem/boxEmitter.cxx index e02e7915b7..3355bf644d 100644 --- a/panda/src/particlesystem/boxEmitter.cxx +++ b/panda/src/particlesystem/boxEmitter.cxx @@ -63,16 +63,16 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void BoxEmitter:: -assign_initial_position(LPoint3f& pos) { - float t_x = NORMALIZED_RAND(); - float t_y = NORMALIZED_RAND(); - float t_z = NORMALIZED_RAND(); +assign_initial_position(LPoint3& pos) { + PN_stdfloat t_x = NORMALIZED_RAND(); + PN_stdfloat t_y = NORMALIZED_RAND(); + PN_stdfloat t_z = NORMALIZED_RAND(); - LVector3f v_diff = _vmax - _vmin; + LVector3 v_diff = _vmax - _vmin; - float lerp_x = _vmin[0] + t_x * v_diff[0]; - float lerp_y = _vmin[1] + t_y * v_diff[1]; - float lerp_z = _vmin[2] + t_z * v_diff[2]; + PN_stdfloat lerp_x = _vmin[0] + t_x * v_diff[0]; + PN_stdfloat lerp_y = _vmin[1] + t_y * v_diff[1]; + PN_stdfloat lerp_z = _vmin[2] + t_z * v_diff[2]; pos.set(lerp_x, lerp_y, lerp_z); } @@ -83,7 +83,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void BoxEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } diff --git a/panda/src/particlesystem/boxEmitter.h b/panda/src/particlesystem/boxEmitter.h index 39a584c5ab..7902414b44 100644 --- a/panda/src/particlesystem/boxEmitter.h +++ b/panda/src/particlesystem/boxEmitter.h @@ -30,24 +30,24 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_min_bound(const LPoint3f& vmin); - INLINE void set_max_bound(const LPoint3f& vmax); + INLINE void set_min_bound(const LPoint3& vmin); + INLINE void set_max_bound(const LPoint3& vmax); - INLINE LPoint3f get_min_bound() const; - INLINE LPoint3f get_max_bound() const; + INLINE LPoint3 get_min_bound() const; + INLINE LPoint3 get_max_bound() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - LPoint3f _vmin; - LPoint3f _vmax; + LPoint3 _vmin; + LPoint3 _vmax; // CUSTOM EMISSION PARAMETERS // none - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "boxEmitter.I" diff --git a/panda/src/particlesystem/colorInterpolationManager.I b/panda/src/particlesystem/colorInterpolationManager.I index 8232f3d517..4bc3b679b3 100755 --- a/panda/src/particlesystem/colorInterpolationManager.I +++ b/panda/src/particlesystem/colorInterpolationManager.I @@ -20,7 +20,7 @@ // Description : Returns the primary color of the function. //////////////////////////////////////////////////////////////////// -INLINE Colorf ColorInterpolationFunctionConstant:: +INLINE LColor ColorInterpolationFunctionConstant:: get_color_a() const { return _c_a; } @@ -32,7 +32,7 @@ get_color_a() const { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationFunctionConstant:: -set_color_a(const Colorf c) { +set_color_a(const LColor c) { _c_a = c; } @@ -42,7 +42,7 @@ set_color_a(const Colorf c) { // Description : Returns the secondary color of the function. //////////////////////////////////////////////////////////////////// -INLINE Colorf ColorInterpolationFunctionLinear:: +INLINE LColor ColorInterpolationFunctionLinear:: get_color_b() const { return _c_b; } @@ -54,7 +54,7 @@ get_color_b() const { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationFunctionLinear:: -set_color_b(const Colorf c) { +set_color_b(const LColor c) { _c_b = c; } @@ -64,7 +64,7 @@ set_color_b(const Colorf c) { // Description : Returns the primary width of the function. //////////////////////////////////////////////////////////////////// -INLINE float ColorInterpolationFunctionStepwave:: +INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: get_width_a() const { return _w_a; } @@ -75,7 +75,7 @@ get_width_a() const { // Description : Returns the secondary width of the function. //////////////////////////////////////////////////////////////////// -INLINE float ColorInterpolationFunctionStepwave:: +INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: get_width_b() const { return _w_b; } @@ -87,7 +87,7 @@ get_width_b() const { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationFunctionStepwave:: -set_width_a(const float w) { +set_width_a(const PN_stdfloat w) { _w_a = w; } @@ -98,7 +98,7 @@ set_width_a(const float w) { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationFunctionStepwave:: -set_width_b(const float w) { +set_width_b(const PN_stdfloat w) { _w_b = w; } @@ -110,7 +110,7 @@ set_width_b(const float w) { // to A again. //////////////////////////////////////////////////////////////////// -INLINE float ColorInterpolationFunctionSinusoid:: +INLINE PN_stdfloat ColorInterpolationFunctionSinusoid:: get_period() const { return _period; } @@ -123,7 +123,7 @@ get_period() const { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationFunctionSinusoid:: -set_period(const float p) { +set_period(const PN_stdfloat p) { _period = p; } @@ -147,7 +147,7 @@ get_function() const { // value in the range [0,1]. //////////////////////////////////////////////////////////////////// -INLINE float ColorInterpolationSegment:: +INLINE PN_stdfloat ColorInterpolationSegment:: get_time_begin() const { return _t_begin; } @@ -160,7 +160,7 @@ get_time_begin() const { // value in the range [0,1]. //////////////////////////////////////////////////////////////////// -INLINE float ColorInterpolationSegment:: +INLINE PN_stdfloat ColorInterpolationSegment:: get_time_end() const { return _t_end; } @@ -220,7 +220,7 @@ set_function(ColorInterpolationFunction* function) { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationSegment:: -set_time_begin(const float time) { +set_time_begin(const PN_stdfloat time) { _t_begin = time; _t_total = _t_end-_t_begin; } @@ -234,7 +234,7 @@ set_time_begin(const float time) { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationSegment:: -set_time_end(const float time) { +set_time_end(const PN_stdfloat time) { _t_end = time; _t_total = _t_end-_t_begin; } @@ -270,7 +270,7 @@ set_enabled(const bool enabled) { //////////////////////////////////////////////////////////////////// INLINE void ColorInterpolationManager:: -set_default_color(const Colorf &c) { +set_default_color(const LColor &c) { _default_color = c; } diff --git a/panda/src/particlesystem/colorInterpolationManager.cxx b/panda/src/particlesystem/colorInterpolationManager.cxx index c1c5063dec..fe4b8978ce 100755 --- a/panda/src/particlesystem/colorInterpolationManager.cxx +++ b/panda/src/particlesystem/colorInterpolationManager.cxx @@ -58,7 +58,7 @@ ColorInterpolationFunctionConstant() : //////////////////////////////////////////////////////////////////// ColorInterpolationFunctionConstant:: -ColorInterpolationFunctionConstant(const Colorf color_a) : +ColorInterpolationFunctionConstant(const LColor color_a) : _c_a(color_a) { } @@ -68,8 +68,8 @@ ColorInterpolationFunctionConstant(const Colorf color_a) : // Description : Returns the color associated with this instance. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationFunctionConstant:: -interpolate(const float t) const { +LColor ColorInterpolationFunctionConstant:: +interpolate(const PN_stdfloat t) const { return _c_a; } @@ -91,8 +91,8 @@ ColorInterpolationFunctionLinear() : //////////////////////////////////////////////////////////////////// ColorInterpolationFunctionLinear:: -ColorInterpolationFunctionLinear(const Colorf color_a, - const Colorf color_b) : +ColorInterpolationFunctionLinear(const LColor color_a, + const LColor color_b) : ColorInterpolationFunctionConstant(color_a), _c_b(color_b) { } @@ -103,8 +103,8 @@ ColorInterpolationFunctionLinear(const Colorf color_a, // Description : Returns the linear mixture of A and B according to 't'. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationFunctionLinear:: -interpolate(const float t) const { +LColor ColorInterpolationFunctionLinear:: +interpolate(const PN_stdfloat t) const { return (1.0f-t)*_c_a + t*_c_b; } @@ -127,10 +127,10 @@ ColorInterpolationFunctionStepwave() : //////////////////////////////////////////////////////////////////// ColorInterpolationFunctionStepwave:: -ColorInterpolationFunctionStepwave(const Colorf color_a, - const Colorf color_b, - const float width_a, - const float width_b) : +ColorInterpolationFunctionStepwave(const LColor color_a, + const LColor color_b, + const PN_stdfloat width_a, + const PN_stdfloat width_b) : ColorInterpolationFunctionLinear(color_a,color_b), _w_a(width_a), _w_b(width_b) { @@ -142,8 +142,8 @@ ColorInterpolationFunctionStepwave(const Colorf color_a, // Description : Returns either A or B. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationFunctionStepwave:: -interpolate(const float t) const { +LColor ColorInterpolationFunctionStepwave:: +interpolate(const PN_stdfloat t) const { if(fmodf(t,(_w_a+_w_b))<_w_a) { return _c_a; } @@ -168,9 +168,9 @@ ColorInterpolationFunctionSinusoid() : //////////////////////////////////////////////////////////////////// ColorInterpolationFunctionSinusoid:: -ColorInterpolationFunctionSinusoid(const Colorf color_a, - const Colorf color_b, - const float period) : +ColorInterpolationFunctionSinusoid(const LColor color_a, + const LColor color_b, + const PN_stdfloat period) : ColorInterpolationFunctionLinear(color_a,color_b), _period(period) { } @@ -183,9 +183,9 @@ ColorInterpolationFunctionSinusoid(const Colorf color_a, // A. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationFunctionSinusoid:: -interpolate(const float t) const { - float weight_a = (1.0f+cos(t*MathNumbers::pi_f*2.0f/_period))/2.0f; +LColor ColorInterpolationFunctionSinusoid:: +interpolate(const PN_stdfloat t) const { + PN_stdfloat weight_a = (1.0f+cos(t*MathNumbers::pi_f*2.0f/_period))/2.0f; return (weight_a*_c_a)+((1.0f-weight_a)*_c_b); } @@ -197,8 +197,8 @@ interpolate(const float t) const { ColorInterpolationSegment:: ColorInterpolationSegment(ColorInterpolationFunction* function, - const float &time_begin, - const float &time_end, + const PN_stdfloat &time_begin, + const PN_stdfloat &time_end, const bool is_modulated, const int id) : _color_inter_func(function), @@ -246,8 +246,8 @@ ColorInterpolationSegment:: // the segment and 1 corresponds to the end. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationSegment:: -interpolateColor(const float t) const { +LColor ColorInterpolationSegment:: +interpolateColor(const PN_stdfloat t) const { return _color_inter_func->interpolate((t-_t_begin)/_t_total); } @@ -259,7 +259,7 @@ interpolateColor(const float t) const { ColorInterpolationManager:: ColorInterpolationManager() : - _default_color(Colorf(1.0f,1.0f,1.0f,1.0f)), + _default_color(LColor(1.0f,1.0f,1.0f,1.0f)), _id_generator(0) { } @@ -270,7 +270,7 @@ ColorInterpolationManager() : //////////////////////////////////////////////////////////////////// ColorInterpolationManager:: -ColorInterpolationManager(const Colorf &c) : +ColorInterpolationManager(const LColor &c) : _default_color(c), _id_generator(0) { } @@ -307,7 +307,7 @@ ColorInterpolationManager:: //////////////////////////////////////////////////////////////////// int ColorInterpolationManager:: -add_constant(const float time_begin, const float time_end, const Colorf color, const bool is_modulated) { +add_constant(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor color, const bool is_modulated) { PT(ColorInterpolationFunctionConstant) fPtr = new ColorInterpolationFunctionConstant(color); PT(ColorInterpolationSegment) sPtr = new ColorInterpolationSegment(fPtr,time_begin,time_end,is_modulated,_id_generator); @@ -324,7 +324,7 @@ add_constant(const float time_begin, const float time_end, const Colorf color, c //////////////////////////////////////////////////////////////////// int ColorInterpolationManager:: -add_linear(const float time_begin, const float time_end, const Colorf color_a, const Colorf color_b, const bool is_modulated) { +add_linear(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor color_a, const LColor color_b, const bool is_modulated) { PT(ColorInterpolationFunctionLinear) fPtr = new ColorInterpolationFunctionLinear(color_a, color_b); PT(ColorInterpolationSegment) sPtr = new ColorInterpolationSegment(fPtr,time_begin,time_end,is_modulated,_id_generator); @@ -341,7 +341,7 @@ add_linear(const float time_begin, const float time_end, const Colorf color_a, c //////////////////////////////////////////////////////////////////// int ColorInterpolationManager:: -add_stepwave(const float time_begin, const float time_end, const Colorf color_a, const Colorf color_b, const float width_a, const float width_b,const bool is_modulated) { +add_stepwave(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor color_a, const LColor color_b, const PN_stdfloat width_a, const PN_stdfloat width_b,const bool is_modulated) { PT(ColorInterpolationFunctionStepwave) fPtr = new ColorInterpolationFunctionStepwave(color_a, color_b, width_a, width_b); PT(ColorInterpolationSegment) sPtr = new ColorInterpolationSegment(fPtr,time_begin,time_end,is_modulated,_id_generator); @@ -359,7 +359,7 @@ add_stepwave(const float time_begin, const float time_end, const Colorf color_a, //////////////////////////////////////////////////////////////////// int ColorInterpolationManager:: -add_sinusoid(const float time_begin, const float time_end, const Colorf color_a, const Colorf color_b, const float period,const bool is_modulated) { +add_sinusoid(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor color_a, const LColor color_b, const PN_stdfloat period,const bool is_modulated) { PT(ColorInterpolationFunctionSinusoid) fPtr = new ColorInterpolationFunctionSinusoid(color_a, color_b, period); PT(ColorInterpolationSegment) sPtr = new ColorInterpolationSegment(fPtr,time_begin,time_end,is_modulated,_id_generator); @@ -407,10 +407,10 @@ clear_to_initial() { // cover that time, the manager's default color is returned. //////////////////////////////////////////////////////////////////// -Colorf ColorInterpolationManager:: -generateColor(const float interpolated_time) { +LColor ColorInterpolationManager:: +generateColor(const PN_stdfloat interpolated_time) { bool segment_found = false; - Colorf out(_default_color); + LColor out(_default_color); ColorInterpolationSegment *cur_seg; pvector::iterator iter; @@ -420,7 +420,7 @@ generateColor(const float interpolated_time) { interpolated_time >= cur_seg->get_time_begin() && interpolated_time <= cur_seg->get_time_end() ) { segment_found = true; - Colorf cur_color = cur_seg->interpolateColor(interpolated_time); + LColor cur_color = cur_seg->interpolateColor(interpolated_time); if( cur_seg->is_modulated() ) { out[0] *= cur_color[0]; out[1] *= cur_color[1]; @@ -437,10 +437,10 @@ generateColor(const float interpolated_time) { } if(segment_found) { - out[0] = max(0.0f, min(out[0], 1.0f)); - out[1] = max(0.0f, min(out[1], 1.0f)); - out[2] = max(0.0f, min(out[2], 1.0f)); - out[3] = max(0.0f, min(out[3], 1.0f)); + out[0] = max((PN_stdfloat)0.0, min(out[0], (PN_stdfloat)1.0)); + out[1] = max((PN_stdfloat)0.0, min(out[1], (PN_stdfloat)1.0)); + out[2] = max((PN_stdfloat)0.0, min(out[2], (PN_stdfloat)1.0)); + out[3] = max((PN_stdfloat)0.0, min(out[3], (PN_stdfloat)1.0)); return out; } diff --git a/panda/src/particlesystem/colorInterpolationManager.h b/panda/src/particlesystem/colorInterpolationManager.h index 945449b9f4..656cba15d4 100755 --- a/panda/src/particlesystem/colorInterpolationManager.h +++ b/panda/src/particlesystem/colorInterpolationManager.h @@ -35,7 +35,7 @@ public: ColorInterpolationFunction(); virtual ~ColorInterpolationFunction(); - virtual Colorf interpolate(const float t = 0) const = 0; + virtual LColor interpolate(const PN_stdfloat t = 0) const = 0; public: static TypeHandle get_class_type() { @@ -64,19 +64,19 @@ private: class ColorInterpolationFunctionConstant : public ColorInterpolationFunction { PUBLISHED: - INLINE Colorf get_color_a() const; + INLINE LColor get_color_a() const; - INLINE void set_color_a(const Colorf c); + INLINE void set_color_a(const LColor c); public: ColorInterpolationFunctionConstant(); - ColorInterpolationFunctionConstant(const Colorf color_a); + ColorInterpolationFunctionConstant(const LColor color_a); protected: - virtual Colorf interpolate(const float t = 0) const; + virtual LColor interpolate(const PN_stdfloat t = 0) const; // virtual string get_type(); - Colorf _c_a; + LColor _c_a; public: static TypeHandle get_class_type() { @@ -105,19 +105,19 @@ private: class ColorInterpolationFunctionLinear : public ColorInterpolationFunctionConstant { PUBLISHED: - INLINE Colorf get_color_b() const; + INLINE LColor get_color_b() const; - INLINE void set_color_b(const Colorf c); + INLINE void set_color_b(const LColor c); public: ColorInterpolationFunctionLinear(); - ColorInterpolationFunctionLinear(const Colorf color_a, const Colorf color_b); + ColorInterpolationFunctionLinear(const LColor color_a, const LColor color_b); protected: - Colorf interpolate(const float t = 0) const; + LColor interpolate(const PN_stdfloat t = 0) const; // virtual string get_type(); - Colorf _c_b; + LColor _c_b; public: static TypeHandle get_class_type() { @@ -149,22 +149,22 @@ private: class ColorInterpolationFunctionStepwave : public ColorInterpolationFunctionLinear { PUBLISHED: - INLINE float get_width_a() const; - INLINE float get_width_b() const; + INLINE PN_stdfloat get_width_a() const; + INLINE PN_stdfloat get_width_b() const; - INLINE void set_width_a(const float w); - INLINE void set_width_b(const float w); + INLINE void set_width_a(const PN_stdfloat w); + INLINE void set_width_b(const PN_stdfloat w); public: ColorInterpolationFunctionStepwave(); - ColorInterpolationFunctionStepwave(const Colorf color_a, const Colorf color_b, const float width_a, const float width_b); + ColorInterpolationFunctionStepwave(const LColor color_a, const LColor color_b, const PN_stdfloat width_a, const PN_stdfloat width_b); protected: - Colorf interpolate(const float t = 0) const; + LColor interpolate(const PN_stdfloat t = 0) const; // virtual string get_type(); - float _w_a; - float _w_b; + PN_stdfloat _w_a; + PN_stdfloat _w_b; public: static TypeHandle get_class_type() { @@ -197,19 +197,19 @@ private: class ColorInterpolationFunctionSinusoid : public ColorInterpolationFunctionLinear { PUBLISHED: - INLINE float get_period() const; + INLINE PN_stdfloat get_period() const; - INLINE void set_period(const float p); + INLINE void set_period(const PN_stdfloat p); public: ColorInterpolationFunctionSinusoid(); - ColorInterpolationFunctionSinusoid(const Colorf color_a, const Colorf color_b, const float period); + ColorInterpolationFunctionSinusoid(const LColor color_a, const LColor color_b, const PN_stdfloat period); protected: - Colorf interpolate(const float t = 0) const; + LColor interpolate(const PN_stdfloat t = 0) const; // virtual string get_type(); - float _period; + PN_stdfloat _period; public: static TypeHandle get_class_type() { @@ -240,32 +240,32 @@ private: class ColorInterpolationSegment : public ReferenceCount { PUBLISHED: - ColorInterpolationSegment(ColorInterpolationFunction* function, const float &time_begin, const float &time_end, const bool is_modulated, const int id); + ColorInterpolationSegment(ColorInterpolationFunction* function, const PN_stdfloat &time_begin, const PN_stdfloat &time_end, const bool is_modulated, const int id); ColorInterpolationSegment(const ColorInterpolationSegment &s); virtual ~ColorInterpolationSegment(); // INLINE ColorInterpolationFunction* get_function() const; INLINE TypedReferenceCount* get_function() const; - INLINE float get_time_begin() const; - INLINE float get_time_end() const; + INLINE PN_stdfloat get_time_begin() const; + INLINE PN_stdfloat get_time_end() const; INLINE bool is_modulated() const; INLINE int get_id() const; INLINE bool is_enabled() const; INLINE void set_function(ColorInterpolationFunction* function); - INLINE void set_time_begin(const float time); - INLINE void set_time_end(const float time); + INLINE void set_time_begin(const PN_stdfloat time); + INLINE void set_time_end(const PN_stdfloat time); INLINE void set_is_modulated(const bool flag); INLINE void set_enabled(const bool enabled); public: - Colorf interpolateColor(const float t) const; + LColor interpolateColor(const PN_stdfloat t) const; protected: PT(ColorInterpolationFunction) _color_inter_func; - float _t_begin; - float _t_end; - float _t_total; + PN_stdfloat _t_begin; + PN_stdfloat _t_end; + PN_stdfloat _t_total; bool _is_modulated; bool _enabled; const int _id; @@ -283,26 +283,26 @@ protected: class ColorInterpolationManager : public ReferenceCount { PUBLISHED: ColorInterpolationManager(); - ColorInterpolationManager(const Colorf &c); + ColorInterpolationManager(const LColor &c); ColorInterpolationManager(const ColorInterpolationManager& copy); virtual ~ColorInterpolationManager(); - int add_constant(const float time_begin = 0.0f, const float time_end = 1.0f, const Colorf color = Colorf(1.0f,1.0f,1.0f,1.0f), const bool is_modulated = true); - int add_linear(const float time_begin = 0.0f, const float time_end = 1.0f, const Colorf color_a = Colorf(1.0f,0.0f,0.0f,1.0f), const Colorf color_b = Colorf(0.0f,1.0f,0.0f,1.0f), const bool is_modulated = true); - int add_stepwave(const float time_begin = 0.0f, const float time_end = 1.0f, const Colorf color_a = Colorf(1.0f,0.0f,0.0f,1.0f), const Colorf color_b = Colorf(0.0f,1.0f,0.0f,1.0f), const float width_a = 0.5f, const float width_b = 0.5f, const bool is_modulated = true); - int add_sinusoid(const float time_begin = 0.0f, const float time_end = 1.0f, const Colorf color_a = Colorf(1.0f,0.0f,0.0f,1.0f), const Colorf color_b = Colorf(0.0f,1.0f,0.0f,1.0f), const float period = 1.0f, const bool is_modulated = true); + int add_constant(const PN_stdfloat time_begin = 0.0f, const PN_stdfloat time_end = 1.0f, const LColor color = LColor(1.0f,1.0f,1.0f,1.0f), const bool is_modulated = true); + int add_linear(const PN_stdfloat time_begin = 0.0f, const PN_stdfloat time_end = 1.0f, const LColor color_a = LColor(1.0f,0.0f,0.0f,1.0f), const LColor color_b = LColor(0.0f,1.0f,0.0f,1.0f), const bool is_modulated = true); + int add_stepwave(const PN_stdfloat time_begin = 0.0f, const PN_stdfloat time_end = 1.0f, const LColor color_a = LColor(1.0f,0.0f,0.0f,1.0f), const LColor color_b = LColor(0.0f,1.0f,0.0f,1.0f), const PN_stdfloat width_a = 0.5f, const PN_stdfloat width_b = 0.5f, const bool is_modulated = true); + int add_sinusoid(const PN_stdfloat time_begin = 0.0f, const PN_stdfloat time_end = 1.0f, const LColor color_a = LColor(1.0f,0.0f,0.0f,1.0f), const LColor color_b = LColor(0.0f,1.0f,0.0f,1.0f), const PN_stdfloat period = 1.0f, const bool is_modulated = true); - INLINE void set_default_color(const Colorf &c); + INLINE void set_default_color(const LColor &c); INLINE ColorInterpolationSegment* get_segment(const int seg_id); INLINE string get_segment_id_list(); void clear_segment(const int seg_id); void clear_to_initial(); public: - Colorf generateColor(const float interpolated_time); + LColor generateColor(const PN_stdfloat interpolated_time); private: - Colorf _default_color; + LColor _default_color; pvector _i_segs; int _id_generator; }; diff --git a/panda/src/particlesystem/discEmitter.I b/panda/src/particlesystem/discEmitter.I index 0f1a78f7aa..7f21639cbf 100644 --- a/panda/src/particlesystem/discEmitter.I +++ b/panda/src/particlesystem/discEmitter.I @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////// INLINE void DiscEmitter:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -30,7 +30,7 @@ set_radius(float r) { //////////////////////////////////////////////////////////////////// INLINE void DiscEmitter:: -set_outer_angle(float o_angle) { +set_outer_angle(PN_stdfloat o_angle) { _outer_aoe = o_angle; } @@ -41,7 +41,7 @@ set_outer_angle(float o_angle) { //////////////////////////////////////////////////////////////////// INLINE void DiscEmitter:: -set_inner_angle(float i_angle) { +set_inner_angle(PN_stdfloat i_angle) { _inner_aoe = i_angle; } @@ -52,7 +52,7 @@ set_inner_angle(float i_angle) { //////////////////////////////////////////////////////////////////// INLINE void DiscEmitter:: -set_outer_magnitude(float o_mag) { +set_outer_magnitude(PN_stdfloat o_mag) { _outer_magnitude = o_mag; } @@ -63,7 +63,7 @@ set_outer_magnitude(float o_mag) { //////////////////////////////////////////////////////////////////// INLINE void DiscEmitter:: -set_inner_magnitude(float i_mag) { +set_inner_magnitude(PN_stdfloat i_mag) { _inner_magnitude = i_mag; } @@ -84,7 +84,7 @@ set_cubic_lerping(bool clerp) { // Description : radius accessor //////////////////////////////////////////////////////////////////// -INLINE float DiscEmitter:: +INLINE PN_stdfloat DiscEmitter:: get_radius() const { return _radius; } @@ -95,7 +95,7 @@ get_radius() const { // Description : aoe accessor //////////////////////////////////////////////////////////////////// -INLINE float DiscEmitter:: +INLINE PN_stdfloat DiscEmitter:: get_outer_angle() const { return _outer_aoe; } @@ -106,7 +106,7 @@ get_outer_angle() const { // Description : aoe accessor //////////////////////////////////////////////////////////////////// -INLINE float DiscEmitter:: +INLINE PN_stdfloat DiscEmitter:: get_inner_angle() const { return _inner_aoe; } @@ -117,7 +117,7 @@ get_inner_angle() const { // Description : mag accessor //////////////////////////////////////////////////////////////////// -INLINE float DiscEmitter:: +INLINE PN_stdfloat DiscEmitter:: get_outer_magnitude() const { return _outer_magnitude; } @@ -128,7 +128,7 @@ get_outer_magnitude() const { // Description : mag accessor //////////////////////////////////////////////////////////////////// -INLINE float DiscEmitter:: +INLINE PN_stdfloat DiscEmitter:: get_inner_magnitude() const { return _inner_magnitude; } diff --git a/panda/src/particlesystem/discEmitter.cxx b/panda/src/particlesystem/discEmitter.cxx index 55d568cf80..92cdd58214 100644 --- a/panda/src/particlesystem/discEmitter.cxx +++ b/panda/src/particlesystem/discEmitter.cxx @@ -72,18 +72,18 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void DiscEmitter:: -assign_initial_position(LPoint3f& pos) { +assign_initial_position(LPoint3& pos) { // position - float theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; + PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; _distance_from_center = NORMALIZED_RAND(); - float r_scalar = _distance_from_center * _radius; + PN_stdfloat r_scalar = _distance_from_center * _radius; _sinf_theta = sinf(theta); _cosf_theta = cosf(theta); - float new_x = _cosf_theta * r_scalar; - float new_y = _sinf_theta * r_scalar; + PN_stdfloat new_x = _cosf_theta * r_scalar; + PN_stdfloat new_y = _sinf_theta * r_scalar; pos.set(new_x, new_y, 0.0f); } @@ -94,8 +94,8 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void DiscEmitter:: -assign_initial_velocity(LVector3f& vel) { - float aoe, mag; +assign_initial_velocity(LVector3& vel) { + PN_stdfloat aoe, mag; // lerp type if (_cubic_lerping == true) { @@ -108,11 +108,11 @@ assign_initial_velocity(LVector3f& vel) { } // velocity - float vel_z = mag * sinf(deg_2_rad(aoe)); - float abs_diff = fabs((mag * mag) - (vel_z * vel_z)); - float root_mag_minus_z_squared = sqrtf(abs_diff); - float vel_x = _cosf_theta * root_mag_minus_z_squared; - float vel_y = _sinf_theta * root_mag_minus_z_squared; + PN_stdfloat vel_z = mag * sinf(deg_2_rad(aoe)); + PN_stdfloat abs_diff = fabs((mag * mag) - (vel_z * vel_z)); + PN_stdfloat root_mag_minus_z_squared = sqrtf(abs_diff); + PN_stdfloat vel_x = _cosf_theta * root_mag_minus_z_squared; + PN_stdfloat vel_y = _sinf_theta * root_mag_minus_z_squared; // quick and dirty if((aoe > 90.0f) && (aoe < 270.0f)) diff --git a/panda/src/particlesystem/discEmitter.h b/panda/src/particlesystem/discEmitter.h index 6a963866fe..aba279d671 100644 --- a/panda/src/particlesystem/discEmitter.h +++ b/panda/src/particlesystem/discEmitter.h @@ -30,42 +30,42 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_radius(float r); - INLINE void set_outer_angle(float o_angle); - INLINE void set_inner_angle(float i_angle); - INLINE void set_outer_magnitude(float o_mag); - INLINE void set_inner_magnitude(float i_mag); + INLINE void set_radius(PN_stdfloat r); + INLINE void set_outer_angle(PN_stdfloat o_angle); + INLINE void set_inner_angle(PN_stdfloat i_angle); + INLINE void set_outer_magnitude(PN_stdfloat o_mag); + INLINE void set_inner_magnitude(PN_stdfloat i_mag); INLINE void set_cubic_lerping(bool clerp); - INLINE float get_radius() const; - INLINE float get_outer_angle() const; - INLINE float get_inner_angle() const; - INLINE float get_outer_magnitude() const; - INLINE float get_inner_magnitude() const; + INLINE PN_stdfloat get_radius() const; + INLINE PN_stdfloat get_outer_angle() const; + INLINE PN_stdfloat get_inner_angle() const; + INLINE PN_stdfloat get_outer_magnitude() const; + INLINE PN_stdfloat get_inner_magnitude() const; INLINE bool get_cubic_lerping() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - float _radius; + PN_stdfloat _radius; // CUSTOM EMISSION PARAMETERS - float _inner_aoe; - float _outer_aoe; - float _inner_magnitude; - float _outer_magnitude; + PN_stdfloat _inner_aoe; + PN_stdfloat _outer_aoe; + PN_stdfloat _inner_magnitude; + PN_stdfloat _outer_magnitude; bool _cubic_lerping; /////////////////////////////// // scratch variables that carry over from position calc to velocity calc - float _distance_from_center; - float _sinf_theta; - float _cosf_theta; + PN_stdfloat _distance_from_center; + PN_stdfloat _sinf_theta; + PN_stdfloat _cosf_theta; /////////////////////////////// - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "discEmitter.I" diff --git a/panda/src/particlesystem/geomParticleRenderer.I b/panda/src/particlesystem/geomParticleRenderer.I index cc1d988227..e84c11d976 100644 --- a/panda/src/particlesystem/geomParticleRenderer.I +++ b/panda/src/particlesystem/geomParticleRenderer.I @@ -64,7 +64,7 @@ set_z_scale_flag(bool animate_z_ratio) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_initial_x_scale(float initial_x_scale) { +set_initial_x_scale(PN_stdfloat initial_x_scale) { _initial_x_scale = initial_x_scale; init_geoms(); } @@ -74,7 +74,7 @@ set_initial_x_scale(float initial_x_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_final_x_scale(float final_x_scale) { +set_final_x_scale(PN_stdfloat final_x_scale) { _final_x_scale = final_x_scale; init_geoms(); } @@ -84,7 +84,7 @@ set_final_x_scale(float final_x_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_initial_y_scale(float initial_y_scale) { +set_initial_y_scale(PN_stdfloat initial_y_scale) { _initial_y_scale = initial_y_scale; init_geoms(); } @@ -94,7 +94,7 @@ set_initial_y_scale(float initial_y_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_final_y_scale(float final_y_scale) { +set_final_y_scale(PN_stdfloat final_y_scale) { _final_y_scale = final_y_scale; init_geoms(); } @@ -104,7 +104,7 @@ set_final_y_scale(float final_y_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_initial_z_scale(float initial_z_scale) { +set_initial_z_scale(PN_stdfloat initial_z_scale) { _initial_z_scale = initial_z_scale; init_geoms(); } @@ -114,7 +114,7 @@ set_initial_z_scale(float initial_z_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void GeomParticleRenderer:: -set_final_z_scale(float final_z_scale) { +set_final_z_scale(PN_stdfloat final_z_scale) { _final_z_scale = final_z_scale; init_geoms(); } @@ -168,7 +168,7 @@ get_z_scale_flag() const { // Function : GeomParticleRenderer::get_initial_x_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_initial_x_scale() const { return _initial_x_scale; } @@ -177,7 +177,7 @@ get_initial_x_scale() const { // Function : GeomParticleRenderer::get_final_x_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_final_x_scale() const { return _final_x_scale; } @@ -186,7 +186,7 @@ get_final_x_scale() const { // Function : GeomParticleRenderer::get_initial_y_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_initial_y_scale() const { return _initial_y_scale; } @@ -195,7 +195,7 @@ get_initial_y_scale() const { // Function : GeomParticleRenderer::get_final_y_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_final_y_scale() const { return _final_y_scale; } @@ -204,7 +204,7 @@ get_final_y_scale() const { // Function : GeomParticleRenderer::get_initial_z_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_initial_z_scale() const { return _initial_z_scale; } @@ -213,7 +213,7 @@ get_initial_z_scale() const { // Function : GeomParticleRenderer::get_final_z_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float GeomParticleRenderer:: +INLINE PN_stdfloat GeomParticleRenderer:: get_final_z_scale() const { return _final_z_scale; } diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 8715353bfa..dcb8fb7fd8 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -32,7 +32,7 @@ GeomParticleRenderer:: GeomParticleRenderer(ParticleRendererAlphaMode am, PandaNode *geom_node) : BaseParticleRenderer(am), _geom_node(geom_node), - _color_interpolation_manager(new ColorInterpolationManager(Colorf(1.0f,1.0f,1.0f,1.0f))), + _color_interpolation_manager(new ColorInterpolationManager(LColor(1.0f,1.0f,1.0f,1.0f))), _pool_size(0), _initial_x_scale(1.0f), _final_x_scale(1.0f), @@ -207,11 +207,11 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { cur_node->set_state(_render_state); - float t = cur_particle->get_parameterized_age(); - Colorf c = _color_interpolation_manager->generateColor(t); + PN_stdfloat t = cur_particle->get_parameterized_age(); + LColor c = _color_interpolation_manager->generateColor(t); if ((_alpha_mode != PR_ALPHA_NONE)) { - float alpha_scalar; + PN_stdfloat alpha_scalar; if(_alpha_mode == PR_ALPHA_USER) { alpha_scalar = get_user_alpha(); @@ -226,15 +226,15 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { c[3] *= alpha_scalar; cur_node->set_attrib(ColorScaleAttrib::make - (Colorf(1.0f, 1.0f, 1.0f, c[3]))); + (LColor(1.0f, 1.0f, 1.0f, c[3]))); } cur_node->set_attrib(ColorAttrib::make_flat(c), 0); // animate scale - float current_x_scale = _initial_x_scale; - float current_y_scale = _initial_y_scale; - float current_z_scale = _initial_z_scale; + PN_stdfloat current_x_scale = _initial_x_scale; + PN_stdfloat current_y_scale = _initial_y_scale; + PN_stdfloat current_z_scale = _initial_z_scale; if (_animate_x_ratio || _animate_y_ratio || _animate_z_ratio) { if (_animate_x_ratio) { @@ -254,7 +254,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { cur_node->set_transform(TransformState::make_pos_quat_scale (cur_particle->get_position(), cur_particle->get_orientation(), - LVecBase3f(current_x_scale, current_y_scale, current_z_scale))); + LVecBase3(current_x_scale, current_y_scale, current_z_scale))); // maybe get out early if possible. diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index 6e02de6548..97ba7ec22f 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -38,22 +38,22 @@ PUBLISHED: INLINE void set_x_scale_flag(bool animate_x_ratio); INLINE void set_y_scale_flag(bool animate_y_ratio); INLINE void set_z_scale_flag(bool animate_z_ratio); - INLINE void set_initial_x_scale(float initial_x_scale); - INLINE void set_final_x_scale(float final_x_scale); - INLINE void set_initial_y_scale(float initial_y_scale); - INLINE void set_final_y_scale(float final_y_scale); - INLINE void set_initial_z_scale(float initial_z_scale); - INLINE void set_final_z_scale(float final_z_scale); + INLINE void set_initial_x_scale(PN_stdfloat initial_x_scale); + INLINE void set_final_x_scale(PN_stdfloat final_x_scale); + INLINE void set_initial_y_scale(PN_stdfloat initial_y_scale); + INLINE void set_final_y_scale(PN_stdfloat final_y_scale); + INLINE void set_initial_z_scale(PN_stdfloat initial_z_scale); + INLINE void set_final_z_scale(PN_stdfloat final_z_scale); INLINE bool get_x_scale_flag() const; INLINE bool get_y_scale_flag() const; INLINE bool get_z_scale_flag() const; - INLINE float get_initial_x_scale() const; - INLINE float get_final_x_scale() const; - INLINE float get_initial_y_scale() const; - INLINE float get_final_y_scale() const; - INLINE float get_initial_z_scale() const; - INLINE float get_final_z_scale() const; + INLINE PN_stdfloat get_initial_x_scale() const; + INLINE PN_stdfloat get_final_x_scale() const; + INLINE PN_stdfloat get_initial_y_scale() const; + INLINE PN_stdfloat get_final_y_scale() const; + INLINE PN_stdfloat get_initial_z_scale() const; + INLINE PN_stdfloat get_final_z_scale() const; public: virtual BaseParticleRenderer *make_copy(); @@ -69,12 +69,12 @@ private: pvector< PT(PandaNode) > _node_vector; int _pool_size; - float _initial_x_scale; - float _final_x_scale; - float _initial_y_scale; - float _final_y_scale; - float _initial_z_scale; - float _final_z_scale; + PN_stdfloat _initial_x_scale; + PN_stdfloat _final_x_scale; + PN_stdfloat _initial_y_scale; + PN_stdfloat _final_y_scale; + PN_stdfloat _initial_z_scale; + PN_stdfloat _final_z_scale; bool _animate_x_ratio; bool _animate_y_ratio; diff --git a/panda/src/particlesystem/lineEmitter.I b/panda/src/particlesystem/lineEmitter.I index c6b37fcba7..d29840a65f 100644 --- a/panda/src/particlesystem/lineEmitter.I +++ b/panda/src/particlesystem/lineEmitter.I @@ -18,7 +18,7 @@ // Description : endpoint assignment //////////////////////////////////////////////////////////////////// INLINE void LineEmitter:: -set_endpoint1(const LPoint3f& point) { +set_endpoint1(const LPoint3& point) { _endpoint1 = point; } @@ -28,7 +28,7 @@ set_endpoint1(const LPoint3f& point) { // Description : endpoint assignment //////////////////////////////////////////////////////////////////// INLINE void LineEmitter:: -set_endpoint2(const LPoint3f& point) { +set_endpoint2(const LPoint3& point) { _endpoint2 = point; } @@ -37,7 +37,7 @@ set_endpoint2(const LPoint3f& point) { // Access : Public // Description : endpoint accessor //////////////////////////////////////////////////////////////////// -INLINE LPoint3f LineEmitter:: +INLINE LPoint3 LineEmitter:: get_endpoint1() const { return _endpoint1; } @@ -47,7 +47,7 @@ get_endpoint1() const { // Access : Public // Description : endpoint accessor //////////////////////////////////////////////////////////////////// -INLINE LPoint3f LineEmitter:: +INLINE LPoint3 LineEmitter:: get_endpoint2() const { return _endpoint2; } diff --git a/panda/src/particlesystem/lineEmitter.cxx b/panda/src/particlesystem/lineEmitter.cxx index 574085b531..f8a4441aff 100644 --- a/panda/src/particlesystem/lineEmitter.cxx +++ b/panda/src/particlesystem/lineEmitter.cxx @@ -63,14 +63,14 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void LineEmitter:: -assign_initial_position(LPoint3f& pos) { - float t = NORMALIZED_RAND(); +assign_initial_position(LPoint3& pos) { + PN_stdfloat t = NORMALIZED_RAND(); - LVector3f v_diff = _endpoint2 - _endpoint1; + LVector3 v_diff = _endpoint2 - _endpoint1; - float lerp_x = _endpoint1[0] + t * v_diff[0]; - float lerp_y = _endpoint1[1] + t * v_diff[1]; - float lerp_z = _endpoint1[2] + t * v_diff[2]; + PN_stdfloat lerp_x = _endpoint1[0] + t * v_diff[0]; + PN_stdfloat lerp_y = _endpoint1[1] + t * v_diff[1]; + PN_stdfloat lerp_z = _endpoint1[2] + t * v_diff[2]; pos.set(lerp_x, lerp_y, lerp_z); } @@ -81,7 +81,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void LineEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } diff --git a/panda/src/particlesystem/lineEmitter.h b/panda/src/particlesystem/lineEmitter.h index 75a17f29ef..2d6e70ebd5 100644 --- a/panda/src/particlesystem/lineEmitter.h +++ b/panda/src/particlesystem/lineEmitter.h @@ -30,24 +30,24 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_endpoint1(const LPoint3f& point); - INLINE void set_endpoint2(const LPoint3f& point); + INLINE void set_endpoint1(const LPoint3& point); + INLINE void set_endpoint2(const LPoint3& point); - INLINE LPoint3f get_endpoint1() const; - INLINE LPoint3f get_endpoint2() const; + INLINE LPoint3 get_endpoint1() const; + INLINE LPoint3 get_endpoint2() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - LPoint3f _endpoint1; - LPoint3f _endpoint2; + LPoint3 _endpoint1; + LPoint3 _endpoint2; // CUSTOM EMISSION PARAMETERS // none - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "lineEmitter.I" diff --git a/panda/src/particlesystem/lineParticleRenderer.I b/panda/src/particlesystem/lineParticleRenderer.I index 0b92fd680d..0c9d2cbe03 100644 --- a/panda/src/particlesystem/lineParticleRenderer.I +++ b/panda/src/particlesystem/lineParticleRenderer.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void LineParticleRenderer:: -set_head_color(const Colorf& c) { +set_head_color(const LColor& c) { _head_color = c; } @@ -26,7 +26,7 @@ set_head_color(const Colorf& c) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void LineParticleRenderer:: -set_tail_color(const Colorf& c) { +set_tail_color(const LColor& c) { _tail_color = c; } @@ -34,7 +34,7 @@ set_tail_color(const Colorf& c) { // Function : get_head_color // Access : public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& LineParticleRenderer:: +INLINE const LColor& LineParticleRenderer:: get_head_color() const { return _head_color; } @@ -43,7 +43,7 @@ get_head_color() const { // Function : get_tail_color // Access : public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& LineParticleRenderer:: +INLINE const LColor& LineParticleRenderer:: get_tail_color() const { return _tail_color; } @@ -53,7 +53,7 @@ get_tail_color() const { // Description : accessor //////////////////////////////////////////////////////////////////// INLINE void LineParticleRenderer:: -set_line_scale_factor(float sf) { +set_line_scale_factor(PN_stdfloat sf) { _line_scale_factor = sf; } @@ -61,7 +61,7 @@ set_line_scale_factor(float sf) { // Function : get_line_scale_factor // Description : accessor //////////////////////////////////////////////////////////////////// -INLINE float LineParticleRenderer:: +INLINE PN_stdfloat LineParticleRenderer:: get_line_scale_factor() const { return _line_scale_factor; } diff --git a/panda/src/particlesystem/lineParticleRenderer.cxx b/panda/src/particlesystem/lineParticleRenderer.cxx index e41e53856f..596d468c7d 100644 --- a/panda/src/particlesystem/lineParticleRenderer.cxx +++ b/panda/src/particlesystem/lineParticleRenderer.cxx @@ -30,8 +30,8 @@ PStatCollector LineParticleRenderer::_render_collector("App:Particles:Line:Rende LineParticleRenderer:: LineParticleRenderer() : - _head_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), - _tail_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)) { + _head_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)), + _tail_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)) { _line_scale_factor = 1.0f; @@ -45,8 +45,8 @@ LineParticleRenderer() : //////////////////////////////////////////////////////////////////// LineParticleRenderer:: -LineParticleRenderer(const Colorf& head, - const Colorf& tail, +LineParticleRenderer(const LColor& head, + const LColor& tail, ParticleRendererAlphaMode alpha_mode) : BaseParticleRenderer(alpha_mode), _head_color(head), _tail_color(tail) @@ -180,7 +180,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (cur_particle->get_alive() == false) continue; - LPoint3f position = cur_particle->get_position(); + LPoint3 position = cur_particle->get_position(); // adjust the aabb @@ -201,14 +201,14 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // draw the particle. - Colorf head_color = _head_color; - Colorf tail_color = _tail_color; + LColor head_color = _head_color; + LColor tail_color = _tail_color; // handle alpha if (_alpha_mode != PR_ALPHA_NONE) { - float alpha; + PN_stdfloat alpha; if (_alpha_mode == PR_ALPHA_USER) { alpha = get_user_alpha(); @@ -226,12 +226,12 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // one line from current position to last position - vertex.add_data3f(position); - LPoint3f last_position = position + + vertex.add_data3(position); + LPoint3 last_position = position + (cur_particle->get_last_position() - position) * _line_scale_factor; - vertex.add_data3f(last_position); - color.add_data4f(head_color); - color.add_data4f(tail_color); + vertex.add_data3(last_position); + color.add_data4(head_color); + color.add_data4(tail_color); _lines->add_next_vertices(2); _lines->close_primitive(); @@ -242,8 +242,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // done filling geomline node, now do the bb stuff - LPoint3f aabb_center = (_aabb_min + _aabb_max) * 0.5f; - float radius = (aabb_center - _aabb_min).length(); + LPoint3 aabb_center = (_aabb_min + _aabb_max) * 0.5f; + PN_stdfloat radius = (aabb_center - _aabb_min).length(); BoundingSphere sphere(aabb_center, radius); _line_primitive->set_bounds(&sphere); diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index 8c7ca4b7fe..77aa28e193 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -34,8 +34,8 @@ class EXPCL_PANDAPHYSICS LineParticleRenderer : public BaseParticleRenderer { PUBLISHED: LineParticleRenderer(); LineParticleRenderer(const LineParticleRenderer& copy); - LineParticleRenderer(const Colorf& head, - const Colorf& tail, + LineParticleRenderer(const LColor& head, + const LColor& tail, ParticleRendererAlphaMode alpha_mode); virtual ~LineParticleRenderer(); @@ -44,21 +44,21 @@ public: virtual BaseParticleRenderer *make_copy(); PUBLISHED: - INLINE void set_head_color(const Colorf& c); - INLINE void set_tail_color(const Colorf& c); + INLINE void set_head_color(const LColor& c); + INLINE void set_tail_color(const LColor& c); - INLINE const Colorf& get_head_color() const; - INLINE const Colorf& get_tail_color() const; + INLINE const LColor& get_head_color() const; + INLINE const LColor& get_tail_color() const; - INLINE void set_line_scale_factor(float sf); - INLINE float get_line_scale_factor() const; + INLINE void set_line_scale_factor(PN_stdfloat sf); + INLINE PN_stdfloat get_line_scale_factor() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; private: - Colorf _head_color; - Colorf _tail_color; + LColor _head_color; + LColor _tail_color; PT(Geom) _line_primitive; PT(GeomLines) _lines; @@ -66,10 +66,10 @@ private: int _max_pool_size; - LPoint3f _aabb_min; - LPoint3f _aabb_max; + LPoint3 _aabb_min; + LPoint3 _aabb_max; - float _line_scale_factor; + PN_stdfloat _line_scale_factor; virtual void birth_particle(int index); virtual void kill_particle(int index); diff --git a/panda/src/particlesystem/orientedParticleFactory.I b/panda/src/particlesystem/orientedParticleFactory.I index 5f65bfd2dd..f5684c11d3 100644 --- a/panda/src/particlesystem/orientedParticleFactory.I +++ b/panda/src/particlesystem/orientedParticleFactory.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// void OrientedParticleFactory:: -set_initial_orientation(const LOrientationf &o) { +set_initial_orientation(const LOrientation &o) { _initial_orientation = o; } @@ -26,7 +26,7 @@ set_initial_orientation(const LOrientationf &o) { // Access : public //////////////////////////////////////////////////////////////////// void OrientedParticleFactory:: -set_final_orientation(const LOrientationf &o) { +set_final_orientation(const LOrientation &o) { _final_orientation = o; } @@ -34,7 +34,7 @@ set_final_orientation(const LOrientationf &o) { // Function : get_initial_orientation // Access : public //////////////////////////////////////////////////////////////////// -LOrientationf OrientedParticleFactory:: +LOrientation OrientedParticleFactory:: get_initial_orientation() const { return _initial_orientation; } @@ -43,7 +43,7 @@ get_initial_orientation() const { // Function : get_final_orientation // Access : public //////////////////////////////////////////////////////////////////// -LOrientationf OrientedParticleFactory:: +LOrientation OrientedParticleFactory:: get_final_orientation() const { return _final_orientation; } diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index 08e150fe6a..85a8869f65 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -30,10 +30,10 @@ PUBLISHED: OrientedParticleFactory(const OrientedParticleFactory ©); virtual ~OrientedParticleFactory(); - INLINE void set_initial_orientation(const LOrientationf &o); - INLINE void set_final_orientation(const LOrientationf &o); - INLINE LOrientationf get_initial_orientation() const; - INLINE LOrientationf get_final_orientation() const; + INLINE void set_initial_orientation(const LOrientation &o); + INLINE void set_final_orientation(const LOrientation &o); + INLINE LOrientation get_initial_orientation() const; + INLINE LOrientation get_final_orientation() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; @@ -42,8 +42,8 @@ private: virtual void populate_child_particle(BaseParticle *bp) const; virtual BaseParticle *alloc_particle() const; - LOrientationf _initial_orientation; - LOrientationf _final_orientation; + LOrientation _initial_orientation; + LOrientation _final_orientation; }; #include "orientedParticleFactory.I" diff --git a/panda/src/particlesystem/particleCommonFuncs.h b/panda/src/particlesystem/particleCommonFuncs.h index 4f5f7299eb..00e12a0566 100644 --- a/panda/src/particlesystem/particleCommonFuncs.h +++ b/panda/src/particlesystem/particleCommonFuncs.h @@ -16,7 +16,7 @@ #define PARTICLECOMMONFUNCS_H // evaluates to a float in the range [0,1] -#define NORMALIZED_RAND() ((float)rand() / (float)RAND_MAX) +#define NORMALIZED_RAND() ((PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX) // linear interpolation // t is in [0,1] diff --git a/panda/src/particlesystem/particleSystem.I b/panda/src/particlesystem/particleSystem.I index c0a1459933..d3b21c76f0 100644 --- a/panda/src/particlesystem/particleSystem.I +++ b/panda/src/particlesystem/particleSystem.I @@ -65,7 +65,7 @@ clear_to_initial() { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -soft_start(float br) { +soft_start(PN_stdfloat br) { if (br > 0.0) set_birth_rate(br); _cur_birth_rate = _birth_rate; @@ -80,7 +80,7 @@ soft_start(float br) { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -soft_stop(float br) { +soft_stop(PN_stdfloat br) { if (br > 0.0) set_soft_birth_rate(br); _cur_birth_rate = _soft_birth_rate; @@ -107,10 +107,10 @@ set_pool_size(int size) { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -set_birth_rate(float new_br) { +set_birth_rate(PN_stdfloat new_br) { _birth_rate = new_br; _cur_birth_rate = _birth_rate; - if(IS_NEARLY_ZERO(_birth_rate)) _birth_rate = NEARLY_ZERO(float); + if(IS_NEARLY_ZERO(_birth_rate)) _birth_rate = NEARLY_ZERO(PN_stdfloat); } //////////////////////////////////////////////////////////////////// @@ -119,9 +119,9 @@ set_birth_rate(float new_br) { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -set_soft_birth_rate(float new_br) { +set_soft_birth_rate(PN_stdfloat new_br) { _soft_birth_rate = new_br; - if(IS_NEARLY_ZERO(_soft_birth_rate)) _soft_birth_rate = NEARLY_ZERO(float); + if(IS_NEARLY_ZERO(_soft_birth_rate)) _soft_birth_rate = NEARLY_ZERO(PN_stdfloat); } //////////////////////////////////////////////////////////////////// @@ -184,7 +184,7 @@ set_factory(BaseParticleFactory *f) { // Access : Public //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -set_floor_z(float z) { +set_floor_z(PN_stdfloat z) { _floor_z = z; } @@ -230,7 +230,7 @@ set_system_grows_older_flag(bool sgo) { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -set_system_lifespan(float sl) { +set_system_lifespan(PN_stdfloat sl) { _system_lifespan = sl; } @@ -240,7 +240,7 @@ set_system_lifespan(float sl) { //////////////////////////////////////////////////////////////////// INLINE void ParticleSystem:: -set_system_age(float age) { +set_system_age(PN_stdfloat age) { _system_age = age; } @@ -339,7 +339,7 @@ get_pool_size() const { // Function : get_birth_rate // Access : Public //////////////////////////////////////////////////////////////////// -INLINE float ParticleSystem:: +INLINE PN_stdfloat ParticleSystem:: get_birth_rate() const { return _birth_rate; } @@ -348,7 +348,7 @@ get_birth_rate() const { // Function : get_soft_birth_rate // Access : Public //////////////////////////////////////////////////////////////////// -INLINE float ParticleSystem:: +INLINE PN_stdfloat ParticleSystem:: get_soft_birth_rate() const { return _soft_birth_rate; } @@ -402,7 +402,7 @@ get_factory() const { // Function : get_factory // Access : Public //////////////////////////////////////////////////////////////////// -INLINE float ParticleSystem:: +INLINE PN_stdfloat ParticleSystem:: get_floor_z() const { return _floor_z; } @@ -456,7 +456,7 @@ get_system_grows_older_flag() const { // Function : get_system_lifespan // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ParticleSystem:: +INLINE PN_stdfloat ParticleSystem:: get_system_lifespan() const { return _system_lifespan; } @@ -465,7 +465,7 @@ get_system_lifespan() const { // Function : get_system_age // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ParticleSystem:: +INLINE PN_stdfloat ParticleSystem:: get_system_age() const { return _system_age; } diff --git a/panda/src/particlesystem/particleSystem.cxx b/panda/src/particlesystem/particleSystem.cxx index 71ea75a60d..ac2f492563 100644 --- a/panda/src/particlesystem/particleSystem.cxx +++ b/panda/src/particlesystem/particleSystem.cxx @@ -171,8 +171,8 @@ birth_particle() { bp->init(); // get the location of the new particle. - LPoint3f new_pos, world_pos; - LVector3f new_vel; + LPoint3 new_pos, world_pos; + LVector3 new_vel; _emitter->generate(new_pos, new_vel); @@ -181,7 +181,7 @@ birth_particle() { NodePath render_np = _renderer->get_render_node_path(); CPT(TransformState) transform = physical_np.get_transform(render_np); - const LMatrix4f &birth_to_render_xform = transform->get_mat(); + const LMatrix4 &birth_to_render_xform = transform->get_mat(); world_pos = new_pos * birth_to_render_xform; // cout << "New particle at " << world_pos << endl; @@ -275,9 +275,9 @@ spawn_child_system(BaseParticle *bp) { parent->add_child(new_pn); CPT(TransformState) transform = physical_np.get_transform(parent_np); - const LMatrix4f &old_system_to_parent_xform = transform->get_mat(); + const LMatrix4 &old_system_to_parent_xform = transform->get_mat(); - LMatrix4f child_space_xform = old_system_to_parent_xform * + LMatrix4 child_space_xform = old_system_to_parent_xform * bp->get_lcs(); new_pn->set_transform(TransformState::make_mat(child_space_xform)); @@ -465,13 +465,13 @@ resize_pool(int size) { //#define PARTICLE_SYSTEM_UPDATE_SENTRIES #endif void ParticleSystem:: -update(float dt) { +update(PN_stdfloat dt) { PStatTimer t1(_update_collector); int ttl_updates_left = _living_particles; int current_index = 0, index_counter = 0; BaseParticle *bp; - float age; + PN_stdfloat age; #ifdef PSSANITYCHECK // check up on things diff --git a/panda/src/particlesystem/particleSystem.h b/panda/src/particlesystem/particleSystem.h index 3a4e023235..6944f8f944 100644 --- a/panda/src/particlesystem/particleSystem.h +++ b/panda/src/particlesystem/particleSystem.h @@ -49,14 +49,14 @@ PUBLISHED: // access/queries INLINE void set_pool_size(int size); - INLINE void set_birth_rate(float new_br); - INLINE void set_soft_birth_rate(float new_br); + INLINE void set_birth_rate(PN_stdfloat new_br); + INLINE void set_soft_birth_rate(PN_stdfloat new_br); INLINE void set_litter_size(int new_ls); INLINE void set_litter_spread(int new_ls); INLINE void set_local_velocity_flag(bool lv); INLINE void set_system_grows_older_flag(bool sgo); - INLINE void set_system_lifespan(float sl); - INLINE void set_system_age(float age); + INLINE void set_system_lifespan(PN_stdfloat sl); + INLINE void set_system_age(PN_stdfloat age); INLINE void set_active_system_flag(bool a); INLINE void set_spawn_on_death_flag(bool sod); INLINE void set_spawn_render_node(PandaNode *node); @@ -67,19 +67,19 @@ PUBLISHED: INLINE void set_renderer(BaseParticleRenderer *r); INLINE void set_emitter(BaseParticleEmitter *e); INLINE void set_factory(BaseParticleFactory *f); - INLINE void set_floor_z(float z); + INLINE void set_floor_z(PN_stdfloat z); INLINE void clear_floor_z(); INLINE int get_pool_size() const; - INLINE float get_birth_rate() const; - INLINE float get_soft_birth_rate() const; + INLINE PN_stdfloat get_birth_rate() const; + INLINE PN_stdfloat get_soft_birth_rate() const; INLINE int get_litter_size() const; INLINE int get_litter_spread() const; INLINE bool get_local_velocity_flag() const; INLINE bool get_system_grows_older_flag() const; - INLINE float get_system_lifespan() const; - INLINE float get_system_age() const; + INLINE PN_stdfloat get_system_lifespan() const; + INLINE PN_stdfloat get_system_age() const; INLINE bool get_active_system_flag() const; INLINE bool get_spawn_on_death_flag() const; INLINE PandaNode *get_spawn_render_node() const; @@ -90,7 +90,7 @@ PUBLISHED: INLINE BaseParticleRenderer *get_renderer() const; INLINE BaseParticleEmitter *get_emitter() const; INLINE BaseParticleFactory *get_factory() const; - INLINE float get_floor_z() const; + INLINE PN_stdfloat get_floor_z() const; // particle template vector @@ -102,9 +102,9 @@ PUBLISHED: INLINE void render(); INLINE void induce_labor(); INLINE void clear_to_initial(); - INLINE void soft_stop(float br = 0.0); - INLINE void soft_start(float br = 0.0); - void update(float dt); + INLINE void soft_stop(PN_stdfloat br = 0.0); + INLINE void soft_start(PN_stdfloat br = 0.0); + void update(PN_stdfloat dt); virtual void output(ostream &out) const; virtual void write_free_particle_fifo(ostream &out, int indent=0) const; @@ -125,15 +125,15 @@ private: int _particle_pool_size; int _living_particles; - float _cur_birth_rate; - float _birth_rate; - float _soft_birth_rate; - float _tics_since_birth; + PN_stdfloat _cur_birth_rate; + PN_stdfloat _birth_rate; + PN_stdfloat _soft_birth_rate; + PN_stdfloat _tics_since_birth; int _litter_size; int _litter_spread; - float _system_age; - float _system_lifespan; - float _floor_z; + PN_stdfloat _system_age; + PN_stdfloat _system_lifespan; + PN_stdfloat _floor_z; PT(BaseParticleFactory) _factory; PT(BaseParticleEmitter) _emitter; diff --git a/panda/src/particlesystem/particleSystemManager.cxx b/panda/src/particlesystem/particleSystemManager.cxx index 73ab5846a9..d131017351 100644 --- a/panda/src/particlesystem/particleSystemManager.cxx +++ b/panda/src/particlesystem/particleSystemManager.cxx @@ -71,7 +71,7 @@ remove_particlesystem(ParticleSystem *ps) { // stepping applies only to rendering. //////////////////////////////////////////////////////////////////// void ParticleSystemManager:: -do_particles(float dt) { +do_particles(PN_stdfloat dt) { // cout << "ParticlesystemManager::doparticles entering." << endl; PStatTimer t1(_do_particles_collector); @@ -102,7 +102,7 @@ do_particles(float dt) { // Handle age: if (cur_ps->get_system_grows_older_flag() == true) { - float age = cur_ps->get_system_age() + dt; + PN_stdfloat age = cur_ps->get_system_age() + dt; cur_ps->set_system_age(age); // handle death @@ -137,12 +137,12 @@ do_particles(float dt) { // updates could be applied before calling the final render. //////////////////////////////////////////////////////////////////// void ParticleSystemManager:: -do_particles(float dt, ParticleSystem *ps, bool do_render) { +do_particles(PN_stdfloat dt, ParticleSystem *ps, bool do_render) { if (ps->get_active_system_flag() == true) { ps->update(dt); // Handle age: if (ps->get_system_grows_older_flag() == true) { - float age = ps->get_system_age() + dt; + PN_stdfloat age = ps->get_system_age() + dt; ps->set_system_age(age); } diff --git a/panda/src/particlesystem/particleSystemManager.h b/panda/src/particlesystem/particleSystemManager.h index a9db234917..0d1ad97a0f 100644 --- a/panda/src/particlesystem/particleSystemManager.h +++ b/panda/src/particlesystem/particleSystemManager.h @@ -39,8 +39,8 @@ PUBLISHED: void remove_particlesystem(ParticleSystem *ps); INLINE void clear(); - void do_particles(float dt); - void do_particles(float dt, ParticleSystem * ps, bool do_render = true); + void do_particles(PN_stdfloat dt); + void do_particles(PN_stdfloat dt, ParticleSystem * ps, bool do_render = true); virtual void output(ostream &out) const; virtual void write_ps_list(ostream &out, int indent=0) const; diff --git a/panda/src/particlesystem/pointEmitter.I b/panda/src/particlesystem/pointEmitter.I index 50c71b2725..0269cac5c8 100644 --- a/panda/src/particlesystem/pointEmitter.I +++ b/panda/src/particlesystem/pointEmitter.I @@ -18,11 +18,11 @@ // Description : point setting //////////////////////////////////////////////////////////////////// INLINE void PointEmitter:: -set_location(const LPoint3f& p) { +set_location(const LPoint3& p) { _location = p; } -INLINE LPoint3f PointEmitter:: +INLINE LPoint3 PointEmitter:: get_location() const { return _location; } diff --git a/panda/src/particlesystem/pointEmitter.cxx b/panda/src/particlesystem/pointEmitter.cxx index d482c58a97..a7d0a148df 100644 --- a/panda/src/particlesystem/pointEmitter.cxx +++ b/panda/src/particlesystem/pointEmitter.cxx @@ -61,7 +61,7 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void PointEmitter:: -assign_initial_position(LPoint3f& pos) { +assign_initial_position(LPoint3& pos) { pos = _location; } @@ -71,7 +71,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void PointEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } diff --git a/panda/src/particlesystem/pointEmitter.h b/panda/src/particlesystem/pointEmitter.h index 888b21661b..7d68f79356 100644 --- a/panda/src/particlesystem/pointEmitter.h +++ b/panda/src/particlesystem/pointEmitter.h @@ -30,20 +30,20 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_location(const LPoint3f& p); - INLINE LPoint3f get_location() const; + INLINE void set_location(const LPoint3& p); + INLINE LPoint3 get_location() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - LPoint3f _location; + LPoint3 _location; // CUSTOM EMISSION PARAMETERS // none - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "pointEmitter.I" diff --git a/panda/src/particlesystem/pointParticle.cxx b/panda/src/particlesystem/pointParticle.cxx index 48209a8689..2b79167cfd 100644 --- a/panda/src/particlesystem/pointParticle.cxx +++ b/panda/src/particlesystem/pointParticle.cxx @@ -20,7 +20,7 @@ // Description : simple constructor //////////////////////////////////////////////////////////////////// PointParticle:: -PointParticle(float lifespan, bool alive) : +PointParticle(PN_stdfloat lifespan, bool alive) : BaseParticle(lifespan, alive) { set_oriented(false); } diff --git a/panda/src/particlesystem/pointParticle.h b/panda/src/particlesystem/pointParticle.h index f25be393b9..b11bb7d550 100644 --- a/panda/src/particlesystem/pointParticle.h +++ b/panda/src/particlesystem/pointParticle.h @@ -24,7 +24,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS PointParticle : public BaseParticle { public: - PointParticle(float lifespan = 0.0f, bool alive = false); + PointParticle(PN_stdfloat lifespan = 0.0f, bool alive = false); PointParticle(const PointParticle ©); virtual ~PointParticle(); diff --git a/panda/src/particlesystem/pointParticleRenderer.I b/panda/src/particlesystem/pointParticleRenderer.I index 5d2ee7c28b..18c7ec4e1b 100644 --- a/panda/src/particlesystem/pointParticleRenderer.I +++ b/panda/src/particlesystem/pointParticleRenderer.I @@ -17,7 +17,7 @@ // Access : Public //////////////////////////////////////////////////////////////////// INLINE void PointParticleRenderer:: -set_point_size(float point_size) { +set_point_size(PN_stdfloat point_size) { _point_size = point_size; _thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _point_size); } @@ -27,7 +27,7 @@ set_point_size(float point_size) { // Access : Public //////////////////////////////////////////////////////////////////// INLINE void PointParticleRenderer:: -set_start_color(const Colorf& sc) { +set_start_color(const LColor& sc) { _start_color = sc; } @@ -36,7 +36,7 @@ set_start_color(const Colorf& sc) { // Access : Public //////////////////////////////////////////////////////////////////// INLINE void PointParticleRenderer:: -set_end_color(const Colorf& ec) { +set_end_color(const LColor& ec) { _end_color = ec; } @@ -62,7 +62,7 @@ set_blend_method(BaseParticleRenderer::ParticleRendererBlendMethod bm) { // Function : get_point_size // Access : Public //////////////////////////////////////////////////////////////////// -INLINE float PointParticleRenderer:: +INLINE PN_stdfloat PointParticleRenderer:: get_point_size() const { return _point_size; } @@ -71,7 +71,7 @@ get_point_size() const { // Function : get_start_color // Access : Public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& PointParticleRenderer:: +INLINE const LColor& PointParticleRenderer:: get_start_color() const { return _start_color; } @@ -80,7 +80,7 @@ get_start_color() const { // Function : get_end_color // Access : Public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& PointParticleRenderer:: +INLINE const LColor& PointParticleRenderer:: get_end_color() const { return _end_color; } diff --git a/panda/src/particlesystem/pointParticleRenderer.cxx b/panda/src/particlesystem/pointParticleRenderer.cxx index 3b03fed578..6da6c0786a 100644 --- a/panda/src/particlesystem/pointParticleRenderer.cxx +++ b/panda/src/particlesystem/pointParticleRenderer.cxx @@ -30,10 +30,10 @@ PStatCollector PointParticleRenderer::_render_collector("App:Particles:Point:Ren PointParticleRenderer:: PointParticleRenderer(ParticleRendererAlphaMode am, - float point_size, + PN_stdfloat point_size, PointParticleBlendType bt, ParticleRendererBlendMethod bm, - const Colorf& sc, const Colorf& ec) : + const LColor& sc, const LColor& ec) : BaseParticleRenderer(am), _start_color(sc), _end_color(ec), _blend_type(bt), _blend_method(bm) @@ -146,11 +146,11 @@ kill_particle(int) { // Description : Generates the point color based on the render_type //////////////////////////////////////////////////////////////////// -Colorf PointParticleRenderer:: +LColor PointParticleRenderer:: create_color(const BaseParticle *p) { - Colorf color; - float life_t, vel_t; - float parameterized_age = 1.0f; + LColor color; + PN_stdfloat life_t, vel_t; + PN_stdfloat parameterized_age = 1.0f; bool have_alpha_t = false; switch (_blend_type) { @@ -241,7 +241,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (!cur_particle->get_alive()) continue; - LPoint3f position = cur_particle->get_position(); + LPoint3 position = cur_particle->get_position(); // x aabb adjust @@ -266,8 +266,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // stuff it into the arrays - vertex.add_data3f(position); - color.add_data4f(create_color(cur_particle)); + vertex.add_data3(position); + color.add_data4(create_color(cur_particle)); // maybe jump out early? @@ -281,8 +281,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // done filling geompoint node, now do the bb stuff - LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); - float radius = (aabb_center - _aabb_min).length(); + LPoint3 aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); + PN_stdfloat radius = (aabb_center - _aabb_min).length(); BoundingSphere sphere(aabb_center, radius); _point_primitive->set_bounds(&sphere); diff --git a/panda/src/particlesystem/pointParticleRenderer.h b/panda/src/particlesystem/pointParticleRenderer.h index 71b6662bca..d691cd296b 100644 --- a/panda/src/particlesystem/pointParticleRenderer.h +++ b/panda/src/particlesystem/pointParticleRenderer.h @@ -43,11 +43,11 @@ PUBLISHED: PointParticleRenderer(const PointParticleRenderer& copy); PointParticleRenderer(ParticleRendererAlphaMode ad = PR_ALPHA_NONE, - float point_size = 1.0f, + PN_stdfloat point_size = 1.0f, PointParticleBlendType bt = PP_ONE_COLOR, ParticleRendererBlendMethod bm = PP_NO_BLEND, - const Colorf& sc = Colorf(1.0f, 1.0f, 1.0f, 1.0f), - const Colorf& ec = Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + const LColor& sc = LColor(1.0f, 1.0f, 1.0f, 1.0f), + const LColor& ec = LColor(1.0f, 1.0f, 1.0f, 1.0f)); virtual ~PointParticleRenderer(); @@ -55,15 +55,15 @@ public: virtual BaseParticleRenderer *make_copy(); PUBLISHED: - INLINE void set_point_size(float point_size); - INLINE void set_start_color(const Colorf& sc); - INLINE void set_end_color(const Colorf& ec); + INLINE void set_point_size(PN_stdfloat point_size); + INLINE void set_start_color(const LColor& sc); + INLINE void set_end_color(const LColor& ec); INLINE void set_blend_type(PointParticleBlendType bt); INLINE void set_blend_method(ParticleRendererBlendMethod bm); - INLINE float get_point_size() const; - INLINE const Colorf& get_start_color() const; - INLINE const Colorf& get_end_color() const; + INLINE PN_stdfloat get_point_size() const; + INLINE const LColor& get_start_color() const; + INLINE const LColor& get_end_color() const; INLINE PointParticleBlendType get_blend_type() const; INLINE ParticleRendererBlendMethod get_blend_method() const; @@ -71,9 +71,9 @@ PUBLISHED: virtual void write(ostream &out, int indent_level = 0) const; private: - Colorf _start_color; - Colorf _end_color; - float _point_size; + LColor _start_color; + LColor _end_color; + PN_stdfloat _point_size; CPT(RenderAttrib) _thick; PT(Geom) _point_primitive; @@ -85,10 +85,10 @@ private: PointParticleBlendType _blend_type; ParticleRendererBlendMethod _blend_method; - LPoint3f _aabb_min; - LPoint3f _aabb_max; + LPoint3 _aabb_min; + LPoint3 _aabb_max; - Colorf create_color(const BaseParticle *p); + LColor create_color(const BaseParticle *p); virtual void birth_particle(int index); virtual void kill_particle(int index); diff --git a/panda/src/particlesystem/rectangleEmitter.I b/panda/src/particlesystem/rectangleEmitter.I index c6daff3d93..7617872cb9 100644 --- a/panda/src/particlesystem/rectangleEmitter.I +++ b/panda/src/particlesystem/rectangleEmitter.I @@ -18,7 +18,7 @@ // Description : boundary set //////////////////////////////////////////////////////////////////// INLINE void RectangleEmitter:: -set_min_bound(const LPoint2f& vmin) { +set_min_bound(const LPoint2& vmin) { _vmin = vmin; } @@ -28,7 +28,7 @@ set_min_bound(const LPoint2f& vmin) { // Description : boundary set //////////////////////////////////////////////////////////////////// INLINE void RectangleEmitter:: -set_max_bound(const LPoint2f& vmax) { +set_max_bound(const LPoint2& vmax) { _vmax = vmax; } @@ -37,7 +37,7 @@ set_max_bound(const LPoint2f& vmax) { // Access : public // Description : boundary get //////////////////////////////////////////////////////////////////// -INLINE LPoint2f RectangleEmitter:: +INLINE LPoint2 RectangleEmitter:: get_min_bound() const { return _vmin; } @@ -47,7 +47,7 @@ get_min_bound() const { // Access : public // Description : boundary get //////////////////////////////////////////////////////////////////// -INLINE LPoint2f RectangleEmitter:: +INLINE LPoint2 RectangleEmitter:: get_max_bound() const { return _vmax; } diff --git a/panda/src/particlesystem/rectangleEmitter.cxx b/panda/src/particlesystem/rectangleEmitter.cxx index 8ede03944c..9afc19f6df 100644 --- a/panda/src/particlesystem/rectangleEmitter.cxx +++ b/panda/src/particlesystem/rectangleEmitter.cxx @@ -63,14 +63,14 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void RectangleEmitter:: -assign_initial_position(LPoint3f& pos) { - float t_x = NORMALIZED_RAND(); - float t_y = NORMALIZED_RAND(); +assign_initial_position(LPoint3& pos) { + PN_stdfloat t_x = NORMALIZED_RAND(); + PN_stdfloat t_y = NORMALIZED_RAND(); - LVector2f v_diff = _vmax - _vmin; + LVector2 v_diff = _vmax - _vmin; - float lerp_x = _vmin[0] + t_x * v_diff[0]; - float lerp_y = _vmin[1] + t_y * v_diff[1]; + PN_stdfloat lerp_x = _vmin[0] + t_x * v_diff[0]; + PN_stdfloat lerp_y = _vmin[1] + t_y * v_diff[1]; pos.set(lerp_x, lerp_y, 0.0f); } @@ -81,7 +81,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void RectangleEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(0.0f,0.0f,0.0f); } diff --git a/panda/src/particlesystem/rectangleEmitter.h b/panda/src/particlesystem/rectangleEmitter.h index 64587fdddb..d4c67c6ea5 100644 --- a/panda/src/particlesystem/rectangleEmitter.h +++ b/panda/src/particlesystem/rectangleEmitter.h @@ -30,24 +30,24 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_min_bound(const LPoint2f& vmin); - INLINE void set_max_bound(const LPoint2f& vmax); + INLINE void set_min_bound(const LPoint2& vmin); + INLINE void set_max_bound(const LPoint2& vmax); - INLINE LPoint2f get_min_bound() const; - INLINE LPoint2f get_max_bound() const; + INLINE LPoint2 get_min_bound() const; + INLINE LPoint2 get_max_bound() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - LPoint2f _vmin; - LPoint2f _vmax; + LPoint2 _vmin; + LPoint2 _vmax; // CUSTOM EMISSION PARAMETERS // none - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "rectangleEmitter.I" diff --git a/panda/src/particlesystem/ringEmitter.I b/panda/src/particlesystem/ringEmitter.I index 4949abc125..31d35afa5a 100644 --- a/panda/src/particlesystem/ringEmitter.I +++ b/panda/src/particlesystem/ringEmitter.I @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////// INLINE void RingEmitter:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -30,7 +30,7 @@ set_radius(float r) { //////////////////////////////////////////////////////////////////// INLINE void RingEmitter:: -set_angle(float angle) { +set_angle(PN_stdfloat angle) { _aoe = angle; } @@ -41,7 +41,7 @@ set_angle(float angle) { //////////////////////////////////////////////////////////////////// INLINE void RingEmitter:: -set_radius_spread(float spread) { +set_radius_spread(PN_stdfloat spread) { _radius_spread = spread; } @@ -62,7 +62,7 @@ set_uniform_emission(int uniform_emission) { // Description : radius get //////////////////////////////////////////////////////////////////// -INLINE float RingEmitter:: +INLINE PN_stdfloat RingEmitter:: get_radius() const { return _radius; } @@ -73,7 +73,7 @@ get_radius() const { // Description : angle of elevation get //////////////////////////////////////////////////////////////////// -INLINE float RingEmitter:: +INLINE PN_stdfloat RingEmitter:: get_angle() const { return _aoe; } @@ -84,7 +84,7 @@ get_angle() const { // Description : radius_spread get //////////////////////////////////////////////////////////////////// -INLINE float RingEmitter:: +INLINE PN_stdfloat RingEmitter:: get_radius_spread() const { return _radius_spread; } diff --git a/panda/src/particlesystem/ringEmitter.cxx b/panda/src/particlesystem/ringEmitter.cxx index 9074ba69af..9037af4ebf 100644 --- a/panda/src/particlesystem/ringEmitter.cxx +++ b/panda/src/particlesystem/ringEmitter.cxx @@ -68,7 +68,7 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void RingEmitter:: -assign_initial_position(LPoint3f& pos) { +assign_initial_position(LPoint3& pos) { if (_uniform_emission > 0) { _theta = _theta + 1.0/_uniform_emission; @@ -83,9 +83,9 @@ assign_initial_position(LPoint3f& pos) { _cos_theta = cosf(_theta * 2.0f * MathNumbers::pi_f); _sin_theta = sinf(_theta * 2.0f * MathNumbers::pi_f); - float new_radius_spread = SPREAD(_radius_spread); - float new_x = _cos_theta * (_radius + new_radius_spread); - float new_y = _sin_theta * (_radius + new_radius_spread); + PN_stdfloat new_radius_spread = SPREAD(_radius_spread); + PN_stdfloat new_x = _cos_theta * (_radius + new_radius_spread); + PN_stdfloat new_y = _sin_theta * (_radius + new_radius_spread); pos.set(new_x, new_y, 0.0f); } @@ -96,13 +96,13 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void RingEmitter:: -assign_initial_velocity(LVector3f& vel) { - float vel_z = sinf(deg_2_rad(_aoe)); - float abs_diff = fabs(1.0f - (vel_z * vel_z)); - float root_mag_minus_z_squared = sqrtf(abs_diff); +assign_initial_velocity(LVector3& vel) { + PN_stdfloat vel_z = sinf(deg_2_rad(_aoe)); + PN_stdfloat abs_diff = fabs(1.0f - (vel_z * vel_z)); + PN_stdfloat root_mag_minus_z_squared = sqrtf(abs_diff); - float vel_x = _cos_theta * root_mag_minus_z_squared; - float vel_y = _sin_theta * root_mag_minus_z_squared; + PN_stdfloat vel_x = _cos_theta * root_mag_minus_z_squared; + PN_stdfloat vel_y = _sin_theta * root_mag_minus_z_squared; // quick and dirty if((_aoe > 90.0f) && (_aoe < 270.0f)) diff --git a/panda/src/particlesystem/ringEmitter.h b/panda/src/particlesystem/ringEmitter.h index feab3a1b60..dbdee9e071 100644 --- a/panda/src/particlesystem/ringEmitter.h +++ b/panda/src/particlesystem/ringEmitter.h @@ -30,39 +30,39 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_radius(float r); - INLINE void set_angle(float angle); - INLINE void set_radius_spread(float spread); + INLINE void set_radius(PN_stdfloat r); + INLINE void set_angle(PN_stdfloat angle); + INLINE void set_radius_spread(PN_stdfloat spread); INLINE void set_uniform_emission(int uniform_emission); - INLINE float get_radius() const; - INLINE float get_angle() const; - INLINE float get_radius_spread() const; + INLINE PN_stdfloat get_radius() const; + INLINE PN_stdfloat get_angle() const; + INLINE PN_stdfloat get_radius_spread() const; INLINE int get_uniform_emission() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; protected: - float _radius; - float _radius_spread; + PN_stdfloat _radius; + PN_stdfloat _radius_spread; // CUSTOM EMISSION PARAMETERS - float _aoe; // angle of elevation + PN_stdfloat _aoe; // angle of elevation // viariables used for uniform particle emission int _uniform_emission; - float _theta; + PN_stdfloat _theta; /////////////////////////////// // scratch variables that carry over from position calc to velocity calc - float _sin_theta; - float _cos_theta; + PN_stdfloat _sin_theta; + PN_stdfloat _cos_theta; /////////////////////////////// private: - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "ringEmitter.I" diff --git a/panda/src/particlesystem/sparkleParticleRenderer.I b/panda/src/particlesystem/sparkleParticleRenderer.I index cdad17b7f4..eca9f2df01 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.I +++ b/panda/src/particlesystem/sparkleParticleRenderer.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void SparkleParticleRenderer:: -set_center_color(const Colorf& c) { +set_center_color(const LColor& c) { _center_color = c; } @@ -26,7 +26,7 @@ set_center_color(const Colorf& c) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SparkleParticleRenderer:: -set_edge_color(const Colorf& c) { +set_edge_color(const LColor& c) { _edge_color = c; } @@ -44,7 +44,7 @@ set_life_scale(SparkleParticleRenderer::SparkleParticleLifeScale ls) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SparkleParticleRenderer:: -set_birth_radius(float radius) { +set_birth_radius(PN_stdfloat radius) { _birth_radius = radius; } @@ -53,7 +53,7 @@ set_birth_radius(float radius) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SparkleParticleRenderer:: -set_death_radius(float radius) { +set_death_radius(PN_stdfloat radius) { _death_radius = radius; } @@ -61,7 +61,7 @@ set_death_radius(float radius) { // Function : get_center_color // Access : public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& SparkleParticleRenderer:: +INLINE const LColor& SparkleParticleRenderer:: get_center_color() const { return _center_color; } @@ -70,7 +70,7 @@ get_center_color() const { // Function : get_edge_color // Access : public //////////////////////////////////////////////////////////////////// -INLINE const Colorf& SparkleParticleRenderer:: +INLINE const LColor& SparkleParticleRenderer:: get_edge_color() const { return _edge_color; } @@ -88,7 +88,7 @@ get_life_scale() const { // Function : get_birth_radius // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SparkleParticleRenderer:: +INLINE PN_stdfloat SparkleParticleRenderer:: get_birth_radius() const { return _birth_radius; } @@ -97,7 +97,7 @@ get_birth_radius() const { // Function : get_death_radius // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SparkleParticleRenderer:: +INLINE PN_stdfloat SparkleParticleRenderer:: get_death_radius() const { return _death_radius; } @@ -106,12 +106,12 @@ get_death_radius() const { // Function : get_radius // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SparkleParticleRenderer:: +INLINE PN_stdfloat SparkleParticleRenderer:: get_radius(BaseParticle *bp) { if (_life_scale == SP_NO_SCALE) return _birth_radius; else { - float s_x = CUBIC_T(bp->get_parameterized_age()); + PN_stdfloat s_x = CUBIC_T(bp->get_parameterized_age()); return LERP(s_x, _birth_radius, _death_radius); } } diff --git a/panda/src/particlesystem/sparkleParticleRenderer.cxx b/panda/src/particlesystem/sparkleParticleRenderer.cxx index 98efd03cff..3827e74d0c 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.cxx +++ b/panda/src/particlesystem/sparkleParticleRenderer.cxx @@ -30,8 +30,8 @@ PStatCollector SparkleParticleRenderer::_render_collector("App:Particles:Sparkle SparkleParticleRenderer:: SparkleParticleRenderer() : BaseParticleRenderer(PR_ALPHA_NONE), - _center_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), - _edge_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), + _center_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)), + _edge_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)), _birth_radius(0.1f), _death_radius(0.1f) { resize_pool(0); @@ -43,8 +43,8 @@ SparkleParticleRenderer() : // Description : Constructor //////////////////////////////////////////////////////////////////// SparkleParticleRenderer:: -SparkleParticleRenderer(const Colorf& center, const Colorf& edge, - float birth_radius, float death_radius, +SparkleParticleRenderer(const LColor& center, const LColor& edge, + PN_stdfloat birth_radius, PN_stdfloat death_radius, SparkleParticleLifeScale life_scale, ParticleRendererAlphaMode alpha_mode) : BaseParticleRenderer(alpha_mode), @@ -176,7 +176,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { continue; } - LPoint3f position = cur_particle->get_position(); + LPoint3 position = cur_particle->get_position(); // adjust the aabb @@ -197,12 +197,12 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // draw the particle. - float radius = get_radius(cur_particle); - float neg_radius = -radius; - float alpha; + PN_stdfloat radius = get_radius(cur_particle); + PN_stdfloat neg_radius = -radius; + PN_stdfloat alpha; - Colorf center_color = _center_color; - Colorf edge_color = _edge_color; + LColor center_color = _center_color; + LColor edge_color = _edge_color; // handle alpha @@ -225,31 +225,31 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // 6 lines coming from the center point. - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(radius, 0.0f, 0.0f)); - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(neg_radius, 0.0f, 0.0f)); - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(0.0f, radius, 0.0f)); - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(0.0f, neg_radius, 0.0f)); - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(0.0f, 0.0f, radius)); - vertex.add_data3f(position); - vertex.add_data3f(position + Vertexf(0.0f, 0.0f, neg_radius)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(radius, 0.0f, 0.0f)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(neg_radius, 0.0f, 0.0f)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(0.0f, radius, 0.0f)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(0.0f, neg_radius, 0.0f)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(0.0f, 0.0f, radius)); + vertex.add_data3(position); + vertex.add_data3(position + LVertex(0.0f, 0.0f, neg_radius)); - color.add_data4f(center_color); - color.add_data4f(edge_color); - color.add_data4f(center_color); - color.add_data4f(edge_color); - color.add_data4f(center_color); - color.add_data4f(edge_color); - color.add_data4f(center_color); - color.add_data4f(edge_color); - color.add_data4f(center_color); - color.add_data4f(edge_color); - color.add_data4f(center_color); - color.add_data4f(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); + color.add_data4(center_color); + color.add_data4(edge_color); _lines->add_next_vertices(2); _lines->close_primitive(); @@ -272,8 +272,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // done filling geomline node, now do the bb stuff - LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); - float radius = (aabb_center - _aabb_min).length(); + LPoint3 aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); + PN_stdfloat radius = (aabb_center - _aabb_min).length(); BoundingSphere sphere(aabb_center, radius); _line_primitive->set_bounds(&sphere); diff --git a/panda/src/particlesystem/sparkleParticleRenderer.h b/panda/src/particlesystem/sparkleParticleRenderer.h index c2abb006da..ce3ae991b8 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.h +++ b/panda/src/particlesystem/sparkleParticleRenderer.h @@ -42,10 +42,10 @@ PUBLISHED: SparkleParticleRenderer(); SparkleParticleRenderer(const SparkleParticleRenderer& copy); - SparkleParticleRenderer(const Colorf& center, - const Colorf& edge, - float birth_radius, - float death_radius, + SparkleParticleRenderer(const LColor& center, + const LColor& edge, + PN_stdfloat birth_radius, + PN_stdfloat death_radius, SparkleParticleLifeScale life_scale, ParticleRendererAlphaMode alpha_mode); @@ -55,27 +55,27 @@ public: virtual BaseParticleRenderer *make_copy(); PUBLISHED: - INLINE void set_center_color(const Colorf& c); - INLINE void set_edge_color(const Colorf& c); - INLINE void set_birth_radius(float radius); - INLINE void set_death_radius(float radius); + INLINE void set_center_color(const LColor& c); + INLINE void set_edge_color(const LColor& c); + INLINE void set_birth_radius(PN_stdfloat radius); + INLINE void set_death_radius(PN_stdfloat radius); INLINE void set_life_scale(SparkleParticleLifeScale); - INLINE const Colorf& get_center_color() const; - INLINE const Colorf& get_edge_color() const; - INLINE float get_birth_radius() const; - INLINE float get_death_radius() const; + INLINE const LColor& get_center_color() const; + INLINE const LColor& get_edge_color() const; + INLINE PN_stdfloat get_birth_radius() const; + INLINE PN_stdfloat get_death_radius() const; INLINE SparkleParticleLifeScale get_life_scale() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; private: - Colorf _center_color; - Colorf _edge_color; + LColor _center_color; + LColor _edge_color; - float _birth_radius; - float _death_radius; + PN_stdfloat _birth_radius; + PN_stdfloat _death_radius; PT(Geom) _line_primitive; PT(GeomLines) _lines; @@ -84,10 +84,10 @@ private: int _max_pool_size; SparkleParticleLifeScale _life_scale; - LPoint3f _aabb_min; - LPoint3f _aabb_max; + LPoint3 _aabb_min; + LPoint3 _aabb_max; - INLINE float get_radius(BaseParticle *bp); + INLINE PN_stdfloat get_radius(BaseParticle *bp); virtual void birth_particle(int index); virtual void kill_particle(int index); diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.I b/panda/src/particlesystem/sphereSurfaceEmitter.I index 698a939766..ab31e44fdd 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.I +++ b/panda/src/particlesystem/sphereSurfaceEmitter.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE void SphereSurfaceEmitter:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -31,7 +31,7 @@ set_radius(float r) { // Description : radius get //////////////////////////////////////////////////////////////////// -INLINE float SphereSurfaceEmitter:: +INLINE PN_stdfloat SphereSurfaceEmitter:: get_radius() const { return _radius; } diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.cxx b/panda/src/particlesystem/sphereSurfaceEmitter.cxx index 7e8989174a..ce4dc0591f 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.cxx +++ b/panda/src/particlesystem/sphereSurfaceEmitter.cxx @@ -60,8 +60,8 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void SphereSurfaceEmitter:: -assign_initial_position(LPoint3f& pos) { - float z, theta, r; +assign_initial_position(LPoint3& pos) { + PN_stdfloat z, theta, r; z = SPREAD(_radius); r = sqrtf((_radius * _radius) - (z * z)); @@ -76,7 +76,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void SphereSurfaceEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.h b/panda/src/particlesystem/sphereSurfaceEmitter.h index c549d4c86c..53943390dd 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.h +++ b/panda/src/particlesystem/sphereSurfaceEmitter.h @@ -30,20 +30,20 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_radius(float r); - INLINE float get_radius() const; + INLINE void set_radius(PN_stdfloat r); + INLINE PN_stdfloat get_radius() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - float _radius; + PN_stdfloat _radius; // CUSTOM EMISSION PARAMETERS // none - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "sphereSurfaceEmitter.I" diff --git a/panda/src/particlesystem/sphereVolumeEmitter.I b/panda/src/particlesystem/sphereVolumeEmitter.I index 007d51ae45..9d52fa5858 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.I +++ b/panda/src/particlesystem/sphereVolumeEmitter.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE void SphereVolumeEmitter:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -31,7 +31,7 @@ set_radius(float r) { // Description : radius get //////////////////////////////////////////////////////////////////// -INLINE float SphereVolumeEmitter:: +INLINE PN_stdfloat SphereVolumeEmitter:: get_radius() const { return _radius; } diff --git a/panda/src/particlesystem/sphereVolumeEmitter.cxx b/panda/src/particlesystem/sphereVolumeEmitter.cxx index cca5c64369..12a11cf764 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.cxx +++ b/panda/src/particlesystem/sphereVolumeEmitter.cxx @@ -61,9 +61,9 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void SphereVolumeEmitter:: -assign_initial_position(LPoint3f& pos) { - float z, theta, r; - float t; +assign_initial_position(LPoint3& pos) { + PN_stdfloat z, theta, r; + PN_stdfloat t; z = SPREAD(_radius); r = sqrtf((_radius * _radius) - (z * z)); @@ -74,9 +74,9 @@ assign_initial_position(LPoint3f& pos) { while (t == 0.0f) t = NORMALIZED_RAND(); - float pos_x = r * cosf(theta) * t; - float pos_y = r * sinf(theta) * t; - float pos_z = z * t; + PN_stdfloat pos_x = r * cosf(theta) * t; + PN_stdfloat pos_y = r * sinf(theta) * t; + PN_stdfloat pos_z = z * t; _particle_pos.set(pos_x, pos_y, pos_z); pos = _particle_pos; @@ -88,7 +88,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void SphereVolumeEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { // set velocity to [0..1] according to distance from center, // along vector from center to position vel = _particle_pos / _radius; diff --git a/panda/src/particlesystem/sphereVolumeEmitter.h b/panda/src/particlesystem/sphereVolumeEmitter.h index 809d513217..a3992e5c1c 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.h +++ b/panda/src/particlesystem/sphereVolumeEmitter.h @@ -30,25 +30,25 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_radius(float r); - INLINE float get_radius() const; + INLINE void set_radius(PN_stdfloat r); + INLINE PN_stdfloat get_radius() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - float _radius; + PN_stdfloat _radius; // CUSTOM EMISSION PARAMETERS // none /////////////////////////////// // scratch variables that carry over from position calc to velocity calc - LPoint3f _particle_pos; + LPoint3 _particle_pos; /////////////////////////////// - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "sphereVolumeEmitter.I" diff --git a/panda/src/particlesystem/spriteParticleRenderer.I b/panda/src/particlesystem/spriteParticleRenderer.I index bdc7d5ffca..aa9567661c 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.I +++ b/panda/src/particlesystem/spriteParticleRenderer.I @@ -25,13 +25,13 @@ // all previously loaded textures and animations. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_texture(Texture *tex, float texels_per_unit) { +set_texture(Texture *tex, PN_stdfloat texels_per_unit) { if (tex != (Texture *)NULL) { // Clear all texture information _anims.clear(); // Insert the single texture - _anims.push_back(new SpriteAnim(tex,TexCoordf(0.0f, 0.0f),TexCoordf(1.0f, 1.0f))); + _anims.push_back(new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f))); // We scale the particle size by the size of the texture. set_size(tex->get_x_size() / texels_per_unit, @@ -50,13 +50,13 @@ set_texture(Texture *tex, float texels_per_unit) { // a previous call to set_texture(). //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -add_texture(Texture *tex, float texels_per_unit, bool resize) { +add_texture(Texture *tex, PN_stdfloat texels_per_unit, bool resize) { if (_anims.size() == 0) { set_texture(tex, texels_per_unit); } else { if(tex != (Texture *)NULL) { if (tex != (Texture *)NULL) { - _anims.push_back(new SpriteAnim(tex,TexCoordf(0.0f, 0.0f),TexCoordf(1.0f, 1.0f))); + _anims.push_back(new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f))); } if(resize) { // We scale the particle size by the size of the texture. @@ -99,7 +99,7 @@ remove_animation(const int n) { // to use only a portion of the texture. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_ll_uv(const TexCoordf &ll_uv) { +set_ll_uv(const LTexCoord &ll_uv) { set_ll_uv(ll_uv,0,0); } @@ -112,7 +112,7 @@ set_ll_uv(const TexCoordf &ll_uv) { // to use only a portion of the texture. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_ll_uv(const TexCoordf &ll_uv, const int anim, const int frame) { +set_ll_uv(const LTexCoord &ll_uv, const int anim, const int frame) { if(anim < (int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) { _anims[anim]->set_ll(frame,ll_uv); } @@ -127,7 +127,7 @@ set_ll_uv(const TexCoordf &ll_uv, const int anim, const int frame) { // to use only a portion of the texture. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_ur_uv(const TexCoordf &ur_uv) { +set_ur_uv(const LTexCoord &ur_uv) { set_ur_uv(ur_uv,0,0); } @@ -140,7 +140,7 @@ set_ur_uv(const TexCoordf &ur_uv) { // to use only a portion of the texture. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_ur_uv(const TexCoordf &ur_uv, const int anim, const int frame) { +set_ur_uv(const LTexCoord &ur_uv, const int anim, const int frame) { if(anim < (int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) { _anims[anim]->set_ur(frame,ur_uv); } @@ -152,7 +152,7 @@ set_ur_uv(const TexCoordf &ur_uv, const int anim, const int frame) { // Description : Sets the size of each particle in world units. //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_size(float width, float height) { +set_size(PN_stdfloat width, PN_stdfloat height) { _width = width; _height = height; init_geoms(); @@ -163,7 +163,7 @@ set_size(float width, float height) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; _color_interpolation_manager->set_default_color(_color); } @@ -203,7 +203,7 @@ set_anim_angle_flag(bool animate_theta) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_initial_x_scale(float initial_x_scale) { +set_initial_x_scale(PN_stdfloat initial_x_scale) { _initial_x_scale = initial_x_scale; init_geoms(); } @@ -213,7 +213,7 @@ set_initial_x_scale(float initial_x_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_final_x_scale(float final_x_scale) { +set_final_x_scale(PN_stdfloat final_x_scale) { _final_x_scale = final_x_scale; } @@ -222,7 +222,7 @@ set_final_x_scale(float final_x_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_initial_y_scale(float initial_y_scale) { +set_initial_y_scale(PN_stdfloat initial_y_scale) { _initial_y_scale = initial_y_scale; init_geoms(); } @@ -232,7 +232,7 @@ set_initial_y_scale(float initial_y_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_final_y_scale(float final_y_scale) { +set_final_y_scale(PN_stdfloat final_y_scale) { _final_y_scale = final_y_scale; } @@ -241,7 +241,7 @@ set_final_y_scale(float final_y_scale) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_nonanimated_theta(float theta) { +set_nonanimated_theta(PN_stdfloat theta) { _theta = theta; init_geoms(); } @@ -278,7 +278,7 @@ set_animate_frames_enable(bool an) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void SpriteParticleRenderer:: -set_animate_frames_rate(float r) { +set_animate_frames_rate(PN_stdfloat r) { nassertv( r >= 0.0); _animate_frames_rate = r; } @@ -343,7 +343,7 @@ get_last_anim() const { // Description : Returns the UV coordinate of the lower-left corner; // see set_ll_uv(). //////////////////////////////////////////////////////////////////// -INLINE TexCoordf SpriteParticleRenderer:: +INLINE LTexCoord SpriteParticleRenderer:: get_ll_uv() const { return get_ll_uv(0,0); } @@ -354,7 +354,7 @@ get_ll_uv() const { // Description : Returns the UV coordinate of the lower-left corner; // see set_ll_uv(). //////////////////////////////////////////////////////////////////// -INLINE TexCoordf SpriteParticleRenderer:: +INLINE LTexCoord SpriteParticleRenderer:: get_ll_uv(const int anim, const int frame) const { int a = anim < (int)_anims.size()?anim:0; int f = frame < (int)_anims[a]->get_num_frames()?frame:0; @@ -367,7 +367,7 @@ get_ll_uv(const int anim, const int frame) const { // Description : Returns the UV coordinate of the lower-left corner; // see set_ur_uv(). //////////////////////////////////////////////////////////////////// -INLINE TexCoordf SpriteParticleRenderer:: +INLINE LTexCoord SpriteParticleRenderer:: get_ur_uv() const { return get_ur_uv(0,0); } @@ -378,7 +378,7 @@ get_ur_uv() const { // Description : Returns the UV coordinate of the upper-right corner; // see set_ur_uv(). //////////////////////////////////////////////////////////////////// -INLINE TexCoordf SpriteParticleRenderer:: +INLINE LTexCoord SpriteParticleRenderer:: get_ur_uv(const int anim, const int frame) const { int a = anim < (int)_anims.size()?anim:0; int f = frame < (int)_anims[a]->get_num_frames()?frame:0; @@ -390,7 +390,7 @@ get_ur_uv(const int anim, const int frame) const { // Access : public // Description : Returns the width of each particle in world units. //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_width() const { return _width; } @@ -400,7 +400,7 @@ get_width() const { // Access : public // Description : Returns the height of each particle in world units. //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_height() const { return _height; } @@ -409,7 +409,7 @@ get_height() const { // Function : SpriteParticleRenderer::get_color // Access : public //////////////////////////////////////////////////////////////////// -INLINE Colorf SpriteParticleRenderer:: +INLINE LColor SpriteParticleRenderer:: get_color() const { return _color; } @@ -445,7 +445,7 @@ get_anim_angle_flag() const { // Function : SpriteParticleRenderer::get_initial_x_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_initial_x_scale() const { return _initial_x_scale; } @@ -454,7 +454,7 @@ get_initial_x_scale() const { // Function : SpriteParticleRenderer::get_final_x_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_final_x_scale() const { return _final_x_scale; } @@ -463,7 +463,7 @@ get_final_x_scale() const { // Function : SpriteParticleRenderer::get_initial_y_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_initial_y_scale() const { return _initial_y_scale; } @@ -472,7 +472,7 @@ get_initial_y_scale() const { // Function : SpriteParticleRenderer::get_final_y_scale // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_final_y_scale() const { return _final_y_scale; } @@ -481,7 +481,7 @@ get_final_y_scale() const { // Function : SpriteParticleRenderer::get_nonanimated_theta // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_nonanimated_theta() const { return _theta; } @@ -517,7 +517,7 @@ get_animate_frames_enable() const { // Function : SpriteParticleRenderer::get_animate_frames_rate // Access : public //////////////////////////////////////////////////////////////////// -INLINE float SpriteParticleRenderer:: +INLINE PN_stdfloat SpriteParticleRenderer:: get_animate_frames_rate() const { return _animate_frames_rate; } diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index ee1ef837ff..7ddff5df5e 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -41,7 +41,7 @@ PStatCollector SpriteParticleRenderer::_render_collector("App:Particles:Sprite:R SpriteParticleRenderer:: SpriteParticleRenderer(Texture *tex) : BaseParticleRenderer(PR_ALPHA_NONE), - _color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), + _color(LColor(1.0f, 1.0f, 1.0f, 1.0f)), _height(1.0f), _width(1.0f), _initial_x_scale(1.0f), @@ -297,7 +297,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { // Load the found textures into the renderer. if (extract_textures_from_node(node_path,np_col,tex_col)) { - pvector< TexCoordf > ll,ur; + pvector< LTexCoord > ll,ur; GeomNode *gnode = NULL; const Geom *geom; const GeomPrimitive *primitive; @@ -311,8 +311,8 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { geom = gnode->get_geom(0); bool got_texcoord = false; - TexCoordf min_uv(0.0f, 0.0f); - TexCoordf max_uv(0.0f, 0.0f); + LTexCoord min_uv(0.0f, 0.0f); + LTexCoord max_uv(0.0f, 0.0f); GeomVertexReader texcoord(geom->get_vertex_data(), InternalName::get_texcoord()); @@ -324,11 +324,11 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { texcoord.set_row_unsafe(vert); if (!got_texcoord) { - min_uv = max_uv = texcoord.get_data2f(); + min_uv = max_uv = texcoord.get_data2(); got_texcoord = true; } else { - const LVecBase2f &uv = texcoord.get_data2f(); + const LVecBase2 &uv = texcoord.get_data2(); min_uv[0] = min(min_uv[0], uv[0]); max_uv[0] = max(max_uv[0], uv[0]); @@ -355,8 +355,8 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { geom = gnode->get_geom(0); bool got_vertex = false; - Vertexf min_xyz(0.0f, 0.0f, 0.0f); - Vertexf max_xyz(0.0f, 0.0f, 0.0f); + LVertex min_xyz(0.0f, 0.0f, 0.0f); + LVertex max_xyz(0.0f, 0.0f, 0.0f); GeomVertexReader vertex(geom->get_vertex_data(), InternalName::get_vertex()); @@ -368,11 +368,11 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { vertex.set_row_unsafe(vert); if (!got_vertex) { - min_xyz = max_xyz = vertex.get_data3f(); + min_xyz = max_xyz = vertex.get_data3(); got_vertex = true; } else { - const LVecBase3f &xyz = vertex.get_data3f(); + const LVecBase3 &xyz = vertex.get_data3(); min_xyz[0] = min(min_xyz[0], xyz[0]); max_xyz[0] = max(max_xyz[0], xyz[0]); @@ -386,14 +386,14 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { } if (got_vertex) { - float width = max_xyz[0] - min_xyz[0]; - float height = max(max_xyz[1] - min_xyz[1], + PN_stdfloat width = max_xyz[0] - min_xyz[0]; + PN_stdfloat height = max(max_xyz[1] - min_xyz[1], max_xyz[2] - min_xyz[2]); if (size_from_texels) { // If size_from_texels is true, we get the particle size from the // number of texels in the source image. - float y_texels = _anims[0]->get_frame(0)->get_y_size() * fabs(_anims[0]->get_ur(0)[1] - _anims[0]->get_ll(0)[1]); + PN_stdfloat y_texels = _anims[0]->get_frame(0)->get_y_size() * fabs(_anims[0]->get_ur(0)[1] - _anims[0]->get_ll(0)[1]); set_size(y_texels * width / height, y_texels); } else { // If size_from_texels is false, we get the particle size from @@ -439,30 +439,30 @@ init_geoms() { // Setup format PT(GeomVertexArrayFormat) array_format = new GeomVertexArrayFormat - (InternalName::get_vertex(), 3, Geom::NT_float32, Geom::C_point, + (InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point, InternalName::get_color(), 1, Geom::NT_packed_dabc, Geom::C_color); if (_animate_theta || _theta != 0.0f) { array_format->add_column - (InternalName::get_rotate(), 1, Geom::NT_float32, Geom::C_other); + (InternalName::get_rotate(), 1, Geom::NT_stdfloat, Geom::C_other); } _base_y_scale = _initial_y_scale; _aspect_ratio = _width / _height; - float final_x_scale = _animate_x_ratio ? _final_x_scale : _initial_x_scale; - float final_y_scale = _animate_y_ratio ? _final_y_scale : _initial_y_scale; + PN_stdfloat final_x_scale = _animate_x_ratio ? _final_x_scale : _initial_x_scale; + PN_stdfloat final_y_scale = _animate_y_ratio ? _final_y_scale : _initial_y_scale; if (_animate_y_ratio) { _base_y_scale = max(_initial_y_scale, _final_y_scale); array_format->add_column - (InternalName::get_size(), 1, Geom::NT_float32, Geom::C_other); + (InternalName::get_size(), 1, Geom::NT_stdfloat, Geom::C_other); } if (_aspect_ratio * _initial_x_scale != _initial_y_scale || _aspect_ratio * final_x_scale != final_y_scale) { array_format->add_column - (InternalName::get_aspect_ratio(), 1, Geom::NT_float32, + (InternalName::get_aspect_ratio(), 1, Geom::NT_stdfloat, Geom::C_other); } @@ -515,9 +515,9 @@ init_geoms() { // Build a transform to convert the texture coordinates to the // ll, ur space. - LPoint2f ul(anim->get_ll(j)[0], anim->get_ur(j)[1]); - LPoint2f lr(anim->get_ur(j)[0], anim->get_ll(j)[1]); - LVector2f sc = lr - ul; + LPoint2 ul(anim->get_ll(j)[0], anim->get_ur(j)[1]); + LPoint2 lr(anim->get_ur(j)[0], anim->get_ll(j)[1]); + LVector2 sc = lr - ul; CPT(TransformState) ts = TransformState::make_pos_rotate_scale2d(ul, 0.0f, sc); state = state->add_attrib(TexMatrixAttrib::make(TextureStage::get_default(), ts)); @@ -619,7 +619,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { continue; } - LPoint3f position = cur_particle->get_position(); + LPoint3 position = cur_particle->get_position(); // x aabb adjust if (position[0] > _aabb_max[0]) @@ -640,7 +640,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { _aabb_min[2] = position[2]; - float t = cur_particle->get_parameterized_age(); + PN_stdfloat t = cur_particle->get_parameterized_age(); int anim_index = cur_particle->get_index(); // If an animation has been removed, we need to reassign @@ -668,7 +668,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { // Calculate the color // This is where we'll want to give the renderer the new color - Colorf c = _color_interpolation_manager->generateColor(t); + LColor c = _color_interpolation_manager->generateColor(t); int alphamode=get_alpha_mode(); if (alphamode != PR_ALPHA_NONE) { @@ -686,11 +686,11 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { } // Send the data on its way... - _sprite_writer[anim_index][frame].vertex.add_data3f(position); - _sprite_writer[anim_index][frame].color.add_data4f(c); + _sprite_writer[anim_index][frame].vertex.add_data3(position); + _sprite_writer[anim_index][frame].color.add_data4(c); - float current_x_scale = _initial_x_scale; - float current_y_scale = _initial_y_scale; + PN_stdfloat current_x_scale = _initial_x_scale; + PN_stdfloat current_y_scale = _initial_y_scale; if (_animate_x_ratio || _animate_y_ratio) { if (_blend_method == PP_BLEND_CUBIC) { @@ -757,8 +757,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { } // done filling geompoint node, now do the bb stuff - LPoint3f aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); - float radius = (aabb_center - _aabb_min).length(); + LPoint3 aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f); + PN_stdfloat radius = (aabb_center - _aabb_min).length(); for (i = 0; i < anim_count; ++i) { for (j = 0; j < _anim_size[i]; ++j) { diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index 30934308f0..7c954bc06e 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -112,13 +112,13 @@ PUBLISHED: } public: - SpriteAnim(Texture* t, TexCoordf ll, TexCoordf ur) { + SpriteAnim(Texture* t, LTexCoord ll, LTexCoord ur) { textures.push_back(t); this->ll.push_back(ll); this->ur.push_back(ur); }; - SpriteAnim(const TextureCollection &t, const pvector< TexCoordf > &lls, const pvector< TexCoordf > &urs) : + SpriteAnim(const TextureCollection &t, const pvector< LTexCoord > &lls, const pvector< LTexCoord > &urs) : ll(lls), ur(urs) { for (int i = 0; i < t.get_num_textures(); ++i) { @@ -126,11 +126,11 @@ public: } }; - void set_ll(const int n, TexCoordf c) { + void set_ll(const int n, LTexCoord c) { ll[n] = c; } - void set_ur(const int n, TexCoordf c) { + void set_ur(const int n, LTexCoord c) { ur[n] = c; } @@ -138,17 +138,17 @@ public: return textures[n]; }; - TexCoordf get_ll(const int n) const { + LTexCoord get_ll(const int n) const { return ll[n]; } - TexCoordf get_ur(const int n) const { + LTexCoord get_ur(const int n) const { return ur[n]; } private: pvector< PT(Texture) > textures; - pvector< TexCoordf > ll,ur; + pvector< LTexCoord > ll,ur; SourceType _source_type; string _source_tex,_source_model,_source_node; }; @@ -173,27 +173,27 @@ PUBLISHED: void add_from_node(const NodePath &node_path, bool size_from_texels = false, bool resize = false); void add_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels = false, bool resize = false); - INLINE void set_texture(Texture *tex, float texels_per_unit = 1.0f); - INLINE void add_texture(Texture *tex, float texels_per_unit = 1.0f, bool resize = false); + INLINE void set_texture(Texture *tex, PN_stdfloat texels_per_unit = 1.0f); + INLINE void add_texture(Texture *tex, PN_stdfloat texels_per_unit = 1.0f, bool resize = false); INLINE void remove_animation(const int n); - INLINE void set_ll_uv(const TexCoordf &ll_uv); - INLINE void set_ll_uv(const TexCoordf &ll_uv, const int anim, const int frame); - INLINE void set_ur_uv(const TexCoordf &ur_uv); - INLINE void set_ur_uv(const TexCoordf &ur_uv, const int anim, const int frame); - INLINE void set_size(float width, float height); - INLINE void set_color(const Colorf &color); + INLINE void set_ll_uv(const LTexCoord &ll_uv); + INLINE void set_ll_uv(const LTexCoord &ll_uv, const int anim, const int frame); + INLINE void set_ur_uv(const LTexCoord &ur_uv); + INLINE void set_ur_uv(const LTexCoord &ur_uv, const int anim, const int frame); + INLINE void set_size(PN_stdfloat width, PN_stdfloat height); + INLINE void set_color(const LColor &color); INLINE void set_x_scale_flag(bool animate_x_ratio); INLINE void set_y_scale_flag(bool animate_y_ratio); INLINE void set_anim_angle_flag(bool animate_theta); - INLINE void set_initial_x_scale(float initial_x_scale); - INLINE void set_final_x_scale(float final_x_scale); - INLINE void set_initial_y_scale(float initial_y_scale); - INLINE void set_final_y_scale(float final_y_scale); - INLINE void set_nonanimated_theta(float theta); + INLINE void set_initial_x_scale(PN_stdfloat initial_x_scale); + INLINE void set_final_x_scale(PN_stdfloat final_x_scale); + INLINE void set_initial_y_scale(PN_stdfloat initial_y_scale); + INLINE void set_final_y_scale(PN_stdfloat final_y_scale); + INLINE void set_nonanimated_theta(PN_stdfloat theta); INLINE void set_alpha_blend_method(ParticleRendererBlendMethod bm); INLINE void set_alpha_disable(bool ad); INLINE void set_animate_frames_enable(bool an); - INLINE void set_animate_frames_rate(float r); + INLINE void set_animate_frames_rate(PN_stdfloat r); INLINE void set_animate_frames_index(int i); INLINE Texture *get_texture() const; @@ -203,25 +203,25 @@ PUBLISHED: MAKE_SEQ(get_anims, get_num_anims, get_anim); INLINE SpriteAnim *get_last_anim() const; INLINE ColorInterpolationManager* get_color_interpolation_manager() const; - INLINE TexCoordf get_ll_uv() const; - INLINE TexCoordf get_ll_uv(const int anim, const int frame) const; - INLINE TexCoordf get_ur_uv() const; - INLINE TexCoordf get_ur_uv(const int anim, const int frame) const; - INLINE float get_width() const; - INLINE float get_height() const; - INLINE Colorf get_color() const; + INLINE LTexCoord get_ll_uv() const; + INLINE LTexCoord get_ll_uv(const int anim, const int frame) const; + INLINE LTexCoord get_ur_uv() const; + INLINE LTexCoord get_ur_uv(const int anim, const int frame) const; + INLINE PN_stdfloat get_width() const; + INLINE PN_stdfloat get_height() const; + INLINE LColor get_color() const; INLINE bool get_x_scale_flag() const; INLINE bool get_y_scale_flag() const; INLINE bool get_anim_angle_flag() const; - INLINE float get_initial_x_scale() const; - INLINE float get_final_x_scale() const; - INLINE float get_initial_y_scale() const; - INLINE float get_final_y_scale() const; - INLINE float get_nonanimated_theta() const; + INLINE PN_stdfloat get_initial_x_scale() const; + INLINE PN_stdfloat get_final_x_scale() const; + INLINE PN_stdfloat get_initial_y_scale() const; + INLINE PN_stdfloat get_final_y_scale() const; + INLINE PN_stdfloat get_nonanimated_theta() const; INLINE ParticleRendererBlendMethod get_alpha_blend_method() const; INLINE bool get_alpha_disable() const; INLINE bool get_animate_frames_enable() const; - INLINE float get_animate_frames_rate() const; + INLINE PN_stdfloat get_animate_frames_rate() const; INLINE int get_animate_frames_index() const; virtual void output(ostream &out) const; @@ -235,18 +235,18 @@ private: pvector< PT(SpriteAnim) > _anims; // Stores texture references and UV info for each geom. - Colorf _color; + LColor _color; - float _height; - float _width; - float _initial_x_scale; - float _final_x_scale; - float _initial_y_scale; - float _final_y_scale; - float _theta; - float _base_y_scale; - float _aspect_ratio; - float _animate_frames_rate; + PN_stdfloat _height; + PN_stdfloat _width; + PN_stdfloat _initial_x_scale; + PN_stdfloat _final_x_scale; + PN_stdfloat _initial_y_scale; + PN_stdfloat _final_y_scale; + PN_stdfloat _theta; + PN_stdfloat _base_y_scale; + PN_stdfloat _aspect_ratio; + PN_stdfloat _animate_frames_rate; int _animate_frames_index; bool _animate_x_ratio; @@ -259,8 +259,8 @@ private: ParticleRendererBlendMethod _blend_method; PT(ColorInterpolationManager) _color_interpolation_manager; - Vertexf _aabb_min; - Vertexf _aabb_max; + LVertex _aabb_min; + LVertex _aabb_max; int _pool_size; diff --git a/panda/src/particlesystem/tangentRingEmitter.I b/panda/src/particlesystem/tangentRingEmitter.I index f794f15ea7..9d4bc86787 100644 --- a/panda/src/particlesystem/tangentRingEmitter.I +++ b/panda/src/particlesystem/tangentRingEmitter.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void TangentRingEmitter:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -26,7 +26,7 @@ set_radius(float r) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void TangentRingEmitter:: -set_radius_spread(float spread) { +set_radius_spread(PN_stdfloat spread) { _radius_spread = spread; } @@ -34,7 +34,7 @@ set_radius_spread(float spread) { // Function : get_radius // Access : public //////////////////////////////////////////////////////////////////// -INLINE float TangentRingEmitter:: +INLINE PN_stdfloat TangentRingEmitter:: get_radius() const { return _radius; } @@ -43,7 +43,7 @@ get_radius() const { // Function : get_radius_spread // Access : public //////////////////////////////////////////////////////////////////// -INLINE float TangentRingEmitter:: +INLINE PN_stdfloat TangentRingEmitter:: get_radius_spread() const { return _radius_spread; } diff --git a/panda/src/particlesystem/tangentRingEmitter.cxx b/panda/src/particlesystem/tangentRingEmitter.cxx index 9d67f421bc..0f23472586 100644 --- a/panda/src/particlesystem/tangentRingEmitter.cxx +++ b/panda/src/particlesystem/tangentRingEmitter.cxx @@ -62,13 +62,13 @@ make_copy() { // Description : Generates a location for a new particle //////////////////////////////////////////////////////////////////// void TangentRingEmitter:: -assign_initial_position(LPoint3f& pos) { - float theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; +assign_initial_position(LPoint3& pos) { + PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; _x = cosf(theta); _y = sinf(theta); - float new_radius = _radius + SPREAD(_radius_spread); + PN_stdfloat new_radius = _radius + SPREAD(_radius_spread); pos.set(new_radius * _x, new_radius * _y, 0.0f); } @@ -78,7 +78,7 @@ assign_initial_position(LPoint3f& pos) { // Description : Generates a velocity for a new particle //////////////////////////////////////////////////////////////////// void TangentRingEmitter:: -assign_initial_velocity(LVector3f& vel) { +assign_initial_velocity(LVector3& vel) { vel.set(-_y, _x, 0.0f); } diff --git a/panda/src/particlesystem/tangentRingEmitter.h b/panda/src/particlesystem/tangentRingEmitter.h index 45f9ea1ebc..20bf70abc7 100644 --- a/panda/src/particlesystem/tangentRingEmitter.h +++ b/panda/src/particlesystem/tangentRingEmitter.h @@ -31,30 +31,30 @@ PUBLISHED: virtual BaseParticleEmitter *make_copy(); - INLINE void set_radius(float r); - INLINE void set_radius_spread(float spread); + INLINE void set_radius(PN_stdfloat r); + INLINE void set_radius_spread(PN_stdfloat spread); - INLINE float get_radius() const; - INLINE float get_radius_spread() const; + INLINE PN_stdfloat get_radius() const; + INLINE PN_stdfloat get_radius_spread() const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; private: - float _radius; - float _radius_spread; + PN_stdfloat _radius; + PN_stdfloat _radius_spread; // CUSTOM EMISSION PARAMETERS // none /////////////////////////////// // scratch variables that carry over from position calc to velocity calc - float _x; - float _y; + PN_stdfloat _x; + PN_stdfloat _y; /////////////////////////////// - virtual void assign_initial_position(LPoint3f& pos); - virtual void assign_initial_velocity(LVector3f& vel); + virtual void assign_initial_position(LPoint3& pos); + virtual void assign_initial_velocity(LVector3& vel); }; #include "tangentRingEmitter.I" diff --git a/panda/src/particlesystem/zSpinParticle.I b/panda/src/particlesystem/zSpinParticle.I index 7c392a94d6..75fd050591 100644 --- a/panda/src/particlesystem/zSpinParticle.I +++ b/panda/src/particlesystem/zSpinParticle.I @@ -17,7 +17,7 @@ // Description : accessor //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticle:: -set_initial_angle(float t) { +set_initial_angle(PN_stdfloat t) { _initial_angle = t; } @@ -25,7 +25,7 @@ set_initial_angle(float t) { // Function : get_initial_angle // Description : accessor //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticle:: +INLINE PN_stdfloat ZSpinParticle:: get_initial_angle() const { return _initial_angle; } @@ -35,7 +35,7 @@ get_initial_angle() const { // Description : accessor //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticle:: -set_final_angle(float t) { +set_final_angle(PN_stdfloat t) { _final_angle = t; } @@ -43,18 +43,18 @@ set_final_angle(float t) { // Function : get_final_angle // Description : accessor //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticle:: +INLINE PN_stdfloat ZSpinParticle:: get_final_angle() const { return _final_angle; } -INLINE float ZSpinParticle:: +INLINE PN_stdfloat ZSpinParticle:: get_angular_velocity() const { return _angular_velocity; } INLINE void ZSpinParticle:: -set_angular_velocity(float v) { +set_angular_velocity(PN_stdfloat v) { _angular_velocity = v; } diff --git a/panda/src/particlesystem/zSpinParticle.cxx b/panda/src/particlesystem/zSpinParticle.cxx index 4e4bd7e3d4..f311d0cb55 100644 --- a/panda/src/particlesystem/zSpinParticle.cxx +++ b/panda/src/particlesystem/zSpinParticle.cxx @@ -114,7 +114,7 @@ die() { // Access : public, virtual // Description : //////////////////////////////////////////////////////////////////// -float ZSpinParticle:: +PN_stdfloat ZSpinParticle:: get_theta() const { return _cur_angle; } diff --git a/panda/src/particlesystem/zSpinParticle.h b/panda/src/particlesystem/zSpinParticle.h index 21a8a531bc..521df2ee7d 100644 --- a/panda/src/particlesystem/zSpinParticle.h +++ b/panda/src/particlesystem/zSpinParticle.h @@ -37,18 +37,18 @@ public: virtual void update(); virtual void die(); - virtual float get_theta() const; + virtual PN_stdfloat get_theta() const; - INLINE void set_initial_angle(float t); - INLINE float get_initial_angle() const; + INLINE void set_initial_angle(PN_stdfloat t); + INLINE PN_stdfloat get_initial_angle() const; - INLINE void set_final_angle(float t); - INLINE float get_final_angle() const; + INLINE void set_final_angle(PN_stdfloat t); + INLINE PN_stdfloat get_final_angle() const; // 'set_final_angle' and 'angular_velocity' are mutually exclusive apis // if angular-velocity is specified, final_angle is ignored - INLINE void set_angular_velocity(float v); - INLINE float get_angular_velocity() const; + INLINE void set_angular_velocity(PN_stdfloat v); + INLINE PN_stdfloat get_angular_velocity() const; INLINE void enable_angular_velocity(bool bEnabled); INLINE bool get_angular_velocity_enabled() const; @@ -57,10 +57,10 @@ public: virtual void write(ostream &out, int indent=0) const; private: - float _initial_angle; - float _final_angle; - float _cur_angle; - float _angular_velocity; + PN_stdfloat _initial_angle; + PN_stdfloat _final_angle; + PN_stdfloat _cur_angle; + PN_stdfloat _angular_velocity; bool _bUseAngularVelocity; }; diff --git a/panda/src/particlesystem/zSpinParticleFactory.I b/panda/src/particlesystem/zSpinParticleFactory.I index fa6e2fbb78..365e0aabf0 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.I +++ b/panda/src/particlesystem/zSpinParticleFactory.I @@ -18,7 +18,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticleFactory:: -set_initial_angle(float angle) { +set_initial_angle(PN_stdfloat angle) { _initial_angle = angle; } @@ -27,7 +27,7 @@ set_initial_angle(float angle) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticleFactory:: -set_final_angle(float angle) { +set_final_angle(PN_stdfloat angle) { _final_angle = angle; } @@ -36,7 +36,7 @@ set_final_angle(float angle) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticleFactory:: -set_initial_angle_spread(float spread) { +set_initial_angle_spread(PN_stdfloat spread) { _initial_angle_spread = spread; } @@ -45,7 +45,7 @@ set_initial_angle_spread(float spread) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void ZSpinParticleFactory:: -set_final_angle_spread(float spread) { +set_final_angle_spread(PN_stdfloat spread) { _final_angle_spread = spread; } @@ -53,7 +53,7 @@ set_final_angle_spread(float spread) { // Function : get_initial_angle // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_initial_angle() const { return _initial_angle; } @@ -62,7 +62,7 @@ get_initial_angle() const { // Function : get_final_angle // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_final_angle() const { return _final_angle; } @@ -71,7 +71,7 @@ get_final_angle() const { // Function : get_initial_angle_spread // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_initial_angle_spread() const { return _initial_angle_spread; } @@ -80,7 +80,7 @@ get_initial_angle_spread() const { // Function : get_final_angle_spread // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_final_angle_spread() const { return _final_angle_spread; } @@ -89,23 +89,23 @@ get_final_angle_spread() const { // Function : get_angular_velocity // Access : public //////////////////////////////////////////////////////////////////// -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_angular_velocity() const { return _angular_velocity; } INLINE void ZSpinParticleFactory:: -set_angular_velocity(float v) { +set_angular_velocity(PN_stdfloat v) { _angular_velocity = v; } -INLINE float ZSpinParticleFactory:: +INLINE PN_stdfloat ZSpinParticleFactory:: get_angular_velocity_spread() const { return _angular_velocity_spread; } INLINE void ZSpinParticleFactory:: -set_angular_velocity_spread(float spread) { +set_angular_velocity_spread(PN_stdfloat spread) { _angular_velocity_spread = spread; } diff --git a/panda/src/particlesystem/zSpinParticleFactory.h b/panda/src/particlesystem/zSpinParticleFactory.h index 8287822942..215297c0dd 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.h +++ b/panda/src/particlesystem/zSpinParticleFactory.h @@ -27,21 +27,21 @@ PUBLISHED: ZSpinParticleFactory(const ZSpinParticleFactory ©); virtual ~ZSpinParticleFactory(); - INLINE void set_initial_angle(float angle); - INLINE void set_final_angle(float angle); - INLINE void set_initial_angle_spread(float spread); - INLINE void set_final_angle_spread(float spread); + INLINE void set_initial_angle(PN_stdfloat angle); + INLINE void set_final_angle(PN_stdfloat angle); + INLINE void set_initial_angle_spread(PN_stdfloat spread); + INLINE void set_final_angle_spread(PN_stdfloat spread); - INLINE float get_initial_angle() const; - INLINE float get_final_angle() const; - INLINE float get_initial_angle_spread() const; - INLINE float get_final_angle_spread() const; + INLINE PN_stdfloat get_initial_angle() const; + INLINE PN_stdfloat get_final_angle() const; + INLINE PN_stdfloat get_initial_angle_spread() const; + INLINE PN_stdfloat get_final_angle_spread() const; - INLINE void set_angular_velocity(float v); - INLINE float get_angular_velocity() const; + INLINE void set_angular_velocity(PN_stdfloat v); + INLINE PN_stdfloat get_angular_velocity() const; - INLINE void set_angular_velocity_spread(float spread); - INLINE float get_angular_velocity_spread() const; + INLINE void set_angular_velocity_spread(PN_stdfloat spread); + INLINE PN_stdfloat get_angular_velocity_spread() const; INLINE void enable_angular_velocity(bool bEnabled); INLINE bool get_angular_velocity_enabled() const; @@ -50,12 +50,12 @@ PUBLISHED: virtual void write(ostream &out, int indent=0) const; private: - float _initial_angle; - float _initial_angle_spread; - float _final_angle; - float _final_angle_spread; - float _angular_velocity; - float _angular_velocity_spread; + PN_stdfloat _initial_angle; + PN_stdfloat _initial_angle_spread; + PN_stdfloat _final_angle; + PN_stdfloat _final_angle_spread; + PN_stdfloat _angular_velocity; + PN_stdfloat _angular_velocity_spread; bool _bUseAngularVelocity; virtual void populate_child_particle(BaseParticle *bp) const; diff --git a/panda/src/pgraph/alphaTestAttrib.I b/panda/src/pgraph/alphaTestAttrib.I index 76c08ec7a3..d16bdcadcd 100644 --- a/panda/src/pgraph/alphaTestAttrib.I +++ b/panda/src/pgraph/alphaTestAttrib.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE AlphaTestAttrib:: AlphaTestAttrib(AlphaTestAttrib::PandaCompareFunc mode, - float reference_alpha) : + PN_stdfloat reference_alpha) : _mode(mode), _reference_alpha(reference_alpha) { } @@ -41,7 +41,7 @@ get_mode() const { // Access: Published // Description: Returns the alpha reference value. //////////////////////////////////////////////////////////////////// -INLINE float AlphaTestAttrib:: +INLINE PN_stdfloat AlphaTestAttrib:: get_reference_alpha() const { return _reference_alpha; } diff --git a/panda/src/pgraph/alphaTestAttrib.cxx b/panda/src/pgraph/alphaTestAttrib.cxx index 3a24417d8f..d5129478c5 100644 --- a/panda/src/pgraph/alphaTestAttrib.cxx +++ b/panda/src/pgraph/alphaTestAttrib.cxx @@ -29,7 +29,7 @@ int AlphaTestAttrib::_attrib_slot; // Description: Constructs a new AlphaTestAttrib object. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) AlphaTestAttrib:: -make(PandaCompareFunc mode, float reference_value) { +make(PandaCompareFunc mode, PN_stdfloat reference_value) { assert((reference_value >=0.0f) && (reference_value <=1.0f)); AlphaTestAttrib *attrib = new AlphaTestAttrib(mode,reference_value); return return_new(attrib); @@ -130,7 +130,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); dg.add_int8(_mode); - dg.add_float32(_reference_alpha); + dg.add_stdfloat(_reference_alpha); } //////////////////////////////////////////////////////////////////// @@ -165,5 +165,5 @@ fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); _mode = (PandaCompareFunc)scan.get_int8(); - _reference_alpha = scan.get_float32(); + _reference_alpha = scan.get_stdfloat(); } diff --git a/panda/src/pgraph/alphaTestAttrib.h b/panda/src/pgraph/alphaTestAttrib.h index bb3e27ffba..b47147f162 100644 --- a/panda/src/pgraph/alphaTestAttrib.h +++ b/panda/src/pgraph/alphaTestAttrib.h @@ -28,14 +28,14 @@ class FactoryParams; class EXPCL_PANDA_PGRAPH AlphaTestAttrib : public RenderAttrib { private: INLINE AlphaTestAttrib(PandaCompareFunc mode = M_always, - float reference_alpha = 1.0f); + PN_stdfloat reference_alpha = 1.0f); PUBLISHED: static CPT(RenderAttrib) make(PandaCompareFunc mode, - float reference_alpha); + PN_stdfloat reference_alpha); static CPT(RenderAttrib) make_default(); - INLINE float get_reference_alpha() const; + INLINE PN_stdfloat get_reference_alpha() const; INLINE PandaCompareFunc get_mode() const; public: @@ -47,7 +47,7 @@ protected: private: PandaCompareFunc _mode; - float _reference_alpha; // should be in range [0.0-1.0] + PN_stdfloat _reference_alpha; // should be in range [0.0-1.0] PUBLISHED: static int get_class_slot() { diff --git a/panda/src/pgraph/audioVolumeAttrib.I b/panda/src/pgraph/audioVolumeAttrib.I index d676b943ab..cfd803ffd6 100755 --- a/panda/src/pgraph/audioVolumeAttrib.I +++ b/panda/src/pgraph/audioVolumeAttrib.I @@ -58,7 +58,7 @@ has_volume() const { // Access: Published // Description: Returns the volume to be applied to sounds. //////////////////////////////////////////////////////////////////// -INLINE float AudioVolumeAttrib:: +INLINE PN_stdfloat AudioVolumeAttrib:: get_volume() const { return _volume; } diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 4cdf651d00..05f546ad55 100755 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -32,7 +32,7 @@ int AudioVolumeAttrib::_attrib_slot; // AudioVolumeAttrib object. //////////////////////////////////////////////////////////////////// AudioVolumeAttrib:: -AudioVolumeAttrib(bool off, float volume) : +AudioVolumeAttrib(bool off, PN_stdfloat volume) : _off(off), _volume(volume) { @@ -64,7 +64,7 @@ make_identity() { // audio volume should be scaled by the indicated factor. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) AudioVolumeAttrib:: -make(float volume) { +make(PN_stdfloat volume) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, volume); return return_new(attrib); } @@ -103,7 +103,7 @@ make_default() { // with the volume changed to the indicated value. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) AudioVolumeAttrib:: -set_volume(float volume) const { +set_volume(PN_stdfloat volume) const { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(*this); assert(volume >= 0.f); attrib->_volume = volume; @@ -225,7 +225,7 @@ invert_compose_impl(const RenderAttrib *other) const { } const AudioVolumeAttrib *ta; DCAST_INTO_R(ta, other, 0); - float new_volume = _volume == 0.0f ? 1.0f : ta->_volume / _volume; + PN_stdfloat new_volume = _volume == 0.0f ? 1.0f : ta->_volume / _volume; AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, new_volume); return return_new(attrib); @@ -256,7 +256,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // version. We can do this since we know that no existing bam files // have an AudioVolumeAttrib in them. dg.add_bool(_off); - dg.add_float32(_volume); + dg.add_stdfloat(_volume); } //////////////////////////////////////////////////////////////////// @@ -291,7 +291,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); _off = scan.get_bool(); - _volume = scan.get_float32(); + _volume = scan.get_stdfloat(); nassertv(_volume >= 0.f); _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f); } diff --git a/panda/src/pgraph/audioVolumeAttrib.h b/panda/src/pgraph/audioVolumeAttrib.h index 5c5132f86a..5f616425a0 100755 --- a/panda/src/pgraph/audioVolumeAttrib.h +++ b/panda/src/pgraph/audioVolumeAttrib.h @@ -29,19 +29,19 @@ class FactoryParams; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH AudioVolumeAttrib : public RenderAttrib { protected: - AudioVolumeAttrib(bool off, float volume); + AudioVolumeAttrib(bool off, PN_stdfloat volume); INLINE AudioVolumeAttrib(const AudioVolumeAttrib ©); PUBLISHED: static CPT(RenderAttrib) make_identity(); - static CPT(RenderAttrib) make(float volume); + static CPT(RenderAttrib) make(PN_stdfloat volume); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); INLINE bool is_off() const; INLINE bool has_volume() const; - INLINE float get_volume() const; - CPT(RenderAttrib) set_volume(float volume) const; + INLINE PN_stdfloat get_volume() const; + CPT(RenderAttrib) set_volume(PN_stdfloat volume) const; public: virtual void output(ostream &out) const; @@ -55,7 +55,7 @@ protected: private: bool _off; bool _has_volume; - float _volume; + PN_stdfloat _volume; static CPT(RenderAttrib) _identity_attrib; PUBLISHED: diff --git a/panda/src/pgraph/billboardEffect.I b/panda/src/pgraph/billboardEffect.I index ed0f9d8e11..9cbe4621f6 100644 --- a/panda/src/pgraph/billboardEffect.I +++ b/panda/src/pgraph/billboardEffect.I @@ -32,8 +32,8 @@ BillboardEffect() { //////////////////////////////////////////////////////////////////// INLINE CPT(RenderEffect) BillboardEffect:: make_axis() { - return make(LVector3f::up(), false, true, - 0.0f, NodePath(), LPoint3f(0.0f, 0.0f, 0.0f)); + return make(LVector3::up(), false, true, + 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } //////////////////////////////////////////////////////////////////// @@ -44,8 +44,8 @@ make_axis() { //////////////////////////////////////////////////////////////////// INLINE CPT(RenderEffect) BillboardEffect:: make_point_eye() { - return make(LVector3f::up(), true, false, - 0.0f, NodePath(), LPoint3f(0.0f, 0.0f, 0.0f)); + return make(LVector3::up(), true, false, + 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } //////////////////////////////////////////////////////////////////// @@ -56,8 +56,8 @@ make_point_eye() { //////////////////////////////////////////////////////////////////// INLINE CPT(RenderEffect) BillboardEffect:: make_point_world() { - return make(LVector3f::up(), false, false, - 0.0f, NodePath(), LPoint3f(0.0f, 0.0f, 0.0f)); + return make(LVector3::up(), false, false, + 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } //////////////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ is_off() const { // Access: Published // Description: Returns the up vector in effect for this billboard. //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &BillboardEffect:: +INLINE const LVector3 &BillboardEffect:: get_up_vector() const { return _up_vector; } @@ -118,7 +118,7 @@ get_axial_rotate() const { // rotating. This can be used to ensure the billboard // is not obscured by nearby geometry. //////////////////////////////////////////////////////////////////// -INLINE float BillboardEffect:: +INLINE PN_stdfloat BillboardEffect:: get_offset() const { return _offset; } @@ -143,7 +143,7 @@ get_look_at() const { // towards which the billboard will rotate. Normally // this is (0, 0, 0). //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &BillboardEffect:: +INLINE const LPoint3 &BillboardEffect:: get_look_at_point() const { return _look_at_point; } diff --git a/panda/src/pgraph/billboardEffect.cxx b/panda/src/pgraph/billboardEffect.cxx index dcbe6fdd59..3578014b05 100644 --- a/panda/src/pgraph/billboardEffect.cxx +++ b/panda/src/pgraph/billboardEffect.cxx @@ -31,9 +31,9 @@ TypeHandle BillboardEffect::_type_handle; // indicated properties. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) BillboardEffect:: -make(const LVector3f &up_vector, bool eye_relative, - bool axial_rotate, float offset, const NodePath &look_at, - const LPoint3f &look_at_point) { +make(const LVector3 &up_vector, bool eye_relative, + bool axial_rotate, PN_stdfloat offset, const NodePath &look_at, + const LPoint3 &look_at_point) { BillboardEffect *effect = new BillboardEffect; effect->_up_vector = up_vector; effect->_eye_relative = eye_relative; @@ -70,7 +70,7 @@ prepare_flatten_transform(const TransformState *net_transform) const { // We don't want any flatten operation to rotate the billboarded // node, since the billboard effect should eat any rotation that // comes in from above. - return net_transform->set_hpr(LVecBase3f(0, 0, 0)); + return net_transform->set_hpr(LVecBase3(0, 0, 0)); } //////////////////////////////////////////////////////////////////// @@ -89,7 +89,7 @@ output(ostream &out) const { } else { out << "(point"; } - if (!_up_vector.almost_equal(LVector3f::up())) { + if (!_up_vector.almost_equal(LVector3::up())) { out << " up " << _up_vector; } if (_eye_relative) { @@ -101,7 +101,7 @@ output(ostream &out) const { if (!_look_at.is_empty()) { out << " look at " << _look_at; } - if (!_look_at_point.almost_equal(LPoint3f(0.0f, 0.0f, 0.0f))) { + if (!_look_at_point.almost_equal(LPoint3(0.0f, 0.0f, 0.0f))) { out << " look at point " << _look_at_point; } out << ")"; @@ -274,7 +274,7 @@ compute_billboard(CPT(TransformState) &node_transform, // And then the translation gets removed from the node, but we keep // its rotation etc., which gets applied after the billboard // operation. - node_transform = node_transform->set_pos(LPoint3f(0.0f, 0.0f, 0.0f)); + node_transform = node_transform->set_pos(LPoint3(0.0f, 0.0f, 0.0f)); CPT(TransformState) rel_transform = net_transform->compose(translate)->invert_compose(camera_transform); @@ -283,10 +283,10 @@ compute_billboard(CPT(TransformState) &node_transform, return; } - const LMatrix4f &rel_mat = rel_transform->get_mat(); + const LMatrix4 &rel_mat = rel_transform->get_mat(); // Determine the look_at point in the camera space. - LVector3f camera_pos, up; + LVector3 camera_pos, up; // If this is an eye-relative Billboard, then (a) the up vector is // relative to the camera, not to the world, and (b) the look @@ -296,7 +296,7 @@ compute_billboard(CPT(TransformState) &node_transform, if (_eye_relative) { up = _up_vector * rel_mat; - camera_pos = LVector3f::forward() * rel_mat; + camera_pos = LVector3::forward() * rel_mat; } else { up = _up_vector; @@ -304,7 +304,7 @@ compute_billboard(CPT(TransformState) &node_transform, } // Now determine the rotation matrix for the Billboard. - LMatrix4f rotate; + LMatrix4 rotate; if (_axial_rotate) { heads_up(rotate, camera_pos, up); } else { @@ -314,7 +314,7 @@ compute_billboard(CPT(TransformState) &node_transform, // Also slide the billboard geometry towards the camera according to // the offset factor. if (_offset != 0.0f) { - LVector3f translate(rel_mat(3, 0), rel_mat(3, 1), rel_mat(3, 2)); + LVector3 translate(rel_mat(3, 0), rel_mat(3, 1), rel_mat(3, 2)); translate.normalize(); translate *= _offset; rotate.set_row(3, translate); @@ -348,7 +348,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { _up_vector.write_datagram(dg); dg.add_bool(_eye_relative); dg.add_bool(_axial_rotate); - dg.add_float32(_offset); + dg.add_stdfloat(_offset); _look_at_point.write_datagram(dg); // *** We don't write out the _look_at NodePath right now. Maybe @@ -390,6 +390,6 @@ fillin(DatagramIterator &scan, BamReader *manager) { _up_vector.read_datagram(scan); _eye_relative = scan.get_bool(); _axial_rotate = scan.get_bool(); - _offset = scan.get_float32(); + _offset = scan.get_stdfloat(); _look_at_point.read_datagram(scan); } diff --git a/panda/src/pgraph/billboardEffect.h b/panda/src/pgraph/billboardEffect.h index b03fd3afc3..97c941b725 100644 --- a/panda/src/pgraph/billboardEffect.h +++ b/panda/src/pgraph/billboardEffect.h @@ -32,23 +32,23 @@ private: INLINE BillboardEffect(); PUBLISHED: - static CPT(RenderEffect) make(const LVector3f &up_vector, + static CPT(RenderEffect) make(const LVector3 &up_vector, bool eye_relative, bool axial_rotate, - float offset, + PN_stdfloat offset, const NodePath &look_at, - const LPoint3f &look_at_point); + const LPoint3 &look_at_point); INLINE static CPT(RenderEffect) make_axis(); INLINE static CPT(RenderEffect) make_point_eye(); INLINE static CPT(RenderEffect) make_point_world(); INLINE bool is_off() const; - INLINE const LVector3f &get_up_vector() const; + INLINE const LVector3 &get_up_vector() const; INLINE bool get_eye_relative() const; INLINE bool get_axial_rotate() const; - INLINE float get_offset() const; + INLINE PN_stdfloat get_offset() const; INLINE const NodePath &get_look_at() const; - INLINE const LPoint3f &get_look_at_point() const; + INLINE const LPoint3 &get_look_at_point() const; public: virtual bool safe_to_transform() const; @@ -75,12 +75,12 @@ private: private: bool _off; - LVector3f _up_vector; + LVector3 _up_vector; bool _eye_relative; bool _axial_rotate; - float _offset; + PN_stdfloat _offset; NodePath _look_at; - LPoint3f _look_at_point; + LPoint3 _look_at_point; public: static void register_with_read_factory(); diff --git a/panda/src/pgraph/colorAttrib.I b/panda/src/pgraph/colorAttrib.I index 50656a169f..f420a4cced 100644 --- a/panda/src/pgraph/colorAttrib.I +++ b/panda/src/pgraph/colorAttrib.I @@ -20,7 +20,7 @@ // ColorAttrib object. //////////////////////////////////////////////////////////////////// INLINE ColorAttrib:: -ColorAttrib(ColorAttrib::Type type, const Colorf &color) : +ColorAttrib(ColorAttrib::Type type, const LColor &color) : _type(type), _color(color) { @@ -54,7 +54,7 @@ get_color_type() const { // color that will be applied to geometry. If the type // is T_vertex, this is meaningless. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &ColorAttrib:: +INLINE const LColor &ColorAttrib:: get_color() const { return _color; } diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index b260f665ff..c752838802 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -37,7 +37,7 @@ make_vertex() { if (_vertex != 0) { return _vertex; } - ColorAttrib *attrib = new ColorAttrib(T_vertex, Colorf::zero()); + ColorAttrib *attrib = new ColorAttrib(T_vertex, LColor::zero()); _vertex = return_new(attrib); return _vertex; } @@ -49,7 +49,7 @@ make_vertex() { // geometry should be rendered in the indicated color. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ColorAttrib:: -make_flat(const Colorf &color) { +make_flat(const LColor &color) { ColorAttrib *attrib = new ColorAttrib(T_flat, color); return return_new(attrib); } @@ -65,7 +65,7 @@ make_off() { if (_off != 0) { return _off; } - ColorAttrib *attrib = new ColorAttrib(T_off, Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + ColorAttrib *attrib = new ColorAttrib(T_off, LColor(1.0f, 1.0f, 1.0f, 1.0f)); _off = return_new(attrib); return _off; } @@ -215,7 +215,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { //////////////////////////////////////////////////////////////////// TypedWritable *ColorAttrib:: make_from_bam(const FactoryParams ¶ms) { - ColorAttrib *attrib = new ColorAttrib(T_off, Colorf::zero()); + ColorAttrib *attrib = new ColorAttrib(T_off, LColor::zero()); DatagramIterator scan; BamReader *manager; diff --git a/panda/src/pgraph/colorAttrib.h b/panda/src/pgraph/colorAttrib.h index 657a30e5d6..7058ee725f 100644 --- a/panda/src/pgraph/colorAttrib.h +++ b/panda/src/pgraph/colorAttrib.h @@ -34,16 +34,16 @@ PUBLISHED: }; private: - INLINE ColorAttrib(Type type, const Colorf &color); + INLINE ColorAttrib(Type type, const LColor &color); PUBLISHED: static CPT(RenderAttrib) make_vertex(); - static CPT(RenderAttrib) make_flat(const Colorf &color); + static CPT(RenderAttrib) make_flat(const LColor &color); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); INLINE Type get_color_type() const; - INLINE const Colorf &get_color() const; + INLINE const LColor &get_color() const; public: virtual void output(ostream &out) const; @@ -57,7 +57,7 @@ private: private: Type _type; - Colorf _color; + LColor _color; static CPT(RenderAttrib) _off; static CPT(RenderAttrib) _vertex; diff --git a/panda/src/pgraph/colorBlendAttrib.I b/panda/src/pgraph/colorBlendAttrib.I index 627712c6a1..99d183a12e 100644 --- a/panda/src/pgraph/colorBlendAttrib.I +++ b/panda/src/pgraph/colorBlendAttrib.I @@ -24,7 +24,7 @@ ColorBlendAttrib() : _mode(M_none), _a(O_one), _b(O_one), - _color(Colorf::zero()), + _color(LColor::zero()), _involves_constant_color(false), _involves_color_scale(false) { @@ -39,7 +39,7 @@ ColorBlendAttrib() : INLINE ColorBlendAttrib:: ColorBlendAttrib(ColorBlendAttrib::Mode mode, ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b, - const Colorf &color) : + const LColor &color) : _mode(mode), _a(a), _b(b), @@ -84,7 +84,7 @@ get_operand_b() const { // Access: Published // Description: Returns the constant color associated with the attrib. //////////////////////////////////////////////////////////////////// -INLINE Colorf ColorBlendAttrib:: +INLINE LColor ColorBlendAttrib:: get_color() const { return _color; } diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx index 0cda7a405c..b5e49cf222 100644 --- a/panda/src/pgraph/colorBlendAttrib.cxx +++ b/panda/src/pgraph/colorBlendAttrib.cxx @@ -46,7 +46,7 @@ make_off() { CPT(RenderAttrib) ColorBlendAttrib:: make(ColorBlendAttrib::Mode mode) { ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, O_one, O_one, - Colorf::zero()); + LColor::zero()); return return_new(attrib); } @@ -60,7 +60,7 @@ make(ColorBlendAttrib::Mode mode) { CPT(RenderAttrib) ColorBlendAttrib:: make(ColorBlendAttrib::Mode mode, ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b, - const Colorf &color) { + const LColor &color) { ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, a, b, color); return return_new(attrib); } diff --git a/panda/src/pgraph/colorBlendAttrib.h b/panda/src/pgraph/colorBlendAttrib.h index b7ef363ff7..ae20d1b65c 100644 --- a/panda/src/pgraph/colorBlendAttrib.h +++ b/panda/src/pgraph/colorBlendAttrib.h @@ -70,19 +70,19 @@ PUBLISHED: private: INLINE ColorBlendAttrib(); INLINE ColorBlendAttrib(Mode mode, Operand a, Operand b, - const Colorf &color); + const LColor &color); PUBLISHED: static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make(Mode mode); static CPT(RenderAttrib) make(Mode mode, Operand a, Operand b, - const Colorf &color = Colorf::zero()); + const LColor &color = LColor::zero()); static CPT(RenderAttrib) make_default(); INLINE Mode get_mode() const; INLINE Operand get_operand_a() const; INLINE Operand get_operand_b() const; - INLINE Colorf get_color() const; + INLINE LColor get_color() const; INLINE bool involves_constant_color() const; INLINE bool involves_color_scale() const; @@ -100,7 +100,7 @@ protected: private: Mode _mode; Operand _a, _b; - Colorf _color; + LColor _color; bool _involves_constant_color; bool _involves_color_scale; diff --git a/panda/src/pgraph/colorScaleAttrib.I b/panda/src/pgraph/colorScaleAttrib.I index 8708d64e45..e23b18aa5a 100644 --- a/panda/src/pgraph/colorScaleAttrib.I +++ b/panda/src/pgraph/colorScaleAttrib.I @@ -96,7 +96,7 @@ has_alpha_scale() const { // Access: Published // Description: Returns the scale to be applied to colors. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &ColorScaleAttrib:: +INLINE const LVecBase4 &ColorScaleAttrib:: get_scale() const { return _scale; } diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 972a534b49..58d6e706b1 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -32,13 +32,13 @@ CPT(RenderAttrib) ColorScaleAttrib::_identity_attrib; // ColorScaleAttrib object. //////////////////////////////////////////////////////////////////// ColorScaleAttrib:: -ColorScaleAttrib(bool off, const LVecBase4f &scale) : +ColorScaleAttrib(bool off, const LVecBase4 &scale) : _off(off), _scale(scale) { quantize_scale(); - _has_scale = !_scale.almost_equal(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)); - _has_rgb_scale = !LVecBase3f(_scale[0], _scale[1], _scale[2]).almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f)); + _has_scale = !_scale.almost_equal(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); + _has_rgb_scale = !LVecBase3(_scale[0], _scale[1], _scale[2]).almost_equal(LVecBase3(1.0f, 1.0f, 1.0f)); _has_alpha_scale = !IS_NEARLY_EQUAL(_scale[3], 1.0f); } @@ -52,7 +52,7 @@ make_identity() { // We make identity a special case and store a pointer forever once // we find it the first time. if (_identity_attrib == (ColorScaleAttrib *)NULL) { - ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f));; + ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f));; _identity_attrib = return_new(attrib); } @@ -66,7 +66,7 @@ make_identity() { // geometry should be scaled by the indicated factor. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ColorScaleAttrib:: -make(const LVecBase4f &scale) { +make(const LVecBase4 &scale) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, scale); return return_new(attrib); } @@ -82,7 +82,7 @@ make(const LVecBase4f &scale) { CPT(RenderAttrib) ColorScaleAttrib:: make_off() { ColorScaleAttrib *attrib = - new ColorScaleAttrib(true, LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)); + new ColorScaleAttrib(true, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); return return_new(attrib); } @@ -95,7 +95,7 @@ make_off() { //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ColorScaleAttrib:: make_default() { - return return_new(new ColorScaleAttrib(false, LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f))); + return return_new(new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f))); } //////////////////////////////////////////////////////////////////// @@ -105,12 +105,12 @@ make_default() { // with the scale changed to the indicated value. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ColorScaleAttrib:: -set_scale(const LVecBase4f &scale) const { +set_scale(const LVecBase4 &scale) const { ColorScaleAttrib *attrib = new ColorScaleAttrib(*this); attrib->_scale = scale; attrib->quantize_scale(); - attrib->_has_scale = !scale.almost_equal(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)); - attrib->_has_rgb_scale = !LVecBase3f(scale[0], scale[1], scale[2]).almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f)); + attrib->_has_scale = !scale.almost_equal(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); + attrib->_has_rgb_scale = !LVecBase3(scale[0], scale[1], scale[2]).almost_equal(LVecBase3(1.0f, 1.0f, 1.0f)); attrib->_has_alpha_scale = !IS_NEARLY_EQUAL(scale[3], 1.0f); return return_new(attrib); } @@ -240,7 +240,7 @@ compose_impl(const RenderAttrib *other) const { return ta; } - LVecBase4f new_scale(ta->_scale[0] * _scale[0], + LVecBase4 new_scale(ta->_scale[0] * _scale[0], ta->_scale[1] * _scale[1], ta->_scale[2] * _scale[2], ta->_scale[3] * _scale[3]); @@ -265,7 +265,7 @@ invert_compose_impl(const RenderAttrib *other) const { } const ColorScaleAttrib *ta; DCAST_INTO_R(ta, other, 0); - LVecBase4f new_scale(_scale[0] == 0.0f ? 1.0f : ta->_scale[0] / _scale[0], + LVecBase4 new_scale(_scale[0] == 0.0f ? 1.0f : ta->_scale[0] / _scale[0], _scale[1] == 0.0f ? 1.0f : ta->_scale[1] / _scale[1], _scale[2] == 0.0f ? 1.0f : ta->_scale[2] / _scale[2], _scale[3] == 0.0f ? 1.0f : ta->_scale[3] / _scale[3]); @@ -327,7 +327,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { //////////////////////////////////////////////////////////////////// TypedWritable *ColorScaleAttrib:: make_from_bam(const FactoryParams ¶ms) { - ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)); + ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); DatagramIterator scan; BamReader *manager; @@ -351,7 +351,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _off = scan.get_bool(); _scale.read_datagram(scan); quantize_scale(); - _has_scale = !_scale.almost_equal(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)); - _has_rgb_scale = !LVecBase3f(_scale[0], _scale[1], _scale[2]).almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f)); + _has_scale = !_scale.almost_equal(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); + _has_rgb_scale = !LVecBase3(_scale[0], _scale[1], _scale[2]).almost_equal(LVecBase3(1.0f, 1.0f, 1.0f)); _has_alpha_scale = !IS_NEARLY_EQUAL(_scale[3], 1.0f); } diff --git a/panda/src/pgraph/colorScaleAttrib.h b/panda/src/pgraph/colorScaleAttrib.h index fc7f025722..b98f1f87f6 100644 --- a/panda/src/pgraph/colorScaleAttrib.h +++ b/panda/src/pgraph/colorScaleAttrib.h @@ -29,12 +29,12 @@ class FactoryParams; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH ColorScaleAttrib : public RenderAttrib { protected: - ColorScaleAttrib(bool off, const LVecBase4f &scale); + ColorScaleAttrib(bool off, const LVecBase4 &scale); INLINE ColorScaleAttrib(const ColorScaleAttrib ©); PUBLISHED: static CPT(RenderAttrib) make_identity(); - static CPT(RenderAttrib) make(const LVecBase4f &scale); + static CPT(RenderAttrib) make(const LVecBase4 &scale); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); @@ -43,8 +43,8 @@ PUBLISHED: INLINE bool has_scale() const; INLINE bool has_rgb_scale() const; INLINE bool has_alpha_scale() const; - INLINE const LVecBase4f &get_scale() const; - CPT(RenderAttrib) set_scale(const LVecBase4f &scale) const; + INLINE const LVecBase4 &get_scale() const; + CPT(RenderAttrib) set_scale(const LVecBase4 &scale) const; public: virtual bool lower_attrib_can_override() const; @@ -64,7 +64,7 @@ private: bool _has_scale; bool _has_rgb_scale; bool _has_alpha_scale; - LVecBase4f _scale; + LVecBase4 _scale; static CPT(RenderAttrib) _identity_attrib; PUBLISHED: diff --git a/panda/src/pgraph/compassEffect.cxx b/panda/src/pgraph/compassEffect.cxx index 0e01844aab..f2987348c2 100644 --- a/panda/src/pgraph/compassEffect.cxx +++ b/panda/src/pgraph/compassEffect.cxx @@ -210,8 +210,8 @@ adjust_transform(CPT(TransformState) &net_transform, } else { // How much of the pos do we want to steal? We can always // determine a transform's pos, even if it's nondecomposable. - LVecBase3f want_pos = net_transform->get_pos(); - const LVecBase3f &ref_pos = ref_transform->get_pos(); + LVecBase3 want_pos = net_transform->get_pos(); + const LVecBase3 &ref_pos = ref_transform->get_pos(); if ((_properties & P_x) != 0) { want_pos[0] = ref_pos[0]; } @@ -241,13 +241,13 @@ adjust_transform(CPT(TransformState) &net_transform, } else { // If we can decompose, then take only the components we want. - LQuaternionf want_quat = net_transform->get_quat(); + LQuaternion want_quat = net_transform->get_quat(); if ((_properties & P_rot) != 0) { want_quat = ref_transform->get_quat(); } - LVecBase3f want_scale = net_transform->get_scale(); - const LVecBase3f &ref_scale = ref_transform->get_scale(); + LVecBase3 want_scale = net_transform->get_scale(); + const LVecBase3 &ref_scale = ref_transform->get_scale(); if ((_properties & P_sx) != 0) { want_scale[0] = ref_scale[0]; } diff --git a/panda/src/pgraph/cullBin.I b/panda/src/pgraph/cullBin.I index 874238d7f2..9017049980 100644 --- a/panda/src/pgraph/cullBin.I +++ b/panda/src/pgraph/cullBin.I @@ -85,7 +85,7 @@ has_flash_color() const { // Description: If has_flash_color returns true, this returns the // color specified. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &CullBin:: +INLINE const LColor &CullBin:: get_flash_color() const { return _flash_color; } diff --git a/panda/src/pgraph/cullBin.h b/panda/src/pgraph/cullBin.h index e2fa28bd80..0f813df7b1 100644 --- a/panda/src/pgraph/cullBin.h +++ b/panda/src/pgraph/cullBin.h @@ -63,7 +63,7 @@ public: PT(PandaNode) make_result_graph(); INLINE bool has_flash_color() const; - INLINE const Colorf &get_flash_color() const; + INLINE const LColor &get_flash_color() const; protected: class ResultGraphBuilder; @@ -78,7 +78,7 @@ protected: GraphicsStateGuardianBase *_gsg; bool _has_flash_color; - Colorf _flash_color; + LColor _flash_color; // Used in make_result_graph() and fill_result_graph(). class ResultGraphBuilder { diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index 07782af5ef..ae8ca10408 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -45,7 +45,7 @@ make_empty() { // modified by the indicated transform. //////////////////////////////////////////////////////////////////// CPT(CullPlanes) CullPlanes:: -xform(const LMatrix4f &mat) const { +xform(const LMatrix4 &mat) const { PT(CullPlanes) new_planes; if (get_ref_count() == 1) { new_planes = (CullPlanes *)this; @@ -121,7 +121,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, CPT(TransformState) new_transform = net_transform->invert_compose(clip_plane.get_net_transform()); - Planef plane = plane_node->get_plane() * new_transform->get_mat(); + LPlane plane = plane_node->get_plane() * new_transform->get_mat(); new_planes->_planes[clip_plane] = new BoundingPlane(-plane); } } @@ -167,20 +167,20 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, // Get a transform from the occluder directly to this node's // space for comparing with the current view frustum. CPT(TransformState) composed_transform = center_transform->compose(occluder_transform); - const LMatrix4f &composed_mat = composed_transform->get_mat(); - LPoint3f ccp[4]; + const LMatrix4 &composed_mat = composed_transform->get_mat(); + LPoint3 ccp[4]; ccp[0] = occluder_node->get_vertex(0) * composed_mat; ccp[1] = occluder_node->get_vertex(1) * composed_mat; ccp[2] = occluder_node->get_vertex(2) * composed_mat; ccp[3] = occluder_node->get_vertex(3) * composed_mat; - LPoint3f ccp_min(min(min(ccp[0][0], ccp[1][0]), + LPoint3 ccp_min(min(min(ccp[0][0], ccp[1][0]), min(ccp[2][0], ccp[3][0])), min(min(ccp[0][1], ccp[1][1]), min(ccp[2][1], ccp[3][1])), min(min(ccp[0][2], ccp[1][2]), min(ccp[2][2], ccp[3][2]))); - LPoint3f ccp_max(max(max(ccp[0][0], ccp[1][0]), + LPoint3 ccp_max(max(max(ccp[0][0], ccp[1][0]), max(ccp[2][0], ccp[3][0])), max(max(ccp[0][1], ccp[1][1]), max(ccp[2][1], ccp[3][1])), @@ -202,19 +202,19 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } // Get the occluder geometry in cull-center space. - const LMatrix4f &occluder_mat = occluder_transform->get_mat(); - LPoint3f points_near[4]; + const LMatrix4 &occluder_mat = occluder_transform->get_mat(); + LPoint3 points_near[4]; points_near[0] = occluder_node->get_vertex(0) * occluder_mat; points_near[1] = occluder_node->get_vertex(1) * occluder_mat; points_near[2] = occluder_node->get_vertex(2) * occluder_mat; points_near[3] = occluder_node->get_vertex(3) * occluder_mat; - Planef plane(points_near[0], points_near[1], points_near[2]); + LPlane plane(points_near[0], points_near[1], points_near[2]); - if (plane.get_normal().dot(LVector3f::forward()) >= 0.0) { + if (plane.get_normal().dot(LVector3::forward()) >= 0.0) { if (occluder_node->is_double_sided()) { swap(points_near[0], points_near[3]); swap(points_near[1], points_near[2]); - plane = Planef(points_near[0], points_near[1], points_near[2]); + plane = LPlane(points_near[0], points_near[1], points_near[2]); } else { // This occluder is facing the wrong direction. Ignore it. if (pgraph_cat.is_spam()) { @@ -225,8 +225,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } } - float near_clip = lens->get_near(); - if (plane.dist_to_plane(LPoint3f::zero()) <= near_clip) { + PN_stdfloat near_clip = lens->get_near(); + if (plane.dist_to_plane(LPoint3::zero()) <= near_clip) { // This occluder is behind the camera's near plane. Ignore it. if (pgraph_cat.is_spam()) { pgraph_cat.spam() @@ -235,10 +235,10 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, continue; } - float d0 = points_near[0].dot(LVector3f::forward()); - float d1 = points_near[1].dot(LVector3f::forward()); - float d2 = points_near[2].dot(LVector3f::forward()); - float d3 = points_near[3].dot(LVector3f::forward()); + PN_stdfloat d0 = points_near[0].dot(LVector3::forward()); + PN_stdfloat d1 = points_near[1].dot(LVector3::forward()); + PN_stdfloat d2 = points_near[2].dot(LVector3::forward()); + PN_stdfloat d3 = points_near[3].dot(LVector3::forward()); if (d0 <= near_clip && d1 <= near_clip && d2 <= near_clip && d3 <= near_clip) { // All four corners of the occluder are behind the camera's @@ -269,20 +269,20 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } if (occluder_node->get_min_coverage()) { - LPoint3f coords[4]; + LPoint3 coords[4]; lens->project(points_near[0], coords[0]); lens->project(points_near[1], coords[1]); lens->project(points_near[2], coords[2]); lens->project(points_near[3], coords[3]); - coords[0][0] = max(-1.f, min(1.f, coords[0][0])); - coords[0][1] = max(-1.f, min(1.f, coords[0][1])); - coords[1][0] = max(-1.f, min(1.f, coords[1][0])); - coords[1][1] = max(-1.f, min(1.f, coords[1][1])); - coords[2][0] = max(-1.f, min(1.f, coords[2][0])); - coords[2][1] = max(-1.f, min(1.f, coords[2][1])); - coords[3][0] = max(-1.f, min(1.f, coords[3][0])); - coords[3][1] = max(-1.f, min(1.f, coords[3][1])); - float coverage = ((coords[0] - coords[1]).cross(coords[0] - coords[2]).length() + coords[0][0] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[0][0])); + coords[0][1] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[0][1])); + coords[1][0] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[1][0])); + coords[1][1] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[1][1])); + coords[2][0] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[2][0])); + coords[2][1] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[2][1])); + coords[3][0] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[3][0])); + coords[3][1] = max((PN_stdfloat)-1.0, min((PN_stdfloat)1.0, coords[3][1])); + PN_stdfloat coverage = ((coords[0] - coords[1]).cross(coords[0] - coords[2]).length() + (coords[3] - coords[1]).cross(coords[3] - coords[2]).length()) * 0.125; if (coverage < occluder_node->get_min_coverage()) { @@ -319,14 +319,14 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, // occluders are fully contained within this new one. // Project those four lines to the camera's far plane. - float far_clip = scene->get_lens()->get_far(); - Planef far_plane(-LVector3f::forward(), LVector3f::forward() * far_clip); + PN_stdfloat far_clip = scene->get_lens()->get_far(); + LPlane far_plane(-LVector3::forward(), LVector3::forward() * far_clip); - LPoint3f points_far[4]; - far_plane.intersects_line(points_far[0], LPoint3f::zero(), points_near[0]); - far_plane.intersects_line(points_far[1], LPoint3f::zero(), points_near[1]); - far_plane.intersects_line(points_far[2], LPoint3f::zero(), points_near[2]); - far_plane.intersects_line(points_far[3], LPoint3f::zero(), points_near[3]); + LPoint3 points_far[4]; + far_plane.intersects_line(points_far[0], LPoint3::zero(), points_near[0]); + far_plane.intersects_line(points_far[1], LPoint3::zero(), points_near[1]); + far_plane.intersects_line(points_far[2], LPoint3::zero(), points_near[2]); + far_plane.intersects_line(points_far[3], LPoint3::zero(), points_near[3]); // With these points, construct the bounding frustum of the // occluded region. diff --git a/panda/src/pgraph/cullPlanes.h b/panda/src/pgraph/cullPlanes.h index 25dc4f77a0..0a41984ec9 100644 --- a/panda/src/pgraph/cullPlanes.h +++ b/panda/src/pgraph/cullPlanes.h @@ -56,7 +56,7 @@ public: INLINE bool is_empty() const; static CPT(CullPlanes) make_empty(); - CPT(CullPlanes) xform(const LMatrix4f &mat) const; + CPT(CullPlanes) xform(const LMatrix4 &mat) const; CPT(CullPlanes) apply_state(const CullTraverser *trav, const CullTraverserData *data, const ClipPlaneAttrib *net_attrib, diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 26112741e6..4868d46529 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -51,7 +51,7 @@ TypeHandle CullResult::_type_handle; // fractional power of two will have a terminating representation in // base 2, and thus will be more likely to have a precise value in // whatever internal representation the graphics API will use. -static const float dual_opaque_level = 252.0f / 256.0f; +static const PN_stdfloat dual_opaque_level = 252.0 / 256.0; static const double bin_color_flash_rate = 1.0; // 1 state change per second //////////////////////////////////////////////////////////////////// @@ -107,10 +107,10 @@ make_next() const { //////////////////////////////////////////////////////////////////// void CullResult:: add_object(CullableObject *object, const CullTraverser *traverser) { - static const Colorf flash_alpha_color(0.92, 0.96, 0.10, 1.0f); - static const Colorf flash_binary_color(0.21f, 0.67f, 0.24f, 1.0f); - static const Colorf flash_multisample_color(0.78f, 0.05f, 0.81f, 1.0f); - static const Colorf flash_dual_color(0.92f, 0.01f, 0.01f, 1.0f); + static const LColor flash_alpha_color(0.92, 0.96, 0.10, 1.0f); + static const LColor flash_binary_color(0.21f, 0.67f, 0.24, 1.0f); + static const LColor flash_multisample_color(0.78f, 0.05f, 0.81f, 1.0f); + static const LColor flash_dual_color(0.92, 0.01f, 0.01f, 1.0f); bool force = !traverser->get_effective_incomplete_render(); Thread *current_thread = traverser->get_current_thread(); @@ -424,7 +424,7 @@ check_flash_bin(CPT(RenderState) &state, CullBin *bin) { // geometry with the specified color. //////////////////////////////////////////////////////////////////// void CullResult:: -check_flash_transparency(CPT(RenderState) &state, const Colorf &transparency) { +check_flash_transparency(CPT(RenderState) &state, const LColor &transparency) { if (show_transparency) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); if ((cycle & 1) == 0) { @@ -470,10 +470,10 @@ get_dual_transparent_state() { if ((cycle & 1) == 0) { static CPT(RenderState) flash_state = NULL; if (flash_state == (const RenderState *)NULL) { - flash_state = state->add_attrib(ColorAttrib::make_flat(Colorf(0.8f, 0.2f, 0.2f, 1.0f)), + flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.2, 0.2, 1.0f)), RenderState::get_max_priority()); - flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)), + flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)), RenderState::get_max_priority()); flash_state = flash_state->add_attrib(AlphaTestAttrib::make(AlphaTestAttrib::M_less, 1.0f), @@ -514,9 +514,9 @@ get_dual_transparent_state_decals() { if ((cycle & 1) == 0) { static CPT(RenderState) flash_state = NULL; if (flash_state == (const RenderState *)NULL) { - flash_state = state->add_attrib(ColorAttrib::make_flat(Colorf(0.8f, 0.2f, 0.2f, 1.0f)), + flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.2, 0.2, 1.0f)), RenderState::get_max_priority()); - flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)), + flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)), RenderState::get_max_priority()); } @@ -549,9 +549,9 @@ get_dual_opaque_state() { if ((cycle & 1) == 0) { static CPT(RenderState) flash_state = NULL; if (flash_state == (const RenderState *)NULL) { - flash_state = state->add_attrib(ColorAttrib::make_flat(Colorf(0.2f, 0.2f, 0.8f, 1.0f)), + flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.2, 0.2, 0.8f, 1.0f)), RenderState::get_max_priority()); - flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)), + flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)), RenderState::get_max_priority()); } diff --git a/panda/src/pgraph/cullResult.h b/panda/src/pgraph/cullResult.h index 12922df5c5..06b7c1a17b 100644 --- a/panda/src/pgraph/cullResult.h +++ b/panda/src/pgraph/cullResult.h @@ -67,7 +67,7 @@ public: private: CullBin *make_new_bin(int bin_index); void check_flash_bin(CPT(RenderState) &state, CullBin *bin); - void check_flash_transparency(CPT(RenderState) &state, const Colorf &color); + void check_flash_transparency(CPT(RenderState) &state, const LColor &color); static CPT(RenderState) get_alpha_state(); static CPT(RenderState) get_binary_state(); diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index e3eceb5c8c..a0f5078992 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -1,5 +1,5 @@ // Filename: cullTraverser.cxx -// Created by: drose (23Feb02) +// Created by: drose (23eb02) // //////////////////////////////////////////////////////////////////// // @@ -410,15 +410,15 @@ make_bounds_viz(const BoundingVolume *vol) { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_stream); for (int sl = 0; sl < num_slices; ++sl) { - float longitude0 = (float)sl / (float)num_slices; - float longitude1 = (float)(sl + 1) / (float)num_slices; - vertex.add_data3f(compute_point(sphere, 0.0, longitude0)); + PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; + PN_stdfloat longitude1 = (PN_stdfloat)(sl + 1) / (PN_stdfloat)num_slices; + vertex.add_data3(compute_point(sphere, 0.0, longitude0)); for (int st = 1; st < num_stacks; ++st) { - float latitude = (float)st / (float)num_stacks; - vertex.add_data3f(compute_point(sphere, latitude, longitude0)); - vertex.add_data3f(compute_point(sphere, latitude, longitude1)); + PN_stdfloat latitude = (PN_stdfloat)st / (PN_stdfloat)num_stacks; + vertex.add_data3(compute_point(sphere, latitude, longitude0)); + vertex.add_data3(compute_point(sphere, latitude, longitude1)); } - vertex.add_data3f(compute_point(sphere, 1.0, longitude0)); + vertex.add_data3(compute_point(sphere, 1.0, longitude0)); strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); @@ -436,7 +436,7 @@ make_bounds_viz(const BoundingVolume *vol) { GeomVertexWriter vertex(vdata, InternalName::get_vertex()); for (int i = 0; i < 8; ++i ) { - vertex.add_data3f(fvol->get_point(i)); + vertex.add_data3(fvol->get_point(i)); } PT(GeomLines) lines = new GeomLines(Geom::UH_stream); @@ -470,7 +470,7 @@ make_bounds_viz(const BoundingVolume *vol) { GeomVertexWriter vertex(vdata, InternalName::get_vertex()); for (int i = 0; i < 8; ++i ) { - vertex.add_data3f(box.get_point(i)); + vertex.add_data3(box.get_point(i)); } PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_stream); @@ -523,7 +523,7 @@ make_tight_bounds_viz(PandaNode *node) const { NodePath np = NodePath::any_path(node); - LPoint3f n, x; + LPoint3 n, x; bool found_any = false; node->calc_tight_bounds(n, x, found_any, TransformState::make_identity(), _current_thread); @@ -534,14 +534,14 @@ make_tight_bounds_viz(PandaNode *node) const { GeomVertexWriter vertex(vdata, InternalName::get_vertex(), _current_thread); - vertex.add_data3f(n[0], n[1], n[2]); - vertex.add_data3f(n[0], n[1], x[2]); - vertex.add_data3f(n[0], x[1], n[2]); - vertex.add_data3f(n[0], x[1], x[2]); - vertex.add_data3f(x[0], n[1], n[2]); - vertex.add_data3f(x[0], n[1], x[2]); - vertex.add_data3f(x[0], x[1], n[2]); - vertex.add_data3f(x[0], x[1], x[2]); + vertex.add_data3(n[0], n[1], n[2]); + vertex.add_data3(n[0], n[1], x[2]); + vertex.add_data3(n[0], x[1], n[2]); + vertex.add_data3(n[0], x[1], x[2]); + vertex.add_data3(x[0], n[1], n[2]); + vertex.add_data3(x[0], n[1], x[2]); + vertex.add_data3(x[0], x[1], n[2]); + vertex.add_data3(x[0], x[1], x[2]); PT(GeomLinestrips) strip = new GeomLinestrips(Geom::UH_stream); @@ -578,16 +578,16 @@ make_tight_bounds_viz(PandaNode *node) const { // Description: Returns a point on the surface of the sphere. // latitude and longitude range from 0.0 to 1.0. //////////////////////////////////////////////////////////////////// -Vertexf CullTraverser:: +LVertex CullTraverser:: compute_point(const BoundingSphere *sphere, - float latitude, float longitude) { - float s1, c1; - csincos(latitude * MathNumbers::pi_f, &s1, &c1); + PN_stdfloat latitude, PN_stdfloat longitude) { + PN_stdfloat s1, c1; + csincos(latitude * MathNumbers::pi, &s1, &c1); - float s2, c2; - csincos(longitude * 2.0f * MathNumbers::pi_f, &s2, &c2); + PN_stdfloat s2, c2; + csincos(longitude * 2.0 * MathNumbers::pi, &s2, &c2); - Vertexf p(s1 * c2, s1 * s2, c1); + LVertex p(s1 * c2, s1 * s2, c1); return p * sphere->get_radius() + sphere->get_center(); } @@ -604,7 +604,7 @@ get_bounds_outer_viz_state() { static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make - (ColorAttrib::make_flat(Colorf(0.3f, 1.0f, 0.5f, 1.0f)), + (ColorAttrib::make_flat(LColor(0.3, 1.0f, 0.5f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise)); } @@ -624,7 +624,7 @@ get_bounds_inner_viz_state() { static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make - (ColorAttrib::make_flat(Colorf(0.15f, 0.5f, 0.25f, 1.0f)), + (ColorAttrib::make_flat(LColor(0.15f, 0.5f, 0.25f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), CullFaceAttrib::make(CullFaceAttrib::M_cull_counter_clockwise)); } diff --git a/panda/src/pgraph/cullTraverser.h b/panda/src/pgraph/cullTraverser.h index d0f9ad6771..5100b0e7eb 100644 --- a/panda/src/pgraph/cullTraverser.h +++ b/panda/src/pgraph/cullTraverser.h @@ -1,5 +1,5 @@ // Filename: cullTraverser.h -// Created by: drose (23Feb02) +// Created by: drose (23eb02) // //////////////////////////////////////////////////////////////////// // @@ -105,8 +105,8 @@ private: void show_bounds(CullTraverserData &data, bool tight); static PT(Geom) make_bounds_viz(const BoundingVolume *vol); PT(Geom) make_tight_bounds_viz(PandaNode *node) const; - static Vertexf compute_point(const BoundingSphere *sphere, - float latitude, float longitude); + static LVertex compute_point(const BoundingSphere *sphere, + PN_stdfloat latitude, PN_stdfloat longitude); static CPT(RenderState) get_bounds_outer_viz_state(); static CPT(RenderState) get_bounds_inner_viz_state(); static CPT(RenderState) get_depth_offset_state(); diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 47c88ff34d..5bd8619152 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -231,7 +231,7 @@ get_fake_view_frustum_cull_state() { static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make - (ColorAttrib::make_flat(Colorf(1.0f, 0.0f, 0.0f, 1.0f)), + (ColorAttrib::make_flat(LColor(1.0f, 0.0f, 0.0f, 1.0f)), TextureAttrib::make_all_off(), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), RenderState::get_max_priority()); diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 35f9278e18..4ea54f5923 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -283,7 +283,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } } - float point_size = 1.0f; + PN_stdfloat point_size = 1.0f; bool perspective = false; const RenderModeAttrib *render_mode = DCAST(RenderModeAttrib, _state->get_attrib(RenderModeAttrib::get_class_slot())); if (render_mode != (RenderModeAttrib *)NULL) { @@ -315,14 +315,14 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // 3-D points to the graphics API. new_array_format = new GeomVertexArrayFormat(InternalName::get_vertex(), 3, - Geom::NT_float32, + Geom::NT_stdfloat, Geom::C_point); } else { // Without retransform_sprites, we will be sending 4-component // clip-space points. new_array_format = new GeomVertexArrayFormat(InternalName::get_vertex(), 4, - Geom::NT_float32, + Geom::NT_stdfloat, Geom::C_clip_point); } if (has_normal) { @@ -340,7 +340,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { if (sprite_texcoord) { new_array_format->add_column (InternalName::get_texcoord(), 2, - Geom::NT_float32, + Geom::NT_stdfloat, Geom::C_texcoord); } else if (has_texcoord) { @@ -355,26 +355,26 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } } - const LMatrix4f &modelview = _modelview_transform->get_mat(); + const LMatrix4 &modelview = _modelview_transform->get_mat(); SceneSetup *scene = traverser->get_scene(); const Lens *lens = scene->get_lens(); - const LMatrix4f &projection = lens->get_projection_mat(); + const LMatrix4 &projection = lens->get_projection_mat(); int viewport_width = scene->get_viewport_width(); int viewport_height = scene->get_viewport_height(); // We need a standard projection matrix, in a known coordinate // system, to compute the perspective height. - LMatrix4f height_projection; + LMatrix4 height_projection; if (perspective) { height_projection = - LMatrix4f::convert_mat(CS_yup_right, lens->get_coordinate_system()) * + LMatrix4::convert_mat(CS_yup_right, lens->get_coordinate_system()) * projection; } - LMatrix4f render_transform = modelview * projection; - LMatrix4f inv_render_transform; + LMatrix4 render_transform = modelview * projection; + LMatrix4 inv_render_transform; inv_render_transform.invert_from(render_transform); // Now convert all of the vertices in the GeomVertexData to quads. @@ -403,25 +403,25 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { int vi = 0; while (!vertex.is_at_end()) { // Get the point in eye-space coordinates. - LPoint3f eye = modelview.xform_point(vertex.get_data3f()); + LPoint3 eye = modelview.xform_point(vertex.get_data3()); points[vi]._eye = eye; points[vi]._dist = gsg->compute_distance_to(points[vi]._eye); // The point in clip coordinates. - LPoint4f p4 = LPoint4f(eye[0], eye[1], eye[2], 1.0f) * projection; + LPoint4 p4 = LPoint4(eye[0], eye[1], eye[2], 1.0f) * projection; if (has_size) { point_size = size.get_data1f(); } - float scale_y = point_size; + PN_stdfloat scale_y = point_size; if (perspective) { // Perspective-sized points. Here point_size is the point's // height in 3-d units. To arrange that, we need to figure out // the appropriate scaling factor based on the current viewport // and projection matrix. - float scale = _modelview_transform->get_scale()[1]; - LVector3f height(0.0f, point_size * scale, scale); + PN_stdfloat scale = _modelview_transform->get_scale()[1]; + LVector3 height(0.0f, point_size * scale, scale); height = height * height_projection; scale_y = height[1] * viewport_height; @@ -436,80 +436,80 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // coordinates still. scale_y *= p4[3]; - float scale_x = scale_y; + PN_stdfloat scale_x = scale_y; if (has_aspect_ratio) { scale_x *= aspect_ratio.get_data1f(); } // Define the first two corners based on the scales in X and Y. - LPoint2f c0(scale_x, scale_y); - LPoint2f c1(-scale_x, scale_y); + LPoint2 c0(scale_x, scale_y); + LPoint2 c1(-scale_x, scale_y); if (has_rotate) { // If we have a rotate factor, apply it to those two corners. - float r = rotate.get_data1f(); - LMatrix3f mat = LMatrix3f::rotate_mat(r); + PN_stdfloat r = rotate.get_data1f(); + LMatrix3 mat = LMatrix3::rotate_mat(r); c0 = c0 * mat; c1 = c1 * mat; } // Finally, scale the corners in their newly-rotated position, // to compensate for the aspect ratio of the viewport. - float rx = 1.0f / viewport_width; - float ry = 1.0f / viewport_height; + PN_stdfloat rx = 1.0f / viewport_width; + PN_stdfloat ry = 1.0f / viewport_height; c0.set(c0[0] * rx, c0[1] * ry); c1.set(c1[0] * rx, c1[1] * ry); if (retransform_sprites) { // With retransform_sprites in effect, we must reconvert the // resulting quad back into the original 3-D space. - new_vertex.set_data4f(inv_render_transform.xform(LPoint4f(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]))); - new_vertex.set_data4f(inv_render_transform.xform(LPoint4f(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]))); - new_vertex.set_data4f(inv_render_transform.xform(LPoint4f(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]))); - new_vertex.set_data4f(inv_render_transform.xform(LPoint4f(p4[0] - c0[0], p4[1] - c0[1], p4[2], p4[3]))); + new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]))); + new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]))); + new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]))); + new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] - c0[0], p4[1] - c0[1], p4[2], p4[3]))); if (has_normal) { - const Normalf &c = normal.get_data3f(); - new_normal.set_data3f(c); - new_normal.set_data3f(c); - new_normal.set_data3f(c); - new_normal.set_data3f(c); + const LNormal &c = normal.get_data3(); + new_normal.set_data3(c); + new_normal.set_data3(c); + new_normal.set_data3(c); + new_normal.set_data3(c); } } else { // Without retransform_sprites, we can simply load the // clip-space coordinates. - new_vertex.set_data4f(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]); - new_vertex.set_data4f(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]); - new_vertex.set_data4f(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]); - new_vertex.set_data4f(p4[0] - c0[0], p4[1] - c0[1], p4[2], p4[3]); + new_vertex.set_data4(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]); + new_vertex.set_data4(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]); + new_vertex.set_data4(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]); + new_vertex.set_data4(p4[0] - c0[0], p4[1] - c0[1], p4[2], p4[3]); if (has_normal) { - Normalf c = render_transform.xform_vec(normal.get_data3f()); - new_normal.set_data3f(c); - new_normal.set_data3f(c); - new_normal.set_data3f(c); - new_normal.set_data3f(c); + LNormal c = render_transform.xform_vec(normal.get_data3()); + new_normal.set_data3(c); + new_normal.set_data3(c); + new_normal.set_data3(c); + new_normal.set_data3(c); } } if (has_color) { - const Colorf &c = color.get_data4f(); - new_color.set_data4f(c); - new_color.set_data4f(c); - new_color.set_data4f(c); - new_color.set_data4f(c); + const LColor &c = color.get_data4(); + new_color.set_data4(c); + new_color.set_data4(c); + new_color.set_data4(c); + new_color.set_data4(c); } if (sprite_texcoord) { - new_texcoord.set_data2f(1.0f, 0.0f); - new_texcoord.set_data2f(0.0f, 0.0f); - new_texcoord.set_data2f(1.0f, 1.0f); - new_texcoord.set_data2f(0.0f, 1.0f); + new_texcoord.set_data2(1.0f, 0.0f); + new_texcoord.set_data2(0.0f, 0.0f); + new_texcoord.set_data2(1.0f, 1.0f); + new_texcoord.set_data2(0.0f, 1.0f); } else if (has_texcoord) { - const LVecBase4f &c = texcoord.get_data4f(); - new_texcoord.set_data4f(c); - new_texcoord.set_data4f(c); - new_texcoord.set_data4f(c); - new_texcoord.set_data4f(c); + const LVecBase4 &c = texcoord.get_data4(); + new_texcoord.set_data4(c); + new_texcoord.set_data4(c); + new_texcoord.set_data4(c); + new_texcoord.set_data4(c); } ++vi; @@ -685,7 +685,7 @@ munge_texcoord_light_vector(const CullTraverser *traverser, bool force) { // Create a new column for the new texcoords. PT(GeomVertexData) new_data = _munged_data->replace_column - (texcoord_name, 3, Geom::NT_float32, Geom::C_texcoord); + (texcoord_name, 3, Geom::NT_stdfloat, Geom::C_texcoord); _munged_data = new_data; // Remove this TexGen stage from the state, since we're handling @@ -695,7 +695,7 @@ munge_texcoord_light_vector(const CullTraverser *traverser, bool force) { // Get the transform from the light to the object. CPT(TransformState) light_transform = _net_transform->invert_compose(light.get_net_transform()); - const LMatrix4f &light_mat = light_transform->get_mat(); + const LMatrix4 &light_mat = light_transform->get_mat(); GeomVertexWriter texcoord(new_data, texcoord_name, current_thread); GeomVertexReader vertex(new_data, InternalName::get_vertex(), @@ -706,14 +706,14 @@ munge_texcoord_light_vector(const CullTraverser *traverser, bool force) { current_thread); while (!vertex.is_at_end()) { - LPoint3f p = vertex.get_data3f(); - LVector3f t = tangent.get_data3f(); - LVector3f b = binormal.get_data3f(); - LVector3f n = normal.get_data3f(); + LPoint3 p = vertex.get_data3(); + LVector3 t = tangent.get_data3(); + LVector3 b = binormal.get_data3(); + LVector3 n = normal.get_data3(); - LVector3f lv; + LVector3 lv; if (light_obj->get_vector_to_light(lv, p, light_mat)) { - texcoord.add_data3f(lv.dot(t), lv.dot(b), lv.dot(n)); + texcoord.add_data3(lv.dot(t), lv.dot(b), lv.dot(n)); } } } @@ -732,7 +732,7 @@ munge_texcoord_light_vector(const CullTraverser *traverser, bool force) { //////////////////////////////////////////////////////////////////// CPT(RenderState) CullableObject:: get_flash_cpu_state() { - static const Colorf flash_cpu_color(0.8f, 0.2f, 0.2f, 1.0f); + static const LColor flash_cpu_color(0.8f, 0.2, 0.2, 1.0f); // Once someone asks for this pointer, we hold its reference count // and never free it. @@ -756,7 +756,7 @@ get_flash_cpu_state() { //////////////////////////////////////////////////////////////////// CPT(RenderState) CullableObject:: get_flash_hardware_state() { - static const Colorf flash_hardware_color(0.2f, 0.2f, 0.8f, 1.0f); + static const LColor flash_hardware_color(0.2, 0.2, 0.8, 1.0); // Once someone asks for this pointer, we hold its reference count // and never free it. diff --git a/panda/src/pgraph/cullableObject.h b/panda/src/pgraph/cullableObject.h index d828bb8c54..4ac2018814 100644 --- a/panda/src/pgraph/cullableObject.h +++ b/panda/src/pgraph/cullableObject.h @@ -118,8 +118,8 @@ private: // This class is used internally by munge_points_to_quads(). class PointData { public: - LPoint3f _eye; - float _dist; + LPoint3 _eye; + PN_stdfloat _dist; }; class SortPoints { public: diff --git a/panda/src/pgraph/fog.I b/panda/src/pgraph/fog.I index cf9565f39b..e04488f81e 100644 --- a/panda/src/pgraph/fog.I +++ b/panda/src/pgraph/fog.I @@ -49,7 +49,7 @@ set_mode(Mode mode) { // Access: Published // Description: Returns the color of the fog. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Fog:: +INLINE const LColor &Fog:: get_color() const { return _color; } @@ -60,7 +60,7 @@ get_color() const { // Description: Sets the color of the fog. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_color(float r, float g, float b) { +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { _color[0] = r; _color[1] = g; _color[2] = b; @@ -73,7 +73,7 @@ set_color(float r, float g, float b) { // not used. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; } @@ -92,8 +92,8 @@ set_color(const Colorf &color) { // M_linear, if it is not already set. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_range(float onset, float opaque) { - LVector3f forward = LVector3f::forward(); +set_linear_range(PN_stdfloat onset, PN_stdfloat opaque) { + LVector3 forward = LVector3::forward(); _linear_onset_point = onset * forward; _linear_opaque_point = opaque * forward; _transformed_onset = onset; @@ -107,7 +107,7 @@ set_linear_range(float onset, float opaque) { // Description: Returns the point in space at which the fog begins. // This is only used if the mode is M_linear. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &Fog:: +INLINE const LPoint3 &Fog:: get_linear_onset_point() const { return _linear_onset_point; } @@ -119,7 +119,7 @@ get_linear_onset_point() const { // This is only used if the mode is M_linear. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_onset_point(float x, float y, float z) { +set_linear_onset_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _linear_onset_point.set(x, y, z); } @@ -130,7 +130,7 @@ set_linear_onset_point(float x, float y, float z) { // This is only used if the mode is M_linear. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_onset_point(const LPoint3f &linear_onset_point) { +set_linear_onset_point(const LPoint3 &linear_onset_point) { _linear_onset_point = linear_onset_point; } @@ -141,7 +141,7 @@ set_linear_onset_point(const LPoint3f &linear_onset_point) { // completely obscures geometry. This is only used if // the mode is M_linear. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &Fog:: +INLINE const LPoint3 &Fog:: get_linear_opaque_point() const { return _linear_opaque_point; } @@ -154,7 +154,7 @@ get_linear_opaque_point() const { // the mode is M_linear. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_opaque_point(float x, float y, float z) { +set_linear_opaque_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _linear_opaque_point.set(x, y, z); } @@ -166,7 +166,7 @@ set_linear_opaque_point(float x, float y, float z) { // the mode is M_linear. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_opaque_point(const LPoint3f &linear_opaque_point) { +set_linear_opaque_point(const LPoint3 &linear_opaque_point) { _linear_opaque_point = linear_opaque_point; } @@ -211,7 +211,7 @@ set_linear_opaque_point(const LPoint3f &linear_opaque_point) { // supercedes the 3-d onset point and opaque points. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_linear_fallback(float angle, float onset, float opaque) { +set_linear_fallback(PN_stdfloat angle, PN_stdfloat onset, PN_stdfloat opaque) { _linear_fallback_cosa = ccos(deg_2_rad(angle)); _linear_fallback_onset = onset; _linear_fallback_opaque = opaque; @@ -224,7 +224,7 @@ set_linear_fallback(float angle, float onset, float opaque) { // calculations. This is only used if the mode is not // M_linear. //////////////////////////////////////////////////////////////////// -INLINE float Fog:: +INLINE PN_stdfloat Fog:: get_exp_density() const { return _exp_density; } @@ -240,7 +240,7 @@ get_exp_density() const { // function implicitly sets it to M_exponential. //////////////////////////////////////////////////////////////////// INLINE void Fog:: -set_exp_density(float exp_density) { +set_exp_density(PN_stdfloat exp_density) { nassertv((exp_density >= 0.0) && (exp_density <= 1.0)); _exp_density = exp_density; diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 058ee9fcef..23fe6264eb 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -116,7 +116,7 @@ make_copy() const { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void Fog:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { _linear_onset_point = _linear_onset_point * mat; _linear_opaque_point = _linear_opaque_point * mat; } @@ -153,9 +153,9 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void Fog:: adjust_to_camera(const TransformState *camera_transform) { - LVector3f forward = LVector3f::forward(); + LVector3 forward = LVector3::forward(); - LPoint3f onset_point, opaque_point; + LPoint3 onset_point, opaque_point; if (get_num_parents() != 0) { // Linear fog is relative to the fog's net transform in the scene // graph. @@ -164,12 +164,12 @@ adjust_to_camera(const TransformState *camera_transform) { CPT(TransformState) rel_transform = camera_transform->invert_compose(this_np.get_net_transform()); - const LMatrix4f &mat = rel_transform->get_mat(); + const LMatrix4 &mat = rel_transform->get_mat(); // How far out of whack are we? - LVector3f fog_vector = (_linear_opaque_point - _linear_onset_point) * mat; + LVector3 fog_vector = (_linear_opaque_point - _linear_onset_point) * mat; fog_vector.normalize(); - float cosa = fog_vector.dot(forward); + PN_stdfloat cosa = fog_vector.dot(forward); if (cabs(cosa) < _linear_fallback_cosa) { // The fog vector is too far from the eye vector; use the // fallback mode. @@ -194,7 +194,7 @@ adjust_to_camera(const TransformState *camera_transform) { // Description: Retrieves the current onset and offset ranges. //////////////////////////////////////////////////////////////////// void Fog:: -get_linear_range(float &onset, float &opaque) { +get_linear_range(PN_stdfloat &onset, PN_stdfloat &opaque) { onset = _transformed_onset; opaque = _transformed_opaque; } @@ -224,10 +224,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { _color.write_datagram(dg); _linear_onset_point.write_datagram(dg); _linear_opaque_point.write_datagram(dg); - dg.add_float32(_exp_density); - dg.add_float32(_linear_fallback_cosa); - dg.add_float32(_linear_fallback_onset); - dg.add_float32(_linear_fallback_opaque); + dg.add_stdfloat(_exp_density); + dg.add_stdfloat(_linear_fallback_cosa); + dg.add_stdfloat(_linear_fallback_onset); + dg.add_stdfloat(_linear_fallback_opaque); } //////////////////////////////////////////////////////////////////// @@ -265,8 +265,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { _color.read_datagram(scan); _linear_onset_point.read_datagram(scan); _linear_opaque_point.read_datagram(scan); - _exp_density = scan.get_float32(); - _linear_fallback_cosa = scan.get_float32(); - _linear_fallback_onset = scan.get_float32(); - _linear_fallback_opaque = scan.get_float32(); + _exp_density = scan.get_stdfloat(); + _linear_fallback_cosa = scan.get_stdfloat(); + _linear_fallback_onset = scan.get_stdfloat(); + _linear_fallback_opaque = scan.get_stdfloat(); } diff --git a/panda/src/pgraph/fog.h b/panda/src/pgraph/fog.h index 07c285b11d..68be446df4 100644 --- a/panda/src/pgraph/fog.h +++ b/panda/src/pgraph/fog.h @@ -54,7 +54,7 @@ public: virtual ~Fog(); virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); PUBLISHED: enum Mode { @@ -66,30 +66,30 @@ PUBLISHED: INLINE Mode get_mode() const; INLINE void set_mode(Mode mode); - INLINE const Colorf &get_color() const; - INLINE void set_color(float r, float g, float b); - INLINE void set_color(const Colorf &color); + INLINE const LColor &get_color() const; + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b); + INLINE void set_color(const LColor &color); - INLINE void set_linear_range(float onset, float opaque); + INLINE void set_linear_range(PN_stdfloat onset, PN_stdfloat opaque); - INLINE const LPoint3f &get_linear_onset_point() const; - INLINE void set_linear_onset_point(float x, float y, float z); - INLINE void set_linear_onset_point(const LPoint3f &linear_onset_point); + INLINE const LPoint3 &get_linear_onset_point() const; + INLINE void set_linear_onset_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE void set_linear_onset_point(const LPoint3 &linear_onset_point); - INLINE const LPoint3f &get_linear_opaque_point() const; - INLINE void set_linear_opaque_point(const LPoint3f &linear_opaque_point); - INLINE void set_linear_opaque_point(float x, float y, float z); + INLINE const LPoint3 &get_linear_opaque_point() const; + INLINE void set_linear_opaque_point(const LPoint3 &linear_opaque_point); + INLINE void set_linear_opaque_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); - INLINE void set_linear_fallback(float angle, float onset, float opaque); + INLINE void set_linear_fallback(PN_stdfloat angle, PN_stdfloat onset, PN_stdfloat opaque); - INLINE float get_exp_density() const; - INLINE void set_exp_density(float exp_density); + INLINE PN_stdfloat get_exp_density() const; + INLINE void set_exp_density(PN_stdfloat exp_density); void output(ostream &out) const; public: void adjust_to_camera(const TransformState *camera_transform); - void get_linear_range(float &onset, float &opaque); + void get_linear_range(PN_stdfloat &onset, PN_stdfloat &opaque); protected: void compute_density(); @@ -104,15 +104,15 @@ protected: protected: Mode _mode; - Colorf _color; - LPoint3f _linear_onset_point; - LPoint3f _linear_opaque_point; - float _exp_density; + LColor _color; + LPoint3 _linear_onset_point; + LPoint3 _linear_opaque_point; + PN_stdfloat _exp_density; - float _linear_fallback_cosa; - float _linear_fallback_onset, _linear_fallback_opaque; + PN_stdfloat _linear_fallback_cosa; + PN_stdfloat _linear_fallback_onset, _linear_fallback_opaque; - float _transformed_onset, _transformed_opaque; + PN_stdfloat _transformed_onset, _transformed_opaque; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 0aebc44b5e..9b5cc91821 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -1,5 +1,5 @@ // Filename: geomNode.cxx -// Created by: drose (23Feb02) +// Created by: drose (23eb02) // //////////////////////////////////////////////////////////////////// // @@ -162,7 +162,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { if (geom_attribs._color_scale != (const RenderAttrib *)NULL) { CPT(ColorScaleAttrib) csa = DCAST(ColorScaleAttrib, geom_attribs._color_scale); - if (csa->get_scale() != LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)) { + if (csa->get_scale() != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { // Now, if we have an "off" or "flat" color attribute, we @@ -184,9 +184,9 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } else if (ca->get_color_type() == ColorAttrib::T_flat) { // ColorAttrib::T_flat means the color scale modulates // the specified color to produce a new color. - const Colorf &c1 = ca->get_color(); - const LVecBase4f &c2 = csa->get_scale(); - Colorf color(c1[0] * c2[0], c1[1] * c2[1], + const LColor &c1 = ca->get_color(); + const LVecBase4 &c2 = csa->get_scale(); + LColor color(c1[0] * c2[0], c1[1] * c2[1], c1[2] * c2[2], c1[3] * c2[3]); entry->_state = entry->_state->set_attrib(ColorAttrib::make_flat(color)); @@ -331,7 +331,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // GeomNodes. //////////////////////////////////////////////////////////////////// void GeomNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { GeomTransformer transformer; transformer.transform_vertices(this, mat); } @@ -456,13 +456,13 @@ combine_with(PandaNode *other) { // already set. //////////////////////////////////////////////////////////////////// CPT(TransformState) GeomNode:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, bool &found_any, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { CPT(TransformState) next_transform = PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, current_thread); - const LMatrix4f &mat = next_transform->get_mat(); + const LMatrix4 &mat = next_transform->get_mat(); CDReader cdata(_cycler, current_thread); GeomList::const_iterator gi; diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index bbe7720998..3f8b64ce60 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -1,5 +1,5 @@ // Filename: geomNode.h -// Created by: drose (22Feb02) +// Created by: drose (22eb02) // //////////////////////////////////////////////////////////////////// // @@ -46,10 +46,10 @@ public: virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PandaNode *combine_with(PandaNode *other); virtual CPT(TransformState) - calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const; diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index da4753d8a6..0c2fbd6b28 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -119,7 +119,7 @@ register_vertices(GeomNode *node, bool might_have_unused) { // if the Geom was changed, false otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -transform_vertices(Geom *geom, const LMatrix4f &mat) { +transform_vertices(Geom *geom, const LMatrix4 &mat) { PStatTimer timer(_apply_vertex_collector); nassertr(geom != (Geom *)NULL, false); @@ -138,16 +138,16 @@ transform_vertices(Geom *geom, const LMatrix4f &mat) { GeomVertexRewriter data(new_vdata, format->get_point(ci)); while (!data.is_at_end()) { - const LPoint3f &point = data.get_data3f(); - data.set_data3f(point * mat); + const LPoint3 &point = data.get_data3(); + data.set_data3(point * mat); } } for (ci = 0; ci < format->get_num_vectors(); ci++) { GeomVertexRewriter data(new_vdata, format->get_vector(ci)); while (!data.is_at_end()) { - const LVector3f &vector = data.get_data3f(); - data.set_data3f(normalize(vector * mat)); + const LVector3 &vector = data.get_data3(); + data.set_data3(normalize(vector * mat)); } } new_data._vdata = new_vdata; @@ -175,7 +175,7 @@ transform_vertices(Geom *geom, const LMatrix4f &mat) { // false otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -transform_vertices(GeomNode *node, const LMatrix4f &mat) { +transform_vertices(GeomNode *node, const LMatrix4 &mat) { bool any_changed = false; Thread *current_thread = Thread::get_current_thread(); @@ -211,7 +211,7 @@ transform_vertices(GeomNode *node, const LMatrix4f &mat) { //////////////////////////////////////////////////////////////////// bool GeomTransformer:: transform_texcoords(Geom *geom, const InternalName *from_name, - InternalName *to_name, const LMatrix4f &mat) { + InternalName *to_name, const LMatrix4 &mat) { PStatTimer timer(_apply_texcoord_collector); nassertr(geom != (Geom *)NULL, false); @@ -249,8 +249,8 @@ transform_texcoords(Geom *geom, const InternalName *from_name, GeomVertexReader fdata(new_vdata, from_name); while (!fdata.is_at_end()) { - const LPoint4f &coord = fdata.get_data4f(); - tdata.set_data4f(coord * mat); + const LPoint4 &coord = fdata.get_data4(); + tdata.set_data4(coord * mat); } new_data._vdata = new_vdata; } @@ -278,7 +278,7 @@ transform_texcoords(Geom *geom, const InternalName *from_name, //////////////////////////////////////////////////////////////////// bool GeomTransformer:: transform_texcoords(GeomNode *node, const InternalName *from_name, - InternalName *to_name, const LMatrix4f &mat) { + InternalName *to_name, const LMatrix4 &mat) { bool any_changed = false; GeomNode::CDWriter cdata(node->_cycler); @@ -305,7 +305,7 @@ transform_texcoords(GeomNode *node, const InternalName *from_name, // Geom was changed, false otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -set_color(Geom *geom, const Colorf &color) { +set_color(Geom *geom, const LColor &color) { PStatTimer timer(_apply_set_color_collector); SourceColors sc; @@ -342,7 +342,7 @@ set_color(Geom *geom, const Colorf &color) { // otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -set_color(GeomNode *node, const Colorf &color) { +set_color(GeomNode *node, const LColor &color) { bool any_changed = false; GeomNode::CDWriter cdata(node->_cycler); @@ -368,7 +368,7 @@ set_color(GeomNode *node, const Colorf &color) { // changed, false otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -transform_colors(Geom *geom, const LVecBase4f &scale) { +transform_colors(Geom *geom, const LVecBase4 &scale) { PStatTimer timer(_apply_scale_color_collector); nassertr(geom != (Geom *)NULL, false); @@ -409,7 +409,7 @@ transform_colors(Geom *geom, const LVecBase4f &scale) { // the GeomNode was changed, false otherwise. //////////////////////////////////////////////////////////////////// bool GeomTransformer:: -transform_colors(GeomNode *node, const LVecBase4f &scale) { +transform_colors(GeomNode *node, const LVecBase4 &scale) { bool any_changed = false; GeomNode::CDWriter cdata(node->_cycler); @@ -438,7 +438,7 @@ transform_colors(GeomNode *node, const LVecBase4f &scale) { //////////////////////////////////////////////////////////////////// bool GeomTransformer:: apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, - const TexMatrixAttrib *tma, const Colorf &base_color, + const TexMatrixAttrib *tma, const LColor &base_color, bool keep_vertex_color) { PStatTimer timer(_apply_texture_color_collector); @@ -455,7 +455,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, // If it's just a one-pixel texture (e.g. a simple ram image), // don't bother scanning the UV's. Just extract the color and // apply it. - Colorf color; + LColor color; peeker->lookup(color, 0.0f, 0.0f); color.set(color[0] * base_color[0], color[1] * base_color[1], @@ -469,10 +469,10 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, } bool got_mat = false; - LMatrix4f mat = LMatrix4f::ident_mat(); + LMatrix4 mat = LMatrix4::ident_mat(); if (tma != (TexMatrixAttrib *)NULL && tma->has_stage(ts)) { mat = tma->get_mat(ts); - got_mat = !mat.almost_equal(LMatrix4f::ident_mat()); + got_mat = !mat.almost_equal(LMatrix4::ident_mat()); } // This version of the code just applied one overall flat color to @@ -483,7 +483,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, // Scan the UV's to get the used range. This is particularly // necessary for palettized textures. - LPoint3f min_point, max_point; + LPoint3 min_point, max_point; bool found_any = false; geom->calc_tight_bounds(min_point, max_point, found_any, geom->get_vertex_data(), @@ -493,7 +493,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, if (found_any) { // Now use that UV range to determine the overall color of the // geom's texture. - Colorf color; + LColor color; peeker->filter_rect(color, min_point[0], min_point[1], min_point[2], max_point[0], max_point[1], max_point[2]); @@ -531,7 +531,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, } else { // Create a color column where there wasn't one before. vdata = new GeomVertexData(*stc._vertex_data->set_color - (Colorf(1.0f, 1.0f, 1.0f, 1.0f), 1, Geom::NT_packed_dabc, Geom::C_color)); + (LColor(1.0f, 1.0f, 1.0f, 1.0f), 1, Geom::NT_packed_dabc, Geom::C_color)); keep_vertex_color = false; } @@ -554,28 +554,28 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, if (got_mat || tex3d) { while (!gtexcoord.is_at_end()) { - TexCoord3f p = gtexcoord.get_data3f(); - Colorf c = gcolor.get_data4f(); + LTexCoord3 p = gtexcoord.get_data3(); + LColor c = gcolor.get_data4(); p = p * mat; - Colorf color; + LColor color; peeker->lookup(color, p[0], p[1], p[2]); color.set(color[0] * base_color[0] * c[0], color[1] * base_color[1] * c[1], color[2] * base_color[2] * c[2], color[3] * base_color[3] * c[3]); - gcolor.set_data4f(color); + gcolor.set_data4(color); } } else { while (!gtexcoord.is_at_end()) { - TexCoordf p = gtexcoord.get_data2f(); - Colorf c = gcolor.get_data4f(); - Colorf color; + LTexCoord p = gtexcoord.get_data2(); + LColor c = gcolor.get_data4(); + LColor color; peeker->lookup(color, p[0], p[1]); color.set(color[0] * base_color[0] * c[0], color[1] * base_color[1] * c[1], color[2] * base_color[2] * c[2], color[3] * base_color[3] * c[3]); - gcolor.set_data4f(color); + gcolor.set_data4(color); } } } else { @@ -585,26 +585,26 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, if (got_mat || tex3d) { while (!gtexcoord.is_at_end()) { - TexCoord3f p = gtexcoord.get_data3f(); + LTexCoord3 p = gtexcoord.get_data3(); p = p * mat; - Colorf color; + LColor color; peeker->lookup(color, p[0], p[1], p[2]); color.set(color[0] * base_color[0], color[1] * base_color[1], color[2] * base_color[2], color[3] * base_color[3]); - gcolor.set_data4f(color); + gcolor.set_data4(color); } } else { while (!gtexcoord.is_at_end()) { - TexCoordf p = gtexcoord.get_data2f(); - Colorf color; + LTexCoord p = gtexcoord.get_data2(); + LColor color; peeker->lookup(color, p[0], p[1]); color.set(color[0] * base_color[0], color[1] * base_color[1], color[2] * base_color[2], color[3] * base_color[3]); - gcolor.set_data4f(color); + gcolor.set_data4(color); } } } @@ -658,7 +658,7 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, geom_state->get_attrib(TexMatrixAttrib::get_class_slot())); const ColorAttrib *ca = DCAST(ColorAttrib, geom_state->get_attrib(ColorAttrib::get_class_slot())); - Colorf base_color(1.0f, 1.0f, 1.0f, 1.0f); + LColor base_color(1.0f, 1.0f, 1.0f, 1.0f); bool keep_vertex_color = true; if (ca != (ColorAttrib *)NULL && ca->get_color_type() == ColorAttrib::T_flat) { base_color = ca->get_color(); @@ -872,14 +872,14 @@ make_compatible_state(GeomNode *node) { // All we need to do is ensure that the geom has a color column. if (!entry._geom.get_read_pointer()->get_vertex_data()->has_column(InternalName::get_color())) { PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy(); - if (set_color(new_geom, Colorf(1,1,1,1))) { + if (set_color(new_geom, LColor(1,1,1,1))) { entry._geom = new_geom; } } } else { // A flat color (or "off", which is white). Set the vertices // to the indicated flat color. - Colorf c = ca->get_color(); + LColor c = ca->get_color(); PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy(); if (set_color(new_geom, c)) { entry._geom = new_geom; diff --git a/panda/src/pgraph/geomTransformer.h b/panda/src/pgraph/geomTransformer.h index 74342343fa..250bb15c43 100644 --- a/panda/src/pgraph/geomTransformer.h +++ b/panda/src/pgraph/geomTransformer.h @@ -55,23 +55,23 @@ public: void register_vertices(Geom *geom, bool might_have_unused); void register_vertices(GeomNode *node, bool might_have_unused); - bool transform_vertices(Geom *geom, const LMatrix4f &mat); - bool transform_vertices(GeomNode *node, const LMatrix4f &mat); + bool transform_vertices(Geom *geom, const LMatrix4 &mat); + bool transform_vertices(GeomNode *node, const LMatrix4 &mat); bool transform_texcoords(Geom *geom, const InternalName *from_name, - InternalName *to_name, const LMatrix4f &mat); + InternalName *to_name, const LMatrix4 &mat); bool transform_texcoords(GeomNode *node, const InternalName *from_name, - InternalName *to_name, const LMatrix4f &mat); + InternalName *to_name, const LMatrix4 &mat); - bool set_color(Geom *geom, const Colorf &color); - bool set_color(GeomNode *node, const Colorf &color); + bool set_color(Geom *geom, const LColor &color); + bool set_color(GeomNode *node, const LColor &color); - bool transform_colors(Geom *geom, const LVecBase4f &scale); - bool transform_colors(GeomNode *node, const LVecBase4f &scale); + bool transform_colors(Geom *geom, const LVecBase4 &scale); + bool transform_colors(GeomNode *node, const LVecBase4 &scale); bool apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, const TexMatrixAttrib *tma, - const Colorf &base_color, bool keep_vertex_color); + const LColor &base_color, bool keep_vertex_color); bool apply_texture_colors(GeomNode *node, const RenderState *state); bool apply_state(GeomNode *node, const RenderState *state); @@ -94,12 +94,6 @@ public: PT(Geom) premunge_geom(const Geom *geom, GeomMunger *munger); -private: - static void get_texel_color(Colorf &color, float u, float v, - const unsigned char *image, - int x_size, int y_size); - - private: int _max_collect_vertices; @@ -131,7 +125,7 @@ private: public: INLINE bool operator < (const SourceVertices &other) const; - LMatrix4f _mat; + LMatrix4 _mat; CPT(GeomVertexData) _vertex_data; }; typedef pmap NewVertices; @@ -143,7 +137,7 @@ private: public: INLINE bool operator < (const SourceTexCoords &other) const; - LMatrix4f _mat; + LMatrix4 _mat; CPT(InternalName) _from; CPT(InternalName) _to; CPT(GeomVertexData) _vertex_data; @@ -157,7 +151,7 @@ private: public: INLINE bool operator < (const SourceColors &other) const; - LVecBase4f _color; + LVecBase4 _color; CPT(GeomVertexData) _vertex_data; }; typedef pmap NewColors; @@ -177,7 +171,7 @@ private: TextureStage *_ts; Texture *_tex; const TexMatrixAttrib *_tma; - Colorf _base_color; + LColor _base_color; bool _keep_vertex_color; CPT(GeomVertexData) _vertex_data; }; diff --git a/panda/src/pgraph/lensNode.I b/panda/src/pgraph/lensNode.I index 8d1a36a165..c6a252690a 100644 --- a/panda/src/pgraph/lensNode.I +++ b/panda/src/pgraph/lensNode.I @@ -111,7 +111,7 @@ deactivate_lens(int index) { // see the point). //////////////////////////////////////////////////////////////////// INLINE bool LensNode:: -is_in_view(const LPoint3f &pos) { +is_in_view(const LPoint3 &pos) { return is_in_view(0, pos); } diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 5002dd3fc0..46ca325058 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -58,7 +58,7 @@ LensNode(const LensNode ©) : // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void LensNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { PandaNode::xform(mat); // We need to actually transform the lens here. } @@ -143,7 +143,7 @@ set_lens_active(int index, bool flag) { // see the point). //////////////////////////////////////////////////////////////////// bool LensNode:: -is_in_view(int index, const LPoint3f &pos) { +is_in_view(int index, const LPoint3 &pos) { Lens *lens = get_lens(index); nassertr(lens != (Lens *)NULL, false); PT(BoundingVolume) bv = lens->make_bounds(); diff --git a/panda/src/pgraph/lensNode.h b/panda/src/pgraph/lensNode.h index 5cbfd47ab9..1db8b193b5 100644 --- a/panda/src/pgraph/lensNode.h +++ b/panda/src/pgraph/lensNode.h @@ -39,7 +39,7 @@ public: virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PandaNode *make_copy() const; PUBLISHED: @@ -55,8 +55,8 @@ PUBLISHED: INLINE bool activate_lens(int index); INLINE bool deactivate_lens(int index); - INLINE bool is_in_view(const LPoint3f &pos); - bool is_in_view(int index, const LPoint3f &pos); + INLINE bool is_in_view(const LPoint3 &pos); + bool is_in_view(int index, const LPoint3 &pos); void show_frustum(); void hide_frustum(); diff --git a/panda/src/pgraph/light.I b/panda/src/pgraph/light.I index 2038278ff7..aa160fa38c 100644 --- a/panda/src/pgraph/light.I +++ b/panda/src/pgraph/light.I @@ -66,7 +66,7 @@ Light(const Light ©) : // Access: Published // Description: Returns the basic color of the light. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Light:: +INLINE const LColor &Light:: get_color() const { CDReader cdata(_cycler); return cdata->_color; @@ -78,7 +78,7 @@ get_color() const { // Description: Sets the basic color of the light. //////////////////////////////////////////////////////////////////// INLINE void Light:: -set_color(const Colorf &color) { +set_color(const LColor &color) { CDWriter cdata(_cycler); cdata->_color = color; mark_viz_stale(); diff --git a/panda/src/pgraph/light.cxx b/panda/src/pgraph/light.cxx index ff72bd55ea..6612fd4364 100644 --- a/panda/src/pgraph/light.cxx +++ b/panda/src/pgraph/light.cxx @@ -94,7 +94,7 @@ is_ambient_light() const { // ambient light). //////////////////////////////////////////////////////////////////// bool Light:: -get_vector_to_light(LVector3f &, const LPoint3f &, const LMatrix4f &) { +get_vector_to_light(LVector3 &, const LPoint3 &, const LMatrix4 &) { return false; } diff --git a/panda/src/pgraph/light.h b/panda/src/pgraph/light.h index a6131761b5..074f3a2f46 100644 --- a/panda/src/pgraph/light.h +++ b/panda/src/pgraph/light.h @@ -52,8 +52,8 @@ PUBLISHED: virtual PandaNode *as_node()=0; virtual bool is_ambient_light() const; - INLINE const Colorf &get_color() const; - INLINE void set_color(const Colorf &color); + INLINE const LColor &get_color() const; + INLINE void set_color(const LColor &color); INLINE void set_priority(int priority); INLINE int get_priority() const; @@ -65,9 +65,9 @@ public: virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)=0; - virtual bool get_vector_to_light(LVector3f &result, - const LPoint3f &from_object_point, - const LMatrix4f &to_object_space); + virtual bool get_vector_to_light(LVector3 &result, + const LPoint3 &from_object_point, + const LMatrix4 &to_object_space); GeomNode *get_viz(); @@ -108,7 +108,7 @@ private: return Light::get_class_type(); } - Colorf _color; + LColor _color; PT(GeomNode) _viz_geom; bool _viz_geom_stale; diff --git a/panda/src/pgraph/lightRampAttrib.I b/panda/src/pgraph/lightRampAttrib.I index 288bdeff30..254681973d 100644 --- a/panda/src/pgraph/lightRampAttrib.I +++ b/panda/src/pgraph/lightRampAttrib.I @@ -43,7 +43,7 @@ get_mode() const { // Access: Published // Description: Returns the nth lighting level. //////////////////////////////////////////////////////////////////// -INLINE float LightRampAttrib:: +INLINE PN_stdfloat LightRampAttrib:: get_level(int n) const { if ((n<0)||(n>1)) return 0.0; return _level[n]; @@ -54,7 +54,7 @@ get_level(int n) const { // Access: Published // Description: Returns the nth threshold level. //////////////////////////////////////////////////////////////////// -INLINE float LightRampAttrib:: +INLINE PN_stdfloat LightRampAttrib:: get_threshold(int n) const { if ((n<0)||(n>1)) return 0.0; return _threshold[n]; diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 6eb57e1063..c0640e14ab 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -69,7 +69,7 @@ make_identity() { // @endcode //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) LightRampAttrib:: -make_single_threshold(float thresh0, float val0) { +make_single_threshold(PN_stdfloat thresh0, PN_stdfloat val0) { LightRampAttrib *attrib = new LightRampAttrib(); attrib->_mode = LRT_single_threshold; attrib->_threshold[0] = thresh0; @@ -94,7 +94,7 @@ make_single_threshold(float thresh0, float val0) { // @endcode //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) LightRampAttrib:: -make_double_threshold(float thresh0, float val0, float thresh1, float val1) { +make_double_threshold(PN_stdfloat thresh0, PN_stdfloat val0, PN_stdfloat thresh1, PN_stdfloat val1) { LightRampAttrib *attrib = new LightRampAttrib(); attrib->_mode = LRT_single_threshold; attrib->_threshold[0] = thresh0; @@ -305,10 +305,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); for (int i=0; i<2; i++) { - dg.add_float32(_level[i]); + dg.add_stdfloat(_level[i]); } for (int i=0; i<2; i++) { - dg.add_float32(_threshold[i]); + dg.add_stdfloat(_threshold[i]); } } @@ -345,9 +345,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _mode = (LightRampMode)scan.get_int8(); for (int i=0; i<2; i++) { - _level[i] = scan.get_float32(); + _level[i] = scan.get_stdfloat(); } for (int i=0; i<2; i++) { - _threshold[i] = scan.get_float32(); + _threshold[i] = scan.get_stdfloat(); } } diff --git a/panda/src/pgraph/lightRampAttrib.h b/panda/src/pgraph/lightRampAttrib.h index 6e2291d3fd..3c107a8a9c 100644 --- a/panda/src/pgraph/lightRampAttrib.h +++ b/panda/src/pgraph/lightRampAttrib.h @@ -45,16 +45,16 @@ PUBLISHED: }; static CPT(RenderAttrib) make_default(); static CPT(RenderAttrib) make_identity(); - static CPT(RenderAttrib) make_single_threshold(float thresh0, float lev0); - static CPT(RenderAttrib) make_double_threshold(float thresh0, float lev0, float thresh1, float lev1); + static CPT(RenderAttrib) make_single_threshold(PN_stdfloat thresh0, PN_stdfloat lev0); + static CPT(RenderAttrib) make_double_threshold(PN_stdfloat thresh0, PN_stdfloat lev0, PN_stdfloat thresh1, PN_stdfloat lev1); static CPT(RenderAttrib) make_hdr0(); static CPT(RenderAttrib) make_hdr1(); static CPT(RenderAttrib) make_hdr2(); INLINE LightRampMode get_mode() const; - INLINE float get_level(int n) const; - INLINE float get_threshold(int n) const; + INLINE PN_stdfloat get_level(int n) const; + INLINE PN_stdfloat get_threshold(int n) const; public: virtual void output(ostream &out) const; @@ -65,8 +65,8 @@ protected: private: LightRampMode _mode; - float _level[2]; - float _threshold[2]; + PN_stdfloat _level[2]; + PN_stdfloat _threshold[2]; static CPT(RenderAttrib) _default; diff --git a/panda/src/pgraph/modelNode.cxx b/panda/src/pgraph/modelNode.cxx index b07678f507..ec4057a227 100644 --- a/panda/src/pgraph/modelNode.cxx +++ b/panda/src/pgraph/modelNode.cxx @@ -179,7 +179,7 @@ register_with_read_factory() { //////////////////////////////////////////////////////////////////// void ModelNode:: test_transform(const TransformState *ts) const { - LPoint3f pos(ts->get_pos()); + LPoint3 pos(ts->get_pos()); nassertv(pos[0] < _transform_limit); nassertv(pos[0] > -_transform_limit); nassertv(pos[1] < _transform_limit); diff --git a/panda/src/pgraph/modelNode.h b/panda/src/pgraph/modelNode.h index 930d8cc6fc..11dc8411e2 100644 --- a/panda/src/pgraph/modelNode.h +++ b/panda/src/pgraph/modelNode.h @@ -65,7 +65,7 @@ PUBLISHED: INLINE void set_preserve_attributes(int attrib_mask); INLINE int get_preserve_attributes() const; - void set_transform_limit(float limit) { _transform_limit = limit; }; + void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; private: PreserveTransform _preserve_transform; @@ -82,7 +82,7 @@ protected: virtual void transform_changed(); void test_transform(const TransformState *ts) const; - float _transform_limit; + PN_stdfloat _transform_limit; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 5305b38a9f..5dc6a6b542 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -740,8 +740,8 @@ get_net_prev_transform(Thread *current_thread) const { // points in between. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_pos(float x, float y, float z) { - set_pos(LPoint3f(x, y, z)); +set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_pos(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -753,21 +753,21 @@ set_pos(float x, float y, float z) { // position to its new position. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_fluid_pos(float x, float y, float z) { - set_fluid_pos(LPoint3f(x, y, z)); +set_fluid_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_fluid_pos(LPoint3(x, y, z)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_x() const { return get_pos()[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_y() const { return get_pos()[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_z() const { return get_pos()[2]; } @@ -779,21 +779,21 @@ get_z() const { // leaving translation and scale untouched. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_hpr(float h, float p, float r) { - set_hpr(LVecBase3f(h, p, r)); +set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_hpr(LVecBase3(h, p, r)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_h() const { return get_hpr()[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_p() const { return get_hpr()[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_r() const { return get_hpr()[2]; } @@ -805,26 +805,26 @@ get_r() const { // leaving translation and rotation untouched. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_scale(float scale) { - set_scale(LVecBase3f(scale, scale, scale)); +set_scale(PN_stdfloat scale) { + set_scale(LVecBase3(scale, scale, scale)); } INLINE void NodePath:: -set_scale(float sx, float sy, float sz) { - set_scale(LVecBase3f(sx, sy, sz)); +set_scale(PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_scale(LVecBase3(sx, sy, sz)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sx() const { return get_scale()[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sy() const { return get_scale()[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sz() const { return get_scale()[2]; } @@ -836,21 +836,21 @@ get_sz() const { // leaving translation, rotation, and scale untouched. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_shear(float shxy, float shxz, float shyz) { - set_shear(LVecBase3f(shxy, shxz, shyz)); +set_shear(PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) { + set_shear(LVecBase3(shxy, shxz, shyz)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shxy() const { return get_shear()[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shxz() const { return get_shear()[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shyz() const { return get_shear()[2]; } @@ -862,8 +862,8 @@ get_shyz() const { // transform, leaving scale untouched. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_pos_hpr(float x, float y, float z, float h, float p, float r) { - set_pos_hpr(LVecBase3f(x, y, z), LVecBase3f(h, p, r)); +set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_pos_hpr(LVecBase3(x, y, z), LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// @@ -873,8 +873,8 @@ set_pos_hpr(float x, float y, float z, float h, float p, float r) { // transform, leaving translation untouched. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_hpr_scale(float h, float p, float r, float sx, float sy, float sz) { - set_hpr_scale(LVecBase3f(h, p, r), LVecBase3f(sx, sy, sz)); +set_hpr_scale(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_hpr_scale(LVecBase3(h, p, r), LVecBase3(sx, sy, sz)); } //////////////////////////////////////////////////////////////////// @@ -884,10 +884,10 @@ set_hpr_scale(float h, float p, float r, float sx, float sy, float sz) { // translation, rotation, and scale components. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_pos_hpr_scale(float x, float y, float z, float h, float p, float r, - float sx, float sy, float sz) { - set_pos_hpr_scale(LVecBase3f(x, y, z), LVecBase3f(h, p, r), - LVecBase3f(sx, sy, sz)); +set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_pos_hpr_scale(LVecBase3(x, y, z), LVecBase3(h, p, r), + LVecBase3(sx, sy, sz)); } //////////////////////////////////////////////////////////////////// @@ -921,9 +921,9 @@ has_mat() const { // the referenced node, or the identity matrix if no // matrix has been applied. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &NodePath:: +INLINE const LMatrix4 &NodePath:: get_mat() const { - nassertr_always(!is_empty(), LMatrix4f::ident_mat()); + nassertr_always(!is_empty(), LMatrix4::ident_mat()); return node()->get_transform()->get_mat(); } @@ -938,8 +938,8 @@ get_mat() const { // node, although it will preserve any translation. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -look_at(float x, float y, float z) { - look_at(LPoint3f(x, y, z)); +look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + look_at(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -950,8 +950,8 @@ look_at(float x, float y, float z) { // "up" direction. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -heads_up(float x, float y, float z) { - heads_up(LPoint3f(x, y, z)); +heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + heads_up(LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -961,8 +961,8 @@ heads_up(float x, float y, float z) { // relative to the other node. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_pos(const NodePath &other, float x, float y, float z) { - set_pos(other, LPoint3f(x, y, z)); +set_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_pos(other, LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -974,21 +974,21 @@ set_pos(const NodePath &other, float x, float y, float z) { // position to its new position. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_fluid_pos(const NodePath &other, float x, float y, float z) { - set_fluid_pos(other, LPoint3f(x, y, z)); +set_fluid_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + set_fluid_pos(other, LPoint3(x, y, z)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_x(const NodePath &other) const { return get_pos(other)[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_y(const NodePath &other) const { return get_pos(other)[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_z(const NodePath &other) const { return get_pos(other)[2]; } @@ -1000,21 +1000,21 @@ get_z(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_hpr(const NodePath &other, float h, float p, float r) { - set_hpr(other, LPoint3f(h, p, r)); +set_hpr(const NodePath &other, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_hpr(other, LPoint3(h, p, r)); } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_h(const NodePath &other) const { return get_hpr(other)[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_p(const NodePath &other) const { return get_hpr(other)[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_r(const NodePath &other) const { return get_hpr(other)[2]; } @@ -1026,8 +1026,8 @@ get_r(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_scale(const NodePath &other, float scale) { - set_scale(other, LPoint3f(scale, scale, scale)); +set_scale(const NodePath &other, PN_stdfloat scale) { + set_scale(other, LPoint3(scale, scale, scale)); } //////////////////////////////////////////////////////////////////// @@ -1037,8 +1037,8 @@ set_scale(const NodePath &other, float scale) { // relative to the other node. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_scale(const NodePath &other, float sx, float sy, float sz) { - set_scale(other, LPoint3f(sx, sy, sz)); +set_scale(const NodePath &other, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_scale(other, LPoint3(sx, sy, sz)); } //////////////////////////////////////////////////////////////////// @@ -1047,17 +1047,17 @@ set_scale(const NodePath &other, float sx, float sy, float sz) { // Description: Returns the relative scale of the referenced node // as seen from the other node. //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sx(const NodePath &other) const { return get_scale(other)[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sy(const NodePath &other) const { return get_scale(other)[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sz(const NodePath &other) const { return get_scale(other)[2]; } @@ -1069,8 +1069,8 @@ get_sz(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_shear(const NodePath &other, float shxy, float shxz, float shyz) { - set_shear(other, LPoint3f(shxy, shxz, shyz)); +set_shear(const NodePath &other, PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) { + set_shear(other, LPoint3(shxy, shxz, shyz)); } //////////////////////////////////////////////////////////////////// @@ -1079,17 +1079,17 @@ set_shear(const NodePath &other, float shxy, float shxz, float shyz) { // Description: Returns the relative shear of the referenced node // as seen from the other node. //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shxy(const NodePath &other) const { return get_shear(other)[0]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shxz(const NodePath &other) const { return get_shear(other)[1]; } -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_shyz(const NodePath &other) const { return get_shear(other)[2]; } @@ -1102,9 +1102,9 @@ get_shyz(const NodePath &other) const { //////////////////////////////////////////////////////////////////// INLINE void NodePath:: set_pos_hpr(const NodePath &other, - float x, float y, float z, - float h, float p, float r) { - set_pos_hpr(other, LVecBase3f(x, y, z), LVecBase3f(h, p, r)); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_pos_hpr(other, LVecBase3(x, y, z), LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// @@ -1117,8 +1117,8 @@ set_pos_hpr(const NodePath &other, //////////////////////////////////////////////////////////////////// INLINE void NodePath:: set_hpr_scale(const NodePath &other, - float h, float p, float r, float sx, float sy, float sz) { - set_hpr_scale(other, LVecBase3f(h, p, r), LVecBase3f(sx, sy, sz)); + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_hpr_scale(other, LVecBase3(h, p, r), LVecBase3(sx, sy, sz)); } //////////////////////////////////////////////////////////////////// @@ -1130,11 +1130,11 @@ set_hpr_scale(const NodePath &other, //////////////////////////////////////////////////////////////////// INLINE void NodePath:: set_pos_hpr_scale(const NodePath &other, - float x, float y, float z, - float h, float p, float r, - float sx, float sy, float sz) { - set_pos_hpr_scale(other, LVecBase3f(x, y, z), LVecBase3f(h, p, r), - LVecBase3f(sx, sy, sz)); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { + set_pos_hpr_scale(other, LVecBase3(x, y, z), LVecBase3(h, p, r), + LVecBase3(sx, sy, sz)); } //////////////////////////////////////////////////////////////////// @@ -1145,8 +1145,8 @@ set_pos_hpr_scale(const NodePath &other, // to the other NodePath. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -look_at(const NodePath &other, float x, float y, float z) { - look_at(other, LPoint3f(x, y, z)); +look_at(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + look_at(other, LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -1157,8 +1157,8 @@ look_at(const NodePath &other, float x, float y, float z) { // "up" direction. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -heads_up(const NodePath &other, float x, float y, float z) { - heads_up(other, LPoint3f(x, y, z)); +heads_up(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + heads_up(other, LPoint3(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -1168,10 +1168,10 @@ heads_up(const NodePath &other, float x, float y, float z) { // referenced node's coordinate frame's origin, and that // of the other node's origin. //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_distance(const NodePath &other) const { - LPoint3f pos = get_pos(other); - return length(LVector3f(pos)); + LPoint3 pos = get_pos(other); + return length(LVector3(pos)); } //////////////////////////////////////////////////////////////////// @@ -1180,8 +1180,8 @@ get_distance(const NodePath &other) const { // Description: Sets the color scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_color_scale(float sr, float sg, float sb, float sa, int priority) { - set_color_scale(LVecBase4f(sr, sg, sb, sa), priority); +set_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) { + set_color_scale(LVecBase4(sr, sg, sb, sa), priority); } //////////////////////////////////////////////////////////////////// @@ -1190,8 +1190,8 @@ set_color_scale(float sr, float sg, float sb, float sa, int priority) { // Description: Sets the color scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -compose_color_scale(float sr, float sg, float sb, float sa, int priority) { - compose_color_scale(LVecBase4f(sr, sg, sb, sa), priority); +compose_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) { + compose_color_scale(LVecBase4(sr, sg, sb, sa), priority); } //////////////////////////////////////////////////////////////////// @@ -1200,8 +1200,8 @@ compose_color_scale(float sr, float sg, float sb, float sa, int priority) { // Description: Sets the red scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_sr(float sr) { - LVecBase4f new_scale = get_color_scale(); +set_sr(PN_stdfloat sr) { + LVecBase4 new_scale = get_color_scale(); new_scale[0] = sr; set_color_scale(new_scale); @@ -1213,8 +1213,8 @@ set_sr(float sr) { // Description: Sets the alpha scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_sg(float sg) { - LVecBase4f new_scale = get_color_scale(); +set_sg(PN_stdfloat sg) { + LVecBase4 new_scale = get_color_scale(); new_scale[1] = sg; set_color_scale(new_scale); @@ -1226,8 +1226,8 @@ set_sg(float sg) { // Description: Sets the blue scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_sb(float sb) { - LVecBase4f new_scale = get_color_scale(); +set_sb(PN_stdfloat sb) { + LVecBase4 new_scale = get_color_scale(); new_scale[2] = sb; set_color_scale(new_scale); @@ -1239,8 +1239,8 @@ set_sb(float sb) { // Description: Sets the alpha scale component of the transform //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_sa(float sa) { - LVecBase4f new_scale = get_color_scale(); +set_sa(PN_stdfloat sa) { + LVecBase4 new_scale = get_color_scale(); new_scale[3] = sa; set_color_scale(new_scale); @@ -1251,7 +1251,7 @@ set_sa(float sa) { // Access: Published // Description: Gets the red scale component of the transform //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sr() const { return get_color_scale()[0]; } @@ -1261,7 +1261,7 @@ get_sr() const { // Access: Published // Description: Gets the green scale component of the transform //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sg() const { return get_color_scale()[1]; } @@ -1271,7 +1271,7 @@ get_sg() const { // Access: Published // Description: Gets the blue scale component of the transform //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sb() const { return get_color_scale()[2]; } @@ -1281,7 +1281,7 @@ get_sb() const { // Access: Published // Description: Gets the alpha scale component of the transform //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_sa() const { return get_color_scale()[3]; } @@ -1296,8 +1296,8 @@ get_sa() const { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_offset(TextureStage *stage, float u, float v) { - set_tex_offset(stage, LVecBase2f(u, v)); +set_tex_offset(TextureStage *stage, PN_stdfloat u, PN_stdfloat v) { + set_tex_offset(stage, LVecBase2(u, v)); } //////////////////////////////////////////////////////////////////// @@ -1310,7 +1310,7 @@ set_tex_offset(TextureStage *stage, float u, float v) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_offset(TextureStage *stage, const LVecBase2f &uv) { +set_tex_offset(TextureStage *stage, const LVecBase2 &uv) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_pos2d(uv)); @@ -1327,7 +1327,7 @@ set_tex_offset(TextureStage *stage, const LVecBase2f &uv) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_rotate(TextureStage *stage, float r) { +set_tex_rotate(TextureStage *stage, PN_stdfloat r) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_rotate2d(r)); @@ -1343,7 +1343,7 @@ set_tex_rotate(TextureStage *stage, float r) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(TextureStage *stage, float scale) { +set_tex_scale(TextureStage *stage, PN_stdfloat scale) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_scale(scale)); @@ -1359,8 +1359,8 @@ set_tex_scale(TextureStage *stage, float scale) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(TextureStage *stage, float su, float sv) { - set_tex_scale(stage, LVecBase2f(su, sv)); +set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) { + set_tex_scale(stage, LVecBase2(su, sv)); } //////////////////////////////////////////////////////////////////// @@ -1373,7 +1373,7 @@ set_tex_scale(TextureStage *stage, float su, float sv) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(TextureStage *stage, const LVecBase2f &scale) { +set_tex_scale(TextureStage *stage, const LVecBase2 &scale) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_scale2d(scale)); @@ -1388,9 +1388,9 @@ set_tex_scale(TextureStage *stage, const LVecBase2f &scale) { // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f NodePath:: +INLINE LVecBase2 NodePath:: get_tex_offset(TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase2f::zero()); + nassertr_always(!is_empty(), LVecBase2::zero()); return get_tex_transform(stage)->get_pos2d(); } @@ -1403,7 +1403,7 @@ get_tex_offset(TextureStage *stage) const { // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_tex_rotate(TextureStage *stage) const { nassertr_always(!is_empty(), 0.0f); return get_tex_transform(stage)->get_rotate2d(); @@ -1418,9 +1418,9 @@ get_tex_rotate(TextureStage *stage) const { // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f NodePath:: +INLINE LVecBase2 NodePath:: get_tex_scale(TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase2f(1.0f, 1.0f)); + nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f)); return get_tex_transform(stage)->get_scale2d(); } @@ -1433,8 +1433,8 @@ get_tex_scale(TextureStage *stage) const { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_pos(TextureStage *stage, float u, float v, float w) { - set_tex_pos(stage, LVecBase3f(u, v, w)); +set_tex_pos(TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) { + set_tex_pos(stage, LVecBase3(u, v, w)); } //////////////////////////////////////////////////////////////////// @@ -1446,7 +1446,7 @@ set_tex_pos(TextureStage *stage, float u, float v, float w) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_pos(TextureStage *stage, const LVecBase3f &uvw) { +set_tex_pos(TextureStage *stage, const LVecBase3 &uvw) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_pos(uvw)); @@ -1462,8 +1462,8 @@ set_tex_pos(TextureStage *stage, const LVecBase3f &uvw) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_hpr(TextureStage *stage, float h, float p, float r) { - set_tex_hpr(stage, LVecBase3f(h, p, r)); +set_tex_hpr(TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_tex_hpr(stage, LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// @@ -1476,7 +1476,7 @@ set_tex_hpr(TextureStage *stage, float h, float p, float r) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_hpr(TextureStage *stage, const LVecBase3f &hpr) { +set_tex_hpr(TextureStage *stage, const LVecBase3 &hpr) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_hpr(hpr)); @@ -1491,8 +1491,8 @@ set_tex_hpr(TextureStage *stage, const LVecBase3f &hpr) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(TextureStage *stage, float su, float sv, float sw) { - set_tex_scale(stage, LVecBase3f(su, sv, sw)); +set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) { + set_tex_scale(stage, LVecBase3(su, sv, sw)); } //////////////////////////////////////////////////////////////////// @@ -1504,7 +1504,7 @@ set_tex_scale(TextureStage *stage, float su, float sv, float sw) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(TextureStage *stage, const LVecBase3f &scale) { +set_tex_scale(TextureStage *stage, const LVecBase3 &scale) { nassertv_always(!is_empty()); set_tex_transform(stage, get_tex_transform(stage)->set_scale(scale)); @@ -1518,9 +1518,9 @@ set_tex_scale(TextureStage *stage, const LVecBase3f &scale) { // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_pos(TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f::zero()); + nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_pos(); } @@ -1532,9 +1532,9 @@ get_tex_pos(TextureStage *stage) const { // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_hpr(TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f::zero()); + nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_hpr(); } @@ -1546,9 +1546,9 @@ get_tex_hpr(TextureStage *stage) const { // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_scale_3d(TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f(1.0f, 1.0f, 1.0f)); + nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f)); return get_tex_transform(stage)->get_scale(); } @@ -1562,8 +1562,8 @@ get_tex_scale_3d(TextureStage *stage) const { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_offset(const NodePath &other, TextureStage *stage, float u, float v) { - set_tex_offset(other, stage, LVecBase2f(u, v)); +set_tex_offset(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v) { + set_tex_offset(other, stage, LVecBase2(u, v)); } //////////////////////////////////////////////////////////////////// @@ -1576,7 +1576,7 @@ set_tex_offset(const NodePath &other, TextureStage *stage, float u, float v) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2f &uv) { +set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2 &uv) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(other, stage)->set_pos2d(uv)); @@ -1593,7 +1593,7 @@ set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2f &uv) // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_rotate(const NodePath &other, TextureStage *stage, float r) { +set_tex_rotate(const NodePath &other, TextureStage *stage, PN_stdfloat r) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(other, stage)->set_rotate2d(r)); @@ -1609,7 +1609,7 @@ set_tex_rotate(const NodePath &other, TextureStage *stage, float r) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(const NodePath &other, TextureStage *stage, float scale) { +set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat scale) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(stage)->set_scale(scale)); @@ -1625,8 +1625,8 @@ set_tex_scale(const NodePath &other, TextureStage *stage, float scale) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv) { - set_tex_scale(other, stage, LVecBase2f(su, sv)); +set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) { + set_tex_scale(other, stage, LVecBase2(su, sv)); } //////////////////////////////////////////////////////////////////// @@ -1639,7 +1639,7 @@ set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv) { // coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2f &scale) { +set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2 &scale) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(stage)->set_scale2d(scale)); @@ -1654,9 +1654,9 @@ set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2f &scal // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f NodePath:: +INLINE LVecBase2 NodePath:: get_tex_offset(const NodePath &other, TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase2f::zero()); + nassertr_always(!is_empty(), LVecBase2::zero()); return get_tex_transform(other, stage)->get_pos2d(); } @@ -1669,7 +1669,7 @@ get_tex_offset(const NodePath &other, TextureStage *stage) const { // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE float NodePath:: +INLINE PN_stdfloat NodePath:: get_tex_rotate(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), 0.0f); return get_tex_transform(other, stage)->get_rotate2d(); @@ -1684,9 +1684,9 @@ get_tex_rotate(const NodePath &other, TextureStage *stage) const { // This call is appropriate for ordinary 2-d texture // coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f NodePath:: +INLINE LVecBase2 NodePath:: get_tex_scale(const NodePath &other, TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase2f(1.0f, 1.0f)); + nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f)); return get_tex_transform(other, stage)->get_scale2d(); } @@ -1699,8 +1699,8 @@ get_tex_scale(const NodePath &other, TextureStage *stage) const { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_pos(const NodePath &other, TextureStage *stage, float u, float v, float w) { - set_tex_pos(other, stage, LVecBase3f(u, v, w)); +set_tex_pos(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) { + set_tex_pos(other, stage, LVecBase3(u, v, w)); } //////////////////////////////////////////////////////////////////// @@ -1712,7 +1712,7 @@ set_tex_pos(const NodePath &other, TextureStage *stage, float u, float v, float // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3f &uvw) { +set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3 &uvw) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(stage)->set_pos(uvw)); @@ -1728,8 +1728,8 @@ set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3f &uvw) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_hpr(const NodePath &other, TextureStage *stage, float h, float p, float r) { - set_tex_hpr(other, stage, LVecBase3f(h, p, r)); +set_tex_hpr(const NodePath &other, TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + set_tex_hpr(other, stage, LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// @@ -1742,7 +1742,7 @@ set_tex_hpr(const NodePath &other, TextureStage *stage, float h, float p, float // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3f &hpr) { +set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3 &hpr) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(stage)->set_hpr(hpr)); @@ -1757,8 +1757,8 @@ set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3f &hpr) { // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv, float sw) { - set_tex_scale(other, stage, LVecBase3f(su, sv, sw)); +set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) { + set_tex_scale(other, stage, LVecBase3(su, sv, sw)); } //////////////////////////////////////////////////////////////////// @@ -1770,7 +1770,7 @@ set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv, fl // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3f &scale) { +set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3 &scale) { nassertv_always(!is_empty()); set_tex_transform(other, stage, get_tex_transform(stage)->set_scale(scale)); @@ -1784,9 +1784,9 @@ set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3f &scal // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_pos(const NodePath &other, TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f::zero()); + nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_pos(); } @@ -1798,9 +1798,9 @@ get_tex_pos(const NodePath &other, TextureStage *stage) const { // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_hpr(const NodePath &other, TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f::zero()); + nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_hpr(); } @@ -1812,9 +1812,9 @@ get_tex_hpr(const NodePath &other, TextureStage *stage) const { // // This call is appropriate for 3-d texture coordinates. //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f NodePath:: +INLINE LVecBase3 NodePath:: get_tex_scale_3d(const NodePath &other, TextureStage *stage) const { - nassertr_always(!is_empty(), LVecBase3f(1.0f, 1.0f, 1.0f)); + nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f)); return get_tex_transform(stage)->get_scale(); } @@ -1850,7 +1850,7 @@ has_texcoord(const string &texcoord_name) const { // will rotate in two dimensions around the up axis. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_billboard_axis(float offset) { +set_billboard_axis(PN_stdfloat offset) { set_billboard_axis(NodePath(), offset); } @@ -1863,7 +1863,7 @@ set_billboard_axis(float offset) { // camera. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_billboard_point_eye(float offset) { +set_billboard_point_eye(PN_stdfloat offset) { set_billboard_point_eye(NodePath(), offset); } @@ -1875,7 +1875,7 @@ set_billboard_point_eye(float offset) { // keeping its up vector oriented to the sky. //////////////////////////////////////////////////////////////////// INLINE void NodePath:: -set_billboard_point_world(float offset) { +set_billboard_point_world(PN_stdfloat offset) { set_billboard_point_world(NodePath(), offset); } diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 7dc087cf6d..b9a40dd123 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -1259,32 +1259,32 @@ set_prev_transform(const NodePath &other, const TransformState *transform, // See Also: NodePath::set_fluid_pos //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos(const LVecBase3f &pos) { +set_pos(const LVecBase3 &pos) { nassertv_always(!is_empty()); set_transform(get_transform()->set_pos(pos)); node()->reset_prev_transform(); } void NodePath:: -set_x(float x) { +set_x(PN_stdfloat x) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[0] = x; set_pos(pos); } void NodePath:: -set_y(float y) { +set_y(PN_stdfloat y) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[1] = y; set_pos(pos); } void NodePath:: -set_z(float z) { +set_z(PN_stdfloat z) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[2] = z; set_pos(pos); } @@ -1299,31 +1299,31 @@ set_z(float z) { // See Also: NodePath::set_pos //////////////////////////////////////////////////////////////////// void NodePath:: -set_fluid_pos(const LVecBase3f &pos) { +set_fluid_pos(const LVecBase3 &pos) { nassertv_always(!is_empty()); set_transform(get_transform()->set_pos(pos)); } void NodePath:: -set_fluid_x(float x) { +set_fluid_x(PN_stdfloat x) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[0] = x; set_fluid_pos(pos); } void NodePath:: -set_fluid_y(float y) { +set_fluid_y(PN_stdfloat y) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[1] = y; set_fluid_pos(pos); } void NodePath:: -set_fluid_z(float z) { +set_fluid_z(PN_stdfloat z) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); pos[2] = z; set_fluid_pos(pos); } @@ -1333,9 +1333,9 @@ set_fluid_z(float z) { // Access: Published // Description: Retrieves the translation component of the transform. //////////////////////////////////////////////////////////////////// -LPoint3f NodePath:: +LPoint3 NodePath:: get_pos() const { - nassertr_always(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform()->get_pos(); } @@ -1353,9 +1353,9 @@ get_pos() const { // will represent the change from the previous frame's // position. //////////////////////////////////////////////////////////////////// -LVector3f NodePath:: +LVector3 NodePath:: get_pos_delta() const { - nassertr_always(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform()->get_pos() - get_prev_transform()->get_pos(); } @@ -1366,7 +1366,7 @@ get_pos_delta() const { // leaving translation and scale untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_hpr(const LVecBase3f &hpr) { +set_hpr(const LVecBase3 &hpr) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); nassertv(transform->has_hpr()); @@ -1374,31 +1374,31 @@ set_hpr(const LVecBase3f &hpr) { } void NodePath:: -set_h(float h) { +set_h(PN_stdfloat h) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); nassertv(transform->has_hpr()); - LVecBase3f hpr = transform->get_hpr(); + LVecBase3 hpr = transform->get_hpr(); hpr[0] = h; set_transform(transform->set_hpr(hpr)); } void NodePath:: -set_p(float p) { +set_p(PN_stdfloat p) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); nassertv(transform->has_hpr()); - LVecBase3f hpr = transform->get_hpr(); + LVecBase3 hpr = transform->get_hpr(); hpr[1] = p; set_transform(transform->set_hpr(hpr)); } void NodePath:: -set_r(float r) { +set_r(PN_stdfloat r) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); nassertv(transform->has_hpr()); - LVecBase3f hpr = transform->get_hpr(); + LVecBase3 hpr = transform->get_hpr(); hpr[2] = r; set_transform(transform->set_hpr(hpr)); } @@ -1408,11 +1408,11 @@ set_r(float r) { // Access: Published // Description: Retrieves the rotation component of the transform. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_hpr() const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(); - nassertr(transform->has_hpr(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr(transform->has_hpr(), LVecBase3(0.0f, 0.0f, 0.0f)); return transform->get_hpr(); } @@ -1423,7 +1423,7 @@ get_hpr() const { // leaving translation and scale untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_quat(const LQuaternionf &quat) { +set_quat(const LQuaternion &quat) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); set_transform(transform->set_quat(quat)); @@ -1434,9 +1434,9 @@ set_quat(const LQuaternionf &quat) { // Access: Published // Description: Retrieves the rotation component of the transform. //////////////////////////////////////////////////////////////////// -LQuaternionf NodePath:: +LQuaternion NodePath:: get_quat() const { - nassertr_always(!is_empty(), LQuaternionf::ident_quat()); + nassertr_always(!is_empty(), LQuaternion::ident_quat()); CPT(TransformState) transform = get_transform(); return transform->get_quat(); } @@ -1448,35 +1448,35 @@ get_quat() const { // leaving translation and rotation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_scale(const LVecBase3f &scale) { +set_scale(const LVecBase3 &scale) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); set_transform(transform->set_scale(scale)); } void NodePath:: -set_sx(float sx) { +set_sx(PN_stdfloat sx) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f scale = transform->get_scale(); + LVecBase3 scale = transform->get_scale(); scale[0] = sx; set_transform(transform->set_scale(scale)); } void NodePath:: -set_sy(float sy) { +set_sy(PN_stdfloat sy) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f scale = transform->get_scale(); + LVecBase3 scale = transform->get_scale(); scale[1] = sy; set_transform(transform->set_scale(scale)); } void NodePath:: -set_sz(float sz) { +set_sz(PN_stdfloat sz) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f scale = transform->get_scale(); + LVecBase3 scale = transform->get_scale(); scale[2] = sz; set_transform(transform->set_scale(scale)); } @@ -1486,9 +1486,9 @@ set_sz(float sz) { // Access: Published // Description: Retrieves the scale component of the transform. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_scale() const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(); return transform->get_scale(); } @@ -1500,35 +1500,35 @@ get_scale() const { // leaving translation and rotation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_shear(const LVecBase3f &shear) { +set_shear(const LVecBase3 &shear) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); set_transform(transform->set_shear(shear)); } void NodePath:: -set_shxy(float shxy) { +set_shxy(PN_stdfloat shxy) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f shear = transform->get_shear(); + LVecBase3 shear = transform->get_shear(); shear[0] = shxy; set_transform(transform->set_shear(shear)); } void NodePath:: -set_shxz(float shxz) { +set_shxz(PN_stdfloat shxz) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f shear = transform->get_shear(); + LVecBase3 shear = transform->get_shear(); shear[1] = shxz; set_transform(transform->set_shear(shear)); } void NodePath:: -set_shyz(float shyz) { +set_shyz(PN_stdfloat shyz) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); - LVecBase3f shear = transform->get_shear(); + LVecBase3 shear = transform->get_shear(); shear[2] = shyz; set_transform(transform->set_shear(shear)); } @@ -1538,9 +1538,9 @@ set_shyz(float shyz) { // Access: Published // Description: Retrieves the shear component of the transform. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_shear() const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(); return transform->get_shear(); } @@ -1552,7 +1552,7 @@ get_shear() const { // transform, leaving scale untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { +set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); transform = TransformState::make_pos_hpr_scale_shear @@ -1568,7 +1568,7 @@ set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { // transform, leaving scale untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_quat(const LVecBase3f &pos, const LQuaternionf &quat) { +set_pos_quat(const LVecBase3 &pos, const LQuaternion &quat) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); transform = TransformState::make_pos_quat_scale_shear @@ -1584,7 +1584,7 @@ set_pos_quat(const LVecBase3f &pos, const LQuaternionf &quat) { // transform, leaving translation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_hpr_scale(const LVecBase3f &hpr, const LVecBase3f &scale) { +set_hpr_scale(const LVecBase3 &hpr, const LVecBase3 &scale) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); transform = TransformState::make_pos_hpr_scale_shear @@ -1599,7 +1599,7 @@ set_hpr_scale(const LVecBase3f &hpr, const LVecBase3f &scale) { // transform, leaving translation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_quat_scale(const LQuaternionf &quat, const LVecBase3f &scale) { +set_quat_scale(const LQuaternion &quat, const LVecBase3 &scale) { nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(); transform = TransformState::make_pos_quat_scale_shear @@ -1614,8 +1614,8 @@ set_quat_scale(const LQuaternionf &quat, const LVecBase3f &scale) { // components, implicitly setting shear to 0. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale) { +set_pos_hpr_scale(const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale) { nassertv_always(!is_empty()); set_transform(TransformState::make_pos_hpr_scale (pos, hpr, scale)); @@ -1629,8 +1629,8 @@ set_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr, // components, implicitly setting shear to 0. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale) { +set_pos_quat_scale(const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale) { nassertv_always(!is_empty()); set_transform(TransformState::make_pos_quat_scale (pos, quat, scale)); @@ -1644,8 +1644,8 @@ set_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat, // translation, rotation, scale, and shear components. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale, const LVecBase3f &shear) { +set_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertv_always(!is_empty()); set_transform(TransformState::make_pos_hpr_scale_shear (pos, hpr, scale, shear)); @@ -1659,8 +1659,8 @@ set_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr, // translation, rotation, scale, and shear components. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale, const LVecBase3f &shear) { +set_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertv_always(!is_empty()); set_transform(TransformState::make_pos_quat_scale_shear (pos, quat, scale, shear)); @@ -1673,7 +1673,7 @@ set_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat, // Description: Directly sets an arbitrary 4x4 transform matrix. //////////////////////////////////////////////////////////////////// void NodePath:: -set_mat(const LMatrix4f &mat) { +set_mat(const LMatrix4 &mat) { nassertv_always(!is_empty()); set_transform(TransformState::make_mat(mat)); node()->reset_prev_transform(); @@ -1686,12 +1686,12 @@ set_mat(const LMatrix4f &mat) { // rotates to face the indicated point in space. //////////////////////////////////////////////////////////////////// void NodePath:: -look_at(const LPoint3f &point, const LVector3f &up) { +look_at(const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); - LQuaternionf quat; + LQuaternion quat; ::look_at(quat, point - pos, up); set_quat(quat); } @@ -1704,12 +1704,12 @@ look_at(const LPoint3f &point, const LVector3f &up) { // "up" direction. //////////////////////////////////////////////////////////////////// void NodePath:: -heads_up(const LPoint3f &point, const LVector3f &up) { +heads_up(const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); - LQuaternionf quat; + LQuaternion quat; ::heads_up(quat, point - pos, up); set_quat(quat); } @@ -1721,7 +1721,7 @@ heads_up(const LPoint3f &point, const LVector3f &up) { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos(const NodePath &other, const LVecBase3f &pos) { +set_pos(const NodePath &other, const LVecBase3 &pos) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -1731,9 +1731,9 @@ set_pos(const NodePath &other, const LVecBase3f &pos) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_hpr = orig_transform->get_hpr(); - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_hpr = orig_transform->get_hpr(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, rel_transform->set_pos(pos)); set_pos_hpr_scale_shear(get_transform()->get_pos(), orig_hpr, orig_scale, orig_shear); @@ -1747,25 +1747,25 @@ set_pos(const NodePath &other, const LVecBase3f &pos) { } void NodePath:: -set_x(const NodePath &other, float x) { +set_x(const NodePath &other, PN_stdfloat x) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[0] = x; set_pos(other, pos); } void NodePath:: -set_y(const NodePath &other, float y) { +set_y(const NodePath &other, PN_stdfloat y) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[1] = y; set_pos(other, pos); } void NodePath:: -set_z(const NodePath &other, float z) { +set_z(const NodePath &other, PN_stdfloat z) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[2] = z; set_pos(other, pos); } @@ -1777,7 +1777,7 @@ set_z(const NodePath &other, float z) { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_fluid_pos(const NodePath &other, const LVecBase3f &pos) { +set_fluid_pos(const NodePath &other, const LVecBase3 &pos) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -1787,9 +1787,9 @@ set_fluid_pos(const NodePath &other, const LVecBase3f &pos) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_hpr = orig_transform->get_hpr(); - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_hpr = orig_transform->get_hpr(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); // Use the relative set_transform() to compute the relative pos, and // then reset all of the other components back to the way they were. @@ -1805,25 +1805,25 @@ set_fluid_pos(const NodePath &other, const LVecBase3f &pos) { } void NodePath:: -set_fluid_x(const NodePath &other, float x) { +set_fluid_x(const NodePath &other, PN_stdfloat x) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[0] = x; set_fluid_pos(other, pos); } void NodePath:: -set_fluid_y(const NodePath &other, float y) { +set_fluid_y(const NodePath &other, PN_stdfloat y) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[1] = y; set_fluid_pos(other, pos); } void NodePath:: -set_fluid_z(const NodePath &other, float z) { +set_fluid_z(const NodePath &other, PN_stdfloat z) { nassertv_always(!is_empty()); - LPoint3f pos = get_pos(other); + LPoint3 pos = get_pos(other); pos[2] = z; set_fluid_pos(other, pos); } @@ -1834,9 +1834,9 @@ set_fluid_z(const NodePath &other, float z) { // Description: Returns the relative position of the referenced node // as seen from the other node. //////////////////////////////////////////////////////////////////// -LPoint3f NodePath:: +LPoint3 NodePath:: get_pos(const NodePath &other) const { - nassertr_always(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform(other)->get_pos(); } @@ -1855,9 +1855,9 @@ get_pos(const NodePath &other) const { // will represent the change from the previous frame's // position. //////////////////////////////////////////////////////////////////// -LVector3f NodePath:: +LVector3 NodePath:: get_pos_delta(const NodePath &other) const { - nassertr_always(!is_empty(), LPoint3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform(other)->get_pos() - get_prev_transform(other)->get_pos(); } @@ -1868,7 +1868,7 @@ get_pos_delta(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_hpr(const NodePath &other, const LVecBase3f &hpr) { +set_hpr(const NodePath &other, const LVecBase3 &hpr) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); nassertv(rel_transform->has_hpr()); @@ -1879,9 +1879,9 @@ set_hpr(const NodePath &other, const LVecBase3f &hpr) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_pos = orig_transform->get_pos(); - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_pos = orig_transform->get_pos(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, rel_transform->set_hpr(hpr)); const TransformState *new_transform = get_transform(); @@ -1898,25 +1898,25 @@ set_hpr(const NodePath &other, const LVecBase3f &hpr) { } void NodePath:: -set_h(const NodePath &other, float h) { +set_h(const NodePath &other, PN_stdfloat h) { nassertv_always(!is_empty()); - LVecBase3f hpr = get_hpr(other); + LVecBase3 hpr = get_hpr(other); hpr[0] = h; set_hpr(other, hpr); } void NodePath:: -set_p(const NodePath &other, float p) { +set_p(const NodePath &other, PN_stdfloat p) { nassertv_always(!is_empty()); - LVecBase3f hpr = get_hpr(other); + LVecBase3 hpr = get_hpr(other); hpr[1] = p; set_hpr(other, hpr); } void NodePath:: -set_r(const NodePath &other, float r) { +set_r(const NodePath &other, PN_stdfloat r) { nassertv_always(!is_empty()); - LVecBase3f hpr = get_hpr(other); + LVecBase3 hpr = get_hpr(other); hpr[2] = r; set_hpr(other, hpr); } @@ -1927,11 +1927,11 @@ set_r(const NodePath &other, float r) { // Description: Returns the relative orientation of the bottom node // as seen from the other node. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_hpr(const NodePath &other) const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(other); - nassertr(transform->has_hpr(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr(transform->has_hpr(), LVecBase3(0.0f, 0.0f, 0.0f)); return transform->get_hpr(); } @@ -1942,7 +1942,7 @@ get_hpr(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_quat(const NodePath &other, const LQuaternionf &quat) { +set_quat(const NodePath &other, const LQuaternion &quat) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -1952,9 +1952,9 @@ set_quat(const NodePath &other, const LQuaternionf &quat) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_pos = orig_transform->get_pos(); - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_pos = orig_transform->get_pos(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, rel_transform->set_quat(quat)); const TransformState *new_transform = get_transform(); @@ -1976,9 +1976,9 @@ set_quat(const NodePath &other, const LQuaternionf &quat) { // Description: Returns the relative orientation of the bottom node // as seen from the other node. //////////////////////////////////////////////////////////////////// -LQuaternionf NodePath:: +LQuaternion NodePath:: get_quat(const NodePath &other) const { - nassertr_always(!is_empty(), LQuaternionf::ident_quat()); + nassertr_always(!is_empty(), LQuaternion::ident_quat()); CPT(TransformState) transform = get_transform(other); return transform->get_quat(); } @@ -1990,7 +1990,7 @@ get_quat(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_scale(const NodePath &other, const LVecBase3f &scale) { +set_scale(const NodePath &other, const LVecBase3 &scale) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -2000,9 +2000,9 @@ set_scale(const NodePath &other, const LVecBase3f &scale) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_pos = orig_transform->get_pos(); - const LVecBase3f &orig_hpr = orig_transform->get_hpr(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_pos = orig_transform->get_pos(); + const LVecBase3 &orig_hpr = orig_transform->get_hpr(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, rel_transform->set_scale(scale)); const TransformState *new_transform = get_transform(); @@ -2019,25 +2019,25 @@ set_scale(const NodePath &other, const LVecBase3f &scale) { } void NodePath:: -set_sx(const NodePath &other, float sx) { +set_sx(const NodePath &other, PN_stdfloat sx) { nassertv_always(!is_empty()); - LVecBase3f scale = get_scale(other); + LVecBase3 scale = get_scale(other); scale[0] = sx; set_scale(other, scale); } void NodePath:: -set_sy(const NodePath &other, float sy) { +set_sy(const NodePath &other, PN_stdfloat sy) { nassertv_always(!is_empty()); - LVecBase3f scale = get_scale(other); + LVecBase3 scale = get_scale(other); scale[1] = sy; set_scale(other, scale); } void NodePath:: -set_sz(const NodePath &other, float sz) { +set_sz(const NodePath &other, PN_stdfloat sz) { nassertv_always(!is_empty()); - LVecBase3f scale = get_scale(other); + LVecBase3 scale = get_scale(other); scale[2] = sz; set_scale(other, scale); } @@ -2048,9 +2048,9 @@ set_sz(const NodePath &other, float sz) { // Description: Returns the relative scale of the bottom node // as seen from the other node. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_scale(const NodePath &other) const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(other); return transform->get_scale(); } @@ -2062,7 +2062,7 @@ get_scale(const NodePath &other) const { // relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_shear(const NodePath &other, const LVecBase3f &shear) { +set_shear(const NodePath &other, const LVecBase3 &shear) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -2072,9 +2072,9 @@ set_shear(const NodePath &other, const LVecBase3f &shear) { // should be careful to preserve the other three components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_pos = orig_transform->get_pos(); - const LVecBase3f &orig_hpr = orig_transform->get_hpr(); - const LVecBase3f &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_pos = orig_transform->get_pos(); + const LVecBase3 &orig_hpr = orig_transform->get_hpr(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); set_transform(other, rel_transform->set_shear(shear)); const TransformState *new_transform = get_transform(); @@ -2091,25 +2091,25 @@ set_shear(const NodePath &other, const LVecBase3f &shear) { } void NodePath:: -set_shxy(const NodePath &other, float shxy) { +set_shxy(const NodePath &other, PN_stdfloat shxy) { nassertv_always(!is_empty()); - LVecBase3f shear = get_shear(other); + LVecBase3 shear = get_shear(other); shear[0] = shxy; set_shear(other, shear); } void NodePath:: -set_shxz(const NodePath &other, float shxz) { +set_shxz(const NodePath &other, PN_stdfloat shxz) { nassertv_always(!is_empty()); - LVecBase3f shear = get_shear(other); + LVecBase3 shear = get_shear(other); shear[1] = shxz; set_shear(other, shear); } void NodePath:: -set_shyz(const NodePath &other, float shyz) { +set_shyz(const NodePath &other, PN_stdfloat shyz) { nassertv_always(!is_empty()); - LVecBase3f shear = get_shear(other); + LVecBase3 shear = get_shear(other); shear[2] = shyz; set_shear(other, shear); } @@ -2120,9 +2120,9 @@ set_shyz(const NodePath &other, float shyz) { // Description: Returns the relative shear of the bottom node // as seen from the other node. //////////////////////////////////////////////////////////////////// -LVecBase3f NodePath:: +LVecBase3 NodePath:: get_shear(const NodePath &other) const { - nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f)); + nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); CPT(TransformState) transform = get_transform(other); return transform->get_shear(); } @@ -2134,8 +2134,8 @@ get_shear(const NodePath &other) const { // transform, relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_hpr(const NodePath &other, const LVecBase3f &pos, - const LVecBase3f &hpr) { +set_pos_hpr(const NodePath &other, const LVecBase3 &pos, + const LVecBase3 &hpr) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -2145,8 +2145,8 @@ set_pos_hpr(const NodePath &other, const LVecBase3f &pos, // should be careful to preserve the other two components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, TransformState::make_pos_hpr_scale_shear (pos, hpr, rel_transform->get_scale(), rel_transform->get_shear())); @@ -2172,8 +2172,8 @@ set_pos_hpr(const NodePath &other, const LVecBase3f &pos, // transform, relative to the other node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_pos_quat(const NodePath &other, const LVecBase3f &pos, - const LQuaternionf &quat) { +set_pos_quat(const NodePath &other, const LVecBase3 &pos, + const LQuaternion &quat) { nassertv_always(!is_empty()); CPT(TransformState) rel_transform = get_transform(other); @@ -2183,8 +2183,8 @@ set_pos_quat(const NodePath &other, const LVecBase3f &pos, // should be careful to preserve the other two components. We // wouldn't need to do this, except for the possibility of // numerical error or decompose ambiguity. - const LVecBase3f &orig_scale = orig_transform->get_scale(); - const LVecBase3f &orig_shear = orig_transform->get_shear(); + const LVecBase3 &orig_scale = orig_transform->get_scale(); + const LVecBase3 &orig_shear = orig_transform->get_shear(); set_transform(other, TransformState::make_pos_quat_scale_shear (pos, quat, rel_transform->get_scale(), rel_transform->get_shear())); @@ -2212,7 +2212,7 @@ set_pos_quat(const NodePath &other, const LVecBase3f &pos, // transform when both hpr and scale are to be changed. //////////////////////////////////////////////////////////////////// void NodePath:: -set_hpr_scale(const NodePath &other, const LVecBase3f &hpr, const LVecBase3f &scale) { +set_hpr_scale(const NodePath &other, const LVecBase3 &hpr, const LVecBase3 &scale) { // We don't bother trying very hard to preserve pos across this // operation, unlike the work we do above to preserve hpr or scale, // since it generally doesn't matter that much if pos is off by a @@ -2233,8 +2233,8 @@ set_hpr_scale(const NodePath &other, const LVecBase3f &hpr, const LVecBase3f &sc // transform when both quat and scale are to be changed. //////////////////////////////////////////////////////////////////// void NodePath:: -set_quat_scale(const NodePath &other, const LQuaternionf &quat, - const LVecBase3f &scale) { +set_quat_scale(const NodePath &other, const LQuaternion &quat, + const LVecBase3 &scale) { // We don't bother trying very hard to preserve pos across this // operation, unlike the work we do above to preserve quat or scale, // since it generally doesn't matter that much if pos is off by a @@ -2255,8 +2255,8 @@ set_quat_scale(const NodePath &other, const LQuaternionf &quat, //////////////////////////////////////////////////////////////////// void NodePath:: set_pos_hpr_scale(const NodePath &other, - const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale) { + const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale) { nassertv_always(!is_empty()); set_transform(other, TransformState::make_pos_hpr_scale (pos, hpr, scale)); @@ -2272,8 +2272,8 @@ set_pos_hpr_scale(const NodePath &other, //////////////////////////////////////////////////////////////////// void NodePath:: set_pos_quat_scale(const NodePath &other, - const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale) { + const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale) { nassertv_always(!is_empty()); set_transform(other, TransformState::make_pos_quat_scale (pos, quat, scale)); @@ -2289,8 +2289,8 @@ set_pos_quat_scale(const NodePath &other, //////////////////////////////////////////////////////////////////// void NodePath:: set_pos_hpr_scale_shear(const NodePath &other, - const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale, const LVecBase3f &shear) { + const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertv_always(!is_empty()); set_transform(other, TransformState::make_pos_hpr_scale_shear (pos, hpr, scale, shear)); @@ -2306,8 +2306,8 @@ set_pos_hpr_scale_shear(const NodePath &other, //////////////////////////////////////////////////////////////////// void NodePath:: set_pos_quat_scale_shear(const NodePath &other, - const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale, const LVecBase3f &shear) { + const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertv_always(!is_empty()); set_transform(other, TransformState::make_pos_quat_scale_shear (pos, quat, scale, shear)); @@ -2321,7 +2321,7 @@ set_pos_quat_scale_shear(const NodePath &other, // space of the bottom node, relative to the other // path's bottom node's coordinate space. //////////////////////////////////////////////////////////////////// -LMatrix4f NodePath:: +LMatrix4 NodePath:: get_mat(const NodePath &other) const { CPT(TransformState) transform = get_transform(other); // We can't safely return a reference to the matrix, because we @@ -2340,7 +2340,7 @@ get_mat(const NodePath &other) const { // applies it to the node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_mat(const NodePath &other, const LMatrix4f &mat) { +set_mat(const NodePath &other, const LMatrix4 &mat) { nassertv_always(!is_empty()); set_transform(other, TransformState::make_mat(mat)); node()->reset_prev_transform(); @@ -2353,10 +2353,10 @@ set_mat(const NodePath &other, const LMatrix4f &mat) { // system of the other node, returns the same point in // this node's coordinate system. //////////////////////////////////////////////////////////////////// -LPoint3f NodePath:: -get_relative_point(const NodePath &other, const LVecBase3f &point) const { +LPoint3 NodePath:: +get_relative_point(const NodePath &other, const LVecBase3 &point) const { CPT(TransformState) transform = other.get_transform(*this); - LPoint3f rel_point = LPoint3f(point) * transform->get_mat(); + LPoint3 rel_point = LPoint3(point) * transform->get_mat(); return rel_point; } @@ -2367,10 +2367,10 @@ get_relative_point(const NodePath &other, const LVecBase3f &point) const { // system of the other node, returns the same vector in // this node's coordinate system. //////////////////////////////////////////////////////////////////// -LVector3f NodePath:: -get_relative_vector(const NodePath &other, const LVecBase3f &vec) const { +LVector3 NodePath:: +get_relative_vector(const NodePath &other, const LVecBase3 &vec) const { CPT(TransformState) transform = other.get_transform(*this); - LVector3f rel_vector = LVector3f(vec) * transform->get_mat(); + LVector3 rel_vector = LVector3(vec) * transform->get_mat(); return rel_vector; } @@ -2382,15 +2382,15 @@ get_relative_vector(const NodePath &other, const LVecBase3f &vec) const { // is relative to the other NodePath. //////////////////////////////////////////////////////////////////// void NodePath:: -look_at(const NodePath &other, const LPoint3f &point, const LVector3f &up) { +look_at(const NodePath &other, const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); CPT(TransformState) transform = other.get_transform(get_parent()); - LPoint3f rel_point = point * transform->get_mat(); + LPoint3 rel_point = point * transform->get_mat(); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); - LQuaternionf quat; + LQuaternion quat; ::look_at(quat, rel_point - pos, up); set_quat(quat); } @@ -2403,15 +2403,15 @@ look_at(const NodePath &other, const LPoint3f &point, const LVector3f &up) { // "up" direction. //////////////////////////////////////////////////////////////////// void NodePath:: -heads_up(const NodePath &other, const LPoint3f &point, const LVector3f &up) { +heads_up(const NodePath &other, const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); CPT(TransformState) transform = other.get_transform(get_parent()); - LPoint3f rel_point = point * transform->get_mat(); + LPoint3 rel_point = point * transform->get_mat(); - LPoint3f pos = get_pos(); + LPoint3 pos = get_pos(); - LQuaternionf quat; + LQuaternion quat; ::heads_up(quat, rel_point - pos, up); set_quat(quat); } @@ -2426,9 +2426,9 @@ heads_up(const NodePath &other, const LPoint3f &point, const LVector3f &up) { // set_color_off()). //////////////////////////////////////////////////////////////////// void NodePath:: -set_color(float r, float g, float b, float a, +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { - set_color(Colorf(r, g, b, a), priority); + set_color(LColor(r, g, b, a), priority); } //////////////////////////////////////////////////////////////////// @@ -2440,7 +2440,7 @@ set_color(float r, float g, float b, float a, // set_color_off()). //////////////////////////////////////////////////////////////////// void NodePath:: -set_color(const Colorf &color, int priority) { +set_color(const LColor &color, int priority) { nassertv_always(!is_empty()); node()->set_attrib(ColorAttrib::make_flat(color), priority); } @@ -2493,7 +2493,7 @@ has_color() const { // Description: Returns the color that has been assigned to the node, // or black if no color has been assigned. //////////////////////////////////////////////////////////////////// -Colorf NodePath:: +LColor NodePath:: get_color() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = @@ -2508,7 +2508,7 @@ get_color() const { pgraph_cat.warning() << "get_color() called on " << *this << " which has no color set.\n"; - return Colorf(1.0f, 1.0f, 1.0f, 1.0f); + return LColor(1.0f, 1.0f, 1.0f, 1.0f); } //////////////////////////////////////////////////////////////////// @@ -2548,7 +2548,7 @@ clear_color_scale() { // rotation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -compose_color_scale(const LVecBase4f &scale, int priority) { +compose_color_scale(const LVecBase4 &scale, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -2560,8 +2560,8 @@ compose_color_scale(const LVecBase4f &scale, int priority) { // Modify the existing ColorScaleAttrib by multiplying with the // indicated colorScale. - LVecBase4f prev_color_scale = csa->get_scale(); - LVecBase4f new_color_scale(prev_color_scale[0]*scale[0], + LVecBase4 prev_color_scale = csa->get_scale(); + LVecBase4 new_color_scale(prev_color_scale[0]*scale[0], prev_color_scale[1]*scale[1], prev_color_scale[2]*scale[2], prev_color_scale[3]*scale[3]); @@ -2580,7 +2580,7 @@ compose_color_scale(const LVecBase4f &scale, int priority) { // leaving translation and rotation untouched. //////////////////////////////////////////////////////////////////// void NodePath:: -set_color_scale(const LVecBase4f &scale, int priority) { +set_color_scale(const LVecBase4 &scale, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -2631,7 +2631,7 @@ set_color_scale_off(int priority) { // scale. //////////////////////////////////////////////////////////////////// void NodePath:: -set_alpha_scale(float scale, int priority) { +set_alpha_scale(PN_stdfloat scale, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -2643,12 +2643,12 @@ set_alpha_scale(float scale, int priority) { // Modify the existing ColorScaleAttrib to add the indicated // colorScale. - const LVecBase4f &sc = csa->get_scale(); - node()->set_attrib(csa->set_scale(LVecBase4f(sc[0], sc[1], sc[2], scale)), priority); + const LVecBase4 &sc = csa->get_scale(); + node()->set_attrib(csa->set_scale(LVecBase4(sc[0], sc[1], sc[2], scale)), priority); } else { // Create a new ColorScaleAttrib for this node. - node()->set_attrib(ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, scale)), priority); + node()->set_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, scale)), priority); } } @@ -2661,7 +2661,7 @@ set_alpha_scale(float scale, int priority) { // will also apply to the alpha scale. //////////////////////////////////////////////////////////////////// void NodePath:: -set_all_color_scale(float scale, int priority) { +set_all_color_scale(PN_stdfloat scale, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -2673,12 +2673,12 @@ set_all_color_scale(float scale, int priority) { // Modify the existing ColorScaleAttrib to add the indicated // colorScale. - const LVecBase4f &sc = csa->get_scale(); - node()->set_attrib(csa->set_scale(LVecBase4f(scale, scale, scale, sc[3])), priority); + const LVecBase4 &sc = csa->get_scale(); + node()->set_attrib(csa->set_scale(LVecBase4(scale, scale, scale, sc[3])), priority); } else { // Create a new ColorScaleAttrib for this node. - node()->set_attrib(ColorScaleAttrib::make(LVecBase4f(scale, scale, scale, 1.0f)), priority); + node()->set_attrib(ColorScaleAttrib::make(LVecBase4(scale, scale, scale, 1.0f)), priority); } } @@ -2691,9 +2691,9 @@ set_all_color_scale(float scale, int priority) { // 1's (identity) if no scale has been applied to this // particular node. //////////////////////////////////////////////////////////////////// -const LVecBase4f &NodePath:: +const LVecBase4 &NodePath:: get_color_scale() const { - static const LVecBase4f ident_scale(1.0f, 1.0f, 1.0f, 1.0f); + static const LVecBase4 ident_scale(1.0f, 1.0f, 1.0f, 1.0f); nassertr_always(!is_empty(), ident_scale); const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); @@ -3299,8 +3299,8 @@ has_occluder(const NodePath &occluder) const { // corner. //////////////////////////////////////////////////////////////////// void NodePath:: -set_scissor(float left, float right, float bottom, float top) { - set_effect(ScissorEffect::make_screen(LVecBase4f(left, right, bottom, top))); +set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_effect(ScissorEffect::make_screen(LVecBase4(left, right, bottom, top))); } //////////////////////////////////////////////////////////////////// @@ -3314,7 +3314,7 @@ set_scissor(float left, float right, float bottom, float top) { // region. //////////////////////////////////////////////////////////////////// void NodePath:: -set_scissor(const LPoint3f &a, const LPoint3f &b) { +set_scissor(const LPoint3 &a, const LPoint3 &b) { set_effect(ScissorEffect::make_node(a, b)); } @@ -3330,8 +3330,8 @@ set_scissor(const LPoint3f &a, const LPoint3f &b) { // encloses all four points). //////////////////////////////////////////////////////////////////// void NodePath:: -set_scissor(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d) { +set_scissor(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d) { set_effect(ScissorEffect::make_node(a, b, c, d)); } @@ -3346,7 +3346,7 @@ set_scissor(const LPoint3f &a, const LPoint3f &b, // the scissor region. //////////////////////////////////////////////////////////////////// void NodePath:: -set_scissor(const NodePath &other, const LPoint3f &a, const LPoint3f &b) { +set_scissor(const NodePath &other, const LPoint3 &a, const LPoint3 &b) { set_effect(ScissorEffect::make_node(a, b, other)); } @@ -3363,8 +3363,8 @@ set_scissor(const NodePath &other, const LPoint3f &a, const LPoint3f &b) { //////////////////////////////////////////////////////////////////// void NodePath:: set_scissor(const NodePath &other, - const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d) { + const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d) { set_effect(ScissorEffect::make_node(a, b, c, d, other)); } @@ -3901,7 +3901,7 @@ set_shader_input(const ShaderInput *inp) { // Description: //////////////////////////////////////////////////////////////////// const ShaderInput *NodePath:: -get_shader_input(InternalName *id) const { +get_shader_input(const InternalName *id) const { nassertr_always(!is_empty(), NULL); const RenderAttrib *attrib = @@ -3940,7 +3940,7 @@ get_instance_count() const { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -clear_shader_input(InternalName *id) { +clear_shader_input(const InternalName *id) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -3958,7 +3958,7 @@ clear_shader_input(InternalName *id) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_float &v, int priority) { +set_shader_input(const InternalName *id, const PTA_float &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -3968,7 +3968,7 @@ set_shader_input(InternalName *id, const PTA_float &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_double &v, int priority) { +set_shader_input(const InternalName *id, const PTA_double &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -3978,7 +3978,7 @@ set_shader_input(InternalName *id, const PTA_double &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) { +set_shader_input(const InternalName *id, const PTA_LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -3988,7 +3988,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) { +set_shader_input(const InternalName *id, const PTA_LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -3999,7 +3999,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) { +set_shader_input(const InternalName *id, const PTA_LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4009,7 +4009,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const LVecBase4f &v, int priority) { +set_shader_input(const InternalName *id, const LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4019,7 +4019,7 @@ set_shader_input(InternalName *id, const LVecBase4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const LVecBase3f &v, int priority) { +set_shader_input(const InternalName *id, const LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4029,7 +4029,7 @@ set_shader_input(InternalName *id, const LVecBase3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const LVecBase2f &v, int priority) { +set_shader_input(const InternalName *id, const LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4039,7 +4039,7 @@ set_shader_input(InternalName *id, const LVecBase2f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) { +set_shader_input(const InternalName *id, const PTA_LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4049,7 +4049,7 @@ set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) { +set_shader_input(const InternalName *id, const PTA_LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4059,7 +4059,7 @@ set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const LMatrix4f &v, int priority) { +set_shader_input(const InternalName *id, const LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4069,7 +4069,7 @@ set_shader_input(InternalName *id, const LMatrix4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const LMatrix3f &v, int priority) { +set_shader_input(const InternalName *id, const LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(id,v,priority)); } @@ -4079,7 +4079,7 @@ set_shader_input(InternalName *id, const LMatrix3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, Texture *tex, int priority) { +set_shader_input(const InternalName *id, Texture *tex, int priority) { set_shader_input(new ShaderInput(id,tex,priority)); } @@ -4089,7 +4089,7 @@ set_shader_input(InternalName *id, Texture *tex, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, const NodePath &np, int priority) { +set_shader_input(const InternalName *id, const NodePath &np, int priority) { set_shader_input(new ShaderInput(id,np,priority)); } @@ -4099,8 +4099,8 @@ set_shader_input(InternalName *id, const NodePath &np, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) { - set_shader_input(new ShaderInput(id, LVecBase4f(n1, n2, n3, n4), priority)); +set_shader_input(const InternalName *id, double n1, double n2, double n3, double n4, int priority) { + set_shader_input(new ShaderInput(id, LVecBase4(n1, n2, n3, n4), priority)); } //////////////////////////////////////////////////////////////////// @@ -4129,7 +4129,7 @@ set_shader_input(const string &id, const PTA_double &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority) { +set_shader_input(const string &id, const PTA_LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4139,7 +4139,7 @@ set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority) { +set_shader_input(const string &id, const PTA_LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4150,7 +4150,7 @@ set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority) { +set_shader_input(const string &id, const PTA_LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4160,7 +4160,7 @@ set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const LVecBase4f &v, int priority) { +set_shader_input(const string &id, const LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4170,7 +4170,7 @@ set_shader_input(const string &id, const LVecBase4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const LVecBase3f &v, int priority) { +set_shader_input(const string &id, const LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4180,7 +4180,7 @@ set_shader_input(const string &id, const LVecBase3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const LVecBase2f &v, int priority) { +set_shader_input(const string &id, const LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4190,7 +4190,7 @@ set_shader_input(const string &id, const LVecBase2f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority) { +set_shader_input(const string &id, const PTA_LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4200,7 +4200,7 @@ set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority) { +set_shader_input(const string &id, const PTA_LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4210,7 +4210,7 @@ set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const LMatrix4f &v, int priority) { +set_shader_input(const string &id, const LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } @@ -4220,7 +4220,7 @@ set_shader_input(const string &id, const LMatrix4f &v, int priority) { // Description: //////////////////////////////////////////////////////////////////// void NodePath:: -set_shader_input(const string &id, const LMatrix3f &v, int priority) { +set_shader_input(const string &id, const LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); } //////////////////////////////////////////////////////////////////// @@ -4250,7 +4250,7 @@ set_shader_input(const string &id, const NodePath &np, int priority) { //////////////////////////////////////////////////////////////////// void NodePath:: set_shader_input(const string &id, double n1, double n2, double n3, double n4, int priority) { - set_shader_input(new ShaderInput(InternalName::make(id), LVecBase4f(n1, n2, n3, n4), priority)); + set_shader_input(new ShaderInput(InternalName::make(id), LVecBase4(n1, n2, n3, n4), priority)); } //////////////////////////////////////////////////////////////////// @@ -4529,7 +4529,7 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, //////////////////////////////////////////////////////////////////// void NodePath:: set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, - const TexCoord3f &constant_value, int priority) { + const LTexCoord3 &constant_value, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -5463,7 +5463,7 @@ get_fog() const { void NodePath:: set_render_mode_wireframe(int priority) { nassertv_always(!is_empty()); - float thickness = get_render_mode_thickness(); + PN_stdfloat thickness = get_render_mode_thickness(); bool perspective = get_render_mode_perspective(); node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_wireframe, thickness, perspective), priority); } @@ -5478,7 +5478,7 @@ set_render_mode_wireframe(int priority) { void NodePath:: set_render_mode_filled(int priority) { nassertv_always(!is_empty()); - float thickness = get_render_mode_thickness(); + PN_stdfloat thickness = get_render_mode_thickness(); bool perspective = get_render_mode_perspective(); node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled, thickness, perspective), priority); } @@ -5502,7 +5502,7 @@ void NodePath:: set_render_mode_perspective(bool perspective, int priority) { nassertv_always(!is_empty()); RenderModeAttrib::Mode mode = get_render_mode(); - float thickness = get_render_mode_thickness(); + PN_stdfloat thickness = get_render_mode_thickness(); node()->set_attrib(RenderModeAttrib::make(mode, thickness, perspective), priority); } @@ -5520,7 +5520,7 @@ set_render_mode_perspective(bool perspective, int priority) { // the node. //////////////////////////////////////////////////////////////////// void NodePath:: -set_render_mode_thickness(float thickness, int priority) { +set_render_mode_thickness(PN_stdfloat thickness, int priority) { nassertv_always(!is_empty()); RenderModeAttrib::Mode mode = get_render_mode(); bool perspective = get_render_mode_perspective(); @@ -5535,7 +5535,7 @@ set_render_mode_thickness(float thickness, int priority) { // the indicated line and/or point thickness. //////////////////////////////////////////////////////////////////// void NodePath:: -set_render_mode(RenderModeAttrib::Mode mode, float thickness, int priority) { +set_render_mode(RenderModeAttrib::Mode mode, PN_stdfloat thickness, int priority) { nassertv_always(!is_empty()); node()->set_attrib(RenderModeAttrib::make(mode, thickness), priority); @@ -5596,7 +5596,7 @@ get_render_mode() const { // specifically set on this node via set_render_mode(), // or 1.0 if nothing has been set. //////////////////////////////////////////////////////////////////// -float NodePath:: +PN_stdfloat NodePath:: get_render_mode_thickness() const { nassertr_always(!is_empty(), 0.0f); const RenderAttrib *attrib = @@ -5922,23 +5922,23 @@ get_depth_offset() const { // rotated. This is similar in principle to heads_up(). //////////////////////////////////////////////////////////////////// void NodePath:: -do_billboard_axis(const NodePath &camera, float offset) { +do_billboard_axis(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(TransformState) transform = camera.get_transform(get_parent()); - const LMatrix4f &rel_mat = transform->get_mat(); + const LMatrix4 &rel_mat = transform->get_mat(); - LVector3f up = LVector3f::up(); - LVector3f rel_pos = -rel_mat.get_row3(3); + LVector3 up = LVector3::up(); + LVector3 rel_pos = -rel_mat.get_row3(3); - LQuaternionf quat; + LQuaternion quat; ::heads_up(quat, rel_pos, up); set_quat(quat); // Also slide the geometry towards the camera according to the // offset factor. if (offset != 0.0f) { - LVector3f translate = rel_mat.get_row3(3); + LVector3 translate = rel_mat.get_row3(3); translate.normalize(); translate *= offset; set_pos(translate); @@ -5955,23 +5955,23 @@ do_billboard_axis(const NodePath &camera, float offset) { // achieved using the ordinary look_at() call. //////////////////////////////////////////////////////////////////// void NodePath:: -do_billboard_point_eye(const NodePath &camera, float offset) { +do_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(TransformState) transform = camera.get_transform(get_parent()); - const LMatrix4f &rel_mat = transform->get_mat(); + const LMatrix4 &rel_mat = transform->get_mat(); - LVector3f up = LVector3f::up() * rel_mat; - LVector3f rel_pos = LVector3f::forward() * rel_mat; + LVector3 up = LVector3::up() * rel_mat; + LVector3 rel_pos = LVector3::forward() * rel_mat; - LQuaternionf quat; + LQuaternion quat; ::look_at(quat, rel_pos, up); set_quat(quat); // Also slide the geometry towards the camera according to the // offset factor. if (offset != 0.0f) { - LVector3f translate = rel_mat.get_row3(3); + LVector3 translate = rel_mat.get_row3(3); translate.normalize(); translate *= offset; set_pos(translate); @@ -5986,23 +5986,23 @@ do_billboard_point_eye(const NodePath &camera, float offset) { // rotated. This is similar in principle to look_at(). //////////////////////////////////////////////////////////////////// void NodePath:: -do_billboard_point_world(const NodePath &camera, float offset) { +do_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(TransformState) transform = camera.get_transform(get_parent()); - const LMatrix4f &rel_mat = transform->get_mat(); + const LMatrix4 &rel_mat = transform->get_mat(); - LVector3f up = LVector3f::up(); - LVector3f rel_pos = -rel_mat.get_row3(3); + LVector3 up = LVector3::up(); + LVector3 rel_pos = -rel_mat.get_row3(3); - LQuaternionf quat; + LQuaternion quat; ::look_at(quat, rel_pos, up); set_quat(quat); // Also slide the geometry towards the camera according to the // offset factor. if (offset != 0.0f) { - LVector3f translate = rel_mat.get_row3(3); + LVector3 translate = rel_mat.get_row3(3); translate.normalize(); translate *= offset; set_pos(translate); @@ -6018,11 +6018,11 @@ do_billboard_point_world(const NodePath &camera, float offset) { // viewing camera. //////////////////////////////////////////////////////////////////// void NodePath:: -set_billboard_axis(const NodePath &camera, float offset) { +set_billboard_axis(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(RenderEffect) billboard = BillboardEffect::make - (LVector3f::up(), false, true, - offset, camera, LPoint3f(0.0f, 0.0f, 0.0f)); + (LVector3::up(), false, true, + offset, camera, LPoint3(0.0f, 0.0f, 0.0f)); node()->set_effect(billboard); } @@ -6036,11 +6036,11 @@ set_billboard_axis(const NodePath &camera, float offset) { // the viewing camera. //////////////////////////////////////////////////////////////////// void NodePath:: -set_billboard_point_eye(const NodePath &camera, float offset) { +set_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(RenderEffect) billboard = BillboardEffect::make - (LVector3f::up(), true, false, - offset, camera, LPoint3f(0.0f, 0.0f, 0.0f)); + (LVector3::up(), true, false, + offset, camera, LPoint3(0.0f, 0.0f, 0.0f)); node()->set_effect(billboard); } @@ -6053,11 +6053,11 @@ set_billboard_point_eye(const NodePath &camera, float offset) { // specified "camera" instead of to the viewing camera. //////////////////////////////////////////////////////////////////// void NodePath:: -set_billboard_point_world(const NodePath &camera, float offset) { +set_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); CPT(RenderEffect) billboard = BillboardEffect::make - (LVector3f::up(), false, false, - offset, camera, LPoint3f(0.0f, 0.0f, 0.0f)); + (LVector3::up(), false, false, + offset, camera, LPoint3(0.0f, 0.0f, 0.0f)); node()->set_effect(billboard); } @@ -6287,7 +6287,7 @@ clear_audio_volume() { // Description: Sets the audio volume component of the transform //////////////////////////////////////////////////////////////////// void NodePath:: -set_audio_volume(float volume, int priority) { +set_audio_volume(PN_stdfloat volume, int priority) { nassertv_always(!is_empty()); const RenderAttrib *attrib = @@ -6335,7 +6335,7 @@ set_audio_volume_off(int priority) { // set_audio_volume(), or 1. (identity) if no volume has // been applied to this particular node. //////////////////////////////////////////////////////////////////// -float NodePath:: +PN_stdfloat NodePath:: get_audio_volume() const { const RenderAttrib *attrib = node()->get_attrib(AudioVolumeAttrib::get_class_slot()); @@ -6353,7 +6353,7 @@ get_audio_volume() const { // Description: Returns the complete audio volume for this node // taking highers nodes in the graph into account. //////////////////////////////////////////////////////////////////// -float NodePath:: +PN_stdfloat NodePath:: get_net_audio_volume() const { CPT(RenderState) net_state = get_net_state(); const RenderAttrib *attrib = net_state->get_attrib(AudioVolumeAttrib::get_class_slot()); @@ -6704,7 +6704,7 @@ write_bounds(ostream &out) const { // bounding volume, or false if none are. //////////////////////////////////////////////////////////////////// bool NodePath:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, Thread *current_thread) const { min_point.set(0.0f, 0.0f, 0.0f); max_point.set(0.0f, 0.0f, 0.0f); diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 668e3b651f..413fcb95b3 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -32,11 +32,11 @@ #include "typedObject.h" #include "pta_float.h" #include "pta_double.h" -#include "pta_LMatrix4f.h" -#include "pta_LMatrix3f.h" -#include "pta_LVecBase4f.h" -#include "pta_LVecBase3f.h" -#include "pta_LVecBase2f.h" +#include "pta_LMatrix4.h" +#include "pta_LMatrix3.h" +#include "pta_LVecBase4.h" +#include "pta_LVecBase3.h" +#include "pta_LVecBase2.h" #include "stl_compares.h" class NodePathCollection; @@ -312,248 +312,248 @@ PUBLISHED: // Methods that get and set the matrix transform: pos, hpr, scale, // in the local coordinate system. - INLINE void set_pos(float x, float y, float z); - void set_pos(const LVecBase3f &pos); - void set_x(float x); - void set_y(float y); - void set_z(float z); - INLINE void set_fluid_pos(float x, float y, float z); - void set_fluid_pos(const LVecBase3f &pos); - void set_fluid_x(float x); - void set_fluid_y(float y); - void set_fluid_z(float z); - LPoint3f get_pos() const; - INLINE float get_x() const; - INLINE float get_y() const; - INLINE float get_z() const; + INLINE void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void set_pos(const LVecBase3 &pos); + void set_x(PN_stdfloat x); + void set_y(PN_stdfloat y); + void set_z(PN_stdfloat z); + INLINE void set_fluid_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void set_fluid_pos(const LVecBase3 &pos); + void set_fluid_x(PN_stdfloat x); + void set_fluid_y(PN_stdfloat y); + void set_fluid_z(PN_stdfloat z); + LPoint3 get_pos() const; + INLINE PN_stdfloat get_x() const; + INLINE PN_stdfloat get_y() const; + INLINE PN_stdfloat get_z() const; - LVector3f get_pos_delta() const; + LVector3 get_pos_delta() const; - INLINE void set_hpr(float h, float p, float r); - void set_hpr(const LVecBase3f &hpr); - void set_h(float h); - void set_p(float p); - void set_r(float r); - LVecBase3f get_hpr() const; - INLINE float get_h() const; - INLINE float get_p() const; - INLINE float get_r() const; + INLINE void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + void set_hpr(const LVecBase3 &hpr); + void set_h(PN_stdfloat h); + void set_p(PN_stdfloat p); + void set_r(PN_stdfloat r); + LVecBase3 get_hpr() const; + INLINE PN_stdfloat get_h() const; + INLINE PN_stdfloat get_p() const; + INLINE PN_stdfloat get_r() const; - void set_quat(const LQuaternionf &quat); - LQuaternionf get_quat() const; + void set_quat(const LQuaternion &quat); + LQuaternion get_quat() const; - INLINE void set_scale(float scale); - INLINE void set_scale(float sx, float sy, float sz); - void set_scale(const LVecBase3f &scale); - void set_sx(float sx); - void set_sy(float sy); - void set_sz(float sz); - LVecBase3f get_scale() const; - INLINE float get_sx() const; - INLINE float get_sy() const; - INLINE float get_sz() const; + INLINE void set_scale(PN_stdfloat scale); + INLINE void set_scale(PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); + void set_scale(const LVecBase3 &scale); + void set_sx(PN_stdfloat sx); + void set_sy(PN_stdfloat sy); + void set_sz(PN_stdfloat sz); + LVecBase3 get_scale() const; + INLINE PN_stdfloat get_sx() const; + INLINE PN_stdfloat get_sy() const; + INLINE PN_stdfloat get_sz() const; - INLINE void set_shear(float shxy, float shxz, float shyz); - void set_shear(const LVecBase3f &shear); - void set_shxy(float shxy); - void set_shxz(float shxz); - void set_shyz(float shyz); - LVecBase3f get_shear() const; - INLINE float get_shxy() const; - INLINE float get_shxz() const; - INLINE float get_shyz() const; + INLINE void set_shear(PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz); + void set_shear(const LVecBase3 &shear); + void set_shxy(PN_stdfloat shxy); + void set_shxz(PN_stdfloat shxz); + void set_shyz(PN_stdfloat shyz); + LVecBase3 get_shear() const; + INLINE PN_stdfloat get_shxy() const; + INLINE PN_stdfloat get_shxz() const; + INLINE PN_stdfloat get_shyz() const; - INLINE void set_pos_hpr(float x, float y, float z, - float h, float p, float r); - void set_pos_hpr(const LVecBase3f &pos, - const LVecBase3f &hpr); - void set_pos_quat(const LVecBase3f &pos, - const LQuaternionf &quat); + INLINE void set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + void set_pos_hpr(const LVecBase3 &pos, + const LVecBase3 &hpr); + void set_pos_quat(const LVecBase3 &pos, + const LQuaternion &quat); - INLINE void set_hpr_scale(float h, float p, float r, - float sx, float sy, float sz); - void set_hpr_scale(const LVecBase3f &hpr, - const LVecBase3f &scale); - void set_quat_scale(const LQuaternionf &quat, - const LVecBase3f &scale); - INLINE void set_pos_hpr_scale(float x, float y, float z, - float h, float p, float r, - float sx, float sy, float sz); - void set_pos_hpr_scale(const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale); - void set_pos_quat_scale(const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale); - void set_pos_hpr_scale_shear(const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale, - const LVecBase3f &shear); - void set_pos_quat_scale_shear(const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale, - const LVecBase3f &shear); + INLINE void set_hpr_scale(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); + void set_hpr_scale(const LVecBase3 &hpr, + const LVecBase3 &scale); + void set_quat_scale(const LQuaternion &quat, + const LVecBase3 &scale); + INLINE void set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); + void set_pos_hpr_scale(const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale); + void set_pos_quat_scale(const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale); + void set_pos_hpr_scale_shear(const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale, + const LVecBase3 &shear); + void set_pos_quat_scale_shear(const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale, + const LVecBase3 &shear); - void set_mat(const LMatrix4f &mat); + void set_mat(const LMatrix4 &mat); INLINE void clear_mat(); INLINE bool has_mat() const; - INLINE const LMatrix4f &get_mat() const; + INLINE const LMatrix4 &get_mat() const; - INLINE void look_at(float x, float y, float z); - void look_at(const LPoint3f &point, const LVector3f &up = LVector3f::up()); - INLINE void heads_up(float x, float y, float z); - void heads_up(const LPoint3f &point, const LVector3f &up = LVector3f::up()); + INLINE void look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void look_at(const LPoint3 &point, const LVector3 &up = LVector3::up()); + INLINE void heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void heads_up(const LPoint3 &point, const LVector3 &up = LVector3::up()); // Methods that get and set the matrix transforms relative to some // other node in the scene graph. These perform an implicit wrt(). - INLINE void set_pos(const NodePath &other, float x, float y, float z); - void set_pos(const NodePath &other, const LVecBase3f &pos); - void set_x(const NodePath &other, float x); - void set_y(const NodePath &other, float y); - void set_z(const NodePath &other, float z); - INLINE void set_fluid_pos(const NodePath &other, float x, float y, float z); - void set_fluid_pos(const NodePath &other, const LVecBase3f &pos); - void set_fluid_x(const NodePath &other, float x); - void set_fluid_y(const NodePath &other, float y); - void set_fluid_z(const NodePath &other, float z); - LPoint3f get_pos(const NodePath &other) const; - INLINE float get_x(const NodePath &other) const; - INLINE float get_y(const NodePath &other) const; - INLINE float get_z(const NodePath &other) const; + INLINE void set_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void set_pos(const NodePath &other, const LVecBase3 &pos); + void set_x(const NodePath &other, PN_stdfloat x); + void set_y(const NodePath &other, PN_stdfloat y); + void set_z(const NodePath &other, PN_stdfloat z); + INLINE void set_fluid_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void set_fluid_pos(const NodePath &other, const LVecBase3 &pos); + void set_fluid_x(const NodePath &other, PN_stdfloat x); + void set_fluid_y(const NodePath &other, PN_stdfloat y); + void set_fluid_z(const NodePath &other, PN_stdfloat z); + LPoint3 get_pos(const NodePath &other) const; + INLINE PN_stdfloat get_x(const NodePath &other) const; + INLINE PN_stdfloat get_y(const NodePath &other) const; + INLINE PN_stdfloat get_z(const NodePath &other) const; - LVector3f get_pos_delta(const NodePath &other) const; + LVector3 get_pos_delta(const NodePath &other) const; - INLINE void set_hpr(const NodePath &other, float h, float p, float r); - void set_hpr(const NodePath &other, const LVecBase3f &hpr); - void set_h(const NodePath &other, float h); - void set_p(const NodePath &other, float p); - void set_r(const NodePath &other, float r); - LVecBase3f get_hpr(const NodePath &other) const; - INLINE float get_h(const NodePath &other) const; - INLINE float get_p(const NodePath &other) const; - INLINE float get_r(const NodePath &other) const; + INLINE void set_hpr(const NodePath &other, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + void set_hpr(const NodePath &other, const LVecBase3 &hpr); + void set_h(const NodePath &other, PN_stdfloat h); + void set_p(const NodePath &other, PN_stdfloat p); + void set_r(const NodePath &other, PN_stdfloat r); + LVecBase3 get_hpr(const NodePath &other) const; + INLINE PN_stdfloat get_h(const NodePath &other) const; + INLINE PN_stdfloat get_p(const NodePath &other) const; + INLINE PN_stdfloat get_r(const NodePath &other) const; - void set_quat(const NodePath &other, const LQuaternionf &quat); - LQuaternionf get_quat(const NodePath &other) const; + void set_quat(const NodePath &other, const LQuaternion &quat); + LQuaternion get_quat(const NodePath &other) const; - INLINE void set_scale(const NodePath &other, float scale); - INLINE void set_scale(const NodePath &other, float sx, float sy, float sz); - void set_scale(const NodePath &other, const LVecBase3f &scale); - void set_sx(const NodePath &other, float sx); - void set_sy(const NodePath &other, float sy); - void set_sz(const NodePath &other, float sz); - LVecBase3f get_scale(const NodePath &other) const; - INLINE float get_sx(const NodePath &other) const; - INLINE float get_sy(const NodePath &other) const; - INLINE float get_sz(const NodePath &other) const; + INLINE void set_scale(const NodePath &other, PN_stdfloat scale); + INLINE void set_scale(const NodePath &other, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); + void set_scale(const NodePath &other, const LVecBase3 &scale); + void set_sx(const NodePath &other, PN_stdfloat sx); + void set_sy(const NodePath &other, PN_stdfloat sy); + void set_sz(const NodePath &other, PN_stdfloat sz); + LVecBase3 get_scale(const NodePath &other) const; + INLINE PN_stdfloat get_sx(const NodePath &other) const; + INLINE PN_stdfloat get_sy(const NodePath &other) const; + INLINE PN_stdfloat get_sz(const NodePath &other) const; - INLINE void set_shear(const NodePath &other, float shxy, float shxz, float shyz); - void set_shear(const NodePath &other, const LVecBase3f &shear); - void set_shxy(const NodePath &other, float shxy); - void set_shxz(const NodePath &other, float shxz); - void set_shyz(const NodePath &other, float shyz); - LVecBase3f get_shear(const NodePath &other) const; - INLINE float get_shxy(const NodePath &other) const; - INLINE float get_shxz(const NodePath &other) const; - INLINE float get_shyz(const NodePath &other) const; + INLINE void set_shear(const NodePath &other, PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz); + void set_shear(const NodePath &other, const LVecBase3 &shear); + void set_shxy(const NodePath &other, PN_stdfloat shxy); + void set_shxz(const NodePath &other, PN_stdfloat shxz); + void set_shyz(const NodePath &other, PN_stdfloat shyz); + LVecBase3 get_shear(const NodePath &other) const; + INLINE PN_stdfloat get_shxy(const NodePath &other) const; + INLINE PN_stdfloat get_shxz(const NodePath &other) const; + INLINE PN_stdfloat get_shyz(const NodePath &other) const; INLINE void set_pos_hpr(const NodePath &other, - float x, float y, float z, - float h, float p, float r); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); void set_pos_hpr(const NodePath &other, - const LVecBase3f &pos, - const LVecBase3f &hpr); + const LVecBase3 &pos, + const LVecBase3 &hpr); void set_pos_quat(const NodePath &other, - const LVecBase3f &pos, - const LQuaternionf &quat); + const LVecBase3 &pos, + const LQuaternion &quat); INLINE void set_hpr_scale(const NodePath &other, - float h, float p, float r, - float sx, float sy, float sz); + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); void set_hpr_scale(const NodePath &other, - const LVecBase3f &hpr, - const LVecBase3f &scale); + const LVecBase3 &hpr, + const LVecBase3 &scale); void set_quat_scale(const NodePath &other, - const LQuaternionf &quat, - const LVecBase3f &scale); + const LQuaternion &quat, + const LVecBase3 &scale); INLINE void set_pos_hpr_scale(const NodePath &other, - float x, float y, float z, - float h, float p, float r, - float sx, float sy, float sz); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, + PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, + PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz); void set_pos_hpr_scale(const NodePath &other, - const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale); + const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale); void set_pos_quat_scale(const NodePath &other, - const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale); + const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale); void set_pos_hpr_scale_shear(const NodePath &other, - const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale, - const LVecBase3f &shear); + const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale, + const LVecBase3 &shear); void set_pos_quat_scale_shear(const NodePath &other, - const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale, - const LVecBase3f &shear); + const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale, + const LVecBase3 &shear); - LMatrix4f get_mat(const NodePath &other) const; - void set_mat(const NodePath &other, const LMatrix4f &mat); + LMatrix4 get_mat(const NodePath &other) const; + void set_mat(const NodePath &other, const LMatrix4 &mat); - LPoint3f get_relative_point(const NodePath &other, const LVecBase3f &point) const; - LVector3f get_relative_vector(const NodePath &other, const LVecBase3f &vec) const; + LPoint3 get_relative_point(const NodePath &other, const LVecBase3 &point) const; + LVector3 get_relative_vector(const NodePath &other, const LVecBase3 &vec) const; INLINE void look_at(const NodePath &other, - float x, float y, float z); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); void look_at(const NodePath &other, - const LPoint3f &point = LPoint3f(0.0, 0.0, 0.0), - const LVector3f &up = LVector3f::up()); + const LPoint3 &point = LPoint3(0.0, 0.0, 0.0), + const LVector3 &up = LVector3::up()); INLINE void heads_up(const NodePath &other, - float x, float y, float z); + PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); void heads_up(const NodePath &other, - const LPoint3f &point = LPoint3f(0.0, 0.0, 0.0), - const LVector3f &up = LVector3f::up()); + const LPoint3 &point = LPoint3(0.0, 0.0, 0.0), + const LVector3 &up = LVector3::up()); - INLINE float get_distance(const NodePath &other) const; + INLINE PN_stdfloat get_distance(const NodePath &other) const; // Methods that affect appearance of geometry: color, texture, etc. // These affect the state at the bottom level only. - void set_color(float r, float g, float b, float a = 1.0, + void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0, int priority = 0); - void set_color(const Colorf &color, int priority = 0); + void set_color(const LColor &color, int priority = 0); void set_color_off(int priority = 0); void clear_color(); bool has_color() const; - Colorf get_color() const; + LColor get_color() const; bool has_color_scale() const; void clear_color_scale(); - void set_color_scale(const LVecBase4f &scale, + void set_color_scale(const LVecBase4 &scale, int priority = 0); - INLINE void set_color_scale(float sx, float sy, float sz, float sa, + INLINE void set_color_scale(PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat sa, int priority = 0); - void compose_color_scale(const LVecBase4f &scale, + void compose_color_scale(const LVecBase4 &scale, int priority = 0); - INLINE void compose_color_scale(float sx, float sy, float sz, float sa, + INLINE void compose_color_scale(PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat sa, int priority = 0); void set_color_scale_off(int priority = 0); - void set_alpha_scale(float scale, int priority = 0); - void set_all_color_scale(float scale, int priority = 0); - INLINE void set_sr(float sr); - INLINE void set_sg(float sg); - INLINE void set_sb(float sb); - INLINE void set_sa(float sa); + void set_alpha_scale(PN_stdfloat scale, int priority = 0); + void set_all_color_scale(PN_stdfloat scale, int priority = 0); + INLINE void set_sr(PN_stdfloat sr); + INLINE void set_sg(PN_stdfloat sg); + INLINE void set_sb(PN_stdfloat sb); + INLINE void set_sa(PN_stdfloat sa); - const LVecBase4f &get_color_scale() const; - INLINE float get_sr() const; - INLINE float get_sg() const; - INLINE float get_sb() const; - INLINE float get_sa() const; + const LVecBase4 &get_color_scale() const; + INLINE PN_stdfloat get_sr() const; + INLINE PN_stdfloat get_sg() const; + INLINE PN_stdfloat get_sb() const; + INLINE PN_stdfloat get_sa() const; void set_light(const NodePath &light, int priority = 0); void set_light_off(int priority = 0); @@ -573,15 +573,15 @@ PUBLISHED: bool has_clip_plane_off() const; bool has_clip_plane_off(const NodePath &clip_plane) const; - void set_scissor(float left, float right, float bottom, float top); - void set_scissor(const LPoint3f &a, const LPoint3f &b); - void set_scissor(const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d); + void set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + void set_scissor(const LPoint3 &a, const LPoint3 &b); + void set_scissor(const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d); void set_scissor(const NodePath &other, - const LPoint3f &a, const LPoint3f &b); + const LPoint3 &a, const LPoint3 &b); void set_scissor(const NodePath &other, - const LPoint3f &a, const LPoint3f &b, - const LPoint3f &c, const LPoint3f &d); + const LPoint3 &a, const LPoint3 &b, + const LPoint3 &c, const LPoint3 &d); void clear_scissor(); bool has_scissor() const; @@ -616,46 +616,46 @@ PUBLISHED: void clear_shader(); void set_shader_input(const ShaderInput *inp); - void set_shader_input(InternalName *id, Texture *tex, int priority=0); - void set_shader_input(InternalName *id, const NodePath &np, int priority=0); - void set_shader_input(InternalName *id, const PTA_float &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_double &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority=0); - void set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority=0); - void set_shader_input(InternalName *id, const LVecBase4f &v, int priority=0); - void set_shader_input(InternalName *id, const LVecBase3f &v, int priority=0); - void set_shader_input(InternalName *id, const LVecBase2f &v, int priority=0); - void set_shader_input(InternalName *id, const LMatrix4f &v, int priority=0); - void set_shader_input(InternalName *id, const LMatrix3f &v, int priority=0); - void set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0, + void set_shader_input(const InternalName *id, Texture *tex, int priority=0); + void set_shader_input(const InternalName *id, const NodePath &np, int priority=0); + void set_shader_input(const InternalName *id, const PTA_float &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_double &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_LVecBase4 &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_LVecBase3 &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_LVecBase2 &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_LMatrix4 &v, int priority=0); + void set_shader_input(const InternalName *id, const PTA_LMatrix3 &v, int priority=0); + void set_shader_input(const InternalName *id, const LVecBase4 &v, int priority=0); + void set_shader_input(const InternalName *id, const LVecBase3 &v, int priority=0); + void set_shader_input(const InternalName *id, const LVecBase2 &v, int priority=0); + void set_shader_input(const InternalName *id, const LMatrix4 &v, int priority=0); + void set_shader_input(const InternalName *id, const LMatrix3 &v, int priority=0); + void set_shader_input(const InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0); - void set_shader_input(const string &id, Texture *tex, int priority=0); + void set_shader_input(const string &id, Texture *tex, int priority=0); void set_shader_input(const string &id, const NodePath &np, int priority=0); void set_shader_input(const string &id, const PTA_float &v, int priority=0); void set_shader_input(const string &id, const PTA_double &v, int priority=0); - void set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority=0); - void set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority=0); - void set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority=0); - void set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority=0); - void set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority=0); - void set_shader_input(const string &id, const LVecBase4f &v, int priority=0); - void set_shader_input(const string &id, const LVecBase3f &v, int priority=0); - void set_shader_input(const string &id, const LVecBase2f &v, int priority=0); - void set_shader_input(const string &id, const LMatrix4f &v, int priority=0); - void set_shader_input(const string &id, const LMatrix3f &v, int priority=0); + void set_shader_input(const string &id, const PTA_LVecBase4 &v, int priority=0); + void set_shader_input(const string &id, const PTA_LVecBase3 &v, int priority=0); + void set_shader_input(const string &id, const PTA_LVecBase2 &v, int priority=0); + void set_shader_input(const string &id, const PTA_LMatrix4 &v, int priority=0); + void set_shader_input(const string &id, const PTA_LMatrix3 &v, int priority=0); + void set_shader_input(const string &id, const LVecBase4 &v, int priority=0); + void set_shader_input(const string &id, const LVecBase3 &v, int priority=0); + void set_shader_input(const string &id, const LVecBase2 &v, int priority=0); + void set_shader_input(const string &id, const LMatrix4 &v, int priority=0); + void set_shader_input(const string &id, const LMatrix3 &v, int priority=0); void set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0); - void clear_shader_input(InternalName *id); + void clear_shader_input(const InternalName *id); void clear_shader_input(const string &id); void set_instance_count(int instance_count); const Shader *get_shader() const; - const ShaderInput *get_shader_input(InternalName *id) const; + const ShaderInput *get_shader_input(const InternalName *id) const; const ShaderInput *get_shader_input(const string &id) const; const int get_instance_count() const; @@ -665,55 +665,55 @@ PUBLISHED: bool has_tex_transform(TextureStage *stage) const; CPT(TransformState) get_tex_transform(TextureStage *stage) const; - INLINE void set_tex_offset(TextureStage *stage, float u, float v); - INLINE void set_tex_offset(TextureStage *stage, const LVecBase2f &uv); - INLINE void set_tex_rotate(TextureStage *stage, float r); - INLINE void set_tex_scale(TextureStage *stage, float scale); - INLINE void set_tex_scale(TextureStage *stage, float su, float sv); - INLINE void set_tex_scale(TextureStage *stage, const LVecBase2f &scale); - INLINE LVecBase2f get_tex_offset(TextureStage *stage) const; - INLINE float get_tex_rotate(TextureStage *stage) const; - INLINE LVecBase2f get_tex_scale(TextureStage *stage) const; + INLINE void set_tex_offset(TextureStage *stage, PN_stdfloat u, PN_stdfloat v); + INLINE void set_tex_offset(TextureStage *stage, const LVecBase2 &uv); + INLINE void set_tex_rotate(TextureStage *stage, PN_stdfloat r); + INLINE void set_tex_scale(TextureStage *stage, PN_stdfloat scale); + INLINE void set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv); + INLINE void set_tex_scale(TextureStage *stage, const LVecBase2 &scale); + INLINE LVecBase2 get_tex_offset(TextureStage *stage) const; + INLINE PN_stdfloat get_tex_rotate(TextureStage *stage) const; + INLINE LVecBase2 get_tex_scale(TextureStage *stage) const; - INLINE void set_tex_pos(TextureStage *stage, float u, float v, float w); - INLINE void set_tex_pos(TextureStage *stage, const LVecBase3f &uvw); - INLINE void set_tex_hpr(TextureStage *stage, float h, float p, float r); - INLINE void set_tex_hpr(TextureStage *stage, const LVecBase3f &hpr); - INLINE void set_tex_scale(TextureStage *stage, float su, float sv, float sw); - INLINE void set_tex_scale(TextureStage *stage, const LVecBase3f &scale); - INLINE LVecBase3f get_tex_pos(TextureStage *stage) const; - INLINE LVecBase3f get_tex_hpr(TextureStage *stage) const; - INLINE LVecBase3f get_tex_scale_3d(TextureStage *stage) const; + INLINE void set_tex_pos(TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w); + INLINE void set_tex_pos(TextureStage *stage, const LVecBase3 &uvw); + INLINE void set_tex_hpr(TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE void set_tex_hpr(TextureStage *stage, const LVecBase3 &hpr); + INLINE void set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw); + INLINE void set_tex_scale(TextureStage *stage, const LVecBase3 &scale); + INLINE LVecBase3 get_tex_pos(TextureStage *stage) const; + INLINE LVecBase3 get_tex_hpr(TextureStage *stage) const; + INLINE LVecBase3 get_tex_scale_3d(TextureStage *stage) const; void set_tex_transform(const NodePath &other, TextureStage *stage, const TransformState *transform); CPT(TransformState) get_tex_transform(const NodePath &other, TextureStage *stage) const; - INLINE void set_tex_offset(const NodePath &other, TextureStage *stage, float u, float v); - INLINE void set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2f &uv); - INLINE void set_tex_rotate(const NodePath &other, TextureStage *stage, float r); - INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, float scale); - INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv); - INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2f &scale); - INLINE LVecBase2f get_tex_offset(const NodePath &other, TextureStage *stage) const; - INLINE float get_tex_rotate(const NodePath &other, TextureStage *stage) const; - INLINE LVecBase2f get_tex_scale(const NodePath &other, TextureStage *stage) const; + INLINE void set_tex_offset(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v); + INLINE void set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2 &uv); + INLINE void set_tex_rotate(const NodePath &other, TextureStage *stage, PN_stdfloat r); + INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat scale); + INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv); + INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2 &scale); + INLINE LVecBase2 get_tex_offset(const NodePath &other, TextureStage *stage) const; + INLINE PN_stdfloat get_tex_rotate(const NodePath &other, TextureStage *stage) const; + INLINE LVecBase2 get_tex_scale(const NodePath &other, TextureStage *stage) const; - INLINE void set_tex_pos(const NodePath &other, TextureStage *stage, float u, float v, float w); - INLINE void set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3f &uvw); - INLINE void set_tex_hpr(const NodePath &other, TextureStage *stage, float h, float p, float r); - INLINE void set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3f &hpr); - INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv, float sw); - INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3f &scale); - INLINE LVecBase3f get_tex_pos(const NodePath &other, TextureStage *stage) const; - INLINE LVecBase3f get_tex_hpr(const NodePath &other, TextureStage *stage) const; - INLINE LVecBase3f get_tex_scale_3d(const NodePath &other, TextureStage *stage) const; + INLINE void set_tex_pos(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w); + INLINE void set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3 &uvw); + INLINE void set_tex_hpr(const NodePath &other, TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE void set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3 &hpr); + INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw); + INLINE void set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3 &scale); + INLINE LVecBase3 get_tex_pos(const NodePath &other, TextureStage *stage) const; + INLINE LVecBase3 get_tex_hpr(const NodePath &other, TextureStage *stage) const; + INLINE LVecBase3 get_tex_scale_3d(const NodePath &other, TextureStage *stage) const; void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority = 0); void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, const string &source_name, const NodePath &light, int priority = 0); void set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, - const TexCoord3f &constant_value, + const LTexCoord3 &constant_value, int priority = 0); void clear_tex_gen(); void clear_tex_gen(TextureStage *stage); @@ -773,13 +773,13 @@ PUBLISHED: void set_render_mode_wireframe(int priority = 0); void set_render_mode_filled(int priority = 0); - void set_render_mode_thickness(float thickness, int priority = 0); + void set_render_mode_thickness(PN_stdfloat thickness, int priority = 0); void set_render_mode_perspective(bool perspective, int priority = 0); - void set_render_mode(RenderModeAttrib::Mode mode, float thickness, int priority = 0); + void set_render_mode(RenderModeAttrib::Mode mode, PN_stdfloat thickness, int priority = 0); void clear_render_mode(); bool has_render_mode() const; RenderModeAttrib::Mode get_render_mode() const; - float get_render_mode_thickness() const; + PN_stdfloat get_render_mode_thickness() const; bool get_render_mode_perspective() const; void set_two_sided(bool two_sided, int priority = 0); @@ -802,15 +802,15 @@ PUBLISHED: bool has_depth_offset() const; int get_depth_offset() const; - void do_billboard_axis(const NodePath &camera, float offset); - void do_billboard_point_eye(const NodePath &camera, float offset); - void do_billboard_point_world(const NodePath &camera, float offset); - INLINE void set_billboard_axis(float offset = 0.0); - INLINE void set_billboard_point_eye(float offset = 0.0); - INLINE void set_billboard_point_world(float offset = 0.0); - void set_billboard_axis(const NodePath &camera, float offset); - void set_billboard_point_eye(const NodePath &camera, float offset); - void set_billboard_point_world(const NodePath &camera, float offset); + void do_billboard_axis(const NodePath &camera, PN_stdfloat offset); + void do_billboard_point_eye(const NodePath &camera, PN_stdfloat offset); + void do_billboard_point_world(const NodePath &camera, PN_stdfloat offset); + INLINE void set_billboard_axis(PN_stdfloat offset = 0.0); + INLINE void set_billboard_point_eye(PN_stdfloat offset = 0.0); + INLINE void set_billboard_point_world(PN_stdfloat offset = 0.0); + void set_billboard_axis(const NodePath &camera, PN_stdfloat offset); + void set_billboard_point_eye(const NodePath &camera, PN_stdfloat offset); + void set_billboard_point_world(const NodePath &camera, PN_stdfloat offset); void clear_billboard(); bool has_billboard() const; @@ -830,11 +830,11 @@ PUBLISHED: bool has_audio_volume() const; void clear_audio_volume(); - void set_audio_volume(float volume, + void set_audio_volume(PN_stdfloat volume, int priority = 0); void set_audio_volume_off(int priority = 0); - float get_audio_volume() const; - float get_net_audio_volume() const; + PN_stdfloat get_audio_volume() const; + PN_stdfloat get_net_audio_volume() const; INLINE void adjust_all_priorities(int adjustment); @@ -877,7 +877,7 @@ PUBLISHED: PT(BoundingVolume) get_bounds(Thread *current_thread = Thread::get_current_thread()) const; void force_recompute_bounds(); void write_bounds(ostream &out) const; - bool calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, Thread *current_thread = Thread::get_current_thread()) const; // void analyze() const; diff --git a/panda/src/pgraph/nodePathCollection.I b/panda/src/pgraph/nodePathCollection.I index dcaa49032f..db82a6460f 100644 --- a/panda/src/pgraph/nodePathCollection.I +++ b/panda/src/pgraph/nodePathCollection.I @@ -86,8 +86,8 @@ ls() const { // Description: Colors all NodePaths in the collection //////////////////////////////////////////////////////////////////// INLINE void NodePathCollection:: -set_color(float r, float g, float b, float a, int priority) { - set_color(Colorf(r, g, b, a), priority); +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { + set_color(LColor(r, g, b, a), priority); } //////////////////////////////////////////////////////////////////// @@ -97,8 +97,8 @@ set_color(float r, float g, float b, float a, int priority) { // collection. The existing color scale is replaced. //////////////////////////////////////////////////////////////////// INLINE void NodePathCollection:: -set_color_scale(float r, float g, float b, float a, int priority) { - set_color_scale(LVecBase4f(r, g, b, a), priority); +set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { + set_color_scale(LVecBase4(r, g, b, a), priority); } //////////////////////////////////////////////////////////////////// @@ -109,6 +109,6 @@ set_color_scale(float r, float g, float b, float a, int priority) { // multiplied by the specified color scale. //////////////////////////////////////////////////////////////////// INLINE void NodePathCollection:: -compose_color_scale(float r, float g, float b, float a, int priority) { - compose_color_scale(LVecBase4f(r, g, b, a), priority); +compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { + compose_color_scale(LVecBase4(r, g, b, a), priority); } diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index e7dcb49c47..2cebc6fa44 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -609,7 +609,7 @@ set_texture_off(TextureStage *stage, int priority) { // Description: Colors all NodePaths in the collection //////////////////////////////////////////////////////////////////// void NodePathCollection:: -set_color(const Colorf &color, int priority) { +set_color(const LColor &color, int priority) { set_attrib(ColorAttrib::make_flat(color), priority); } @@ -620,7 +620,7 @@ set_color(const Colorf &color, int priority) { // collection. The existing color scale is replaced. //////////////////////////////////////////////////////////////////// void NodePathCollection:: -set_color_scale(const LVecBase4f &scale, int priority) { +set_color_scale(const LVecBase4 &scale, int priority) { StateMap state_map; NodePaths::iterator npi; @@ -648,7 +648,7 @@ set_color_scale(const LVecBase4f &scale, int priority) { // multiplied by the specified color scale. //////////////////////////////////////////////////////////////////// void NodePathCollection:: -compose_color_scale(const LVecBase4f &scale, int priority) { +compose_color_scale(const LVecBase4 &scale, int priority) { StateMap state_map; NodePaths::iterator npi; diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index ba04e9df6a..24cfe3f208 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -82,17 +82,17 @@ PUBLISHED: void set_texture_off(int priority = 0); void set_texture_off(TextureStage *stage, int priority = 0); - INLINE void set_color(float r, float g, float b, float a = 1.0, + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0, int priority = 0); - void set_color(const Colorf &color, int priority = 0); + void set_color(const LColor &color, int priority = 0); - INLINE void set_color_scale(float r, float g, float b, float a = 1.0, + INLINE void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0, int priority = 0); - void set_color_scale(const LVecBase4f &scale, int priority = 0); + void set_color_scale(const LVecBase4 &scale, int priority = 0); - INLINE void compose_color_scale(float r, float g, float b, float a = 1.0, + INLINE void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0, int priority = 0); - void compose_color_scale(const LVecBase4f &scale, int priority = 0); + void compose_color_scale(const LVecBase4 &scale, int priority = 0); void set_attrib(const RenderAttrib *attrib, int priority = 0); diff --git a/panda/src/pgraph/nodePathLerps.cxx b/panda/src/pgraph/nodePathLerps.cxx index 053ef813e4..f502bee78d 100644 --- a/panda/src/pgraph/nodePathLerps.cxx +++ b/panda/src/pgraph/nodePathLerps.cxx @@ -25,7 +25,7 @@ TypeHandle ColorScaleLerpFunctor::_type_handle; PosLerpFunctor::PosLerpFunctor(const PosLerpFunctor& c) - : LPoint3fLerpFunctor(c), _node_path(c._node_path) {} + : LPoint3LerpFunctor(c), _node_path(c._node_path) {} PosLerpFunctor::~PosLerpFunctor() { @@ -33,11 +33,11 @@ PosLerpFunctor::~PosLerpFunctor() PosLerpFunctor& PosLerpFunctor::operator=(const PosLerpFunctor& c) { _node_path = c._node_path; - LPoint3fLerpFunctor::operator=(c); + LPoint3LerpFunctor::operator=(c); return *this; } -void PosLerpFunctor::operator()(float t) { +void PosLerpFunctor::operator()(PN_stdfloat t) { if (_is_wrt) _node_path.set_pos(_wrt_path, interpolate(t)); else @@ -45,7 +45,7 @@ void PosLerpFunctor::operator()(float t) { } HprLerpFunctor::HprLerpFunctor(const HprLerpFunctor& c) - : LVecBase3fLerpFunctor(c), _node_path(c._node_path) {} + : LVecBase3LerpFunctor(c), _node_path(c._node_path) {} void HprLerpFunctor::take_shortest() { // so long as these are actually degrees @@ -73,11 +73,11 @@ HprLerpFunctor::~HprLerpFunctor() HprLerpFunctor& HprLerpFunctor::operator=(const HprLerpFunctor& c) { _node_path = c._node_path; - LVecBase3fLerpFunctor::operator=(c); + LVecBase3LerpFunctor::operator=(c); return *this; } -void HprLerpFunctor::operator()(float t) { +void HprLerpFunctor::operator()(PN_stdfloat t) { if (_is_wrt) _node_path.set_hpr(_wrt_path, interpolate(t)); else @@ -85,7 +85,7 @@ void HprLerpFunctor::operator()(float t) { } ScaleLerpFunctor::ScaleLerpFunctor(const ScaleLerpFunctor& c) - : LVecBase3fLerpFunctor(c), _node_path(c._node_path) {} + : LVecBase3LerpFunctor(c), _node_path(c._node_path) {} ScaleLerpFunctor::~ScaleLerpFunctor() { @@ -93,11 +93,11 @@ ScaleLerpFunctor::~ScaleLerpFunctor() ScaleLerpFunctor& ScaleLerpFunctor::operator=(const ScaleLerpFunctor& c) { _node_path = c._node_path; - LVecBase3fLerpFunctor::operator=(c); + LVecBase3LerpFunctor::operator=(c); return *this; } -void ScaleLerpFunctor::operator()(float t) { +void ScaleLerpFunctor::operator()(PN_stdfloat t) { if (_is_wrt) _node_path.set_scale(_wrt_path, interpolate(t)); else @@ -105,7 +105,7 @@ void ScaleLerpFunctor::operator()(float t) { } ColorLerpFunctor::ColorLerpFunctor(const ColorLerpFunctor& c) - : LVecBase4fLerpFunctor(c), _node_path(c._node_path) {} + : LVecBase4LerpFunctor(c), _node_path(c._node_path) {} ColorLerpFunctor::~ColorLerpFunctor() { @@ -113,11 +113,11 @@ ColorLerpFunctor::~ColorLerpFunctor() ColorLerpFunctor& ColorLerpFunctor::operator=(const ColorLerpFunctor& c) { _node_path = c._node_path; - LVecBase4fLerpFunctor::operator=(c); + LVecBase4LerpFunctor::operator=(c); return *this; } -void ColorLerpFunctor::operator()(float t) { +void ColorLerpFunctor::operator()(PN_stdfloat t) { _node_path.set_color(interpolate(t)); } @@ -161,9 +161,9 @@ PosHprLerpFunctor& PosHprLerpFunctor::operator=(const PosHprLerpFunctor& c) { return *this; } -void PosHprLerpFunctor::operator()(float t) { - LPoint3f p = ((t * _pdiff_cache) + _pstart); - LVecBase3f h = ((t * _hdiff_cache) + _hstart); +void PosHprLerpFunctor::operator()(PN_stdfloat t) { + LPoint3 p = ((t * _pdiff_cache) + _pstart); + LVecBase3 h = ((t * _hdiff_cache) + _hstart); if (_is_wrt) _node_path.set_pos_hpr(_wrt_path, p, h); else @@ -210,9 +210,9 @@ HprScaleLerpFunctor::operator=(const HprScaleLerpFunctor& c) { return *this; } -void HprScaleLerpFunctor::operator()(float t) { - LVecBase3f h = ((t * _hdiff_cache) + _hstart); - LVecBase3f s = ((t * _sdiff_cache) + _sstart); +void HprScaleLerpFunctor::operator()(PN_stdfloat t) { + LVecBase3 h = ((t * _hdiff_cache) + _hstart); + LVecBase3 s = ((t * _sdiff_cache) + _sstart); if (_is_wrt) _node_path.set_hpr_scale(_wrt_path, h, s); else @@ -262,10 +262,10 @@ PosHprScaleLerpFunctor::operator=(const PosHprScaleLerpFunctor& c) { return *this; } -void PosHprScaleLerpFunctor::operator()(float t) { - LPoint3f p = ((t * _pdiff_cache) + _pstart); - LVecBase3f h = ((t * _hdiff_cache) + _hstart); - LVecBase3f s = ((t * _sdiff_cache) + _sstart); +void PosHprScaleLerpFunctor::operator()(PN_stdfloat t) { + LPoint3 p = ((t * _pdiff_cache) + _pstart); + LVecBase3 h = ((t * _hdiff_cache) + _hstart); + LVecBase3 s = ((t * _sdiff_cache) + _sstart); if (_is_wrt) _node_path.set_pos_hpr_scale(_wrt_path, p, h, s); else @@ -273,7 +273,7 @@ void PosHprScaleLerpFunctor::operator()(float t) { } ColorScaleLerpFunctor::ColorScaleLerpFunctor(const ColorScaleLerpFunctor& c) - : LVecBase4fLerpFunctor(c), _node_path(c._node_path) {} + : LVecBase4LerpFunctor(c), _node_path(c._node_path) {} ColorScaleLerpFunctor::~ColorScaleLerpFunctor() { @@ -281,11 +281,11 @@ ColorScaleLerpFunctor::~ColorScaleLerpFunctor() ColorScaleLerpFunctor& ColorScaleLerpFunctor::operator=(const ColorScaleLerpFunctor& c) { _node_path = c._node_path; - LVecBase4fLerpFunctor::operator=(c); + LVecBase4LerpFunctor::operator=(c); return *this; } -void ColorScaleLerpFunctor::operator()(float t) { +void ColorScaleLerpFunctor::operator()(PN_stdfloat t) { _node_path.set_color_scale(interpolate(t)); } diff --git a/panda/src/pgraph/nodePathLerps.h b/panda/src/pgraph/nodePathLerps.h index c25ba9dfe2..08d22df3c1 100644 --- a/panda/src/pgraph/nodePathLerps.h +++ b/panda/src/pgraph/nodePathLerps.h @@ -24,32 +24,32 @@ // Class : PosLerpFunctor // Description : Class for Lerping between positions in space //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH PosLerpFunctor : public LPoint3fLerpFunctor { +class EXPCL_PANDA_PGRAPH PosLerpFunctor : public LPoint3LerpFunctor { private: NodePath _node_path; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - PosLerpFunctor(NodePath np, LPoint3f start, LPoint3f end) - : LPoint3fLerpFunctor(start, end), _node_path(np), _is_wrt(false) {} - PosLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, float ey, - float ez) : LPoint3fLerpFunctor(LPoint3f(sx, sy, sz), - LPoint3f(ex, ey, ez)), + PosLerpFunctor(NodePath np, LPoint3 start, LPoint3 end) + : LPoint3LerpFunctor(start, end), _node_path(np), _is_wrt(false) {} + PosLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, PN_stdfloat ey, + PN_stdfloat ez) : LPoint3LerpFunctor(LPoint3(sx, sy, sz), + LPoint3(ex, ey, ez)), _node_path(np), _is_wrt(false) {} - PosLerpFunctor(NodePath np, LPoint3f start, LPoint3f end, NodePath wrt) - : LPoint3fLerpFunctor(start, end), _node_path(np), _is_wrt(true), + PosLerpFunctor(NodePath np, LPoint3 start, LPoint3 end, NodePath wrt) + : LPoint3LerpFunctor(start, end), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} - PosLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, float ey, - float ez, NodePath wrt) - : LPoint3fLerpFunctor(LPoint3f(sx, sy, sz), LPoint3f(ex, ey, ez)), + PosLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, PN_stdfloat ey, + PN_stdfloat ez, NodePath wrt) + : LPoint3LerpFunctor(LPoint3(sx, sy, sz), LPoint3(ex, ey, ez)), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} public: PosLerpFunctor(const PosLerpFunctor&); virtual ~PosLerpFunctor(); PosLerpFunctor& operator=(const PosLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -57,9 +57,9 @@ public: return _type_handle; } static void init_type() { - LPoint3fLerpFunctor::init_type(); + LPoint3LerpFunctor::init_type(); register_type(_type_handle, "PosLerpFunctor", - LPoint3fLerpFunctor::get_class_type()); + LPoint3LerpFunctor::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); @@ -78,25 +78,25 @@ private: // Class : HprLerpFunctor // Description : Class for Lerping between orientations in space //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH HprLerpFunctor : public LVecBase3fLerpFunctor { +class EXPCL_PANDA_PGRAPH HprLerpFunctor : public LVecBase3LerpFunctor { private: NodePath _node_path; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - HprLerpFunctor(NodePath np, LVecBase3f start, LVecBase3f end) - : LVecBase3fLerpFunctor(start, end), _node_path(np), _is_wrt(false) {} - HprLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, float ey, - float ez) : LVecBase3fLerpFunctor(LVecBase3f(sx, sy, sz), - LVecBase3f(ex, ey, ez)), + HprLerpFunctor(NodePath np, LVecBase3 start, LVecBase3 end) + : LVecBase3LerpFunctor(start, end), _node_path(np), _is_wrt(false) {} + HprLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, PN_stdfloat ey, + PN_stdfloat ez) : LVecBase3LerpFunctor(LVecBase3(sx, sy, sz), + LVecBase3(ex, ey, ez)), _node_path(np), _is_wrt(false) {} - HprLerpFunctor(NodePath np, LVecBase3f start, LVecBase3f end, NodePath wrt) - : LVecBase3fLerpFunctor(start, end), _node_path(np), _is_wrt(true), + HprLerpFunctor(NodePath np, LVecBase3 start, LVecBase3 end, NodePath wrt) + : LVecBase3LerpFunctor(start, end), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} - HprLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, float ey, - float ez, NodePath wrt) - : LVecBase3fLerpFunctor(LVecBase3f(sx, sy, sz), LVecBase3f(ex, ey, ez)), + HprLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, PN_stdfloat ey, + PN_stdfloat ez, NodePath wrt) + : LVecBase3LerpFunctor(LVecBase3(sx, sy, sz), LVecBase3(ex, ey, ez)), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} void take_shortest(); void take_longest(); @@ -105,7 +105,7 @@ public: HprLerpFunctor(const HprLerpFunctor&); virtual ~HprLerpFunctor(); HprLerpFunctor& operator=(const HprLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -113,9 +113,9 @@ public: return _type_handle; } static void init_type() { - LVecBase3fLerpFunctor::init_type(); + LVecBase3LerpFunctor::init_type(); register_type(_type_handle, "HprLerpFunctor", - LVecBase3fLerpFunctor::get_class_type()); + LVecBase3LerpFunctor::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); @@ -132,32 +132,32 @@ private: // Class : ScaleLerpFunctor // Description : Class for Lerping between scales //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH ScaleLerpFunctor : public LVecBase3fLerpFunctor { +class EXPCL_PANDA_PGRAPH ScaleLerpFunctor : public LVecBase3LerpFunctor { private: NodePath _node_path; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - ScaleLerpFunctor(NodePath np, LVecBase3f start, LVecBase3f end) - : LVecBase3fLerpFunctor(start, end), _node_path(np), _is_wrt(false) {} - ScaleLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, - float ey, float ez) - : LVecBase3fLerpFunctor(LVecBase3f(sx, sy, sz), LVecBase3f(ex, ey, ez)), + ScaleLerpFunctor(NodePath np, LVecBase3 start, LVecBase3 end) + : LVecBase3LerpFunctor(start, end), _node_path(np), _is_wrt(false) {} + ScaleLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, + PN_stdfloat ey, PN_stdfloat ez) + : LVecBase3LerpFunctor(LVecBase3(sx, sy, sz), LVecBase3(ex, ey, ez)), _node_path(np), _is_wrt(false) {} - ScaleLerpFunctor(NodePath np, LVecBase3f start, LVecBase3f end, NodePath wrt) - : LVecBase3fLerpFunctor(start, end), _node_path(np), _is_wrt(true), + ScaleLerpFunctor(NodePath np, LVecBase3 start, LVecBase3 end, NodePath wrt) + : LVecBase3LerpFunctor(start, end), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} - ScaleLerpFunctor(NodePath np, float sx, float sy, float sz, float ex, - float ey, float ez, NodePath wrt) - : LVecBase3fLerpFunctor(LVecBase3f(sx, sy, sz), LVecBase3f(ex, ey, ez)), + ScaleLerpFunctor(NodePath np, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz, PN_stdfloat ex, + PN_stdfloat ey, PN_stdfloat ez, NodePath wrt) + : LVecBase3LerpFunctor(LVecBase3(sx, sy, sz), LVecBase3(ex, ey, ez)), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} public: ScaleLerpFunctor(const ScaleLerpFunctor&); virtual ~ScaleLerpFunctor(); ScaleLerpFunctor& operator=(const ScaleLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -165,9 +165,9 @@ public: return _type_handle; } static void init_type() { - LVecBase3fLerpFunctor::init_type(); + LVecBase3LerpFunctor::init_type(); register_type(_type_handle, "ScaleLerpFunctor", - LVecBase3fLerpFunctor::get_class_type()); + LVecBase3LerpFunctor::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); @@ -184,31 +184,31 @@ private: // Class : ColorLerpFunctor // Description : Class for Lerping between colors //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH ColorLerpFunctor : public LVecBase4fLerpFunctor { +class EXPCL_PANDA_PGRAPH ColorLerpFunctor : public LVecBase4LerpFunctor { private: NodePath _node_path; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - ColorLerpFunctor(NodePath np, LVecBase4f start, LVecBase4f end) - : LVecBase4fLerpFunctor(start, end), _node_path(np), _is_wrt(false) {} - ColorLerpFunctor(NodePath np, float sr, float sg, float sb, float sa, - float er, float eg, float eb, float ea) : LVecBase4fLerpFunctor(LVecBase4f(sr, sg, sb, sa), - LVecBase4f(er, eg, eb, ea)), _node_path(np), _is_wrt(false) {} - ColorLerpFunctor(NodePath np, LVecBase4f start, LVecBase4f end, NodePath wrt) - : LVecBase4fLerpFunctor(start, end), _node_path(np), _is_wrt(true), + ColorLerpFunctor(NodePath np, LVecBase4 start, LVecBase4 end) + : LVecBase4LerpFunctor(start, end), _node_path(np), _is_wrt(false) {} + ColorLerpFunctor(NodePath np, PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, + PN_stdfloat er, PN_stdfloat eg, PN_stdfloat eb, PN_stdfloat ea) : LVecBase4LerpFunctor(LVecBase4(sr, sg, sb, sa), + LVecBase4(er, eg, eb, ea)), _node_path(np), _is_wrt(false) {} + ColorLerpFunctor(NodePath np, LVecBase4 start, LVecBase4 end, NodePath wrt) + : LVecBase4LerpFunctor(start, end), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} - ColorLerpFunctor(NodePath np, float sr, float sg, float sb, float sa, float er, float eg, - float eb, float ea, NodePath wrt) - : LVecBase4fLerpFunctor(LVecBase4f(sr, sg, sb, sa), LVecBase4f(er, eg, eb, ea)), + ColorLerpFunctor(NodePath np, PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, PN_stdfloat er, PN_stdfloat eg, + PN_stdfloat eb, PN_stdfloat ea, NodePath wrt) + : LVecBase4LerpFunctor(LVecBase4(sr, sg, sb, sa), LVecBase4(er, eg, eb, ea)), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} public: ColorLerpFunctor(const ColorLerpFunctor&); virtual ~ColorLerpFunctor(); ColorLerpFunctor& operator=(const ColorLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -216,9 +216,9 @@ public: return _type_handle; } static void init_type() { - LVecBase4fLerpFunctor::init_type(); + LVecBase4LerpFunctor::init_type(); register_type(_type_handle, "ColorLerpFunctor", - LVecBase4fLerpFunctor::get_class_type()); + LVecBase4LerpFunctor::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); @@ -239,36 +239,36 @@ private: class EXPCL_PANDA_PGRAPH PosHprLerpFunctor : public LerpFunctor { private: NodePath _node_path; - LPoint3f _pstart; - LPoint3f _pend; - LPoint3f _pdiff_cache; - LVecBase3f _hstart; - LVecBase3f _hend; - LVecBase3f _hdiff_cache; + LPoint3 _pstart; + LPoint3 _pend; + LPoint3 _pdiff_cache; + LVecBase3 _hstart; + LVecBase3 _hend; + LVecBase3 _hdiff_cache; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - PosHprLerpFunctor(NodePath np, LPoint3f pstart, LPoint3f pend, - LVecBase3f hstart, LVecBase3f hend) + PosHprLerpFunctor(NodePath np, LPoint3 pstart, LPoint3 pend, + LVecBase3 hstart, LVecBase3 hend) : LerpFunctor(), _node_path(np), _pstart(pstart), _pend(pend), _pdiff_cache(pend-pstart), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _is_wrt(false) {} - PosHprLerpFunctor(NodePath np, float psx, float psy, float psz, float pex, - float pey, float pez, float hsx, float hsy, float hsz, - float hex, float hey, float hez) + PosHprLerpFunctor(NodePath np, PN_stdfloat psx, PN_stdfloat psy, PN_stdfloat psz, PN_stdfloat pex, + PN_stdfloat pey, PN_stdfloat pez, PN_stdfloat hsx, PN_stdfloat hsy, PN_stdfloat hsz, + PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez) : LerpFunctor(), _node_path(np), _pstart(psx, psy, psz), _pend(pex, pey, pez), _pdiff_cache(_pend-_pstart), _hstart(hsx, hsy, hsz), _hend(hex, hey, hez), _hdiff_cache(_hend - _hstart), _is_wrt(false) {} - PosHprLerpFunctor(NodePath np, LPoint3f pstart, LPoint3f pend, - LVecBase3f hstart, LVecBase3f hend, NodePath wrt) + PosHprLerpFunctor(NodePath np, LPoint3 pstart, LPoint3 pend, + LVecBase3 hstart, LVecBase3 hend, NodePath wrt) : LerpFunctor(), _node_path(np), _pstart(pstart), _pend(pend), _pdiff_cache(pend-pstart), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _is_wrt(true), _wrt_path(wrt) {} - PosHprLerpFunctor(NodePath np, float psx, float psy, float psz, float pex, - float pey, float pez, float hsx, float hsy, float hsz, - float hex, float hey, float hez, NodePath wrt) + PosHprLerpFunctor(NodePath np, PN_stdfloat psx, PN_stdfloat psy, PN_stdfloat psz, PN_stdfloat pex, + PN_stdfloat pey, PN_stdfloat pez, PN_stdfloat hsx, PN_stdfloat hsy, PN_stdfloat hsz, + PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez, NodePath wrt) : LerpFunctor(), _node_path(np), _pstart(psx, psy, psz), _pend(pex, pey, pez), _pdiff_cache(_pend-_pstart), _hstart(hsx, hsy, hsz), _hend(hex, hey, hez), @@ -280,7 +280,7 @@ public: PosHprLerpFunctor(const PosHprLerpFunctor&); virtual ~PosHprLerpFunctor(); PosHprLerpFunctor& operator=(const PosHprLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -311,39 +311,39 @@ private: class EXPCL_PANDA_PGRAPH HprScaleLerpFunctor : public LerpFunctor { private: NodePath _node_path; - LVecBase3f _hstart; - LVecBase3f _hend; - LVecBase3f _hdiff_cache; - LVecBase3f _sstart; - LVecBase3f _send; - LVecBase3f _sdiff_cache; + LVecBase3 _hstart; + LVecBase3 _hend; + LVecBase3 _hdiff_cache; + LVecBase3 _sstart; + LVecBase3 _send; + LVecBase3 _sdiff_cache; bool _is_wrt; NodePath _wrt_path; PUBLISHED: HprScaleLerpFunctor(NodePath np, - LVecBase3f hstart, LVecBase3f hend, LVecBase3f sstart, - LVecBase3f send) + LVecBase3 hstart, LVecBase3 hend, LVecBase3 sstart, + LVecBase3 send) : LerpFunctor(), _node_path(np), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _sstart(sstart), _send(send), _sdiff_cache(send-sstart), _is_wrt(false) {} - HprScaleLerpFunctor(NodePath np, float hsx, float hsy, - float hsz, float hex, float hey, float hez, float ssx, - float ssy, float ssz, float sex, float sey, float sez) + HprScaleLerpFunctor(NodePath np, PN_stdfloat hsx, PN_stdfloat hsy, + PN_stdfloat hsz, PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez, PN_stdfloat ssx, + PN_stdfloat ssy, PN_stdfloat ssz, PN_stdfloat sex, PN_stdfloat sey, PN_stdfloat sez) : LerpFunctor(), _node_path(np), _hstart(hsx, hsy, hsz), _hend(hex, hey, hez), _hdiff_cache(_hend-_hstart), _sstart(ssx, ssy, ssz), _send(sex, sey, sez), _sdiff_cache(_send-_sstart), _is_wrt(false) {} HprScaleLerpFunctor(NodePath np, - LVecBase3f hstart, LVecBase3f hend, LVecBase3f sstart, - LVecBase3f send, NodePath wrt) + LVecBase3 hstart, LVecBase3 hend, LVecBase3 sstart, + LVecBase3 send, NodePath wrt) : LerpFunctor(), _node_path(np), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _sstart(sstart), _send(send), _sdiff_cache(send-sstart), _is_wrt(true), _wrt_path(wrt) {} - HprScaleLerpFunctor(NodePath np, float hsx, float hsy, - float hsz, float hex, float hey, float hez, float ssx, - float ssy, float ssz, float sex, float sey, float sez, + HprScaleLerpFunctor(NodePath np, PN_stdfloat hsx, PN_stdfloat hsy, + PN_stdfloat hsz, PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez, PN_stdfloat ssx, + PN_stdfloat ssy, PN_stdfloat ssz, PN_stdfloat sex, PN_stdfloat sey, PN_stdfloat sez, NodePath wrt) : LerpFunctor(), _node_path(np), _hstart(hsx, hsy, hsz), _hend(hex, hey, hez), @@ -357,7 +357,7 @@ public: HprScaleLerpFunctor(const HprScaleLerpFunctor&); virtual ~HprScaleLerpFunctor(); HprScaleLerpFunctor& operator=(const HprScaleLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -388,46 +388,46 @@ private: class EXPCL_PANDA_PGRAPH PosHprScaleLerpFunctor : public LerpFunctor { private: NodePath _node_path; - LPoint3f _pstart; - LPoint3f _pend; - LPoint3f _pdiff_cache; - LVecBase3f _hstart; - LVecBase3f _hend; - LVecBase3f _hdiff_cache; - LVecBase3f _sstart; - LVecBase3f _send; - LVecBase3f _sdiff_cache; + LPoint3 _pstart; + LPoint3 _pend; + LPoint3 _pdiff_cache; + LVecBase3 _hstart; + LVecBase3 _hend; + LVecBase3 _hdiff_cache; + LVecBase3 _sstart; + LVecBase3 _send; + LVecBase3 _sdiff_cache; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - PosHprScaleLerpFunctor(NodePath np, LPoint3f pstart, LPoint3f pend, - LVecBase3f hstart, LVecBase3f hend, LVecBase3f sstart, - LVecBase3f send) + PosHprScaleLerpFunctor(NodePath np, LPoint3 pstart, LPoint3 pend, + LVecBase3 hstart, LVecBase3 hend, LVecBase3 sstart, + LVecBase3 send) : LerpFunctor(), _node_path(np), _pstart(pstart), _pend(pend), _pdiff_cache(pend-pstart), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _sstart(sstart), _send(send), _sdiff_cache(send-sstart), _is_wrt(false) {} - PosHprScaleLerpFunctor(NodePath np, float psx, float psy, float psz, - float pex, float pey, float pez, float hsx, float hsy, - float hsz, float hex, float hey, float hez, float ssx, - float ssy, float ssz, float sex, float sey, float sez) + PosHprScaleLerpFunctor(NodePath np, PN_stdfloat psx, PN_stdfloat psy, PN_stdfloat psz, + PN_stdfloat pex, PN_stdfloat pey, PN_stdfloat pez, PN_stdfloat hsx, PN_stdfloat hsy, + PN_stdfloat hsz, PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez, PN_stdfloat ssx, + PN_stdfloat ssy, PN_stdfloat ssz, PN_stdfloat sex, PN_stdfloat sey, PN_stdfloat sez) : LerpFunctor(), _node_path(np), _pstart(psx, psy, psz), _pend(pex, pey, pez), _pdiff_cache(_pend-_pstart), _hstart(hsx, hsy, hsz), _hend(hex, hey, hez), _hdiff_cache(_hend-_hstart), _sstart(ssx, ssy, ssz), _send(sex, sey, sez), _sdiff_cache(_send-_sstart), _is_wrt(false) {} - PosHprScaleLerpFunctor(NodePath np, LPoint3f pstart, LPoint3f pend, - LVecBase3f hstart, LVecBase3f hend, LVecBase3f sstart, - LVecBase3f send, NodePath wrt) + PosHprScaleLerpFunctor(NodePath np, LPoint3 pstart, LPoint3 pend, + LVecBase3 hstart, LVecBase3 hend, LVecBase3 sstart, + LVecBase3 send, NodePath wrt) : LerpFunctor(), _node_path(np), _pstart(pstart), _pend(pend), _pdiff_cache(pend-pstart), _hstart(hstart), _hend(hend), _hdiff_cache(hend-hstart), _sstart(sstart), _send(send), _sdiff_cache(send-sstart), _is_wrt(true), _wrt_path(wrt) {} - PosHprScaleLerpFunctor(NodePath np, float psx, float psy, float psz, - float pex, float pey, float pez, float hsx, float hsy, - float hsz, float hex, float hey, float hez, float ssx, - float ssy, float ssz, float sex, float sey, float sez, + PosHprScaleLerpFunctor(NodePath np, PN_stdfloat psx, PN_stdfloat psy, PN_stdfloat psz, + PN_stdfloat pex, PN_stdfloat pey, PN_stdfloat pez, PN_stdfloat hsx, PN_stdfloat hsy, + PN_stdfloat hsz, PN_stdfloat hex, PN_stdfloat hey, PN_stdfloat hez, PN_stdfloat ssx, + PN_stdfloat ssy, PN_stdfloat ssz, PN_stdfloat sex, PN_stdfloat sey, PN_stdfloat sez, NodePath wrt) : LerpFunctor(), _node_path(np), _pstart(psx, psy, psz), _pend(pex, pey, pez), _pdiff_cache(_pend-_pstart), @@ -442,7 +442,7 @@ public: PosHprScaleLerpFunctor(const PosHprScaleLerpFunctor&); virtual ~PosHprScaleLerpFunctor(); PosHprScaleLerpFunctor& operator=(const PosHprScaleLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -469,31 +469,31 @@ private: // Class : ColorScaleLerpFunctor // Description : Class for Lerping between color scales //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH ColorScaleLerpFunctor : public LVecBase4fLerpFunctor { +class EXPCL_PANDA_PGRAPH ColorScaleLerpFunctor : public LVecBase4LerpFunctor { private: NodePath _node_path; bool _is_wrt; NodePath _wrt_path; PUBLISHED: - ColorScaleLerpFunctor(NodePath np, LVecBase4f start, LVecBase4f end) - : LVecBase4fLerpFunctor(start, end), _node_path(np), _is_wrt(false) {} - ColorScaleLerpFunctor(NodePath np, float sr, float sg, float sb, float sa, - float er, float eg, float eb, float ea) : LVecBase4fLerpFunctor(LVecBase4f(sr, sg, sb, sa), - LVecBase4f(er, eg, eb, ea)), _node_path(np), _is_wrt(false) {} - ColorScaleLerpFunctor(NodePath np, LVecBase4f start, LVecBase4f end, NodePath wrt) - : LVecBase4fLerpFunctor(start, end), _node_path(np), _is_wrt(true), + ColorScaleLerpFunctor(NodePath np, LVecBase4 start, LVecBase4 end) + : LVecBase4LerpFunctor(start, end), _node_path(np), _is_wrt(false) {} + ColorScaleLerpFunctor(NodePath np, PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, + PN_stdfloat er, PN_stdfloat eg, PN_stdfloat eb, PN_stdfloat ea) : LVecBase4LerpFunctor(LVecBase4(sr, sg, sb, sa), + LVecBase4(er, eg, eb, ea)), _node_path(np), _is_wrt(false) {} + ColorScaleLerpFunctor(NodePath np, LVecBase4 start, LVecBase4 end, NodePath wrt) + : LVecBase4LerpFunctor(start, end), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} - ColorScaleLerpFunctor(NodePath np, float sr, float sg, float sb, float sa, float er, float eg, - float eb, float ea, NodePath wrt) - : LVecBase4fLerpFunctor(LVecBase4f(sr, sg, sb, sa), LVecBase4f(er, eg, eb, ea)), + ColorScaleLerpFunctor(NodePath np, PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, PN_stdfloat er, PN_stdfloat eg, + PN_stdfloat eb, PN_stdfloat ea, NodePath wrt) + : LVecBase4LerpFunctor(LVecBase4(sr, sg, sb, sa), LVecBase4(er, eg, eb, ea)), _node_path(np), _is_wrt(true), _wrt_path(wrt) {} public: ColorScaleLerpFunctor(const ColorScaleLerpFunctor&); virtual ~ColorScaleLerpFunctor(); ColorScaleLerpFunctor& operator=(const ColorScaleLerpFunctor&); - virtual void operator()(float); + virtual void operator()(PN_stdfloat); public: // now for typehandle stuff @@ -501,9 +501,9 @@ public: return _type_handle; } static void init_type() { - LVecBase4fLerpFunctor::init_type(); + LVecBase4LerpFunctor::init_type(); register_type(_type_handle, "ColorScaleLerpFunctor", - LVecBase4fLerpFunctor::get_class_type()); + LVecBase4LerpFunctor::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/pgraph/occluderNode.I b/panda/src/pgraph/occluderNode.I index f562d95eeb..1e47ce5ffa 100644 --- a/panda/src/pgraph/occluderNode.I +++ b/panda/src/pgraph/occluderNode.I @@ -21,8 +21,8 @@ // orientation when looking at the face of the occluder. //////////////////////////////////////////////////////////////////// INLINE void OccluderNode:: -set_vertices(const LPoint3f &v0, const LPoint3f &v1, - const LPoint3f &v2, const LPoint3f &v3) { +set_vertices(const LPoint3 &v0, const LPoint3 &v1, + const LPoint3 &v2, const LPoint3 &v3) { _vertices.clear(); _vertices.reserve(4); _vertices.push_back(v0); @@ -47,9 +47,9 @@ get_num_vertices() const { // Access: Published // Description: Returns the nth vertex of the occluder polygon. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &OccluderNode:: +INLINE const LPoint3 &OccluderNode:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3f::zero()); + nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero()); return _vertices[n]; } @@ -79,7 +79,7 @@ INLINE bool OccluderNode::is_double_sided() { // would mean that the occluder needs to cover 20% of // the screen to be considered. //////////////////////////////////////////////////////////////////// -INLINE void OccluderNode::set_min_coverage(float value) { +INLINE void OccluderNode::set_min_coverage(PN_stdfloat value) { _min_coverage = value; } @@ -88,6 +88,6 @@ INLINE void OccluderNode::set_min_coverage(float value) { // Access: Published // Description: Returns the minimum screen coverage. //////////////////////////////////////////////////////////////////// -INLINE float OccluderNode::get_min_coverage() { +INLINE PN_stdfloat OccluderNode::get_min_coverage() { return _min_coverage; } diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index b733b1f262..4ddc936812 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -63,10 +63,10 @@ OccluderNode(const string &name) : set_overall_hidden(true); set_double_sided(false); set_min_coverage(0.0); - set_vertices(LPoint3f::rfu(-1.0, 0.0, -1.0), - LPoint3f::rfu(1.0, 0.0, -1.0), - LPoint3f::rfu(1.0, 0.0, 1.0), - LPoint3f::rfu(-1.0, 0.0, 1.0)); + set_vertices(LPoint3::rfu(-1.0, 0.0, -1.0), + LPoint3::rfu(1.0, 0.0, -1.0), + LPoint3::rfu(1.0, 0.0, 1.0), + LPoint3::rfu(-1.0, 0.0, 1.0)); } //////////////////////////////////////////////////////////////////// @@ -125,7 +125,7 @@ preserve_name() const { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void OccluderNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); for (Vertices::iterator vi = _vertices.begin(); @@ -233,8 +233,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // Now actually compute the bounding volume by putting it around all // of our vertices. if (!_vertices.empty()) { - const LPoint3f *vertices_begin = &_vertices[0]; - const LPoint3f *vertices_end = vertices_begin + _vertices.size(); + const LPoint3 *vertices_begin = &_vertices[0]; + const LPoint3 *vertices_end = vertices_begin + _vertices.size(); gbv->around(vertices_begin, vertices_end); } @@ -262,27 +262,27 @@ get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { (get_name(), GeomVertexFormat::get_v3n3t2(), Geom::UH_static); // Compute the polygon normal from the first three vertices. - Planef plane(_vertices[0], _vertices[1], _vertices[2]); - LVector3f poly_normal = plane.get_normal(); + LPlane plane(_vertices[0], _vertices[1], _vertices[2]); + LVector3 poly_normal = plane.get_normal(); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter normal(vdata, InternalName::get_normal()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - vertex.add_data3f(_vertices[0]); - normal.add_data3f(poly_normal); - texcoord.add_data2f(0.0, 0.0); + vertex.add_data3(_vertices[0]); + normal.add_data3(poly_normal); + texcoord.add_data2(0.0, 0.0); - vertex.add_data3f(_vertices[1]); - normal.add_data3f(poly_normal); - texcoord.add_data2f(8.0, 0.0); + vertex.add_data3(_vertices[1]); + normal.add_data3(poly_normal); + texcoord.add_data2(8.0, 0.0); - vertex.add_data3f(_vertices[2]); - normal.add_data3f(poly_normal); - texcoord.add_data2f(8.0, 8.0); + vertex.add_data3(_vertices[2]); + normal.add_data3(poly_normal); + texcoord.add_data2(8.0, 8.0); - vertex.add_data3f(_vertices[3]); - normal.add_data3f(poly_normal); - texcoord.add_data2f(0.0, 8.0); + vertex.add_data3(_vertices[3]); + normal.add_data3(poly_normal); + texcoord.add_data2(0.0, 8.0); PT(GeomTriangles) triangles = new GeomTriangles(Geom::UH_static); triangles->add_vertices(0, 1, 2); @@ -328,7 +328,7 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { static CPT(RenderState) viz_state; if (viz_state == NULL) { viz_state = RenderState::make - (ColorAttrib::make_flat(LVecBase4f(1.0f, 1.0f, 1.0f, 0.5f)), + (ColorAttrib::make_flat(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthOffsetAttrib::make(), TextureAttrib::make(_viz_tex)); @@ -355,7 +355,7 @@ get_frame_viz_state(CullTraverser *trav, CullTraverserData &data) { static CPT(RenderState) viz_state; if (viz_state == NULL) { viz_state = RenderState::make - (ColorAttrib::make_flat(LVecBase4f(0.0f, 0.0f, 0.0f, 1.0f)), + (ColorAttrib::make_flat(LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)), TextureAttrib::make_off()); viz_state = viz_state->adjust_all_priorities(1); } @@ -441,7 +441,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _vertices.clear(); _vertices.reserve(num_vertices); for (int i = 0; i < num_vertices; i++) { - LPoint3f vertex; + LPoint3 vertex; vertex.read_datagram(scan); _vertices.push_back(vertex); } diff --git a/panda/src/pgraph/occluderNode.h b/panda/src/pgraph/occluderNode.h index 432f6cbbfc..8bae1497c4 100644 --- a/panda/src/pgraph/occluderNode.h +++ b/panda/src/pgraph/occluderNode.h @@ -43,7 +43,7 @@ public: virtual ~OccluderNode(); virtual PandaNode *make_copy() const; virtual bool preserve_name() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; @@ -53,12 +53,12 @@ public: PUBLISHED: INLINE void set_double_sided(bool value); INLINE bool is_double_sided(); - INLINE void set_min_coverage(float value); - INLINE float get_min_coverage(); - INLINE void set_vertices(const LPoint3f &v0, const LPoint3f &v1, - const LPoint3f &v2, const LPoint3f &v3); + INLINE void set_min_coverage(PN_stdfloat value); + INLINE PN_stdfloat get_min_coverage(); + INLINE void set_vertices(const LPoint3 &v0, const LPoint3 &v1, + const LPoint3 &v2, const LPoint3 &v3); INLINE int get_num_vertices() const; - INLINE const LPoint3f &get_vertex(int n) const; + INLINE const LPoint3 &get_vertex(int n) const; MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); protected: @@ -72,8 +72,8 @@ protected: private: bool _double_sided; - float _min_coverage; - typedef pvector Vertices; + PN_stdfloat _min_coverage; + typedef pvector Vertices; Vertices _vertices; PT(Geom) _occluder_viz, _frame_viz; diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 1e984668e8..1a72c106c0 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -356,7 +356,7 @@ void PandaNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { - const LMatrix4f &mat = attribs._transform->get_mat(); + const LMatrix4 &mat = attribs._transform->get_mat(); xform(mat); Thread *current_thread = Thread::get_current_thread(); @@ -378,7 +378,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void PandaNode:: -xform(const LMatrix4f &) { +xform(const LMatrix4 &) { } //////////////////////////////////////////////////////////////////// @@ -437,7 +437,7 @@ combine_with(PandaNode *other) { // node's transform. //////////////////////////////////////////////////////////////////// CPT(TransformState) PandaNode:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, bool &found_any, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { CPT(TransformState) next_transform = transform->compose(get_transform()); diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 164bbb8600..c6919ff7c6 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -97,10 +97,10 @@ public: virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual CPT(TransformState) - calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread = Thread::get_current_thread()) const; diff --git a/panda/src/pgraph/planeNode.I b/panda/src/pgraph/planeNode.I index 7bc9577a0e..cdde44ff78 100644 --- a/panda/src/pgraph/planeNode.I +++ b/panda/src/pgraph/planeNode.I @@ -47,7 +47,7 @@ CData(const PlaneNode::CData ©) : // PlaneNode. //////////////////////////////////////////////////////////////////// INLINE void PlaneNode:: -set_plane(const Planef &plane) { +set_plane(const LPlane &plane) { CDWriter cdata(_cycler); if (cdata->_plane != plane) { cdata->_plane = plane; @@ -61,7 +61,7 @@ set_plane(const Planef &plane) { // Access: Public // Description: Returns the plane represented by the PlaneNode. //////////////////////////////////////////////////////////////////// -INLINE const Planef &PlaneNode:: +INLINE const LPlane &PlaneNode:: get_plane() const { CDReader cdata(_cycler); return cdata->_plane; @@ -74,7 +74,7 @@ get_plane() const { // the plane that is drawn if the PlaneNode is shown. //////////////////////////////////////////////////////////////////// INLINE void PlaneNode:: -set_viz_scale(float viz_scale) { +set_viz_scale(PN_stdfloat viz_scale) { CDWriter cdata(_cycler); if (cdata->_viz_scale != viz_scale) { cdata->_viz_scale = viz_scale; @@ -89,7 +89,7 @@ set_viz_scale(float viz_scale) { // Description: Returns the size of the visual representation of // the plane that is drawn if the PlaneNode is shown. //////////////////////////////////////////////////////////////////// -INLINE float PlaneNode:: +INLINE PN_stdfloat PlaneNode:: get_viz_scale() const { CDReader cdata(_cycler); return cdata->_viz_scale; diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index 0c76e279a8..0623cbdfb4 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -69,7 +69,7 @@ fillin(DatagramIterator &scan, BamReader *) { // Description: //////////////////////////////////////////////////////////////////// PlaneNode:: -PlaneNode(const string &name, const Planef &plane) : +PlaneNode(const string &name, const LPlane &plane) : PandaNode(name), _priority(0), _clip_effect(~0) @@ -128,7 +128,7 @@ make_copy() const { // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void PlaneNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { PandaNode::xform(mat); CDWriter cdata(_cycler); cdata->_plane = cdata->_plane * mat; @@ -223,7 +223,7 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { // Figure out whether we are looking at the front or the back of the // plane. const Lens *lens = trav->get_scene()->get_lens(); - Planef eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat(); + LPlane eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat(); bool front = (eye_plane.dist_to_plane(lens->get_nodal_point()) >= 0.0f); if (cdata->_front_viz != (Geom *)NULL) { @@ -236,7 +236,7 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { } CDWriter cdataw(_cycler, cdata, false); - const Planef &plane = cdataw->_plane; + const LPlane &plane = cdataw->_plane; PT(GeomVertexData) vdata = new GeomVertexData (get_name(), GeomVertexFormat::get_v3cp(), Geom::UH_static); @@ -244,7 +244,7 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { GeomVertexWriter vertex(vdata, InternalName::get_vertex()); PT(GeomLines) lines = new GeomLines(Geom::UH_static); - LVector3f a, b; + LVector3 a, b; if (fabs(plane[0]) > fabs(plane[1])) { // X > Y @@ -275,22 +275,22 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { b *= cdataw->_viz_scale / (num_segs * 2); for (int x = -num_segs; x <= num_segs; ++x) { - vertex.add_data3f(plane.project(a * x - b * num_segs)); - vertex.add_data3f(plane.project(a * x + b * num_segs)); + vertex.add_data3(plane.project(a * x - b * num_segs)); + vertex.add_data3(plane.project(a * x + b * num_segs)); lines->add_next_vertices(2); lines->close_primitive(); } for (int y = -num_segs; y <= num_segs; ++y) { - vertex.add_data3f(plane.project(b * y - a * num_segs)); - vertex.add_data3f(plane.project(b * y + a * num_segs)); + vertex.add_data3(plane.project(b * y - a * num_segs)); + vertex.add_data3(plane.project(b * y + a * num_segs)); lines->add_next_vertices(2); lines->close_primitive(); } - cdataw->_front_viz = new Geom(vdata->set_color(Colorf(1.0f, 1.0f, 0.0f, 1.0f))); + cdataw->_front_viz = new Geom(vdata->set_color(LColor(1.0f, 1.0f, 0.0f, 1.0f))); cdataw->_front_viz->add_primitive(lines); - cdataw->_back_viz = new Geom(vdata->set_color(Colorf(0.4f, 0.4f, 0.0f, 1.0f))); + cdataw->_back_viz = new Geom(vdata->set_color(LColor(0.4, 0.4, 0.0f, 1.0f))); cdataw->_back_viz->add_primitive(lines); return front ? cdataw->_front_viz : cdataw->_back_viz; diff --git a/panda/src/pgraph/planeNode.h b/panda/src/pgraph/planeNode.h index 5e3334c616..bd46949c9b 100644 --- a/panda/src/pgraph/planeNode.h +++ b/panda/src/pgraph/planeNode.h @@ -38,7 +38,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode { PUBLISHED: - PlaneNode(const string &name, const Planef &plane = Planef()); + PlaneNode(const string &name, const LPlane &plane = LPlane()); protected: PlaneNode(const PlaneNode ©); @@ -46,17 +46,17 @@ public: virtual void output(ostream &out) const; virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; PUBLISHED: - INLINE void set_plane(const Planef &plane); - INLINE const Planef &get_plane() const; + INLINE void set_plane(const LPlane &plane); + INLINE const LPlane &get_plane() const; - INLINE void set_viz_scale(float viz_scale); - INLINE float get_viz_scale() const; + INLINE void set_viz_scale(PN_stdfloat viz_scale); + INLINE PN_stdfloat get_viz_scale() const; INLINE void set_priority(int priority); INLINE int get_priority() const; @@ -98,9 +98,9 @@ private: return PlaneNode::get_class_type(); } - Planef _plane; + LPlane _plane; PT(Geom) _front_viz, _back_viz; - float _viz_scale; + PN_stdfloat _viz_scale; }; PipelineCycler _cycler; diff --git a/panda/src/pgraph/polylightEffect.I b/panda/src/pgraph/polylightEffect.I index ee0649deba..7711b2b601 100755 --- a/panda/src/pgraph/polylightEffect.I +++ b/panda/src/pgraph/polylightEffect.I @@ -43,7 +43,7 @@ PolylightEffect(const PolylightEffect ©) : // Access: Published // Description: Get the weight value //////////////////////////////////////////////////////////////////// -INLINE float PolylightEffect:: +INLINE PN_stdfloat PolylightEffect:: get_weight() const { return _weight; } @@ -63,7 +63,7 @@ get_contrib() const { // Access: Published // Description: Return the value of the _effect_center //////////////////////////////////////////////////////////////////// -INLINE LPoint3f PolylightEffect:: +INLINE LPoint3 PolylightEffect:: get_effect_center() const { return _effect_center; } diff --git a/panda/src/pgraph/polylightEffect.cxx b/panda/src/pgraph/polylightEffect.cxx index 8bcb7f20d6..84fa09efc5 100755 --- a/panda/src/pgraph/polylightEffect.cxx +++ b/panda/src/pgraph/polylightEffect.cxx @@ -35,7 +35,7 @@ make() { PolylightEffect *effect = new PolylightEffect; effect->_contribution_type = CT_proximal; effect->_weight = 1.0; // 0.9; // Asad: I don't think we should monkey with the weight. - effect->_effect_center = LPoint3f(0.0,0.0,0.0); + effect->_effect_center = LPoint3(0.0,0.0,0.0); return return_new(effect); } @@ -45,7 +45,7 @@ make() { // Description: Constructs a new PolylightEffect object. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) PolylightEffect:: -make(float weight, ContribType contrib, LPoint3f effect_center) { +make(PN_stdfloat weight, ContribType contrib, LPoint3 effect_center) { PolylightEffect *effect = new PolylightEffect; effect->_contribution_type = contrib; effect->_weight = weight; @@ -59,7 +59,7 @@ make(float weight, ContribType contrib, LPoint3f effect_center) { // Description: Constructs a new PolylightEffect object. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) PolylightEffect:: -make(float weight, ContribType contrib, LPoint3f effect_center, +make(PN_stdfloat weight, ContribType contrib, LPoint3 effect_center, const LightGroup &lights) { PolylightEffect *effect = new PolylightEffect; effect->_contribution_type = contrib; @@ -123,13 +123,13 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(RenderAttrib) PolylightEffect:: do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const TransformState *node_transform) const { //static bool was_under_polylight = false; - float dist; // To calculate the distance of each light from the node - float r,g,b; // To hold the color calculation - float min_dist; // hold the dist from light that avatar is closer to + PN_stdfloat dist; // To calculate the distance of each light from the node + PN_stdfloat r,g,b; // To hold the color calculation + PN_stdfloat min_dist; // hold the dist from light that avatar is closer to int num_lights = 0; // Keep track of number of lights for division - float light_scale; // Variable to calculate attenuation - float weight_scale = 1.0f; // Variable to compensate snap of color when you walk inside the light volume - float Rcollect, Gcollect, Bcollect; + PN_stdfloat light_scale; // Variable to calculate attenuation + PN_stdfloat weight_scale = 1.0f; // Variable to compensate snap of color when you walk inside the light volume + PN_stdfloat Rcollect, Gcollect, Bcollect; const NodePath &root = scene->get_scene_root(); //const NodePath &camera = scene->get_camera_path(); @@ -140,7 +140,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran Rcollect = Gcollect = Bcollect = 0.0; // get the avatar's base color scale - Colorf scene_color = root.get_color_scale(); + LColor scene_color = root.get_color_scale(); if (polylight_info) { pgraph_cat.debug() << "scene color scale = " << scene_color << endl; } @@ -152,31 +152,31 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran // light holds the current PolylightNode if (light->is_enabled()) { // if enabled get all the properties - float light_radius = light->get_radius(); + PN_stdfloat light_radius = light->get_radius(); // Calculate the distance of the node from the light //dist = light_iter->second->get_distance(data->_node_path.get_node_path()); const NodePath lightnp = *light_iter; - LPoint3f relative_point = data->_node_path.get_node_path().get_relative_point(lightnp, light->get_pos()); + LPoint3 relative_point = data->_node_path.get_node_path().get_relative_point(lightnp, light->get_pos()); if (_effect_center[2]) { dist = (relative_point - _effect_center).length(); // this counts height difference } else { // get distance as if the light is at the same height of player - LVector2f xz(relative_point[0], relative_point[1]); + LVector2 xz(relative_point[0], relative_point[1]); dist = xz.length(); // this does not count height difference } if (dist <= light_radius) { // If node is in range of this light // as to Schuyler's suggestion, lets do some vector processing relative to camera - LPoint3f light_position = light->get_pos(); - //LPoint3f camera_position = camera.get_relative_point(lightnp, light->get_pos()); - LPoint3f camera_position = lightnp.get_relative_point(camera, LPoint3f(0,0,0)); - LPoint3f avatar_position = lightnp.get_relative_point(data->_node_path.get_node_path(), LPoint3f(0,0,0)); - LVector3f light_camera = camera_position - light_position; - LVector3f light_avatar = avatar_position - light_position; + LPoint3 light_position = light->get_pos(); + //LPoint3 camera_position = camera.get_relative_point(lightnp, light->get_pos()); + LPoint3 camera_position = lightnp.get_relative_point(camera, LPoint3(0,0,0)); + LPoint3 avatar_position = lightnp.get_relative_point(data->_node_path.get_node_path(), LPoint3(0,0,0)); + LVector3 light_camera = camera_position - light_position; + LVector3 light_avatar = avatar_position - light_position; light_camera.normalize(); light_avatar.normalize(); - float intensity = light_camera.dot(light_avatar); + PN_stdfloat intensity = light_camera.dot(light_avatar); if (polylight_info) { pgraph_cat.debug() << "light position = " << light_position << endl; @@ -197,7 +197,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran } PolylightNode::Attenuation_Type light_attenuation = light->get_attenuation(); - Colorf light_color; + LColor light_color; if (light->is_flickering()) { // If flickering, modify color light_color = light->flicker(); } else { @@ -205,15 +205,15 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran //light_color = light->get_color_scenegraph(); } - float ratio = dist/light_radius; + PN_stdfloat ratio = dist/light_radius; if (light_attenuation == PolylightNode::ALINEAR) { light_scale = 1.0 - ratio; } else if (light_attenuation == PolylightNode::AQUADRATIC) { /* - float fd; // Variable for quadratic attenuation - float light_a0 = light->get_a0(); - float light_a1 = light->get_a1(); - float light_a2 = light->get_a2(); + PN_stdfloat fd; // Variable for quadratic attenuation + PN_stdfloat light_a0 = light->get_a0(); + PN_stdfloat light_a1 = light->get_a1(); + PN_stdfloat light_a2 = light->get_a2(); if (light_a0 == 0 && light_a1 == 0 && light_a2 == 0) { // To prevent division by zero light_a0 = 1.0; } @@ -300,7 +300,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran /* // normalize the color - LVector3f color_vector(r, g, b); + LVector3 color_vector(r, g, b); color_vector.normalize(); r = color_vector[0]; g = color_vector[1]; @@ -343,7 +343,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran } */ - return ColorScaleAttrib::make(LVecBase4f(r, g, b, 1.0)); + return ColorScaleAttrib::make(LVecBase4(r, g, b, 1.0)); } //////////////////////////////////////////////////////////////////// @@ -448,7 +448,7 @@ remove_light(const NodePath &newlight) const { // Here, we just pass that to the make //////////////////////////////////////////////////////////////////// CPT(RenderEffect) PolylightEffect:: -set_weight(float w) const { +set_weight(PN_stdfloat w) const { PolylightEffect *effect = new PolylightEffect(*this); effect->_weight = w; return return_new(effect); @@ -480,7 +480,7 @@ set_contrib(ContribType ct) const { // Here, we just pass that to the make //////////////////////////////////////////////////////////////////// CPT(RenderEffect) PolylightEffect:: -set_effect_center(LPoint3f ec) const{ +set_effect_center(LPoint3 ec) const{ PolylightEffect *effect = new PolylightEffect(*this); effect->_effect_center = ec; return return_new(effect); diff --git a/panda/src/pgraph/polylightEffect.h b/panda/src/pgraph/polylightEffect.h index d27814887a..d2318732cd 100755 --- a/panda/src/pgraph/polylightEffect.h +++ b/panda/src/pgraph/polylightEffect.h @@ -51,16 +51,16 @@ protected: PUBLISHED: static CPT(RenderEffect) make(); - static CPT(RenderEffect) make(float weight, ContribType contrib, LPoint3f effect_center); - static CPT(RenderEffect) make(float weight, ContribType contrib, LPoint3f effect_center, const LightGroup &lights); + static CPT(RenderEffect) make(PN_stdfloat weight, ContribType contrib, LPoint3 effect_center); + static CPT(RenderEffect) make(PN_stdfloat weight, ContribType contrib, LPoint3 effect_center, const LightGroup &lights); CPT(RenderEffect) add_light(const NodePath &newlight) const; CPT(RenderEffect) remove_light(const NodePath &newlight) const; - CPT(RenderEffect) set_weight(float w) const; + CPT(RenderEffect) set_weight(PN_stdfloat w) const; CPT(RenderEffect) set_contrib(ContribType c) const; - CPT(RenderEffect) set_effect_center(LPoint3f ec) const; - INLINE float get_weight() const; + CPT(RenderEffect) set_effect_center(LPoint3 ec) const; + INLINE PN_stdfloat get_weight() const; INLINE ContribType get_contrib() const; - INLINE LPoint3f get_effect_center()const; + INLINE LPoint3 get_effect_center()const; bool has_light(const NodePath &light) const; @@ -77,9 +77,9 @@ public: private: ContribType _contribution_type; - float _weight; + PN_stdfloat _weight; LightGroup _lightgroup; - LPoint3f _effect_center; + LPoint3 _effect_center; protected: virtual int compare_to_impl(const RenderEffect *other) const; diff --git a/panda/src/pgraph/polylightNode.I b/panda/src/pgraph/polylightNode.I index b04813f257..8c71d45f36 100755 --- a/panda/src/pgraph/polylightNode.I +++ b/panda/src/pgraph/polylightNode.I @@ -85,7 +85,7 @@ disable(){ // Description: Set this light's position //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_pos(LVecBase3f position){ +set_pos(LVecBase3 position){ _position = position; } @@ -96,7 +96,7 @@ set_pos(LVecBase3f position){ // Description: Set this light's position //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_pos(float x, float y, float z){ +set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z){ _position[0]=x; _position[1]=y; _position[2]=z; @@ -105,9 +105,9 @@ set_pos(float x, float y, float z){ //////////////////////////////////////////////////////////////////// // Function: PolylightNode::get_pos // Access: Published -// Description: Returns position as a LPoint3f +// Description: Returns position as a LPoint3 //////////////////////////////////////////////////////////////////// -INLINE LVecBase3f PolylightNode:: +INLINE LVecBase3 PolylightNode:: get_pos() const { return _position; } @@ -118,7 +118,7 @@ get_pos() const { // Description: Set radius of the spherical light volume //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_radius(float r){ +set_radius(PN_stdfloat r){ _radius=r; } @@ -127,7 +127,7 @@ set_radius(float r){ // Access: Published // Description: Get radius of the spherical light volume //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_radius() const { return _radius; } @@ -162,7 +162,7 @@ get_attenuation() const { // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_a0(float a0){ +set_a0(PN_stdfloat a0){ _a0=a0; } @@ -173,7 +173,7 @@ set_a0(float a0){ // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_a1(float a1){ +set_a1(PN_stdfloat a1){ _a1=a1; } @@ -184,7 +184,7 @@ set_a1(float a1){ // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_a2(float a2){ +set_a2(PN_stdfloat a2){ _a2=a2; } @@ -194,7 +194,7 @@ set_a2(float a2){ // Description: Get the quadratic attenuation factor a0 // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_a0() const { return _a0; } @@ -205,7 +205,7 @@ get_a0() const { // Description: Get the quadratic attenuation factor a1 // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_a1() const { return _a1; } @@ -216,7 +216,7 @@ get_a1() const { // Description: Get the quadratic attenuation factor a2 // fd = 1 / ( a0 + a1*distance + a2*distance*distance) //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_a2() const { return _a2; } @@ -286,7 +286,7 @@ get_flicker_type() const { // This value is added to the variation //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_offset(float offset){ +set_offset(PN_stdfloat offset){ _offset=offset; } @@ -296,7 +296,7 @@ set_offset(float offset){ // Description: Get the offset value for the random and sin // flicker variations //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_offset() const { return _offset; } @@ -309,7 +309,7 @@ get_offset() const { // This value is multiplied with the variation //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_scale(float scale){ +set_scale(PN_stdfloat scale){ _scale=scale; } @@ -319,7 +319,7 @@ set_scale(float scale){ // Description: Get the scale value for the random and sin // flicker variations //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_scale() const { return _scale; } @@ -332,7 +332,7 @@ get_scale() const { // to the sin function //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_step_size(float step){ +set_step_size(PN_stdfloat step){ _step_size=step; } @@ -343,7 +343,7 @@ set_step_size(float step){ // This is the increment size for the value supplied // to the sin function //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_step_size() const { return _step_size; } @@ -354,7 +354,7 @@ get_step_size() const { // Description: Set the light's color... //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_color(Colorf color) { +set_color(LColor color) { //PandaNode::set_attrib(ColorAttrib::make_flat(color)); _color = color; } @@ -365,9 +365,9 @@ set_color(Colorf color) { // Description: Set the light's color... 3 floats between 0 and 1 //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_color(float r, float g, float b) { +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { /* - Colorf color; + LColor color; color[0] = r; color[1] = g; color[2] = b; @@ -383,9 +383,9 @@ set_color(float r, float g, float b) { //////////////////////////////////////////////////////////////////// // Function: PolylightNode::get_color // Access: Published -// Description: Returns the light's color as Colorf +// Description: Returns the light's color as LColor //////////////////////////////////////////////////////////////////// -INLINE Colorf PolylightNode:: +INLINE LColor PolylightNode:: get_color() const { return _color; } @@ -398,7 +398,7 @@ get_color() const { // flattening external to the PolylightNode is not // ignored. //////////////////////////////////////////////////////////////////// -INLINE Colorf PolylightNode:: +INLINE LColor PolylightNode:: get_color_scenegraph() const { const RenderAttrib *attrib = @@ -421,7 +421,7 @@ get_color_scenegraph() const { // Description: Set frequency of sin flicker //////////////////////////////////////////////////////////////////// INLINE void PolylightNode:: -set_freq(float f) { +set_freq(PN_stdfloat f) { _sin_freq=f; } @@ -430,7 +430,7 @@ set_freq(float f) { // Access: Published // Description: Get frequency of sin flicker //////////////////////////////////////////////////////////////////// -INLINE float PolylightNode:: +INLINE PN_stdfloat PolylightNode:: get_freq() const { return _sin_freq; } diff --git a/panda/src/pgraph/polylightNode.cxx b/panda/src/pgraph/polylightNode.cxx index e436a2e210..1d2c87693c 100755 --- a/panda/src/pgraph/polylightNode.cxx +++ b/panda/src/pgraph/polylightNode.cxx @@ -75,11 +75,11 @@ make_copy() const { // Use offset, scale and step_size to tweak // Future addition: custom function variations to flicker //////////////////////////////////////////////////////////////////// -Colorf PolylightNode::flicker() const { - float r,g,b; +LColor PolylightNode::flicker() const { + PN_stdfloat r,g,b; - float variation= 0.0; - Colorf color = get_color(); //color = get_color_scenegraph(); + PN_stdfloat variation= 0.0; + LColor color = get_color(); //color = get_color_scenegraph(); r = color[0]; g = color[1]; @@ -126,7 +126,7 @@ Colorf PolylightNode::flicker() const { } */ pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << endl; - return Colorf(r,g,b,1.0); + return LColor(r,g,b,1.0); } //////////////////////////////////////////////////////////////////// @@ -154,14 +154,14 @@ compare_to(const PolylightNode &other) const { if (_radius != other._radius) { return _radius < other._radius ? -1 :1; } - LVecBase3f position = get_pos(); - LVecBase3f other_position = other.get_pos(); + LVecBase3 position = get_pos(); + LVecBase3 other_position = other.get_pos(); if (position != other_position) { return position < other_position ? -1 :1; } - Colorf color = get_color(); - Colorf other_color = other.get_color(); + LColor color = get_color(); + LColor other_color = other.get_color(); if (color != other_color) { return color < other_color ? -1 :1; } @@ -233,17 +233,11 @@ register_with_read_factory() { void PolylightNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); - LVecBase3f position; - Colorf color; - position = get_pos(); - color = get_color(); - dg.add_float32(position[0]); - dg.add_float32(position[1]); - dg.add_float32(position[2]); - dg.add_float32(color[0]); - dg.add_float32(color[1]); - dg.add_float32(color[2]); - dg.add_float32(_radius); + _position.write_datagram(dg); + LRGBColor color; + color.set(_color[0], _color[1], _color[2]); + color.write_datagram(dg); + dg.add_stdfloat(_radius); } //////////////////////////////////////////////////////////////////// @@ -276,17 +270,11 @@ make_from_bam(const FactoryParams ¶ms) { void PolylightNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); - LVecBase3f position; - Colorf color; - position[0] = scan.get_float32(); - position[1] = scan.get_float32(); - position[2] = scan.get_float32(); - set_pos(position[0],position[1],position[2]); - color[0] = scan.get_float32(); - color[1] = scan.get_float32(); - color[2] = scan.get_float32(); + _position.read_datagram(scan); + LRGBColor color; + color.read_datagram(scan); set_color(color[0], color[1], color[2]); - _radius = scan.get_float32(); + _radius = scan.get_stdfloat(); } diff --git a/panda/src/pgraph/polylightNode.h b/panda/src/pgraph/polylightNode.h index 3affac62f3..94f2fda38e 100755 --- a/panda/src/pgraph/polylightNode.h +++ b/panda/src/pgraph/polylightNode.h @@ -38,9 +38,9 @@ PUBLISHED: // separate wrapper for each parameter... so its better to // have a simpler constructor and require the programmer // to use set_* methods. - PolylightNode(const string &name, float x = 0.0, float y = 0.0, float z = 0.0, - float r = 1.0, float g = 1.0, float b = 1.0, - float radius=50.0, string attenuation_type= "linear", + PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0, + PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0, + PN_stdfloat radius=50.0, string attenuation_type= "linear", bool flickering =false, string flicker_type="random"); */ @@ -58,36 +58,36 @@ PUBLISHED: PolylightNode(const string &name); INLINE void enable(); INLINE void disable(); - INLINE void set_pos(LVecBase3f position); - INLINE void set_pos(float x,float y, float z); - INLINE LVecBase3f get_pos() const; - INLINE void set_color(Colorf color); - INLINE void set_color(float r, float g, float b); - INLINE Colorf get_color() const; - INLINE Colorf get_color_scenegraph() const; - INLINE void set_radius(float r); - INLINE float get_radius() const; + INLINE void set_pos(LVecBase3 position); + INLINE void set_pos(PN_stdfloat x,PN_stdfloat y, PN_stdfloat z); + INLINE LVecBase3 get_pos() const; + INLINE void set_color(LColor color); + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b); + INLINE LColor get_color() const; + INLINE LColor get_color_scenegraph() const; + INLINE void set_radius(PN_stdfloat r); + INLINE PN_stdfloat get_radius() const; INLINE bool set_attenuation(Attenuation_Type type); INLINE Attenuation_Type get_attenuation() const; - INLINE void set_a0(float a0); - INLINE void set_a1(float a1); - INLINE void set_a2(float a2); - INLINE float get_a0() const; - INLINE float get_a1() const; - INLINE float get_a2() const; + INLINE void set_a0(PN_stdfloat a0); + INLINE void set_a1(PN_stdfloat a1); + INLINE void set_a2(PN_stdfloat a2); + INLINE PN_stdfloat get_a0() const; + INLINE PN_stdfloat get_a1() const; + INLINE PN_stdfloat get_a2() const; INLINE void flicker_on(); INLINE void flicker_off(); INLINE bool is_flickering() const; INLINE bool set_flicker_type(Flicker_Type type); INLINE Flicker_Type get_flicker_type() const; - INLINE void set_offset(float offset); - INLINE float get_offset() const; - INLINE void set_scale(float scale); - INLINE float get_scale() const; - INLINE void set_step_size(float step) ; - INLINE float get_step_size() const; - INLINE void set_freq(float f); - INLINE float get_freq() const; + INLINE void set_offset(PN_stdfloat offset); + INLINE PN_stdfloat get_offset() const; + INLINE void set_scale(PN_stdfloat scale); + INLINE PN_stdfloat get_scale() const; + INLINE void set_step_size(PN_stdfloat step) ; + INLINE PN_stdfloat get_step_size() const; + INLINE void set_freq(PN_stdfloat f); + INLINE PN_stdfloat get_freq() const; // Comparison methods INLINE bool operator == (const PolylightNode &other) const; @@ -98,27 +98,27 @@ PUBLISHED: INLINE bool is_enabled() const; public: - Colorf flicker() const; + LColor flicker() const; virtual PandaNode *make_copy() const; private: bool _enabled; - LVecBase3f _position; - Colorf _color; - float _radius; + LVecBase3 _position; + LColor _color; + PN_stdfloat _radius; Attenuation_Type _attenuation_type; - float _a0; - float _a1; - float _a2; + PN_stdfloat _a0; + PN_stdfloat _a1; + PN_stdfloat _a2; bool _flickering; Flicker_Type _flicker_type; - float _offset; - float _scale; - float _step_size; - float _sin_freq; - //float _speed; - //float fixed_points + PN_stdfloat _offset; + PN_stdfloat _scale; + PN_stdfloat _step_size; + PN_stdfloat _sin_freq; + //PN_stdfloat _speed; + //PN_stdfloat fixed_points public: diff --git a/panda/src/pgraph/portalClipper.I b/panda/src/pgraph/portalClipper.I index fe1e143d5c..0c7798048d 100755 --- a/panda/src/pgraph/portalClipper.I +++ b/panda/src/pgraph/portalClipper.I @@ -28,7 +28,7 @@ Point() { // Description: //////////////////////////////////////////////////////////////////// INLINE PortalClipper::Point:: -Point(const LVecBase3f &point, const Colorf &color) : +Point(const LVecBase3 &point, const LColor &color) : _point(point[0], point[1], point[2]), _color(color) { @@ -66,8 +66,8 @@ operator = (const PortalClipper::Point ©) { // move_to() or create(), this creates a single point. //////////////////////////////////////////////////////////////////// INLINE void PortalClipper:: -move_to(float x, float y, float z) { - move_to(Vertexf(x, y, z)); +move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + move_to(LVertex(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -80,8 +80,8 @@ move_to(float x, float y, float z) { // is called. //////////////////////////////////////////////////////////////////// INLINE void PortalClipper:: -draw_to(float x, float y, float z) { - draw_to(Vertexf(x, y, z)); +draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + draw_to(LVertex(x, y, z)); } //////////////////////////////////////////////////////////////////// @@ -92,7 +92,7 @@ draw_to(float x, float y, float z) { //////////////////////////////////////////////////////////////////// INLINE void PortalClipper:: draw_camera_frustum() { - _color = Colorf(1,1,1,1); + _color = LColor(1,1,1,1); draw_hexahedron(_view_frustum); } @@ -148,7 +148,7 @@ get_clip_state() const { // //////////////////////////////////////////////////////////////////// INLINE void PortalClipper:: -set_reduced_viewport(const LPoint2f& min, const LPoint2f& max) { +set_reduced_viewport(const LPoint2& min, const LPoint2& max) { _reduced_viewport_min = min; _reduced_viewport_max = max; } @@ -160,7 +160,7 @@ set_reduced_viewport(const LPoint2f& min, const LPoint2f& max) { // Description: Return the reduced viewport //////////////////////////////////////////////////////////////////// INLINE void PortalClipper:: -get_reduced_viewport(LPoint2f& min, LPoint2f& max) const { +get_reduced_viewport(LPoint2& min, LPoint2& max) const { min = _reduced_viewport_min; max = _reduced_viewport_max; } @@ -174,7 +174,7 @@ get_reduced_viewport(LPoint2f& min, LPoint2f& max) const { // is facing the camera's near plane //////////////////////////////////////////////////////////////////// INLINE bool PortalClipper:: -is_facing_view(Planef portal_plane) { +is_facing_view(LPlane portal_plane) { portal_cat.debug() << "portal plane check value: " << portal_plane[3] << "\n"; return (portal_plane[3] > 0); } @@ -187,7 +187,7 @@ is_facing_view(Planef portal_plane) { // is a 2nd level test to weed out most of the portals //////////////////////////////////////////////////////////////////// INLINE bool PortalClipper:: -is_whole_portal_in_view(LMatrix4f cmat) { +is_whole_portal_in_view(LMatrix4 cmat) { // I am about to xform this gbv, so lets make a copy const BoundingVolume *bv = _portal_node->get_bounds(); BoundingVolume *cbv = bv->make_copy(); @@ -230,9 +230,9 @@ is_partial_portal_in_view() { // Access: Public // Description: Given the x and z, solve for y: from the plane //////////////////////////////////////////////////////////////////// -INLINE float PortalClipper:: -get_plane_depth(float x, float z, Planef *portal_plane) { - float y = 0.0; +INLINE PN_stdfloat PortalClipper:: +get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) { + PN_stdfloat y = 0.0; // Plane equation: Ax + By + Cz + D = 0 // y = (Ax + Cz + D) / -B portal_cat.spam() << *portal_plane << endl; diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index b888e74365..b805352688 100755 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -70,7 +70,7 @@ PortalClipper:: // move_to() or create(), this creates a single point. //////////////////////////////////////////////////////////////////// void PortalClipper:: -move_to(const LVecBase3f &v) { +move_to(const LVecBase3 &v) { // We create a new SegmentList with the initial point in it. SegmentList segs; segs.push_back(Point(v, _color)); @@ -89,7 +89,7 @@ move_to(const LVecBase3f &v) { // is called. //////////////////////////////////////////////////////////////////// void PortalClipper:: -draw_to(const LVecBase3f &v) { +draw_to(const LVecBase3 &v) { if (_list.empty()) { // Let our first call to draw_to() be an implicit move_to(). move_to(v); @@ -181,8 +181,8 @@ draw_lines() { // A segment of length 1 is just a point. for (sl = segs.begin(); sl != segs.end(); sl++) { points->add_vertex(v); - vertex.add_data3f((*sl)._point); - color.add_data4f((*sl)._color); + vertex.add_data3((*sl)._point); + color.add_data4((*sl)._color); v++; } points->close_primitive(); @@ -192,8 +192,8 @@ draw_lines() { // segments. for (sl = segs.begin(); sl != segs.end(); sl++) { lines->add_vertex(v); - vertex.add_data3f((*sl)._point); - color.add_data4f((*sl)._color); + vertex.add_data3((*sl)._point); + color.add_data4((*sl)._color); v++; } lines->close_primitive(); @@ -234,10 +234,10 @@ prepare_portal(const NodePath &node_path) // Get the camera transformation matrix CPT(TransformState) ctransform = node_path.get_transform(_scene_setup->get_cull_center()); //CPT(TransformState) ctransform = node_path.get_transform(_scene_setup->get_camera_path()); - LMatrix4f cmat = ctransform->get_mat(); + LMatrix4 cmat = ctransform->get_mat(); portal_cat.spam() << cmat << endl; - Vertexf temp[4]; + LVertex temp[4]; temp[0] = _portal_node->get_vertex(0); temp[1] = _portal_node->get_vertex(1); temp[2] = _portal_node->get_vertex(2); @@ -254,7 +254,7 @@ prepare_portal(const NodePath &node_path) temp[2] = temp[2]*cmat; temp[3] = temp[3]*cmat; - Planef portal_plane(temp[0], temp[1], temp[2]); + LPlane portal_plane(temp[0], temp[1], temp[2]); if (!is_facing_view(portal_plane)) { portal_cat.debug() << "portal failed 1st level test (isn't facing the camera)\n"; return false; @@ -270,7 +270,7 @@ prepare_portal(const NodePath &node_path) // portals intersecting the near plane or the 0 point are a weird case anyhow, therefore we don't reduce the frustum any further // and just return true. In effect the portal doesn't reduce visibility but will draw everything in its out cell const Lens *lens = _scene_setup->get_lens(); - LVector3f forward = LVector3f::forward(lens->get_coordinate_system()); + LVector3 forward = LVector3::forward(lens->get_coordinate_system()); int forward_axis; if (forward[1]) { forward_axis = 1; @@ -290,7 +290,7 @@ prepare_portal(const NodePath &node_path) } // project portal points, so they are in the -1..1 range - LPoint3f projected_coords[4]; + LPoint3 projected_coords[4]; lens->project(temp[0], projected_coords[0]); lens->project(temp[1], projected_coords[1]); lens->project(temp[2], projected_coords[2]); @@ -303,7 +303,7 @@ prepare_portal(const NodePath &node_path) portal_cat.spam() << projected_coords[3] << endl; // calculate axis aligned bounding box of the portal - float min_x, max_x, min_y, max_y; + PN_stdfloat min_x, max_x, min_y, max_y; min_x = min(min(min(projected_coords[0][0], projected_coords[1][0]), projected_coords[2][0]), projected_coords[3][0]); max_x = max(max(max(projected_coords[0][0], projected_coords[1][0]), projected_coords[2][0]), projected_coords[3][0]); min_y = min(min(min(projected_coords[0][1], projected_coords[1][1]), projected_coords[2][1]), projected_coords[3][1]); @@ -329,12 +329,12 @@ prepare_portal(const NodePath &node_path) _reduced_viewport_max.set(max_x, max_y); // calculate the near and far points so we can construct a frustum - LPoint3f near_point[4]; - LPoint3f far_point[4]; - lens->extrude(LPoint2f(min_x, min_y), near_point[0], far_point[0]); - lens->extrude(LPoint2f(max_x, min_y), near_point[1], far_point[1]); - lens->extrude(LPoint2f(max_x, max_y), near_point[2], far_point[2]); - lens->extrude(LPoint2f(min_x, max_y), near_point[3], far_point[3]); + LPoint3 near_point[4]; + LPoint3 far_point[4]; + lens->extrude(LPoint2(min_x, min_y), near_point[0], far_point[0]); + lens->extrude(LPoint2(max_x, min_y), near_point[1], far_point[1]); + lens->extrude(LPoint2(max_x, max_y), near_point[2], far_point[2]); + lens->extrude(LPoint2(min_x, max_y), near_point[3], far_point[3]); // With these points, construct the new reduced frustum _reduced_frustum = new BoundingHexahedron(far_point[0], far_point[1], far_point[2], far_point[3], @@ -345,11 +345,11 @@ prepare_portal(const NodePath &node_path) // do debug rendering, if requested if (debug_portal_cull) { // draw the reduced frustum - _color = Colorf(0,0,1,1); + _color = LColor(0,0,1,1); draw_hexahedron(DCAST(BoundingHexahedron, _reduced_frustum)); // lets first add the clipped portal (in yellow) - _color = Colorf(1,1,0,1); + _color = LColor(1,1,0,1); move_to((near_point[0]*0.99+far_point[0]*0.01)); // I choose a point in the middle between near and far.. could also be some other z value.. draw_to((near_point[1]*0.99+far_point[1]*0.01)); draw_to((near_point[2]*0.99+far_point[2]*0.01)); @@ -357,7 +357,7 @@ prepare_portal(const NodePath &node_path) draw_to((near_point[0]*0.99+far_point[0]*0.01)); // ok, now lets add the original portal (in cyan) - _color = Colorf(0,1,1,1); + _color = LColor(0,1,1,1); move_to(temp[0]); draw_to(temp[1]); draw_to(temp[2]); diff --git a/panda/src/pgraph/portalClipper.h b/panda/src/pgraph/portalClipper.h index db191ea5cc..4b55c29093 100755 --- a/panda/src/pgraph/portalClipper.h +++ b/panda/src/pgraph/portalClipper.h @@ -55,8 +55,8 @@ public: ~PortalClipper(); INLINE bool is_partial_portal_in_view(); - INLINE bool is_facing_view(Planef portal_plane); - INLINE bool is_whole_portal_in_view(LMatrix4f cmat); + INLINE bool is_facing_view(LPlane portal_plane); + INLINE bool is_whole_portal_in_view(LMatrix4 cmat); bool prepare_portal(const NodePath &node_path); @@ -64,18 +64,18 @@ public: INLINE void draw_camera_frustum(); void draw_hexahedron(BoundingHexahedron *frustum); - INLINE void move_to(float x, float y, float z); - void move_to(const LVecBase3f &v); + INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void move_to(const LVecBase3 &v); - INLINE void draw_to(float x, float y, float z); - void draw_to(const LVecBase3f &v); + INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void draw_to(const LVecBase3 &v); void draw_current_portal(); INLINE BoundingHexahedron *get_reduced_frustum() const; INLINE void set_reduced_frustum(BoundingHexahedron *bh); - INLINE void get_reduced_viewport(LPoint2f& min, LPoint2f& max) const; - INLINE void set_reduced_viewport(const LPoint2f& min, const LPoint2f& max); + INLINE void get_reduced_viewport(LPoint2& min, LPoint2& max) const; + INLINE void set_reduced_viewport(const LPoint2& min, const LPoint2& max); INLINE const RenderState* get_clip_state() const; INLINE void set_clip_state(const RenderState* clip_state); @@ -100,32 +100,32 @@ private: class Point { public: INLINE Point(); - INLINE Point(const LVecBase3f &point, const Colorf &color); + INLINE Point(const LVecBase3 &point, const LColor &color); INLINE Point(const Point ©); INLINE void operator = (const Point ©); - Vertexf _point; - Colorf _color; + LVertex _point; + LColor _color; }; typedef pvector SegmentList; typedef pvector LineList; LineList _list; - Colorf _color; + LColor _color; PT(GeomVertexData) _created_data; BoundingHexahedron *_view_frustum; BoundingHexahedron *_reduced_frustum; - LPoint2f _reduced_viewport_min; - LPoint2f _reduced_viewport_max; + LPoint2 _reduced_viewport_min; + LPoint2 _reduced_viewport_max; CPT(RenderState) _clip_state; // each portal node needs to know the clip state of its "parent" portal Node PortalNode *_portal_node; // current working portal for dereference ease //int _num_vert; - //Vertexf _coords[4]; + //LVertex _coords[4]; public: PT(GeomNode) _previous; diff --git a/panda/src/pgraph/portalNode.I b/panda/src/pgraph/portalNode.I index b949403563..c8798e1da3 100755 --- a/panda/src/pgraph/portalNode.I +++ b/panda/src/pgraph/portalNode.I @@ -139,7 +139,7 @@ clear_vertices() { // orientation when viewing through the portal. //////////////////////////////////////////////////////////////////// INLINE void PortalNode:: -add_vertex(const LPoint3f &vertex) { +add_vertex(const LPoint3 &vertex) { _vertices.push_back(vertex); } @@ -158,9 +158,9 @@ get_num_vertices() const { // Access: Published // Description: Returns the nth vertex of the portal polygon. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &PortalNode:: +INLINE const LPoint3 &PortalNode:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3f::zero()); + nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero()); return _vertices[n]; } diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index 998301b345..de021bbadc 100755 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -62,7 +62,7 @@ PortalNode(const string &name) : // to create an arbitrary portal and setup from Python //////////////////////////////////////////////////////////////////// PortalNode:: -PortalNode(const string &name, LPoint3f pos, float scale) : +PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) : PandaNode(name), _from_portal_mask(PortalMask::all_on()), _into_portal_mask(PortalMask::all_on()), @@ -70,10 +70,10 @@ PortalNode(const string &name, LPoint3f pos, float scale) : { set_cull_callback(); - add_vertex(LPoint3f(pos[0]-1.0*scale, pos[1], pos[2]-1.0*scale)); - add_vertex(LPoint3f(pos[0]+1.0*scale, pos[1], pos[2]-1.0*scale)); - add_vertex(LPoint3f(pos[0]+1.0*scale, pos[1], pos[2]+1.0*scale)); - add_vertex(LPoint3f(pos[0]-1.0*scale, pos[1], pos[2]+1.0*scale)); + add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]-1.0*scale)); + add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]-1.0*scale)); + add_vertex(LPoint3(pos[0]+1.0*scale, pos[1], pos[2]+1.0*scale)); + add_vertex(LPoint3(pos[0]-1.0*scale, pos[1], pos[2]+1.0*scale)); _visible = false; _open = true; @@ -172,7 +172,7 @@ enable_clipping_planes() { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void PortalNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); } @@ -236,7 +236,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PT(BoundingVolume) reduced_frustum; // remember old viewport and frustum, so we can restore them for the siblings. (it gets changed by the prepare_portal call) - LPoint2f old_reduced_viewport_min, old_reduced_viewport_max; + LPoint2 old_reduced_viewport_min, old_reduced_viewport_max; portal_viewer->get_reduced_viewport(old_reduced_viewport_min, old_reduced_viewport_max); PT(BoundingHexahedron) old_bh = portal_viewer->get_reduced_frustum(); @@ -394,8 +394,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // Now actually compute the bounding volume by putting it around all // of our vertices. - const LPoint3f *vertices_begin = &_vertices[0]; - const LPoint3f *vertices_end = vertices_begin + _vertices.size(); + const LPoint3 *vertices_begin = &_vertices[0]; + const LPoint3 *vertices_end = vertices_begin + _vertices.size(); // Now actually compute the bounding volume by putting it around all gbv->around(vertices_begin, vertices_end); @@ -419,7 +419,7 @@ get_last_pos_state() { static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make - (ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 1.0f, 0.5f)), + (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } @@ -504,7 +504,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_vertices = scan.get_uint16(); _vertices.reserve(num_vertices); for (int i = 0; i < num_vertices; i++) { - LPoint3f vertex; + LPoint3 vertex; vertex.read_datagram(scan); _vertices.push_back(vertex); } diff --git a/panda/src/pgraph/portalNode.h b/panda/src/pgraph/portalNode.h index 04e265f67e..8a82e39498 100755 --- a/panda/src/pgraph/portalNode.h +++ b/panda/src/pgraph/portalNode.h @@ -34,7 +34,7 @@ class EXPCL_PANDA_PGRAPH PortalNode : public PandaNode { PUBLISHED: PortalNode(const string &name); - PortalNode(const string &name, LPoint3f pos, float scale=10.0); + PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale=10.0); protected: PortalNode(const PortalNode ©); @@ -43,7 +43,7 @@ public: virtual ~PortalNode(); virtual PandaNode *make_copy() const; virtual bool preserve_name() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual PandaNode *combine_with(PandaNode *other); virtual void enable_clipping_planes(); @@ -64,10 +64,10 @@ PUBLISHED: INLINE bool get_portal_geom() const; INLINE void clear_vertices(); - INLINE void add_vertex(const LPoint3f &vertex); + INLINE void add_vertex(const LPoint3 &vertex); INLINE int get_num_vertices() const; - INLINE const LPoint3f &get_vertex(int n) const; + INLINE const LPoint3 &get_vertex(int n) const; MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); INLINE void set_cell_in(const NodePath &cell); @@ -111,7 +111,7 @@ private: }; int _flags; - typedef pvector Vertices; + typedef pvector Vertices; Vertices _vertices; NodePath _cell_in; // This is the cell it resides in diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 5ecbf33039..314c156c52 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -130,7 +130,7 @@ safe_to_combine() const { // indicated matrix. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) RenderEffect:: -xform(const LMatrix4f &) const { +xform(const LMatrix4 &) const { return this; } diff --git a/panda/src/pgraph/renderEffect.h b/panda/src/pgraph/renderEffect.h index e0812c8e08..796ae49008 100644 --- a/panda/src/pgraph/renderEffect.h +++ b/panda/src/pgraph/renderEffect.h @@ -66,7 +66,7 @@ public: virtual bool safe_to_transform() const; virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; virtual bool safe_to_combine() const; - virtual CPT(RenderEffect) xform(const LMatrix4f &mat) const; + virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 1c4e914e42..7d7872ebfb 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -154,7 +154,7 @@ safe_to_combine() const { // indicated matrix. //////////////////////////////////////////////////////////////////// CPT(RenderEffects) RenderEffects:: -xform(const LMatrix4f &mat) const { +xform(const LMatrix4 &mat) const { if (is_empty()) { return this; } diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index d35b9dbf38..b8aafcfc23 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -57,7 +57,7 @@ public: bool safe_to_transform() const; virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; bool safe_to_combine() const; - CPT(RenderEffects) xform(const LMatrix4f &mat) const; + CPT(RenderEffects) xform(const LMatrix4 &mat) const; PUBLISHED: bool operator < (const RenderEffects &other) const; diff --git a/panda/src/pgraph/renderModeAttrib.I b/panda/src/pgraph/renderModeAttrib.I index 9ae2032477..b324663d9b 100644 --- a/panda/src/pgraph/renderModeAttrib.I +++ b/panda/src/pgraph/renderModeAttrib.I @@ -20,7 +20,7 @@ // RenderModeAttrib object. //////////////////////////////////////////////////////////////////// INLINE RenderModeAttrib:: -RenderModeAttrib(RenderModeAttrib::Mode mode, float thickness, +RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness, bool perspective) : _mode(mode), _thickness(thickness), @@ -47,7 +47,7 @@ get_mode() const { // rendering actual points or lines primitives in // M_polygon mode). //////////////////////////////////////////////////////////////////// -INLINE float RenderModeAttrib:: +INLINE PN_stdfloat RenderModeAttrib:: get_thickness() const { return _thickness; } diff --git a/panda/src/pgraph/renderModeAttrib.cxx b/panda/src/pgraph/renderModeAttrib.cxx index 0b2218e931..9de256c811 100644 --- a/panda/src/pgraph/renderModeAttrib.cxx +++ b/panda/src/pgraph/renderModeAttrib.cxx @@ -46,7 +46,7 @@ int RenderModeAttrib::_attrib_slot; // regardless of distance from the camera. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) RenderModeAttrib:: -make(RenderModeAttrib::Mode mode, float thickness, bool perspective) { +make(RenderModeAttrib::Mode mode, PN_stdfloat thickness, bool perspective) { RenderModeAttrib *attrib = new RenderModeAttrib(mode, thickness, perspective); return return_new(attrib); } @@ -205,7 +205,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); dg.add_int8(_mode); - dg.add_float32(_thickness); + dg.add_stdfloat(_thickness); dg.add_bool(_perspective); } @@ -241,6 +241,6 @@ fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); _mode = (Mode)scan.get_int8(); - _thickness = scan.get_float32(); + _thickness = scan.get_stdfloat(); _perspective = scan.get_bool(); } diff --git a/panda/src/pgraph/renderModeAttrib.h b/panda/src/pgraph/renderModeAttrib.h index 3369cddc0b..8e0043f8e5 100644 --- a/panda/src/pgraph/renderModeAttrib.h +++ b/panda/src/pgraph/renderModeAttrib.h @@ -48,15 +48,15 @@ PUBLISHED: }; private: - INLINE RenderModeAttrib(Mode mode, float thickness, bool perspective); + INLINE RenderModeAttrib(Mode mode, PN_stdfloat thickness, bool perspective); PUBLISHED: - static CPT(RenderAttrib) make(Mode mode, float thickness = 1.0f, + static CPT(RenderAttrib) make(Mode mode, PN_stdfloat thickness = 1.0f, bool perspective = false); static CPT(RenderAttrib) make_default(); INLINE Mode get_mode() const; - INLINE float get_thickness() const; + INLINE PN_stdfloat get_thickness() const; INLINE bool get_perspective() const; INLINE int get_geom_rendering(int geom_rendering) const; @@ -71,7 +71,7 @@ protected: private: Mode _mode; - float _thickness; + PN_stdfloat _thickness; bool _perspective; PUBLISHED: diff --git a/panda/src/pgraph/sceneGraphReducer.I b/panda/src/pgraph/sceneGraphReducer.I index e27094d067..1e79b03b9b 100644 --- a/panda/src/pgraph/sceneGraphReducer.I +++ b/panda/src/pgraph/sceneGraphReducer.I @@ -62,7 +62,7 @@ get_gsg() const { // CS_other were set). //////////////////////////////////////////////////////////////////// INLINE void SceneGraphReducer:: -set_combine_radius(float combine_radius) { +set_combine_radius(PN_stdfloat combine_radius) { _combine_radius = combine_radius; } @@ -72,7 +72,7 @@ set_combine_radius(float combine_radius) { // Description: Returns the radius that is used in conjunction with // CS_within_radius. See set_combine_radius(). //////////////////////////////////////////////////////////////////// -INLINE float SceneGraphReducer:: +INLINE PN_stdfloat SceneGraphReducer:: get_combine_radius() const { return _combine_radius; } diff --git a/panda/src/pgraph/sceneGraphReducer.h b/panda/src/pgraph/sceneGraphReducer.h index b23182be03..4be6b27e12 100644 --- a/panda/src/pgraph/sceneGraphReducer.h +++ b/panda/src/pgraph/sceneGraphReducer.h @@ -124,8 +124,8 @@ PUBLISHED: void clear_gsg(); INLINE GraphicsStateGuardianBase *get_gsg() const; - INLINE void set_combine_radius(float combine_radius); - INLINE float get_combine_radius() const; + INLINE void set_combine_radius(PN_stdfloat combine_radius); + INLINE PN_stdfloat get_combine_radius() const; INLINE void apply_attribs(PandaNode *node, int attrib_types = ~(TT_clip_plane | TT_cull_face | TT_apply_texture_color)); INLINE void apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, @@ -189,7 +189,7 @@ protected: private: PT(GraphicsStateGuardianBase) _gsg; - float _combine_radius; + PN_stdfloat _combine_radius; GeomTransformer _transformer; static PStatCollector _flatten_collector; diff --git a/panda/src/pgraph/scissorAttrib.I b/panda/src/pgraph/scissorAttrib.I index ad3c8b7527..d04829cabc 100644 --- a/panda/src/pgraph/scissorAttrib.I +++ b/panda/src/pgraph/scissorAttrib.I @@ -22,8 +22,8 @@ // DisplayRegion, and (1,1) is the upper-right corner. //////////////////////////////////////////////////////////////////// INLINE CPT(RenderAttrib) ScissorAttrib:: -make(float left, float right, float bottom, float top) { - return make(LVecBase4f(left, right, bottom, top)); +make(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + return make(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ make(float left, float right, float bottom, float top) { // corner of the DisplayRegion, and 1,1 is the // upper-right corner. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &ScissorAttrib:: +INLINE const LVecBase4 &ScissorAttrib:: get_frame() const { return _frame; } diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index cb1fe93d03..cafc949bc6 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -31,14 +31,14 @@ CPT(RenderAttrib) ScissorAttrib::_off; // ScissorAttrib object. //////////////////////////////////////////////////////////////////// ScissorAttrib:: -ScissorAttrib(const LVecBase4f &frame) : +ScissorAttrib(const LVecBase4 &frame) : _frame(frame) { // Impose sensible bounds. - _frame[0] = max(min(_frame[0], 1.0f), 0.0f); - _frame[1] = max(min(_frame[1], 1.0f), _frame[0]); - _frame[2] = max(min(_frame[2], 1.0f), 0.0f); - _frame[3] = max(min(_frame[3], 1.0f), _frame[2]); + _frame[0] = max(min(_frame[0], (PN_stdfloat)1.0), (PN_stdfloat)0.0); + _frame[1] = max(min(_frame[1], (PN_stdfloat)1.0), _frame[0]); + _frame[2] = max(min(_frame[2], (PN_stdfloat)1.0), (PN_stdfloat)0.0); + _frame[3] = max(min(_frame[3], (PN_stdfloat)1.0), _frame[2]); } //////////////////////////////////////////////////////////////////// @@ -52,7 +52,7 @@ make_off() { if (_off != 0) { return _off; } - ScissorAttrib *attrib = new ScissorAttrib(LVecBase4f(0.0f, 1.0f, 0.0f, 1.0f)); + ScissorAttrib *attrib = new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); _off = return_new(attrib); return _off; } @@ -66,7 +66,7 @@ make_off() { // DisplayRegion, and (1,1) is the upper-right corner. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ScissorAttrib:: -make(const LVecBase4f &frame) { +make(const LVecBase4 &frame) { ScissorAttrib *attrib = new ScissorAttrib(frame); return return_new(attrib); } @@ -80,7 +80,7 @@ make(const LVecBase4f &frame) { //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ScissorAttrib:: make_default() { - return return_new(new ScissorAttrib(LVecBase4f(0.0f, 1.0f, 0.0f, 1.0f))); + return return_new(new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f))); } //////////////////////////////////////////////////////////////////// @@ -154,7 +154,7 @@ compose_impl(const RenderAttrib *other) const { const ScissorAttrib *ta; DCAST_INTO_R(ta, other, 0); - LVecBase4f new_frame(max(ta->_frame[0], _frame[0]), + LVecBase4 new_frame(max(ta->_frame[0], _frame[0]), min(ta->_frame[1], _frame[1]), max(ta->_frame[2], _frame[2]), min(ta->_frame[3], _frame[3])); @@ -197,7 +197,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { //////////////////////////////////////////////////////////////////// TypedWritable *ScissorAttrib:: make_from_bam(const FactoryParams ¶ms) { - ScissorAttrib *attrib = new ScissorAttrib(LVecBase4f(0.0f, 1.0f, 0.0f, 1.0f)); + ScissorAttrib *attrib = new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); DatagramIterator scan; BamReader *manager; diff --git a/panda/src/pgraph/scissorAttrib.h b/panda/src/pgraph/scissorAttrib.h index 81ca401921..0004ccc7c2 100644 --- a/panda/src/pgraph/scissorAttrib.h +++ b/panda/src/pgraph/scissorAttrib.h @@ -40,15 +40,15 @@ class FactoryParams; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH ScissorAttrib : public RenderAttrib { private: - ScissorAttrib(const LVecBase4f &frame); + ScissorAttrib(const LVecBase4 &frame); PUBLISHED: static CPT(RenderAttrib) make_off(); - INLINE static CPT(RenderAttrib) make(float left, float right, float bottom, float top); - static CPT(RenderAttrib) make(const LVecBase4f &frame); + INLINE static CPT(RenderAttrib) make(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + static CPT(RenderAttrib) make(const LVecBase4 &frame); static CPT(RenderAttrib) make_default(); - INLINE const LVecBase4f &get_frame() const; + INLINE const LVecBase4 &get_frame() const; public: virtual void output(ostream &out) const; @@ -59,7 +59,7 @@ protected: virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; private: - LVecBase4f _frame; + LVecBase4 _frame; static CPT(RenderAttrib) _off; PUBLISHED: diff --git a/panda/src/pgraph/scissorEffect.I b/panda/src/pgraph/scissorEffect.I index 4f130173bd..f3a4c1a5f3 100644 --- a/panda/src/pgraph/scissorEffect.I +++ b/panda/src/pgraph/scissorEffect.I @@ -34,7 +34,7 @@ is_screen() const { // the scissor frame relative to the current // DisplayRegion. See ScissorAttrib. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &ScissorEffect:: +INLINE const LVecBase4 &ScissorEffect:: get_frame() const { return _frame; } @@ -60,9 +60,9 @@ get_num_points() const { // which define any opposite corners of the scissor // frame. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &ScissorEffect:: +INLINE const LPoint3 &ScissorEffect:: get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3f::zero()); + nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); return _points[n]._p; } diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 989905aa8e..0c67f9c58a 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -32,7 +32,7 @@ TypeHandle ScissorEffect::_type_handle; // ScissorEffect object. //////////////////////////////////////////////////////////////////// ScissorEffect:: -ScissorEffect(bool screen, const LVecBase4f &frame, +ScissorEffect(bool screen, const LVecBase4 &frame, const PointDef *points, int num_points, bool clip) : _screen(screen), _frame(frame), _clip(clip) { @@ -65,7 +65,7 @@ ScissorEffect(const ScissorEffect ©) : // relative to the DisplayRegion. See ScissorAttrib. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: -make_screen(const LVecBase4f &frame, bool clip) { +make_screen(const LVecBase4 &frame, bool clip) { ScissorEffect *effect = new ScissorEffect(true, frame, NULL, 0, clip); return return_new(effect); } @@ -80,7 +80,7 @@ make_screen(const LVecBase4f &frame, bool clip) { //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: make_node(bool clip) { - ScissorEffect *effect = new ScissorEffect(false, LVecBase4f::zero(), NULL, 0, clip); + ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), NULL, 0, clip); return return_new(effect); } @@ -94,13 +94,13 @@ make_node(bool clip) { // corners of the scissor region. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: -make_node(const LPoint3f &a, const LPoint3f &b, const NodePath &node) { +make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node) { PointDef points[2]; points[0]._p = a; points[0]._node = node; points[1]._p = b; points[1]._node = node; - ScissorEffect *effect = new ScissorEffect(false, LVecBase4f::zero(), points, 2, true); + ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), points, 2, true); return return_new(effect); } @@ -114,7 +114,7 @@ make_node(const LPoint3f &a, const LPoint3f &b, const NodePath &node) { // surrounding the scissor region. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: -make_node(const LPoint3f &a, const LPoint3f &b, const LPoint3f &c, const LPoint3f &d, const NodePath &node) { +make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d, const NodePath &node) { PointDef points[4]; points[0]._p = a; points[0]._node = node; @@ -124,7 +124,7 @@ make_node(const LPoint3f &a, const LPoint3f &b, const LPoint3f &c, const LPoint3 points[2]._node = node; points[3]._p = d; points[3]._node = node; - ScissorEffect *effect = new ScissorEffect(false, LVecBase4f::zero(), points, 4, true); + ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), points, 4, true); return return_new(effect); } @@ -141,7 +141,7 @@ make_node(const LPoint3f &a, const LPoint3f &b, const LPoint3f &c, const LPoint3 // desired. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: -add_point(const LPoint3f &p, const NodePath &node) const { +add_point(const LPoint3 &p, const NodePath &node) const { nassertr(!is_screen(), this); ScissorEffect *effect = new ScissorEffect(*this); PointDef point; @@ -158,7 +158,7 @@ add_point(const LPoint3f &p, const NodePath &node) const { // indicated matrix. //////////////////////////////////////////////////////////////////// CPT(RenderEffect) ScissorEffect:: -xform(const LMatrix4f &mat) const { +xform(const LMatrix4 &mat) const { if (is_screen()) { return this; } @@ -237,7 +237,7 @@ void ScissorEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, CPT(RenderState) &node_state) const { - LVecBase4f frame; + LVecBase4 frame; const Lens *lens = trav->get_scene()->get_lens(); CPT(TransformState) modelview_transform = data.get_modelview_transform(trav); CPT(TransformState) net_transform = modelview_transform->compose(node_transform); @@ -249,29 +249,29 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, if (is_screen()) { frame = _frame; } else { - const LMatrix4f &proj_mat = lens->get_projection_mat(); - LMatrix4f net_mat = net_transform->get_mat() * proj_mat; + const LMatrix4 &proj_mat = lens->get_projection_mat(); + LMatrix4 net_mat = net_transform->get_mat() * proj_mat; bool any_points = false; Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { const PointDef &point = (*pi); - LVecBase4f pv(point._p[0], point._p[1], point._p[2], 1.0f); + LVecBase4 pv(point._p[0], point._p[1], point._p[2], 1.0f); if (point._node.is_empty()) { // Relative to this node. pv = pv * net_mat; } else { // Relative to some other node. - LMatrix4f other_mat = point._node.get_net_transform()->get_mat() * proj_mat; + LMatrix4 other_mat = point._node.get_net_transform()->get_mat() * proj_mat; pv = pv * other_mat; } if (pv[3] == 0) { continue; } - LPoint3f pr(pv[0] / pv[3], pv[1] / pv[3], pv[2] / pv[3]); + LPoint3 pr(pv[0] / pv[3], pv[1] / pv[3], pv[2] / pv[3]); if (!any_points) { frame[0] = pr[0]; frame[1] = pr[0]; @@ -294,10 +294,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, } // Impose bounding volumes. - frame[0] = max(min(frame[0], 1.0f), 0.0f); - frame[1] = max(min(frame[1], 1.0f), frame[0]); - frame[2] = max(min(frame[2], 1.0f), 0.0f); - frame[3] = max(min(frame[3], 1.0f), frame[2]); + frame[0] = max(min(frame[0], (PN_stdfloat)1.0), (PN_stdfloat)0.0); + frame[1] = max(min(frame[1], (PN_stdfloat)1.0), frame[0]); + frame[2] = max(min(frame[2], (PN_stdfloat)1.0), (PN_stdfloat)0.0); + frame[3] = max(min(frame[3], (PN_stdfloat)1.0), frame[2]); if (_clip) { CPT(RenderAttrib) scissor_attrib = ScissorAttrib::make(frame); @@ -408,7 +408,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { //////////////////////////////////////////////////////////////////// TypedWritable *ScissorEffect:: make_from_bam(const FactoryParams ¶ms) { - ScissorEffect *effect = new ScissorEffect(true, LVecBase4f::zero(), NULL, 0, false); + ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), NULL, 0, false); DatagramIterator scan; BamReader *manager; @@ -451,16 +451,16 @@ fillin(DatagramIterator &scan, BamReader *manager) { // properties, given the indicated scissor frame. //////////////////////////////////////////////////////////////////// PT(GeometricBoundingVolume) ScissorEffect:: -make_frustum(const Lens *lens, const LVecBase4f &frame) const{ +make_frustum(const Lens *lens, const LVecBase4 &frame) const{ // Scale the frame from 0 .. 1 into -1 .. 1. - LVecBase4f f2(frame[0] * 2.0f - 1.0f, - frame[1] * 2.0f - 1.0f, - frame[2] * 2.0f - 1.0f, - frame[3] * 2.0f - 1.0f); + LVecBase4 f2(frame[0] * 2.0f - 1.0f, + frame[1] * 2.0f - 1.0f, + frame[2] * 2.0f - 1.0f, + frame[3] * 2.0f - 1.0f); - LPoint3f fll, flr, ful, fur; - LPoint3f nll, nlr, nul, nur; - LPoint2f corner; + LPoint3 fll, flr, ful, fur; + LPoint3 nll, nlr, nul, nur; + LPoint2 corner; corner[0] = f2[0]; corner[1] = f2[3]; diff --git a/panda/src/pgraph/scissorEffect.h b/panda/src/pgraph/scissorEffect.h index 6c157a4485..bde3aa16d2 100644 --- a/panda/src/pgraph/scissorEffect.h +++ b/panda/src/pgraph/scissorEffect.h @@ -33,26 +33,26 @@ class EXPCL_PANDA_PGRAPH ScissorEffect : public RenderEffect { private: class PointDef { public: - LPoint3f _p; + LPoint3 _p; NodePath _node; }; - ScissorEffect(bool screen, const LVecBase4f &frame, + ScissorEffect(bool screen, const LVecBase4 &frame, const PointDef *points, int num_points, bool clip); ScissorEffect(const ScissorEffect ©); PUBLISHED: - static CPT(RenderEffect) make_screen(const LVecBase4f &frame, bool clip = true); + static CPT(RenderEffect) make_screen(const LVecBase4 &frame, bool clip = true); static CPT(RenderEffect) make_node(bool clip = true); - static CPT(RenderEffect) make_node(const LPoint3f &a, const LPoint3f &b, const NodePath &node = NodePath()); - static CPT(RenderEffect) make_node(const LPoint3f &a, const LPoint3f &b, const LPoint3f &c, const LPoint3f &d, const NodePath &node = NodePath()); - CPT(RenderEffect) add_point(const LPoint3f &point, const NodePath &node = NodePath()) const; + static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node = NodePath()); + static CPT(RenderEffect) make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d, const NodePath &node = NodePath()); + CPT(RenderEffect) add_point(const LPoint3 &point, const NodePath &node = NodePath()) const; INLINE bool is_screen() const; - INLINE const LVecBase4f &get_frame() const; + INLINE const LVecBase4 &get_frame() const; INLINE int get_num_points() const; - INLINE const LPoint3f &get_point(int n) const; + INLINE const LPoint3 &get_point(int n) const; MAKE_SEQ(get_points, get_num_points, get_point); INLINE NodePath get_node(int n) const; MAKE_SEQ(get_nodes, get_num_points, get_node); @@ -60,7 +60,7 @@ PUBLISHED: INLINE bool get_clip() const; public: - virtual CPT(RenderEffect) xform(const LMatrix4f &mat) const; + virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const; virtual void output(ostream &out) const; virtual bool has_cull_callback() const; @@ -72,11 +72,11 @@ protected: virtual int compare_to_impl(const RenderEffect *other) const; private: - PT(GeometricBoundingVolume) make_frustum(const Lens *lens, const LVecBase4f &frame) const; + PT(GeometricBoundingVolume) make_frustum(const Lens *lens, const LVecBase4 &frame) const; private: bool _screen; - LVecBase4f _frame; + LVecBase4 _frame; typedef pvector Points; Points _points; bool _clip; diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 86738bf607..e533388aef 100755 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -227,7 +227,7 @@ set_shader_input(const ShaderInput *input) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_float &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_float &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -237,7 +237,7 @@ set_shader_input(InternalName *id, const PTA_float &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_double &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_double &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -247,7 +247,7 @@ set_shader_input(InternalName *id, const PTA_double &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_LVecBase4 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -257,7 +257,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority) const // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_LVecBase3 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -268,7 +268,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority) const // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_LVecBase2 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -278,7 +278,7 @@ set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority) const // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const LVecBase4f &v, int priority) const { +set_shader_input(const InternalName *id, const LVecBase4 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -288,7 +288,7 @@ set_shader_input(InternalName *id, const LVecBase4f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const LVecBase3f &v, int priority) const { +set_shader_input(const InternalName *id, const LVecBase3 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -298,7 +298,7 @@ set_shader_input(InternalName *id, const LVecBase3f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const LVecBase2f &v, int priority) const { +set_shader_input(const InternalName *id, const LVecBase2 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -308,7 +308,7 @@ set_shader_input(InternalName *id, const LVecBase2f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_LMatrix4 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -318,7 +318,7 @@ set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) const { +set_shader_input(const InternalName *id, const PTA_LMatrix3 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -328,7 +328,7 @@ set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const LMatrix4f &v, int priority) const { +set_shader_input(const InternalName *id, const LMatrix4 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -338,7 +338,7 @@ set_shader_input(InternalName *id, const LMatrix4f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const LMatrix3f &v, int priority) const { +set_shader_input(const InternalName *id, const LMatrix3 &v, int priority) const { return set_shader_input(new ShaderInput(id,v,priority)); } @@ -348,7 +348,7 @@ set_shader_input(InternalName *id, const LMatrix3f &v, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, Texture *tex, int priority) const { +set_shader_input(const InternalName *id, Texture *tex, int priority) const { return set_shader_input(new ShaderInput(id,tex,priority)); } @@ -358,7 +358,7 @@ set_shader_input(InternalName *id, Texture *tex, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, const NodePath &np, int priority) const { +set_shader_input(const InternalName *id, const NodePath &np, int priority) const { return set_shader_input(new ShaderInput(id,np,priority)); } @@ -368,158 +368,8 @@ set_shader_input(InternalName *id, const NodePath &np, int priority) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) const { - return set_shader_input(new ShaderInput(id, LVecBase4f(n1,n2,n3,n4), priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_float &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_double &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const LVecBase4f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const LVecBase3f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const LVecBase2f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const LMatrix4f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const LMatrix3f &v, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),v,priority)); -} -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, Texture *tex, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),tex,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, const NodePath &np, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id),np,priority)); -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(const string &id, double n1, double n2, double n3, double n4, int priority) const { - return set_shader_input(new ShaderInput(InternalName::make(id), LVecBase4f(n1,n2,n3,n4), priority)); +set_shader_input(const InternalName *id, double n1, double n2, double n3, double n4, int priority) const { + return set_shader_input(new ShaderInput(id, LVecBase4(n1,n2,n3,n4), priority)); } //////////////////////////////////////////////////////////////////// @@ -543,7 +393,7 @@ set_instance_count(int instance_count) const { // Description: //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) ShaderAttrib:: -clear_shader_input(InternalName *id) const { +clear_shader_input(const InternalName *id) const { ShaderAttrib *result = new ShaderAttrib(*this); result->_inputs.erase(id); return return_new(result); @@ -579,7 +429,7 @@ clear_all_shader_inputs() const { // NULL --- it returns the "blank" ShaderInput. //////////////////////////////////////////////////////////////////// const ShaderInput *ShaderAttrib:: -get_shader_input(InternalName *id) const { +get_shader_input(const InternalName *id) const { Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { return ShaderInput::get_blank(); @@ -607,7 +457,7 @@ get_shader_input(const string &id) const { // fails if there is none, or if it is not a nodepath. //////////////////////////////////////////////////////////////////// const NodePath &ShaderAttrib:: -get_shader_input_nodepath(InternalName *id) const { +get_shader_input_nodepath(const InternalName *id) const { static NodePath resfail; Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { @@ -636,9 +486,9 @@ get_shader_input_nodepath(InternalName *id) const { // Description: Returns the ShaderInput as a vector. Assertion // fails if there is none, or if it is not a vector. //////////////////////////////////////////////////////////////////// -const LVector4f &ShaderAttrib:: +const LVecBase4 &ShaderAttrib:: get_shader_input_vector(InternalName *id) const { - static LVector4f resfail(0,0,0,0); + static LVecBase4 resfail(0,0,0,0); Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { ostringstream strm; @@ -665,7 +515,7 @@ get_shader_input_vector(InternalName *id) const { // a PTA(double/float) //////////////////////////////////////////////////////////////////// const Shader::ShaderPtrData *ShaderAttrib:: -get_shader_input_ptr(InternalName *id) const { +get_shader_input_ptr(const InternalName *id) const { Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { ostringstream strm; @@ -691,7 +541,7 @@ get_shader_input_ptr(InternalName *id) const { // fails if there is none, or if it is not a texture. //////////////////////////////////////////////////////////////////// Texture *ShaderAttrib:: -get_shader_input_texture(InternalName *id) const { +get_shader_input_texture(const InternalName *id) const { Inputs::const_iterator i = _inputs.find(id); if (i == _inputs.end()) { ostringstream strm; diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index d700a744a6..09be382a67 100755 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -25,11 +25,11 @@ #include "shader.h" #include "pta_float.h" #include "pta_double.h" -#include "pta_LMatrix4f.h" -#include "pta_LMatrix3f.h" -#include "pta_LVecBase4f.h" -#include "pta_LVecBase3f.h" -#include "pta_LVecBase2f.h" +#include "pta_LMatrix4.h" +#include "pta_LMatrix3.h" +#include "pta_LVecBase4.h" +#include "pta_LVecBase3.h" +#include "pta_LVecBase2.h" //////////////////////////////////////////////////////////////////// // Class : ShaderAttrib @@ -73,38 +73,21 @@ PUBLISHED: CPT(RenderAttrib) set_shader_input(const ShaderInput *inp) const; // InternalName* id - CPT(RenderAttrib) set_shader_input(InternalName *id, Texture *tex, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const NodePath &np, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_float &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_double &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LMatrix4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LMatrix3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const PTA_LVecBase2f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const LVecBase2f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const LMatrix4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, const LMatrix3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1, - int priority=0) const; - // String id - CPT(RenderAttrib) set_shader_input(const string &id, Texture *tex, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const NodePath &np, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_float &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_double &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LMatrix4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LMatrix3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const PTA_LVecBase2f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const LVecBase2f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const LMatrix4f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, const LMatrix3f &v, int priority=0) const; - CPT(RenderAttrib) set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1, + CPT(RenderAttrib) set_shader_input(const InternalName *id, Texture *tex, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const NodePath &np, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_float &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_double &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_LMatrix4 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_LMatrix3 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_LVecBase4 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_LVecBase3 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const PTA_LVecBase2 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const LVecBase4 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const LVecBase3 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const LVecBase2 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const LMatrix4 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, const LMatrix3 &v, int priority=0) const; + CPT(RenderAttrib) set_shader_input(const InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0) const; CPT(RenderAttrib) set_instance_count(int instance_count) const; @@ -112,21 +95,21 @@ PUBLISHED: CPT(RenderAttrib) set_flag(int flag, bool value) const; CPT(RenderAttrib) clear_flag(int flag) const; - CPT(RenderAttrib) clear_shader_input(InternalName *id) const; + CPT(RenderAttrib) clear_shader_input(const InternalName *id) const; CPT(RenderAttrib) clear_shader_input(const string &id) const; CPT(RenderAttrib) clear_all_shader_inputs() const; - INLINE bool get_flag(int flag) const; + INLINE bool get_flag(int flag) const; - const Shader *get_shader() const; - const ShaderInput *get_shader_input(InternalName *id) const; + const Shader *get_shader() const; + const ShaderInput *get_shader_input(const InternalName *id) const; const ShaderInput *get_shader_input(const string &id) const; - const NodePath &get_shader_input_nodepath(InternalName *id) const; - const LVector4f &get_shader_input_vector(InternalName *id) const; - Texture* get_shader_input_texture(InternalName *id) const; - const Shader::ShaderPtrData *get_shader_input_ptr(InternalName *id) const; + const NodePath &get_shader_input_nodepath(const InternalName *id) const; + const LVecBase4 &get_shader_input_vector(InternalName *id) const; + Texture *get_shader_input_texture(const InternalName *id) const; + const Shader::ShaderPtrData *get_shader_input_ptr(const InternalName *id) const; static void register_with_read_factory(); diff --git a/panda/src/pgraph/shaderInput.I b/panda/src/pgraph/shaderInput.I index 91546fd0a9..bc0c2da6e1 100644 --- a/panda/src/pgraph/shaderInput.I +++ b/panda/src/pgraph/shaderInput.I @@ -28,14 +28,10 @@ INLINE ShaderInput:: // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, int priority) : +ShaderInput(const InternalName *name, int priority) : _name(name), _type(M_invalid), - _priority(priority), - _stored_ptr(), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVector4f(0,0,0,1)) + _priority(priority) { } @@ -45,14 +41,11 @@ ShaderInput(InternalName *name, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, Texture *tex, int priority) : +ShaderInput(const InternalName *name, Texture *tex, int priority) : _name(name), _type(M_texture), _priority(priority), - _stored_ptr(), - _stored_texture(tex), - _stored_nodepath(NodePath()), - _stored_vector(LVector4f(0,0,0,1)) + _stored_texture(tex) { } @@ -62,14 +55,11 @@ ShaderInput(InternalName *name, Texture *tex, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const NodePath &np, int priority) : +ShaderInput(const InternalName *name, const NodePath &np, int priority) : _name(name), _type(M_nodepath), _priority(priority), - _stored_ptr(), - _stored_texture(NULL), - _stored_nodepath(np), - _stored_vector(LVector4f(0,0,0,1)) + _stored_nodepath(np) { } @@ -79,14 +69,11 @@ ShaderInput(InternalName *name, const NodePath &np, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_float &ptr, int priority) : +ShaderInput(const InternalName *name, const PTA_float &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -96,14 +83,11 @@ ShaderInput(InternalName *name, const PTA_float &ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_double &ptr, int priority) : +ShaderInput(const InternalName *name, const PTA_LVecBase4f &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -113,14 +97,11 @@ ShaderInput(InternalName *name, const PTA_double &ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_LVecBase4f& ptr, int priority) : +ShaderInput(const InternalName *name, const PTA_LVecBase3f &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -130,14 +111,11 @@ ShaderInput(InternalName *name, const PTA_LVecBase4f& ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_LVecBase3f& ptr, int priority) : +ShaderInput(const InternalName *name, const PTA_LVecBase2f &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -147,31 +125,12 @@ ShaderInput(InternalName *name, const PTA_LVecBase3f& ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_LVecBase2f& ptr, int priority) : - _name(name), - _type(M_numeric), - _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE ShaderInput:: -ShaderInput(InternalName *name, const LVecBase4f& vec, int priority) : +ShaderInput(const InternalName *name, const LVecBase4f &vec, int priority) : _name(name), _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(vec) //old GLSL inputs must be supported + _stored_vector(LCAST(PN_stdfloat, vec)) //old GLSL inputs must be supported { } @@ -181,14 +140,152 @@ ShaderInput(InternalName *name, const LVecBase4f& vec, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const LVecBase3f& vec, int priority) : +ShaderInput(const InternalName *name, const LVecBase3f &vec, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(vec) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const LVecBase2f &vec, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(vec) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_LMatrix4f &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_LMatrix3f &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const LMatrix4f &mat, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(mat) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const LMatrix3f &mat, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(mat) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_double &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_LVecBase4d &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_LVecBase3d &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const PTA_LVecBase2d &ptr, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(ptr) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const LVecBase4d &vec, int priority) : _name(name), _type(M_numeric), _priority(priority), _stored_ptr(vec), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_vector(LCAST(PN_stdfloat, vec)) //old GLSL inputs must be supported { } @@ -198,14 +295,11 @@ ShaderInput(InternalName *name, const LVecBase3f& vec, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const LVecBase2f& vec, int priority) : +ShaderInput(const InternalName *name, const LVecBase3d &vec, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(vec), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(vec) { } @@ -215,14 +309,11 @@ ShaderInput(InternalName *name, const LVecBase2f& vec, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_LMatrix4f& ptr, int priority) : +ShaderInput(const InternalName *name, const LVecBase2d &vec, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(vec) { } @@ -232,14 +323,11 @@ ShaderInput(InternalName *name, const PTA_LMatrix4f& ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const PTA_LMatrix3f& ptr, int priority) : +ShaderInput(const InternalName *name, const PTA_LMatrix4d &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(ptr), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -249,14 +337,11 @@ ShaderInput(InternalName *name, const PTA_LMatrix3f& ptr, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const LMatrix4f& mat, int priority) : +ShaderInput(const InternalName *name, const PTA_LMatrix3d &ptr, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(ptr) { } @@ -266,14 +351,25 @@ ShaderInput(InternalName *name, const LMatrix4f& mat, int priority) : // Description: //////////////////////////////////////////////////////////////////// INLINE ShaderInput:: -ShaderInput(InternalName *name, const LMatrix3f& mat, int priority) : +ShaderInput(const InternalName *name, const LMatrix4d &mat, int priority) : _name(name), _type(M_numeric), _priority(priority), - _stored_ptr(mat), - _stored_texture(NULL), - _stored_nodepath(NodePath()), - _stored_vector(LVecBase4f::zero()) + _stored_ptr(mat) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ShaderInput::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ShaderInput:: +ShaderInput(const InternalName *name, const LMatrix3d &mat, int priority) : + _name(name), + _type(M_numeric), + _priority(priority), + _stored_ptr(mat) { } @@ -282,7 +378,7 @@ ShaderInput(InternalName *name, const LMatrix3f& mat, int priority) : // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE InternalName *ShaderInput:: +INLINE const InternalName *ShaderInput:: get_name() const { return _name; } @@ -322,7 +418,7 @@ get_texture() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const Shader::ShaderPtrData& ShaderInput:: +INLINE const Shader::ShaderPtrData &ShaderInput:: get_ptr() const { return _stored_ptr; } @@ -342,7 +438,7 @@ get_nodepath() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LVector4f &ShaderInput:: +INLINE const LVecBase4 &ShaderInput:: get_vector() const { return _stored_vector; } diff --git a/panda/src/pgraph/shaderInput.h b/panda/src/pgraph/shaderInput.h index 1b4a4445ca..86e473bf04 100644 --- a/panda/src/pgraph/shaderInput.h +++ b/panda/src/pgraph/shaderInput.h @@ -25,11 +25,11 @@ #include "shader.h" #include "pta_float.h" #include "pta_double.h" -#include "pta_LMatrix4f.h" -#include "pta_LMatrix3f.h" -#include "pta_LVecBase4f.h" -#include "pta_LVecBase3f.h" -#include "pta_LVecBase2f.h" +#include "pta_LMatrix4.h" +#include "pta_LMatrix3.h" +#include "pta_LVecBase4.h" +#include "pta_LVecBase3.h" +#include "pta_LVecBase2.h" //////////////////////////////////////////////////////////////////// // Class : ShaderInput @@ -44,21 +44,32 @@ public: PUBLISHED: static const ShaderInput *get_blank(); - INLINE ShaderInput(InternalName *id, int priority=0); - INLINE ShaderInput(InternalName *id, const NodePath &np, int priority=0); - INLINE ShaderInput(InternalName *id, Texture *tex, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_float &ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_double &ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_LVecBase4f& ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_LVecBase3f& ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_LVecBase2f& ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_LMatrix4f& ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const PTA_LMatrix3f& ptr, int priority=0); - INLINE ShaderInput(InternalName *id, const LVecBase4f& vec, int priority=0); - INLINE ShaderInput(InternalName *id, const LVecBase3f& vec, int priority=0); - INLINE ShaderInput(InternalName *id, const LVecBase2f& vec, int priority=0); - INLINE ShaderInput(InternalName *id, const LMatrix4f& mat, int priority=0); - INLINE ShaderInput(InternalName *id, const LMatrix3f& mat, int priority=0); + INLINE ShaderInput(const InternalName *id, int priority=0); + INLINE ShaderInput(const InternalName *id, const NodePath &np, int priority=0); + INLINE ShaderInput(const InternalName *id, Texture *tex, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_float &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase4f &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase3f &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase2f &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LMatrix4f &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LMatrix3f &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase4f &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase3f &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase2f &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LMatrix4f &mat, int priority=0); + INLINE ShaderInput(const InternalName *id, const LMatrix3f &mat, int priority=0); + + INLINE ShaderInput(const InternalName *id, const PTA_double &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase4d &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase3d &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LVecBase2d &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LMatrix4d &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const PTA_LMatrix3d &ptr, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase4d &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase3d &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LVecBase2d &vec, int priority=0); + INLINE ShaderInput(const InternalName *id, const LMatrix4d &mat, int priority=0); + INLINE ShaderInput(const InternalName *id, const LMatrix3d &mat, int priority=0); enum ShaderInputType { M_invalid = 0, @@ -67,26 +78,26 @@ PUBLISHED: M_numeric }; - INLINE InternalName *get_name() const; + INLINE const InternalName *get_name() const; - INLINE int get_value_type() const; - INLINE int get_priority() const; - INLINE Texture *get_texture() const; - INLINE const NodePath &get_nodepath() const; - INLINE const LVector4f &get_vector() const; - INLINE const Shader::ShaderPtrData &get_ptr() const; + INLINE int get_value_type() const; + INLINE int get_priority() const; + INLINE Texture *get_texture() const; + INLINE const NodePath &get_nodepath() const; + INLINE const LVecBase4 &get_vector() const; + INLINE const Shader::ShaderPtrData &get_ptr() const; public: static void register_with_read_factory(); private: - PT(InternalName) _name; + CPT(InternalName) _name; int _type; int _priority; Shader::ShaderPtrData _stored_ptr; - PT(Texture) _stored_texture; - NodePath _stored_nodepath; - LVector4f _stored_vector; + PT(Texture) _stored_texture; + NodePath _stored_nodepath; + LVecBase4 _stored_vector; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 95867948eb..d1efb46d4e 100755 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -137,7 +137,7 @@ add_stage(TextureStage *stage, TexGenAttrib::Mode mode, //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) TexGenAttrib:: add_stage(TextureStage *stage, TexGenAttrib::Mode mode, - const TexCoord3f &constant_value) const { + const LTexCoord3 &constant_value) const { nassertr(mode == M_constant, this); CPT(RenderAttrib) removed = remove_stage(stage); @@ -282,13 +282,13 @@ get_light(TextureStage *stage) const { // texture stage. This is only meaningful if the mode // is M_constant. //////////////////////////////////////////////////////////////////// -const TexCoord3f &TexGenAttrib:: +const LTexCoord3 &TexGenAttrib:: get_constant_value(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); if (mi != _stages.end()) { return (*mi).second._constant_value; } - return TexCoord3f::zero(); + return LTexCoord3::zero(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/texGenAttrib.h b/panda/src/pgraph/texGenAttrib.h index 4809a3c09f..99c5c0c029 100755 --- a/panda/src/pgraph/texGenAttrib.h +++ b/panda/src/pgraph/texGenAttrib.h @@ -55,7 +55,7 @@ PUBLISHED: CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode) const; CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const string &source_name, const NodePath &light) const; - CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const TexCoord3f &constant_value) const; + CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const LTexCoord3 &constant_value) const; CPT(RenderAttrib) remove_stage(TextureStage *stage) const; bool is_empty() const; @@ -64,7 +64,7 @@ PUBLISHED: bool has_gen_texcoord_stage(TextureStage *stage) const; string get_source_name(TextureStage *stage) const; NodePath get_light(TextureStage *stage) const; - const TexCoord3f &get_constant_value(TextureStage *stage) const; + const LTexCoord3 &get_constant_value(TextureStage *stage) const; INLINE int get_geom_rendering(int geom_rendering) const; @@ -92,7 +92,7 @@ private: Mode _mode; string _source_name; NodePath _light; - TexCoord3f _constant_value; + LTexCoord3 _constant_value; }; typedef pmap Stages; Stages _stages; diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index 65d959a12e..b90b0047fb 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -59,10 +59,10 @@ make() { // interface is deprecated. //////////////////////////////////////////////////////////////////// CPT(RenderAttrib) TexMatrixAttrib:: -make(const LMatrix4f &mat) { +make(const LMatrix4 &mat) { pgraph_cat.warning() << "Using deprecated TexMatrixAttrib interface.\n"; - if (mat == LMatrix4f::ident_mat()) { + if (mat == LMatrix4::ident_mat()) { return make(); } CPT(TransformState) transform = TransformState::make_mat(mat); @@ -129,7 +129,7 @@ remove_stage(TextureStage *stage) const { // Description: Returns the transformation matrix associated with // the default texture stage. //////////////////////////////////////////////////////////////////// -const LMatrix4f &TexMatrixAttrib:: +const LMatrix4 &TexMatrixAttrib:: get_mat() const { return get_mat(TextureStage::get_default()); } @@ -190,7 +190,7 @@ get_stage(int n) const { // the indicated texture stage, or identity matrix if // nothing is associated with the indicated stage. //////////////////////////////////////////////////////////////////// -const LMatrix4f &TexMatrixAttrib:: +const LMatrix4 &TexMatrixAttrib:: get_mat(TextureStage *stage) const { return get_transform(stage)->get_mat(); } diff --git a/panda/src/pgraph/texMatrixAttrib.h b/panda/src/pgraph/texMatrixAttrib.h index 0f8bf48fcc..813ebd2a7b 100644 --- a/panda/src/pgraph/texMatrixAttrib.h +++ b/panda/src/pgraph/texMatrixAttrib.h @@ -40,7 +40,7 @@ public: PUBLISHED: static CPT(RenderAttrib) make(); - static CPT(RenderAttrib) make(const LMatrix4f &mat); + static CPT(RenderAttrib) make(const LMatrix4 &mat); static CPT(RenderAttrib) make(TextureStage *stage, const TransformState *transform); static CPT(RenderAttrib) make_default(); @@ -54,8 +54,8 @@ PUBLISHED: TextureStage *get_stage(int n) const; MAKE_SEQ(get_stages, get_num_stages, get_stage); - const LMatrix4f &get_mat() const; - const LMatrix4f &get_mat(TextureStage *stage) const; + const LMatrix4 &get_mat() const; + const LMatrix4 &get_mat(TextureStage *stage) const; CPT(TransformState) get_transform(TextureStage *stage) const; INLINE int get_override(TextureStage *stage) const; diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index 44a14aeaed..a5bfe52cf0 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -225,9 +225,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, static CPT(TransformState) fixmat; if (fixmat == (TransformState *)NULL) { fixmat = TransformState::make_pos_hpr_scale - (LVecBase3f(0.5f, 0.5f, 0.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(0.5f, 0.5f, 1.0f)); + (LVecBase3(0.5f, 0.5f, 0.0f), + LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(0.5f, 0.5f, 1.0f)); } // Now apply both to the current transform. diff --git a/panda/src/pgraph/transformState.I b/panda/src/pgraph/transformState.I index 1c576af66a..58fe5d1bb3 100644 --- a/panda/src/pgraph/transformState.I +++ b/panda/src/pgraph/transformState.I @@ -55,10 +55,10 @@ get_hash() const { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos(const LVecBase3f &pos) { +make_pos(const LVecBase3 &pos) { return make_pos_hpr_scale(pos, - LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(1.0f, 1.0f, 1.0f)); + LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(1.0f, 1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -68,10 +68,10 @@ make_pos(const LVecBase3f &pos) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_hpr(const LVecBase3f &hpr) { - return make_pos_hpr_scale(LVecBase3f(0.0f, 0.0f, 0.0f), +make_hpr(const LVecBase3 &hpr) { + return make_pos_hpr_scale(LVecBase3(0.0f, 0.0f, 0.0f), hpr, - LVecBase3f(1.0f, 1.0f, 1.0f)); + LVecBase3(1.0f, 1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -81,10 +81,10 @@ make_hpr(const LVecBase3f &hpr) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_quat(const LQuaternionf &quat) { - return make_pos_quat_scale(LVecBase3f(0.0f, 0.0f, 0.0f), +make_quat(const LQuaternion &quat) { + return make_pos_quat_scale(LVecBase3(0.0f, 0.0f, 0.0f), quat, - LVecBase3f(1.0f, 1.0f, 1.0f)); + LVecBase3(1.0f, 1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -94,9 +94,9 @@ make_quat(const LQuaternionf &quat) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { +make_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { return make_pos_hpr_scale(pos, hpr, - LVecBase3f(1.0, 1.0f, 1.0f)); + LVecBase3(1.0, 1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -106,7 +106,7 @@ make_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_scale(float scale) { +make_scale(PN_stdfloat scale) { // We actually map this 3-d uniform make_scale() to the 2-d // version--might as well call it a 2-d scale. return make_scale2d(scale); @@ -119,9 +119,9 @@ make_scale(float scale) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_scale(const LVecBase3f &scale) { - return make_pos_hpr_scale(LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), +make_scale(const LVecBase3 &scale) { + return make_pos_hpr_scale(LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(0.0f, 0.0f, 0.0f), scale); } @@ -132,10 +132,10 @@ make_scale(const LVecBase3f &scale) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_shear(const LVecBase3f &shear) { - return make_pos_hpr_scale_shear(LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), - LVecBase3f(1.0f, 1.0f, 1.0f), +make_shear(const LVecBase3 &shear) { + return make_pos_hpr_scale_shear(LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(0.0f, 0.0f, 0.0f), + LVecBase3(1.0f, 1.0f, 1.0f), shear); } @@ -146,9 +146,9 @@ make_shear(const LVecBase3f &shear) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale) { - return make_pos_hpr_scale_shear(pos, hpr, scale, LVecBase3f::zero()); +make_pos_hpr_scale(const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale) { + return make_pos_hpr_scale_shear(pos, hpr, scale, LVecBase3::zero()); } //////////////////////////////////////////////////////////////////// @@ -158,9 +158,9 @@ make_pos_hpr_scale(const LVecBase3f &pos, const LVecBase3f &hpr, // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale) { - return make_pos_quat_scale_shear(pos, quat, scale, LVecBase3f::zero()); +make_pos_quat_scale(const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale) { + return make_pos_quat_scale_shear(pos, quat, scale, LVecBase3::zero()); } //////////////////////////////////////////////////////////////////// @@ -170,8 +170,8 @@ make_pos_quat_scale(const LVecBase3f &pos, const LQuaternionf &quat, // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos2d(const LVecBase2f &pos) { - return make_pos_rotate_scale2d(pos, 0.0f, LVecBase2f(1.0f, 1.0f)); +make_pos2d(const LVecBase2 &pos) { + return make_pos_rotate_scale2d(pos, 0.0f, LVecBase2(1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -181,9 +181,9 @@ make_pos2d(const LVecBase2f &pos) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_rotate2d(float rotate) { - return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), rotate, - LVecBase2f(1.0f, 1.0f)); +make_rotate2d(PN_stdfloat rotate) { + return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), rotate, + LVecBase2(1.0f, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -193,9 +193,9 @@ make_rotate2d(float rotate) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos_rotate2d(const LVecBase2f &pos, float rotate) { +make_pos_rotate2d(const LVecBase2 &pos, PN_stdfloat rotate) { return make_pos_rotate_scale2d(pos, rotate, - LVecBase2f(1.0, 1.0f)); + LVecBase2(1.0, 1.0f)); } //////////////////////////////////////////////////////////////////// @@ -205,9 +205,9 @@ make_pos_rotate2d(const LVecBase2f &pos, float rotate) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_scale2d(float scale) { - return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), 0.0f, - LVecBase2f(scale, scale)); +make_scale2d(PN_stdfloat scale) { + return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), 0.0f, + LVecBase2(scale, scale)); } //////////////////////////////////////////////////////////////////// @@ -217,8 +217,8 @@ make_scale2d(float scale) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_scale2d(const LVecBase2f &scale) { - return make_pos_rotate_scale2d(LVecBase2f(0.0f, 0.0f), 0.0f, scale); +make_scale2d(const LVecBase2 &scale) { + return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), 0.0f, scale); } //////////////////////////////////////////////////////////////////// @@ -228,9 +228,9 @@ make_scale2d(const LVecBase2f &scale) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_shear2d(float shear) { - return make_pos_rotate_scale_shear2d(LVecBase2f(0.0f, 0.0f), 0.0f, - LVecBase2f(1.0f, 1.0f), shear); +make_shear2d(PN_stdfloat shear) { + return make_pos_rotate_scale_shear2d(LVecBase2(0.0f, 0.0f), 0.0f, + LVecBase2(1.0f, 1.0f), shear); } //////////////////////////////////////////////////////////////////// @@ -240,8 +240,8 @@ make_shear2d(float shear) { // components. //////////////////////////////////////////////////////////////////// INLINE CPT(TransformState) TransformState:: -make_pos_rotate_scale2d(const LVecBase2f &pos, float rotate, - const LVecBase2f &scale) { +make_pos_rotate_scale2d(const LVecBase2 &pos, PN_stdfloat rotate, + const LVecBase2 &scale) { return make_pos_rotate_scale_shear2d(pos, rotate, scale, 0.0f); } @@ -483,7 +483,7 @@ has_mat() const { // Description: Returns the pos component of the transform. It is an // error to call this if has_pos() returned false. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &TransformState:: +INLINE const LPoint3 &TransformState:: get_pos() const { check_components(); nassertr(has_pos(), _pos); @@ -497,7 +497,7 @@ get_pos() const { // trio of Euler angles. It is an error to call this if // has_components() returned false. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &TransformState:: +INLINE const LVecBase3 &TransformState:: get_hpr() const { check_hpr(); nassertr(!is_invalid(), _hpr); @@ -518,7 +518,7 @@ get_hpr() const { // It is an error to call this if has_components() // returned false. //////////////////////////////////////////////////////////////////// -INLINE const LQuaternionf &TransformState:: +INLINE const LQuaternion &TransformState:: get_quat() const { check_quat(); nassertr(!is_invalid(), _quat); @@ -534,7 +534,7 @@ get_quat() const { // normalized. It is an error to call this if // has_components() returned false. //////////////////////////////////////////////////////////////////// -INLINE const LQuaternionf &TransformState:: +INLINE const LQuaternion &TransformState:: get_norm_quat() const { check_norm_quat(); nassertr(!is_invalid(), _norm_quat); @@ -548,7 +548,7 @@ get_norm_quat() const { // error to call this if has_components() returned // false. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &TransformState:: +INLINE const LVecBase3 &TransformState:: get_scale() const { check_components(); nassertr(!is_invalid(), _scale); @@ -562,7 +562,7 @@ get_scale() const { // single number. It is an error to call this if // has_uniform_scale() returned false. //////////////////////////////////////////////////////////////////// -INLINE float TransformState:: +INLINE PN_stdfloat TransformState:: get_uniform_scale() const { check_components(); nassertr(has_uniform_scale(), _scale[0]); @@ -576,7 +576,7 @@ get_uniform_scale() const { // an error to call this if has_components() returned // false. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &TransformState:: +INLINE const LVecBase3 &TransformState:: get_shear() const { check_components(); nassertr(!is_invalid(), _shear); @@ -588,9 +588,9 @@ get_shear() const { // Access: Published // Description: Returns the matrix that describes the transform. //////////////////////////////////////////////////////////////////// -INLINE const LMatrix4f &TransformState:: +INLINE const LMatrix4 &TransformState:: get_mat() const { - nassertr(has_mat(), LMatrix4f::ident_mat()); + nassertr(has_mat(), LMatrix4::ident_mat()); check_mat(); return _mat; } @@ -602,11 +602,11 @@ get_mat() const { // is an error to call this if has_pos() or is_2d() // returned false. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f TransformState:: +INLINE LVecBase2 TransformState:: get_pos2d() const { check_components(); - nassertr(has_pos() && is_2d(), LVecBase2f::zero()); - return LVecBase2f(_pos[0], _pos[1]); + nassertr(has_pos() && is_2d(), LVecBase2::zero()); + return LVecBase2(_pos[0], _pos[1]); } //////////////////////////////////////////////////////////////////// @@ -617,7 +617,7 @@ get_pos2d() const { // It is an error to call this if has_components() or // is_2d() returned false. //////////////////////////////////////////////////////////////////// -INLINE float TransformState:: +INLINE PN_stdfloat TransformState:: get_rotate2d() const { check_hpr(); nassertr(!is_invalid() && is_2d(), 0); @@ -641,11 +641,11 @@ get_rotate2d() const { // is an error to call this if has_components() or // is_2d() returned false. //////////////////////////////////////////////////////////////////// -INLINE LVecBase2f TransformState:: +INLINE LVecBase2 TransformState:: get_scale2d() const { check_components(); - nassertr(!is_invalid() && is_2d(), LVecBase2f::zero()); - return LVecBase2f(_scale[0], _scale[1]); + nassertr(!is_invalid() && is_2d(), LVecBase2::zero()); + return LVecBase2(_scale[0], _scale[1]); } //////////////////////////////////////////////////////////////////// @@ -655,7 +655,7 @@ get_scale2d() const { // is an error to call this if has_components() or // is_2d() returned false. //////////////////////////////////////////////////////////////////// -INLINE float TransformState:: +INLINE PN_stdfloat TransformState:: get_shear2d() const { check_components(); nassertr(!is_invalid() && is_2d(), 0.0f); @@ -669,11 +669,11 @@ get_shear2d() const { // transform. It is an error to call this if is_2d() // returned false. //////////////////////////////////////////////////////////////////// -INLINE LMatrix3f TransformState:: +INLINE LMatrix3 TransformState:: get_mat3() const { - nassertr(has_mat() && is_2d(), LMatrix3f::ident_mat()); + nassertr(has_mat() && is_2d(), LMatrix3::ident_mat()); check_mat(); - return LMatrix3f(_mat(0, 0), _mat(0, 1), _mat(0, 3), + return LMatrix3(_mat(0, 0), _mat(0, 1), _mat(0, 3), _mat(1, 0), _mat(1, 1), _mat(1, 3), _mat(3, 0), _mat(3, 1), _mat(3, 3)); } @@ -1150,7 +1150,7 @@ check_uniform_scale() { } } - if (!_shear.almost_equal(LVecBase3f::zero())) { + if (!_shear.almost_equal(LVecBase3::zero())) { _flags |= F_has_nonzero_shear; } } @@ -1176,7 +1176,7 @@ check_uniform_scale2d() { } } - if (!_shear.almost_equal(LVecBase3f::zero())) { + if (!_shear.almost_equal(LVecBase3::zero())) { _flags |= F_has_nonzero_shear; } } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 300571e434..e990cca0f1 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -63,7 +63,7 @@ TransformState() : _lock("TransformState") { } _saved_entry = -1; _flags = F_is_identity | F_singular_known | F_is_2d; - _inv_mat = (LMatrix4f *)NULL; + _inv_mat = (LMatrix4 *)NULL; _cache_stats.add_num_states(1); } @@ -100,9 +100,9 @@ TransformState:: set_destructing(); // Free the inverse matrix computation, if it has been stored. - if (_inv_mat != (LMatrix4f *)NULL) { + if (_inv_mat != (LMatrix4 *)NULL) { delete _inv_mat; - _inv_mat = (LMatrix4f *)NULL; + _inv_mat = (LMatrix4 *)NULL; } LightReMutexHolder holder(*_states_lock); @@ -232,14 +232,14 @@ make_invalid() { // components. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -make_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr, - const LVecBase3f &scale, const LVecBase3f &shear) { +make_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertr(!(pos.is_nan() || hpr.is_nan() || scale.is_nan() || shear.is_nan()) , make_invalid()); // Make a special-case check for the identity transform. - if (pos == LVecBase3f(0.0f, 0.0f, 0.0f) && - hpr == LVecBase3f(0.0f, 0.0f, 0.0f) && - scale == LVecBase3f(1.0f, 1.0f, 1.0f) && - shear == LVecBase3f(0.0f, 0.0f, 0.0f)) { + if (pos == LVecBase3(0.0f, 0.0f, 0.0f) && + hpr == LVecBase3(0.0f, 0.0f, 0.0f) && + scale == LVecBase3(1.0f, 1.0f, 1.0f) && + shear == LVecBase3(0.0f, 0.0f, 0.0f)) { return make_identity(); } @@ -260,14 +260,14 @@ make_pos_hpr_scale_shear(const LVecBase3f &pos, const LVecBase3f &hpr, // components. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -make_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat, - const LVecBase3f &scale, const LVecBase3f &shear) { +make_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, + const LVecBase3 &scale, const LVecBase3 &shear) { nassertr(!(pos.is_nan() || quat.is_nan() || scale.is_nan() || shear.is_nan()) , make_invalid()); // Make a special-case check for the identity transform. - if (pos == LVecBase3f(0.0f, 0.0f, 0.0f) && - quat == LQuaternionf::ident_quat() && - scale == LVecBase3f(1.0f, 1.0f, 1.0f) && - shear == LVecBase3f(0.0f, 0.0f, 0.0f)) { + if (pos == LVecBase3(0.0f, 0.0f, 0.0f) && + quat == LQuaternion::ident_quat() && + scale == LVecBase3(1.0f, 1.0f, 1.0f) && + shear == LVecBase3(0.0f, 0.0f, 0.0f)) { return make_identity(); } @@ -288,10 +288,10 @@ make_pos_quat_scale_shear(const LVecBase3f &pos, const LQuaternionf &quat, // transformation matrix. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -make_mat(const LMatrix4f &mat) { +make_mat(const LMatrix4 &mat) { nassertr(!mat.is_nan(), make_invalid()); // Make a special-case check for the identity matrix. - if (mat == LMatrix4f::ident_mat()) { + if (mat == LMatrix4::ident_mat()) { return make_identity(); } @@ -309,14 +309,14 @@ make_mat(const LMatrix4f &mat) { // specified components. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -make_pos_rotate_scale_shear2d(const LVecBase2f &pos, float rotate, - const LVecBase2f &scale, - float shear) { +make_pos_rotate_scale_shear2d(const LVecBase2 &pos, PN_stdfloat rotate, + const LVecBase2 &scale, + PN_stdfloat shear) { nassertr(!(pos.is_nan() || cnan(rotate) || scale.is_nan() || cnan(shear)) , make_invalid()); // Make a special-case check for the identity transform. - if (pos == LVecBase2f(0.0f, 0.0f) && + if (pos == LVecBase2(0.0f, 0.0f) && rotate == 0.0f && - scale == LVecBase2f(1.0f, 1.0f) && + scale == LVecBase2(1.0f, 1.0f) && shear == 0.0f) { return make_identity(); } @@ -353,10 +353,10 @@ make_pos_rotate_scale_shear2d(const LVecBase2f &pos, float rotate, // specified 3x3 transformation matrix. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -make_mat3(const LMatrix3f &mat) { +make_mat3(const LMatrix3 &mat) { nassertr(!mat.is_nan(), make_invalid()); // Make a special-case check for the identity matrix. - if (mat == LMatrix3f::ident_mat()) { + if (mat == LMatrix3::ident_mat()) { return make_identity(); } @@ -377,7 +377,7 @@ make_mat3(const LMatrix3f &mat) { // replaced with the indicated value. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_pos(const LVecBase3f &pos) const { +set_pos(const LVecBase3 &pos) const { nassertr(!pos.is_nan(), this); nassertr(!is_invalid(), this); if (is_identity() || components_given()) { @@ -391,7 +391,7 @@ set_pos(const LVecBase3f &pos) const { } else { // Otherwise, we have a matrix transform, and we keep it that way. - LMatrix4f mat = get_mat(); + LMatrix4 mat = get_mat(); mat.set_row(3, pos); return make_mat(mat); } @@ -405,7 +405,7 @@ set_pos(const LVecBase3f &pos) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_hpr(const LVecBase3f &hpr) const { +set_hpr(const LVecBase3 &hpr) const { nassertr(!hpr.is_nan(), this); nassertr(!is_invalid(), this); // nassertr(has_components(), this); @@ -420,7 +420,7 @@ set_hpr(const LVecBase3f &hpr) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_quat(const LQuaternionf &quat) const { +set_quat(const LQuaternion &quat) const { nassertr(!quat.is_nan(), this); nassertr(!is_invalid(), this); // nassertr(has_components(), this); @@ -435,7 +435,7 @@ set_quat(const LQuaternionf &quat) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_scale(const LVecBase3f &scale) const { +set_scale(const LVecBase3 &scale) const { nassertr(!scale.is_nan(), this); nassertr(!is_invalid(), this); @@ -443,7 +443,7 @@ set_scale(const LVecBase3f &scale) const { // Don't inflate from 2-d to 3-d just because we got a uniform // scale. return make_pos_rotate_scale_shear2d(get_pos2d(), get_rotate2d(), - LVecBase2f(scale[0], scale[0]), + LVecBase2(scale[0], scale[0]), get_shear2d()); } @@ -463,7 +463,7 @@ set_scale(const LVecBase3f &scale) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_shear(const LVecBase3f &shear) const { +set_shear(const LVecBase3 &shear) const { nassertr(!shear.is_nan(), this); nassertr(!is_invalid(), this); // nassertr(has_components(), this); @@ -482,11 +482,11 @@ set_shear(const LVecBase3f &shear) const { // replaced with the indicated value. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_pos2d(const LVecBase2f &pos) const { +set_pos2d(const LVecBase2 &pos) const { nassertr(!pos.is_nan(), this); nassertr(!is_invalid(), this); if (!is_2d()) { - return set_pos(LVecBase3f(pos[0], pos[1], 0.0f)); + return set_pos(LVecBase3(pos[0], pos[1], 0.0f)); } if (is_identity() || components_given()) { @@ -497,7 +497,7 @@ set_pos2d(const LVecBase2f &pos) const { } else { // Otherwise, we have a matrix transform, and we keep it that way. - LMatrix3f mat = get_mat3(); + LMatrix3 mat = get_mat3(); mat.set_row(2, pos); return make_mat3(mat); } @@ -511,7 +511,7 @@ set_pos2d(const LVecBase2f &pos) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_rotate2d(float rotate) const { +set_rotate2d(PN_stdfloat rotate) const { nassertr(!cnan(rotate), this); nassertr(!is_invalid(), this); @@ -519,13 +519,13 @@ set_rotate2d(float rotate) const { switch (get_default_coordinate_system()) { default: case CS_zup_right: - return set_hpr(LVecBase3f(rotate, 0.0f, 0.0f)); + return set_hpr(LVecBase3(rotate, 0.0f, 0.0f)); case CS_zup_left: - return set_hpr(LVecBase3f(-rotate, 0.0f, 0.0f)); + return set_hpr(LVecBase3(-rotate, 0.0f, 0.0f)); case CS_yup_right: - return set_hpr(LVecBase3f(0.0f, 0.0f, -rotate)); + return set_hpr(LVecBase3(0.0f, 0.0f, -rotate)); case CS_yup_left: - return set_hpr(LVecBase3f(0.0f, 0.0f, rotate)); + return set_hpr(LVecBase3(0.0f, 0.0f, rotate)); } } @@ -541,12 +541,12 @@ set_rotate2d(float rotate) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_scale2d(const LVecBase2f &scale) const { +set_scale2d(const LVecBase2 &scale) const { nassertr(!scale.is_nan(), this); nassertr(!is_invalid(), this); if (!is_2d()) { - return set_scale(LVecBase3f(scale[0], scale[1], 1.0f)); + return set_scale(LVecBase3(scale[0], scale[1], 1.0f)); } return make_pos_rotate_scale_shear2d(get_pos2d(), get_rotate2d(), scale, get_shear2d()); @@ -560,11 +560,11 @@ set_scale2d(const LVecBase2f &scale) const { // replaced with the indicated value, if possible. //////////////////////////////////////////////////////////////////// CPT(TransformState) TransformState:: -set_shear2d(float shear) const { +set_shear2d(PN_stdfloat shear) const { nassertr(!cnan(shear), this); nassertr(!is_invalid(), this); if (!is_2d()) { - return set_shear(LVecBase3f(shear, 0.0f, 0.0f)); + return set_shear(LVecBase3(shear, 0.0f, 0.0f)); } return make_pos_rotate_scale_shear2d(get_pos2d(), get_rotate2d(), get_scale2d(), shear); @@ -961,7 +961,7 @@ output(ostream &out) const { out << "(identity)"; } else if (has_components()) { - bool output_hpr = !get_hpr().almost_equal(LVecBase3f(0.0f, 0.0f, 0.0f)); + bool output_hpr = !get_hpr().almost_equal(LVecBase3(0.0f, 0.0f, 0.0f)); if (!components_given()) { // A leading "m" indicates the transform was described as a full @@ -979,7 +979,7 @@ output(ostream &out) const { char lead = '('; if (is_2d()) { - if (!get_pos2d().almost_equal(LVecBase2f(0.0f, 0.0f))) { + if (!get_pos2d().almost_equal(LVecBase2(0.0f, 0.0f))) { out << lead << "pos " << get_pos2d(); lead = ' '; } @@ -987,7 +987,7 @@ output(ostream &out) const { out << lead << "rotate " << get_rotate2d(); lead = ' '; } - if (!get_scale2d().almost_equal(LVecBase2f(1.0f, 1.0f))) { + if (!get_scale2d().almost_equal(LVecBase2(1.0f, 1.0f))) { if (has_uniform_scale()) { out << lead << "scale " << get_uniform_scale(); lead = ' '; @@ -1001,7 +1001,7 @@ output(ostream &out) const { lead = ' '; } } else { - if (!get_pos().almost_equal(LVecBase3f(0.0f, 0.0f, 0.0f))) { + if (!get_pos().almost_equal(LVecBase3(0.0f, 0.0f, 0.0f))) { out << lead << "pos " << get_pos(); lead = ' '; } @@ -1009,7 +1009,7 @@ output(ostream &out) const { out << lead << "hpr " << get_hpr(); lead = ' '; } - if (!get_scale().almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f))) { + if (!get_scale().almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { if (has_uniform_scale()) { out << lead << "scale " << get_uniform_scale(); lead = ' '; @@ -1734,28 +1734,28 @@ do_compose(const TransformState *other) const { CPT(TransformState) result; if (is_2d() && other->is_2d()) { // Do a 2-d compose. - LVecBase2f pos = get_pos2d(); - float rotate = get_rotate2d(); - LQuaternionf quat = get_norm_quat(); - float scale = get_uniform_scale(); + LVecBase2 pos = get_pos2d(); + PN_stdfloat rotate = get_rotate2d(); + LQuaternion quat = get_norm_quat(); + PN_stdfloat scale = get_uniform_scale(); - LPoint3f op = quat.xform(other->get_pos()); - pos += LVecBase2f(op[0], op[1]) * scale; + LPoint3 op = quat.xform(other->get_pos()); + pos += LVecBase2(op[0], op[1]) * scale; rotate += other->get_rotate2d(); - LVecBase2f new_scale = other->get_scale2d() * scale; + LVecBase2 new_scale = other->get_scale2d() * scale; result = make_pos_rotate_scale2d(pos, rotate, new_scale); } else { // A normal 3-d compose. - LVecBase3f pos = get_pos(); - LQuaternionf quat = get_norm_quat(); - float scale = get_uniform_scale(); + LVecBase3 pos = get_pos(); + LQuaternion quat = get_norm_quat(); + PN_stdfloat scale = get_uniform_scale(); pos += quat.xform(other->get_pos()) * scale; quat = other->get_norm_quat() * quat; - LVecBase3f new_scale = other->get_scale() * scale; + LVecBase3 new_scale = other->get_scale() * scale; result = make_pos_quat_scale(pos, quat, new_scale); } @@ -1763,7 +1763,7 @@ do_compose(const TransformState *other) const { #ifndef NDEBUG if (paranoid_compose) { // Now verify against the matrix. - LMatrix4f new_mat; + LMatrix4 new_mat; new_mat.multiply(other->get_mat(), get_mat()); if (!new_mat.almost_equal(result->get_mat(), 0.1)) { CPT(TransformState) correct = make_mat(new_mat); @@ -1781,10 +1781,10 @@ do_compose(const TransformState *other) const { // Do the operation with matrices. if (is_2d() && other->is_2d()) { - LMatrix3f new_mat = other->get_mat3() * get_mat3(); + LMatrix3 new_mat = other->get_mat3() * get_mat3(); return make_mat3(new_mat); } else { - LMatrix4f new_mat; + LMatrix4 new_mat; new_mat.multiply(other->get_mat(), get_mat()); return make_mat(new_mat); } @@ -1966,10 +1966,10 @@ do_invert_compose(const TransformState *other) const { CPT(TransformState) result; if (is_2d() && other->is_2d()) { // Do a 2-d invert compose. - LVecBase2f pos = get_pos2d(); - float rotate = get_rotate2d(); - LQuaternionf quat = get_norm_quat(); - float scale = get_uniform_scale(); + LVecBase2 pos = get_pos2d(); + PN_stdfloat rotate = get_rotate2d(); + LQuaternion quat = get_norm_quat(); + PN_stdfloat scale = get_uniform_scale(); // First, invert our own transform. if (scale == 0.0f) { @@ -1979,14 +1979,14 @@ do_invert_compose(const TransformState *other) const { scale = 1.0f / scale; quat.invert_in_place(); rotate = -rotate; - LVecBase3f mp = quat.xform(-LVecBase3f(pos[0], pos[1], 0.0f)); - pos = LVecBase2f(mp[0], mp[1]) * scale; - LVecBase2f new_scale(scale, scale); + LVecBase3 mp = quat.xform(-LVecBase3(pos[0], pos[1], 0.0f)); + pos = LVecBase2(mp[0], mp[1]) * scale; + LVecBase2 new_scale(scale, scale); // Now compose the inverted transform with the other transform. if (!other->is_identity()) { - LPoint3f op = quat.xform(other->get_pos()); - pos += LVecBase2f(op[0], op[1]) * scale; + LPoint3 op = quat.xform(other->get_pos()); + pos += LVecBase2(op[0], op[1]) * scale; rotate += other->get_rotate2d(); new_scale = other->get_scale2d() * scale; @@ -1996,9 +1996,9 @@ do_invert_compose(const TransformState *other) const { } else { // Do a normal, 3-d invert compose. - LVecBase3f pos = get_pos(); - LQuaternionf quat = get_norm_quat(); - float scale = get_uniform_scale(); + LVecBase3 pos = get_pos(); + LQuaternion quat = get_norm_quat(); + PN_stdfloat scale = get_uniform_scale(); // First, invert our own transform. if (scale == 0.0f) { @@ -2008,7 +2008,7 @@ do_invert_compose(const TransformState *other) const { scale = 1.0f / scale; quat.invert_in_place(); pos = quat.xform(-pos) * scale; - LVecBase3f new_scale(scale, scale, scale); + LVecBase3 new_scale(scale, scale, scale); // Now compose the inverted transform with the other transform. if (!other->is_identity()) { @@ -2027,8 +2027,8 @@ do_invert_compose(const TransformState *other) const { pgraph_cat.warning() << "Unexpected singular matrix found for " << *this << "\n"; } else { - nassertr(_inv_mat != (LMatrix4f *)NULL, make_invalid()); - LMatrix4f new_mat; + nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); + LMatrix4 new_mat; new_mat.multiply(other->get_mat(), *_inv_mat); if (!new_mat.almost_equal(result->get_mat(), 0.1)) { CPT(TransformState) correct = make_mat(new_mat); @@ -2051,13 +2051,13 @@ do_invert_compose(const TransformState *other) const { // Now that is_singular() has returned false, we can assume that // _inv_mat has been allocated and filled in. - nassertr(_inv_mat != (LMatrix4f *)NULL, make_invalid()); + nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); if (is_2d() && other->is_2d()) { - const LMatrix4f &i = *_inv_mat; - LMatrix3f inv3(i(0, 0), i(0, 1), i(0, 3), - i(1, 0), i(1, 1), i(1, 3), - i(3, 0), i(3, 1), i(3, 3)); + const LMatrix4 &i = *_inv_mat; + LMatrix3 inv3(i(0, 0), i(0, 1), i(0, 3), + i(1, 0), i(1, 1), i(1, 3), + i(3, 0), i(3, 1), i(3, 3)); if (other->is_identity()) { return make_mat3(inv3); } else { @@ -2487,8 +2487,8 @@ calc_singular() { // someone is asking whether we're singular). // This should be NULL if no one has called calc_singular() yet. - nassertv(_inv_mat == (LMatrix4f *)NULL); - _inv_mat = new LMatrix4f; + nassertv(_inv_mat == (LMatrix4 *)NULL); + _inv_mat = new LMatrix4; if ((_flags & F_mat_known) == 0) { do_calc_mat(); @@ -2498,7 +2498,7 @@ calc_singular() { if (!inverted) { _flags |= F_is_singular; delete _inv_mat; - _inv_mat = (LMatrix4f *)NULL; + _inv_mat = (LMatrix4 *)NULL; } _flags |= F_singular_known; } @@ -2523,7 +2523,7 @@ do_calc_components() { _scale.set(1.0f, 1.0f, 1.0f); _shear.set(0.0f, 0.0f, 0.0f); _hpr.set(0.0f, 0.0f, 0.0f); - _quat = LQuaternionf::ident_quat(); + _quat = LQuaternion::ident_quat(); _pos.set(0.0f, 0.0f, 0.0f); _flags |= F_has_components | F_components_known | F_hpr_known | F_quat_known | F_uniform_scale; @@ -2618,7 +2618,7 @@ void TransformState:: calc_norm_quat() { PStatTimer timer(_transform_calc_pcollector); - LQuaternionf quat = get_quat(); + LQuaternion quat = get_quat(); LightMutexHolder holder(_lock); _norm_quat = quat; _norm_quat.normalize(); @@ -2642,7 +2642,7 @@ do_calc_mat() { nassertv((_flags & F_is_invalid) == 0); if ((_flags & F_is_identity) != 0) { - _mat = LMatrix4f::ident_mat(); + _mat = LMatrix4::ident_mat(); } else { // If we don't have a matrix and we're not identity, the only diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 8ec06ce141..915eb7f504 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -78,46 +78,46 @@ PUBLISHED: static CPT(TransformState) make_identity(); static CPT(TransformState) make_invalid(); - INLINE static CPT(TransformState) make_pos(const LVecBase3f &pos); - INLINE static CPT(TransformState) make_hpr(const LVecBase3f &hpr); - INLINE static CPT(TransformState) make_quat(const LQuaternionf &quat); - INLINE static CPT(TransformState) make_pos_hpr(const LVecBase3f &pos, - const LVecBase3f &hpr); - INLINE static CPT(TransformState) make_scale(float scale); - INLINE static CPT(TransformState) make_scale(const LVecBase3f &scale); - INLINE static CPT(TransformState) make_shear(const LVecBase3f &shear); - INLINE static CPT(TransformState) make_pos_hpr_scale(const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale); - INLINE static CPT(TransformState) make_pos_quat_scale(const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale); - static CPT(TransformState) make_pos_hpr_scale_shear(const LVecBase3f &pos, - const LVecBase3f &hpr, - const LVecBase3f &scale, - const LVecBase3f &shear); - static CPT(TransformState) make_pos_quat_scale_shear(const LVecBase3f &pos, - const LQuaternionf &quat, - const LVecBase3f &scale, - const LVecBase3f &shear); - static CPT(TransformState) make_mat(const LMatrix4f &mat); + INLINE static CPT(TransformState) make_pos(const LVecBase3 &pos); + INLINE static CPT(TransformState) make_hpr(const LVecBase3 &hpr); + INLINE static CPT(TransformState) make_quat(const LQuaternion &quat); + INLINE static CPT(TransformState) make_pos_hpr(const LVecBase3 &pos, + const LVecBase3 &hpr); + INLINE static CPT(TransformState) make_scale(PN_stdfloat scale); + INLINE static CPT(TransformState) make_scale(const LVecBase3 &scale); + INLINE static CPT(TransformState) make_shear(const LVecBase3 &shear); + INLINE static CPT(TransformState) make_pos_hpr_scale(const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale); + INLINE static CPT(TransformState) make_pos_quat_scale(const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale); + static CPT(TransformState) make_pos_hpr_scale_shear(const LVecBase3 &pos, + const LVecBase3 &hpr, + const LVecBase3 &scale, + const LVecBase3 &shear); + static CPT(TransformState) make_pos_quat_scale_shear(const LVecBase3 &pos, + const LQuaternion &quat, + const LVecBase3 &scale, + const LVecBase3 &shear); + static CPT(TransformState) make_mat(const LMatrix4 &mat); - INLINE static CPT(TransformState) make_pos2d(const LVecBase2f &pos); - INLINE static CPT(TransformState) make_rotate2d(float rotate); - INLINE static CPT(TransformState) make_pos_rotate2d(const LVecBase2f &pos, - float rotate); - INLINE static CPT(TransformState) make_scale2d(float scale); - INLINE static CPT(TransformState) make_scale2d(const LVecBase2f &scale); - INLINE static CPT(TransformState) make_shear2d(float shear); - INLINE static CPT(TransformState) make_pos_rotate_scale2d(const LVecBase2f &pos, - float rotate, - const LVecBase2f &scale); - static CPT(TransformState) make_pos_rotate_scale_shear2d(const LVecBase2f &pos, - float rotate, - const LVecBase2f &scale, - float shear); - static CPT(TransformState) make_mat3(const LMatrix3f &mat); + INLINE static CPT(TransformState) make_pos2d(const LVecBase2 &pos); + INLINE static CPT(TransformState) make_rotate2d(PN_stdfloat rotate); + INLINE static CPT(TransformState) make_pos_rotate2d(const LVecBase2 &pos, + PN_stdfloat rotate); + INLINE static CPT(TransformState) make_scale2d(PN_stdfloat scale); + INLINE static CPT(TransformState) make_scale2d(const LVecBase2 &scale); + INLINE static CPT(TransformState) make_shear2d(PN_stdfloat shear); + INLINE static CPT(TransformState) make_pos_rotate_scale2d(const LVecBase2 &pos, + PN_stdfloat rotate, + const LVecBase2 &scale); + static CPT(TransformState) make_pos_rotate_scale_shear2d(const LVecBase2 &pos, + PN_stdfloat rotate, + const LVecBase2 &scale, + PN_stdfloat shear); + static CPT(TransformState) make_mat3(const LMatrix3 &mat); INLINE bool is_identity() const; @@ -139,31 +139,31 @@ PUBLISHED: INLINE bool has_nonzero_shear() const; INLINE bool has_mat() const; - INLINE const LPoint3f &get_pos() const; - INLINE const LVecBase3f &get_hpr() const; - INLINE const LQuaternionf &get_quat() const; - INLINE const LQuaternionf &get_norm_quat() const; - INLINE const LVecBase3f &get_scale() const; - INLINE float get_uniform_scale() const; - INLINE const LVecBase3f &get_shear() const; - INLINE const LMatrix4f &get_mat() const; + INLINE const LPoint3 &get_pos() const; + INLINE const LVecBase3 &get_hpr() const; + INLINE const LQuaternion &get_quat() const; + INLINE const LQuaternion &get_norm_quat() const; + INLINE const LVecBase3 &get_scale() const; + INLINE PN_stdfloat get_uniform_scale() const; + INLINE const LVecBase3 &get_shear() const; + INLINE const LMatrix4 &get_mat() const; - INLINE LVecBase2f get_pos2d() const; - INLINE float get_rotate2d() const; - INLINE LVecBase2f get_scale2d() const; - INLINE float get_shear2d() const; - INLINE LMatrix3f get_mat3() const; + INLINE LVecBase2 get_pos2d() const; + INLINE PN_stdfloat get_rotate2d() const; + INLINE LVecBase2 get_scale2d() const; + INLINE PN_stdfloat get_shear2d() const; + INLINE LMatrix3 get_mat3() const; - CPT(TransformState) set_pos(const LVecBase3f &pos) const; - CPT(TransformState) set_hpr(const LVecBase3f &hpr) const; - CPT(TransformState) set_quat(const LQuaternionf &quat) const; - CPT(TransformState) set_scale(const LVecBase3f &scale) const; - CPT(TransformState) set_shear(const LVecBase3f &shear) const; + CPT(TransformState) set_pos(const LVecBase3 &pos) const; + CPT(TransformState) set_hpr(const LVecBase3 &hpr) const; + CPT(TransformState) set_quat(const LQuaternion &quat) const; + CPT(TransformState) set_scale(const LVecBase3 &scale) const; + CPT(TransformState) set_shear(const LVecBase3 &shear) const; - CPT(TransformState) set_pos2d(const LVecBase2f &pos) const; - CPT(TransformState) set_rotate2d(float rotate) const; - CPT(TransformState) set_scale2d(const LVecBase2f &scale) const; - CPT(TransformState) set_shear2d(float shear) const; + CPT(TransformState) set_pos2d(const LVecBase2 &pos) const; + CPT(TransformState) set_rotate2d(PN_stdfloat rotate) const; + CPT(TransformState) set_scale2d(const LVecBase2 &scale) const; + CPT(TransformState) set_shear2d(PN_stdfloat shear) const; CPT(TransformState) compose(const TransformState *other) const; CPT(TransformState) invert_compose(const TransformState *other) const; @@ -366,11 +366,11 @@ private: F_hash_known = 0x00020000, F_norm_quat_known = 0x00040000, }; - LPoint3f _pos; - LVecBase3f _hpr, _scale, _shear; - LQuaternionf _quat, _norm_quat; - LMatrix4f _mat; - LMatrix4f *_inv_mat; + LPoint3 _pos; + LVecBase3 _hpr, _scale, _shear; + LQuaternion _quat, _norm_quat; + LMatrix4 _mat; + LMatrix4 *_inv_mat; size_t _hash; unsigned int _flags; diff --git a/panda/src/pgraphnodes/directionalLight.I b/panda/src/pgraphnodes/directionalLight.I index 5b15f13840..cee022bbcd 100644 --- a/panda/src/pgraphnodes/directionalLight.I +++ b/panda/src/pgraphnodes/directionalLight.I @@ -1,5 +1,5 @@ // Filename: directionalLight.I -// Created by: mike (04Feb99) +// Created by: mike (04eb99) // //////////////////////////////////////////////////////////////////// // @@ -22,7 +22,7 @@ INLINE DirectionalLight::CData:: CData() : _specular_color(1.0f, 1.0f, 1.0f, 1.0f), _point(0.0f, 0.0f, 0.0f), - _direction(LVector3f::forward()) + _direction(LVector3::forward()) { } @@ -45,7 +45,7 @@ CData(const DirectionalLight::CData ©) : // Description: Returns the color of specular highlights generated by // the light. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &DirectionalLight:: +INLINE const LColor &DirectionalLight:: get_specular_color() const { CDReader cdata(_cycler); return cdata->_specular_color; @@ -58,7 +58,7 @@ get_specular_color() const { // the light. //////////////////////////////////////////////////////////////////// INLINE void DirectionalLight:: -set_specular_color(const Colorf &color) { +set_specular_color(const LColor &color) { CDWriter cdata(_cycler); cdata->_specular_color = color; } @@ -75,7 +75,7 @@ set_specular_color(const Colorf &color) { // infinitely far away. This is only used to create a // visible representation of the light. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &DirectionalLight:: +INLINE const LPoint3 &DirectionalLight:: get_point() const { CDReader cdata(_cycler); return cdata->_point; @@ -87,7 +87,7 @@ get_point() const { // Description: Sets the point in space at which the light is located. //////////////////////////////////////////////////////////////////// INLINE void DirectionalLight:: -set_point(const LPoint3f &point) { +set_point(const LPoint3 &point) { CDWriter cdata(_cycler); cdata->_point = point; mark_viz_stale(); @@ -100,7 +100,7 @@ set_point(const LPoint3f &point) { // This is local to the coordinate space in which the // light is assigned. //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &DirectionalLight:: +INLINE const LVector3 &DirectionalLight:: get_direction() const { CDReader cdata(_cycler); return cdata->_direction; @@ -112,7 +112,7 @@ get_direction() const { // Description: Sets the direction in which the light is aimed. //////////////////////////////////////////////////////////////////// INLINE void DirectionalLight:: -set_direction(const LVector3f &direction) { +set_direction(const LVector3 &direction) { CDWriter cdata(_cycler); cdata->_direction = direction; mark_viz_stale(); diff --git a/panda/src/pgraphnodes/directionalLight.cxx b/panda/src/pgraphnodes/directionalLight.cxx index 41fbb0415e..8bab9cbb91 100644 --- a/panda/src/pgraphnodes/directionalLight.cxx +++ b/panda/src/pgraphnodes/directionalLight.cxx @@ -106,7 +106,7 @@ make_copy() const { // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void DirectionalLight:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightLensNode::xform(mat); CDWriter cdata(_cycler); cdata->_point = cdata->_point * mat; @@ -148,8 +148,8 @@ write(ostream &out, int indent_level) const { // ambient light). //////////////////////////////////////////////////////////////////// bool DirectionalLight:: -get_vector_to_light(LVector3f &result, const LPoint3f &, - const LMatrix4f &to_object_space) { +get_vector_to_light(LVector3 &result, const LPoint3 &, + const LMatrix4 &to_object_space) { CDReader cdata(_cycler); result = -(cdata->_direction * to_object_space); diff --git a/panda/src/pgraphnodes/directionalLight.h b/panda/src/pgraphnodes/directionalLight.h index ae6c562066..9a13cfaf98 100644 --- a/panda/src/pgraphnodes/directionalLight.h +++ b/panda/src/pgraphnodes/directionalLight.h @@ -33,22 +33,22 @@ protected: public: virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void write(ostream &out, int indent_level) const; - virtual bool get_vector_to_light(LVector3f &result, - const LPoint3f &from_object_point, - const LMatrix4f &to_object_space); + virtual bool get_vector_to_light(LVector3 &result, + const LPoint3 &from_object_point, + const LMatrix4 &to_object_space); PUBLISHED: - INLINE const Colorf &get_specular_color() const; - INLINE void set_specular_color(const Colorf &color); + INLINE const LColor &get_specular_color() const; + INLINE void set_specular_color(const LColor &color); - INLINE const LPoint3f &get_point() const; - INLINE void set_point(const LPoint3f &point); + INLINE const LPoint3 &get_point() const; + INLINE void set_point(const LPoint3 &point); - INLINE const LVector3f &get_direction() const; - INLINE void set_direction(const LVector3f &direction); + INLINE const LVector3 &get_direction() const; + INLINE void set_direction(const LVector3 &direction); virtual int get_class_priority() const; @@ -69,9 +69,9 @@ private: return DirectionalLight::get_class_type(); } - Colorf _specular_color; - LPoint3f _point; - LVector3f _direction; + LColor _specular_color; + LPoint3 _point; + LVector3 _direction; }; PipelineCycler _cycler; diff --git a/panda/src/pgraphnodes/fadeLodNode.I b/panda/src/pgraphnodes/fadeLodNode.I index 4278a7458c..3b93097f91 100755 --- a/panda/src/pgraphnodes/fadeLodNode.I +++ b/panda/src/pgraphnodes/fadeLodNode.I @@ -19,7 +19,7 @@ // Description: set the time taken to complete an LOD switch //////////////////////////////////////////////////////////////////// INLINE void FadeLODNode:: -set_fade_time(float t) { +set_fade_time(PN_stdfloat t) { _fade_time = t; } @@ -28,7 +28,7 @@ set_fade_time(float t) { // Access: Published // Description: get the time taken to complete an LOD switch //////////////////////////////////////////////////////////////////// -INLINE float FadeLODNode:: +INLINE PN_stdfloat FadeLODNode:: get_fade_time() const { return _fade_time; } diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index 9d0d555ed8..0c339b77a0 100755 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -157,14 +157,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (ldata->_fade_mode != FadeLODNodeData::FM_solid) { // Play the transition. - float elapsed = now - ldata->_fade_start; + PN_stdfloat elapsed = now - ldata->_fade_start; if (elapsed >= _fade_time) { // Transition complete. ldata->_fade_mode = FadeLODNodeData::FM_solid; } else { - float half_fade_time = _fade_time * 0.5f; + PN_stdfloat half_fade_time = _fade_time * 0.5f; int in_child = ldata->_fade_in; int out_child = ldata->_fade_out; @@ -200,7 +200,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (child != (PandaNode *)NULL) { CullTraverserData next_data_in(data, child); - float in_alpha = elapsed / half_fade_time; + PN_stdfloat in_alpha = elapsed / half_fade_time; next_data_in._state = next_data_in._state->compose(get_fade_1_new_state(in_alpha)); trav->traverse(next_data_in); @@ -226,7 +226,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (child != (PandaNode *)NULL) { CullTraverserData next_data_out(data, child); - float out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; + PN_stdfloat out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; next_data_out._state = next_data_out._state->compose(get_fade_2_old_state(out_alpha)); trav->traverse(next_data_out); @@ -321,7 +321,7 @@ get_fade_1_old_state() { // during first half of fade. //////////////////////////////////////////////////////////////////// CPT(RenderState) FadeLODNode:: -get_fade_1_new_state(float in_alpha) { +get_fade_1_new_state(PN_stdfloat in_alpha) { if (_fade_1_new_state == (const RenderState *)NULL) { _fade_1_new_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), @@ -330,7 +330,7 @@ get_fade_1_new_state(float in_alpha) { _fade_state_override); } - LVecBase4f alpha_scale(1.0f, 1.0f, 1.0f, in_alpha); + LVecBase4 alpha_scale(1.0f, 1.0f, 1.0f, in_alpha); return _fade_1_new_state->compose (RenderState::make(ColorScaleAttrib::make(alpha_scale))); } @@ -342,7 +342,7 @@ get_fade_1_new_state(float in_alpha) { // during second half of fade. //////////////////////////////////////////////////////////////////// CPT(RenderState) FadeLODNode:: -get_fade_2_old_state(float out_alpha) { +get_fade_2_old_state(PN_stdfloat out_alpha) { if (_fade_2_old_state == (const RenderState *)NULL) { _fade_2_old_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), @@ -351,7 +351,7 @@ get_fade_2_old_state(float out_alpha) { _fade_state_override); } - LVecBase4f alpha_scale(1.0f, 1.0f, 1.0f, out_alpha); + LVecBase4 alpha_scale(1.0f, 1.0f, 1.0f, out_alpha); return _fade_2_old_state->compose (RenderState::make(ColorScaleAttrib::make(alpha_scale))); } diff --git a/panda/src/pgraphnodes/fadeLodNode.h b/panda/src/pgraphnodes/fadeLodNode.h index a9abcd83ef..4a840fa9ab 100755 --- a/panda/src/pgraphnodes/fadeLodNode.h +++ b/panda/src/pgraphnodes/fadeLodNode.h @@ -35,8 +35,8 @@ public: virtual void output(ostream &out) const; PUBLISHED: - INLINE void set_fade_time(float t); - INLINE float get_fade_time() const; + INLINE void set_fade_time(PN_stdfloat t); + INLINE PN_stdfloat get_fade_time() const; void set_fade_bin(const string &name, int draw_order); INLINE const string &get_fade_bin_name() const; @@ -47,12 +47,12 @@ PUBLISHED: private: CPT(RenderState) get_fade_1_old_state(); - CPT(RenderState) get_fade_1_new_state(float in_alpha); - CPT(RenderState) get_fade_2_old_state(float out_alpha); + CPT(RenderState) get_fade_1_new_state(PN_stdfloat in_alpha); + CPT(RenderState) get_fade_2_old_state(PN_stdfloat out_alpha); CPT(RenderState) get_fade_2_new_state(); private: - float _fade_time; + PN_stdfloat _fade_time; string _fade_bin_name; int _fade_bin_draw_order; int _fade_state_override; diff --git a/panda/src/pgraphnodes/fadeLodNodeData.h b/panda/src/pgraphnodes/fadeLodNodeData.h index 4ee59bff1a..b3c6306f4b 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.h +++ b/panda/src/pgraphnodes/fadeLodNodeData.h @@ -32,7 +32,7 @@ public: FM_less_detail, }; FadeMode _fade_mode; - float _fade_start; + PN_stdfloat _fade_start; int _fade_out; int _fade_in; diff --git a/panda/src/pgraphnodes/lodNode.I b/panda/src/pgraphnodes/lodNode.I index 579808ae22..e3d860d089 100644 --- a/panda/src/pgraphnodes/lodNode.I +++ b/panda/src/pgraphnodes/lodNode.I @@ -52,7 +52,7 @@ LODNode(const LODNode ©) : // "out". //////////////////////////////////////////////////////////////////// INLINE void LODNode:: -add_switch(float in, float out) { +add_switch(PN_stdfloat in, PN_stdfloat out) { nassertv(in >= out); CDWriter cdata(_cycler); @@ -71,7 +71,7 @@ add_switch(float in, float out) { // the LODNode. See add_switch(). //////////////////////////////////////////////////////////////////// INLINE bool LODNode:: -set_switch(int index, float in, float out) { +set_switch(int index, PN_stdfloat in, PN_stdfloat out) { nassertr(in >= out, false); CDWriter cdata(_cycler); @@ -124,7 +124,7 @@ get_num_switches() const { // Access: Published // Description: Returns the multiplier for lod distances //////////////////////////////////////////////////////////////////// -INLINE float LODNode:: +INLINE PN_stdfloat LODNode:: get_lod_scale() const { CDReader cdata(_cycler); return cdata->_lod_scale; @@ -137,7 +137,7 @@ get_lod_scale() const { // value means you'll see farther switchs than normal //////////////////////////////////////////////////////////////////// INLINE void LODNode:: -set_lod_scale(float value) { +set_lod_scale(PN_stdfloat value) { CDWriter cdata(_cycler); cdata->_lod_scale = value; } @@ -150,7 +150,7 @@ set_lod_scale(float value) { // range. This should be larger than the "out" distance // of the same range. //////////////////////////////////////////////////////////////////// -INLINE float LODNode:: +INLINE PN_stdfloat LODNode:: get_in(int index) const { CDReader cdata(_cycler); nassertr(index >= 0 && index < (int)cdata->_switch_vector.size(), 0.0); @@ -164,7 +164,7 @@ get_in(int index) const { // range. This should be smaller than the "in" distance // of the same range. //////////////////////////////////////////////////////////////////// -INLINE float LODNode:: +INLINE PN_stdfloat LODNode:: get_out(int index) const { CDReader cdata(_cycler); nassertr(index >= 0 && index < (int)cdata->_switch_vector.size(), 0.0); @@ -234,7 +234,7 @@ clear_force_switch() { // determine the particular LOD that should be chosen. //////////////////////////////////////////////////////////////////// INLINE void LODNode:: -set_center(const LPoint3f ¢er) { +set_center(const LPoint3 ¢er) { CDWriter cdata(_cycler); cdata->_center = center; @@ -250,7 +250,7 @@ set_center(const LPoint3f ¢er) { // that is compared to the camera (in camera space) to // determine the particular LOD that should be chosen. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &LODNode:: +INLINE const LPoint3 &LODNode:: get_center() const { CDReader cdata(_cycler); return cdata->_center; @@ -328,7 +328,7 @@ CData(const LODNode::CData ©) : // Description: //////////////////////////////////////////////////////////////////// INLINE LODNode::Switch:: -Switch(float in, float out) : +Switch(PN_stdfloat in, PN_stdfloat out) : _shown(false), _bounds_seq(UpdateSeq::old()), _verify_ok(false) @@ -341,7 +341,7 @@ Switch(float in, float out) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE float LODNode::Switch:: +INLINE PN_stdfloat LODNode::Switch:: get_in() const { return _in; } @@ -351,7 +351,7 @@ get_in() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -INLINE float LODNode::Switch:: +INLINE PN_stdfloat LODNode::Switch:: get_out() const { return _out; } @@ -362,7 +362,7 @@ get_out() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void LODNode::Switch:: -set_range(float in, float out) { +set_range(PN_stdfloat in, PN_stdfloat out) { _in = in; _out = out; clear_ring_viz(); @@ -375,7 +375,7 @@ set_range(float in, float out) { // range for the LOD. //////////////////////////////////////////////////////////////////// INLINE bool LODNode::Switch:: -in_range(float dist) const { +in_range(PN_stdfloat dist) const { return (dist >= _out && dist < _in); } @@ -388,7 +388,7 @@ in_range(float dist) const { // camera to the object.) //////////////////////////////////////////////////////////////////// INLINE bool LODNode::Switch:: -in_range_2(float dist2) const { +in_range_2(PN_stdfloat dist2) const { return (dist2 >= _out * _out && dist2 < _in * _in); } @@ -398,7 +398,7 @@ in_range_2(float dist2) const { // Description: Scales the switching distances by the indicated factor. //////////////////////////////////////////////////////////////////// INLINE void LODNode::Switch:: -rescale(float factor) { +rescale(PN_stdfloat factor) { _in *= factor; _out *= factor; clear_ring_viz(); @@ -421,7 +421,7 @@ is_shown() const { // color. //////////////////////////////////////////////////////////////////// INLINE void LODNode::Switch:: -show(const Colorf &color) { +show(const LColor &color) { _shown = true; _show_color = color; } @@ -491,8 +491,8 @@ get_viz_model_state() const { //////////////////////////////////////////////////////////////////// INLINE void LODNode::Switch:: write_datagram(Datagram &destination) const { - destination.add_float32(_in); - destination.add_float32(_out); + destination.add_stdfloat(_in); + destination.add_stdfloat(_out); } //////////////////////////////////////////////////////////////////// @@ -503,8 +503,8 @@ write_datagram(Datagram &destination) const { //////////////////////////////////////////////////////////////////// INLINE void LODNode::Switch:: read_datagram(DatagramIterator &source) { - _in = source.get_float32(); - _out = source.get_float32(); + _in = source.get_stdfloat(); + _out = source.get_stdfloat(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index 35a7b02c32..4d0b551c25 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -113,15 +113,15 @@ safe_to_combine_children() const { // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void LODNode:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { CDWriter cdata(_cycler); cdata->_center = cdata->_center * mat; // We'll take just the length of the y axis as the matrix's scale. - LVector3f y; + LVector3 y; mat.get_row3(y, 1); - float factor = y.length(); + PN_stdfloat factor = y.length(); SwitchVector::iterator si; for (si = cdata->_switch_vector.begin(); @@ -167,8 +167,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { CDReader cdata(_cycler); CPT(TransformState) rel_transform = get_rel_transform(trav, data); - LPoint3f center = cdata->_center * rel_transform->get_mat(); - float dist2 = center.dot(center); + LPoint3 center = cdata->_center * rel_transform->get_mat(); + PN_stdfloat dist2 = center.dot(center); int num_children = min(get_num_children(), (int)cdata->_switch_vector.size()); for (int index = 0; index < num_children; ++index) { @@ -274,7 +274,7 @@ show_switch(int index) { // behavior. //////////////////////////////////////////////////////////////////// void LODNode:: -show_switch(int index, const Colorf &color) { +show_switch(int index, const LColor &color) { CDWriter cdata(_cycler); do_show_switch(cdata, index, color); mark_internal_bounds_stale(); @@ -336,7 +336,7 @@ verify_child_bounds() const { CDReader cdata(_cycler); for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { - float suggested_radius; + PN_stdfloat suggested_radius; if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; pgraph_cat.warning() @@ -372,8 +372,8 @@ compute_child(CullTraverser *trav, CullTraverserData &data) { } CPT(TransformState) rel_transform = get_rel_transform(trav, data); - LPoint3f center = cdata->_center * rel_transform->get_mat(); - float dist2 = center.dot(center); + LPoint3 center = cdata->_center * rel_transform->get_mat(); + PN_stdfloat dist2 = center.dot(center); for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { if (cdata->_switch_vector[index].in_range_2(dist2*cdata->_lod_scale)) { @@ -410,13 +410,13 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { CDReader cdata(_cycler); CPT(TransformState) rel_transform = get_rel_transform(trav, data); - LPoint3f center = cdata->_center * rel_transform->get_mat(); - float dist2 = center.dot(center); + LPoint3 center = cdata->_center * rel_transform->get_mat(); + PN_stdfloat dist2 = center.dot(center); // Now orient the disk(s) in camera space such that their origin is // at center, and the (0, 0, 0) point in camera space is on the disk. - LMatrix4f mat; - look_at(mat, -center, LVector3f(0.0f, 0.0f, 1.0f)); + LMatrix4 mat; + look_at(mat, -center, LVector3(0.0f, 0.0f, 1.0f)); mat.set_row(3, center); CPT(TransformState) viz_transform = rel_transform->invert_compose(TransformState::make_mat(mat)); @@ -552,7 +552,7 @@ get_rel_transform(CullTraverser *trav, CullTraverserData &data) { // Description: The private implementation of show_switch(). //////////////////////////////////////////////////////////////////// void LODNode:: -do_show_switch(LODNode::CData *cdata, int index, const Colorf &color) { +do_show_switch(LODNode::CData *cdata, int index, const LColor &color) { nassertv(index >= 0 && index < (int)cdata->_switch_vector.size()); if (!cdata->_switch_vector[index].is_shown()) { @@ -588,7 +588,7 @@ do_hide_switch(LODNode::CData *cdata, int index) { //////////////////////////////////////////////////////////////////// bool LODNode:: do_verify_child_bounds(const LODNode::CData *cdata, int index, - float &suggested_radius) const { + PN_stdfloat &suggested_radius) const { suggested_radius = 0.0f; if (index < get_num_children()) { @@ -646,8 +646,8 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, // This child's radius partially encloses its (loose) bounding // volume. We have to look closer to determine whether it, in // fact, fully encloses its geometry. - LPoint3f min_point(0.0f, 0.0f, 0.0f); - LPoint3f max_point(0.0f, 0.0f, 0.0f); + LPoint3 min_point(0.0f, 0.0f, 0.0f); + LPoint3 max_point(0.0f, 0.0f, 0.0f); bool found_any = false; child->calc_tight_bounds(min_point, max_point, found_any, @@ -662,8 +662,8 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, // that fits within this box. All we can say about this sphere // is that it should definitely fit entirely within a bounding // sphere that contains all the points of the child. - LPoint3f box_center = (min_point + max_point) / 2.0f; - float box_radius = min(min(max_point[0] - box_center[0], + LPoint3 box_center = (min_point + max_point) / 2.0f; + PN_stdfloat box_radius = min(min(max_point[0] - box_center[0], max_point[1] - box_center[1]), max_point[2] - box_center[2]); @@ -711,7 +711,7 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { if (seq != cdata->_bounds_seq) { // Time to validate the children again. for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { - float suggested_radius; + PN_stdfloat suggested_radius; if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; ostringstream strm; @@ -734,17 +734,17 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { // Description: Returns a default color appropriate for showing the // indicated level. //////////////////////////////////////////////////////////////////// -const Colorf &LODNode:: +const LColor &LODNode:: get_default_show_color(int index) { - static Colorf default_colors[] = { - Colorf(1.0f, 0.0f, 0.0f, 0.7f), - Colorf(0.0f, 1.0f, 0.0f, 0.7f), - Colorf(0.0f, 0.0f, 1.0f, 0.7f), - Colorf(0.0f, 1.0f, 1.0f, 0.7f), - Colorf(1.0f, 0.0f, 1.0f, 0.7f), - Colorf(1.0f, 1.0f, 0.0f, 0.7f), + static LColor default_colors[] = { + LColor(1.0f, 0.0f, 0.0f, 0.7f), + LColor(0.0f, 1.0f, 0.0f, 0.7f), + LColor(0.0f, 0.0f, 1.0f, 0.7f), + LColor(0.0f, 1.0f, 1.0f, 0.7f), + LColor(1.0f, 0.0f, 1.0f, 0.7f), + LColor(1.0f, 1.0f, 0.0f, 0.7f), }; - static const int num_default_colors = sizeof(default_colors) / sizeof(Colorf); + static const int num_default_colors = sizeof(default_colors) / sizeof(LColor); return default_colors[index % num_default_colors]; } @@ -896,7 +896,7 @@ compute_ring_viz() { // There are also two more triangle strips, one for the outer edge, // and one for the inner edge. - static const float edge_ratio = 0.1; // ratio of edge height to diameter. + static const PN_stdfloat edge_ratio = 0.1; // ratio of edge height to diameter. const GeomVertexFormat *format = GeomVertexFormat::get_v3n3cp(); PT(GeomVertexData) vdata = new GeomVertexData("LOD_ring", format, Geom::UH_static); @@ -910,53 +910,53 @@ compute_ring_viz() { int ri, si; for (ri = 0; ri <= num_rings; ++ri) { // r is in the range [0.0, 1.0]. - float r = (float)ri / (float)num_rings; + PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; // d is in the range [_out, _in]. - float d = r * (_in - _out) + _out; + PN_stdfloat d = r * (_in - _out) + _out; for (si = 0; si < num_slices; ++si) { // s is in the range [0.0, 1.0). - float s = (float)si / (float)num_slices; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; // t is in the range [0.0, 2pi). - float t = MathNumbers::pi_f * 2.0f * s; + PN_stdfloat t = MathNumbers::pi * 2.0f * s; - float x = cosf(t); - float y = sinf(t); - vertex.add_data3f(x * d, y * d, 0.0f); - normal.add_data3f(0.0f, 0.0f, 1.0f); - color.add_data4f(_show_color); + PN_stdfloat x = ccos(t); + PN_stdfloat y = csin(t); + vertex.add_data3(x * d, y * d, 0.0f); + normal.add_data3(0.0f, 0.0f, 1.0f); + color.add_data4(_show_color); } } // Next, the vertices for the inner and outer edges. for (ri = 0; ri <= 1; ++ri) { - float r = (float)ri; - float d = r * (_in - _out) + _out; + PN_stdfloat r = (PN_stdfloat)ri; + PN_stdfloat d = r * (_in - _out) + _out; for (si = 0; si < num_slices; ++si) { - float s = (float)si / (float)num_slices; - float t = MathNumbers::pi_f * 2.0f * s; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; + PN_stdfloat t = MathNumbers::pi * 2.0f * s; - float x = cosf(t); - float y = sinf(t); + PN_stdfloat x = ccos(t); + PN_stdfloat y = csin(t); - vertex.add_data3f(x * d, y * d, 0.5f * edge_ratio * d); - normal.add_data3f(x, y, 0.0f); - color.add_data4f(_show_color); + vertex.add_data3(x * d, y * d, 0.5f * edge_ratio * d); + normal.add_data3(x, y, 0.0f); + color.add_data4(_show_color); } for (si = 0; si < num_slices; ++si) { - float s = (float)si / (float)num_slices; - float t = MathNumbers::pi_f * 2.0f * s; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; + PN_stdfloat t = MathNumbers::pi * 2.0f * s; - float x = cosf(t); - float y = sinf(t); + PN_stdfloat x = ccos(t); + PN_stdfloat y = csin(t); - vertex.add_data3f(x * d, y * d, -0.5f * edge_ratio * d); - normal.add_data3f(x, y, 0.0f); - color.add_data4f(_show_color); + vertex.add_data3(x * d, y * d, -0.5f * edge_ratio * d); + normal.add_data3(x, y, 0.0f); + color.add_data4(_show_color); } } @@ -1037,23 +1037,23 @@ compute_spindle_viz() { int ri, si; for (ri = 0; ri <= num_rings; ++ri) { // r is in the range [0.0, 1.0]. - float r = (float)ri / (float)num_rings; + PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; // z is in the range [100.0, -100.0] - float z = 100.0f - r * 200.0f; + PN_stdfloat z = 100.0f - r * 200.0f; for (si = 0; si < num_slices; ++si) { // s is in the range [0.0, 1.0). - float s = (float)si / (float)num_slices; + PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; // t is in the range [0.0, 2pi). - float t = MathNumbers::pi_f * 2.0f * s; + PN_stdfloat t = MathNumbers::pi * 2.0f * s; - float x = cosf(t); - float y = sinf(t); - vertex.add_data3f(x, y, z); - normal.add_data3f(x, y, 0.0f); - color.add_data4f(_show_color); + PN_stdfloat x = ccos(t); + PN_stdfloat y = csin(t); + vertex.add_data3(x, y, z); + normal.add_data3(x, y, 0.0f); + color.add_data4(_show_color); } } diff --git a/panda/src/pgraphnodes/lodNode.h b/panda/src/pgraphnodes/lodNode.h index 044830dc5c..9033e1a221 100644 --- a/panda/src/pgraphnodes/lodNode.h +++ b/panda/src/pgraphnodes/lodNode.h @@ -40,7 +40,7 @@ public: virtual PandaNode *make_copy() const; virtual bool safe_to_combine() const; virtual bool safe_to_combine_children() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual void output(ostream &out) const; @@ -53,14 +53,14 @@ PUBLISHED: // and switches "out" at the close distance. Thus, "in" should be // larger than "out". - INLINE void add_switch(float in, float out); - INLINE bool set_switch(int index, float in, float out); + INLINE void add_switch(PN_stdfloat in, PN_stdfloat out); + INLINE bool set_switch(int index, PN_stdfloat in, PN_stdfloat out); INLINE void clear_switches(); INLINE int get_num_switches() const; - INLINE float get_in(int index) const; + INLINE PN_stdfloat get_in(int index) const; MAKE_SEQ(get_ins, get_num_switches, get_in); - INLINE float get_out(int index) const; + INLINE PN_stdfloat get_out(int index) const; MAKE_SEQ(get_outs, get_num_switches, get_out); INLINE int get_lowest_switch() const; @@ -71,15 +71,15 @@ PUBLISHED: //for performance tuning, increasing this value should improve performance //at the cost of model quality - INLINE void set_lod_scale(float value); - INLINE float get_lod_scale() const; + INLINE void set_lod_scale(PN_stdfloat value); + INLINE PN_stdfloat get_lod_scale() const; - INLINE void set_center(const LPoint3f ¢er); - INLINE const LPoint3f &get_center() const; + INLINE void set_center(const LPoint3 ¢er); + INLINE const LPoint3 &get_center() const; void show_switch(int index); - void show_switch(int index, const Colorf &color); + void show_switch(int index, const LColor &color); void hide_switch(int index); void show_all_switches(); void hide_all_switches(); @@ -102,29 +102,29 @@ protected: private: class CData; - void do_show_switch(CData *cdata, int index, const Colorf &color); + void do_show_switch(CData *cdata, int index, const LColor &color); void do_hide_switch(CData *cdata, int index); bool do_verify_child_bounds(const CData *cdata, int index, - float &suggested_radius) const; + PN_stdfloat &suggested_radius) const; void do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data); - static const Colorf &get_default_show_color(int index); + static const LColor &get_default_show_color(int index); protected: class Switch { public: - INLINE Switch(float in, float out); - INLINE float get_in() const; - INLINE float get_out() const; + INLINE Switch(PN_stdfloat in, PN_stdfloat out); + INLINE PN_stdfloat get_in() const; + INLINE PN_stdfloat get_out() const; - INLINE void set_range(float in, float out); - INLINE bool in_range(float dist) const; - INLINE bool in_range_2(float dist2) const; + INLINE void set_range(PN_stdfloat in, PN_stdfloat out); + INLINE bool in_range(PN_stdfloat dist) const; + INLINE bool in_range_2(PN_stdfloat dist2) const; - INLINE void rescale(float factor); + INLINE void rescale(PN_stdfloat factor); INLINE bool is_shown() const; - INLINE void show(const Colorf &color); + INLINE void show(const LColor &color); INLINE void hide(); INLINE PandaNode *get_ring_viz() const; @@ -142,10 +142,10 @@ protected: void compute_viz_model_state(); private: - float _in; - float _out; + PN_stdfloat _in; + PN_stdfloat _out; bool _shown; - Colorf _show_color; + LColor _show_color; PT(PandaNode) _ring_viz; PT(PandaNode) _spindle_viz; CPT(RenderState) _viz_model_state; @@ -171,7 +171,7 @@ private: return LODNode::get_class_type(); } - LPoint3f _center; + LPoint3 _center; SwitchVector _switch_vector; size_t _lowest, _highest; UpdateSeq _bounds_seq; @@ -179,7 +179,7 @@ private: bool _got_force_switch; int _force_switch; int _num_shown; - float _lod_scale; + PN_stdfloat _lod_scale; }; PipelineCycler _cycler; diff --git a/panda/src/pgraphnodes/pointLight.I b/panda/src/pgraphnodes/pointLight.I index cbf51b6bca..deb1cabbfe 100644 --- a/panda/src/pgraphnodes/pointLight.I +++ b/panda/src/pgraphnodes/pointLight.I @@ -1,5 +1,5 @@ // Filename: pointLight.I -// Created by: mike (04Feb99) +// Created by: mike (04eb99) // //////////////////////////////////////////////////////////////////// // @@ -45,7 +45,7 @@ CData(const PointLight::CData ©) : // Description: Returns the color of specular highlights generated by // the light. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &PointLight:: +INLINE const LColor &PointLight:: get_specular_color() const { CDReader cdata(_cycler); return cdata->_specular_color; @@ -58,7 +58,7 @@ get_specular_color() const { // the light. //////////////////////////////////////////////////////////////////// INLINE void PointLight:: -set_specular_color(const Colorf &color) { +set_specular_color(const LColor &color) { CDWriter cdata(_cycler); cdata->_specular_color = color; } @@ -71,7 +71,7 @@ set_specular_color(const Colorf &color) { // and quadratic terms based on the distance from the // point to the vertex. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &PointLight:: +INLINE const LVecBase3 &PointLight:: get_attenuation() const { CDReader cdata(_cycler); return cdata->_attenuation; @@ -86,7 +86,7 @@ get_attenuation() const { // point to the vertex. //////////////////////////////////////////////////////////////////// INLINE void PointLight:: -set_attenuation(const LVecBase3f &attenuation) { +set_attenuation(const LVecBase3 &attenuation) { CDWriter cdata(_cycler); cdata->_attenuation = attenuation; } @@ -98,7 +98,7 @@ set_attenuation(const LVecBase3f &attenuation) { // located. This is local to the coordinate space in // which the light is assigned. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &PointLight:: +INLINE const LPoint3 &PointLight:: get_point() const { CDReader cdata(_cycler); return cdata->_point; @@ -110,7 +110,7 @@ get_point() const { // Description: Sets the point in space at which the light is located. //////////////////////////////////////////////////////////////////// INLINE void PointLight:: -set_point(const LPoint3f &point) { +set_point(const LPoint3 &point) { CDWriter cdata(_cycler); cdata->_point = point; mark_viz_stale(); diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 86e26eaf87..5ac0c8885c 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -143,7 +143,7 @@ make_copy() const { // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void PointLight:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightLensNode::xform(mat); CDWriter cdata(_cycler); cdata->_point = cdata->_point * mat; @@ -184,10 +184,10 @@ write(ostream &out, int indent_level) const { // ambient light). //////////////////////////////////////////////////////////////////// bool PointLight:: -get_vector_to_light(LVector3f &result, const LPoint3f &from_object_point, - const LMatrix4f &to_object_space) { +get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, + const LMatrix4 &to_object_space) { CDReader cdata(_cycler); - LPoint3f point = cdata->_point * to_object_space; + LPoint3 point = cdata->_point * to_object_space; result = point - from_object_point; return true; diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index f796197adf..64c71e494e 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -33,22 +33,22 @@ protected: public: virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void write(ostream &out, int indent_level) const; - virtual bool get_vector_to_light(LVector3f &result, - const LPoint3f &from_object_point, - const LMatrix4f &to_object_space); + virtual bool get_vector_to_light(LVector3 &result, + const LPoint3 &from_object_point, + const LMatrix4 &to_object_space); PUBLISHED: - INLINE const Colorf &get_specular_color() const; - INLINE void set_specular_color(const Colorf &color); + INLINE const LColor &get_specular_color() const; + INLINE void set_specular_color(const LColor &color); - INLINE const LVecBase3f &get_attenuation() const; - INLINE void set_attenuation(const LVecBase3f &attenuation); + INLINE const LVecBase3 &get_attenuation() const; + INLINE void set_attenuation(const LVecBase3 &attenuation); - INLINE const LPoint3f &get_point() const; - INLINE void set_point(const LPoint3f &point); + INLINE const LPoint3 &get_point() const; + INLINE void set_point(const LPoint3 &point); virtual int get_class_priority() const; @@ -69,9 +69,9 @@ private: return PointLight::get_class_type(); } - Colorf _specular_color; - LVecBase3f _attenuation; - LPoint3f _point; + LColor _specular_color; + LVecBase3 _attenuation; + LPoint3 _point; }; PipelineCycler _cycler; diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.I b/panda/src/pgraphnodes/sceneGraphAnalyzer.I index 15fa3e09bb..9275fd4ea3 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.I +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.I @@ -292,7 +292,7 @@ get_num_short_normals() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -float SceneGraphAnalyzer:: +PN_stdfloat SceneGraphAnalyzer:: get_total_normal_length() const { return _total_normal_length; } diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index 6ccf889418..80dc69fd4e 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -81,6 +81,7 @@ clear() { _prim_data_size = 0; _num_vertices = 0; + _num_vertices_64 = 0; _num_normals = 0; _num_colors = 0; _num_texcoords = 0; @@ -141,16 +142,25 @@ write(ostream &out, int indent_level) const { << " GeomVertexFormats, appear on " << _num_geom_nodes << " GeomNodes.\n"; - indent(out, indent_level) - << _num_vertices << " vertices, " << _num_normals << " normals, " - << _num_colors << " colors, " - << _num_texcoords << " texture coordinates.\n"; + indent(out, indent_level); + if (_num_vertices_64 != 0) { + out << _num_vertices_64 << " 64-bit vertices, "; + if (_num_vertices != _num_vertices_64) { + out << _num_vertices - _num_vertices_64 << " 32-bit vertices, "; + } + } else { + out << _num_vertices << " vertices, "; + } + + out << _num_normals << " normals, " + << _num_colors << " colors, " + << _num_texcoords << " texture coordinates.\n"; if (_num_long_normals != 0 || _num_short_normals != 0) { indent(out, indent_level) << _num_long_normals << " normals are too long, " << _num_short_normals << " are too short. Average normal length is " - << _total_normal_length / (float)_num_normals << "\n"; + << _total_normal_length / (PN_stdfloat)_num_normals << "\n"; } indent(out, indent_level) @@ -386,10 +396,15 @@ collect_statistics(const Geom *geom) { ++dup_count; int num_rows = vdata->get_num_rows(); - if (vdata->has_column(InternalName::get_vertex())) { + const GeomVertexFormat *format = vdata->get_format(); + if (format->has_column(InternalName::get_vertex())) { _num_vertices += num_rows; + const GeomVertexColumn *vcolumn = format->get_column(InternalName::get_vertex()); + if (vcolumn->get_numeric_type() == GeomEnums::NT_float64) { + _num_vertices_64 += num_rows; + } } - if (vdata->has_column(InternalName::get_normal())) { + if (format->has_column(InternalName::get_normal())) { _num_normals += num_rows; GeomVertexReader rnormal(vdata, InternalName::get_normal()); while (!rnormal.is_at_end()) { @@ -405,10 +420,9 @@ collect_statistics(const Geom *geom) { _total_normal_length += length; } } - if (vdata->has_column(InternalName::get_color())) { + if (format->has_column(InternalName::get_color())) { _num_colors += num_rows; } - const GeomVertexFormat *format = vdata->get_format(); int num_texcoords = format->get_num_texcoords(); _num_texcoords += num_rows * num_texcoords; diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.h b/panda/src/pgraphnodes/sceneGraphAnalyzer.h index 980e5e0d60..6da5e459bf 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.h +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.h @@ -85,7 +85,7 @@ PUBLISHED: INLINE int get_num_long_normals() const; INLINE int get_num_short_normals() const; - INLINE float get_total_normal_length() const; + INLINE PN_stdfloat get_total_normal_length() const; private: void collect_statistics(PandaNode *node, bool under_instance); @@ -134,6 +134,7 @@ private: size_t _prim_data_size; int _num_vertices; + int _num_vertices_64; int _num_normals; int _num_colors; int _num_texcoords; @@ -151,7 +152,7 @@ private: int _num_long_normals; int _num_short_normals; - float _total_normal_length; + PN_stdfloat _total_normal_length; }; #include "sceneGraphAnalyzer.I" diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 7830602f88..bced4ff5b2 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -350,7 +350,7 @@ analyze_renderstate(const RenderState *rs) { if (_lighting && (_alights.size() > 0)) { if (_material->has_ambient()) { - Colorf a = _material->get_ambient(); + LColor a = _material->get_ambient(); if ((a[0]!=0.0)||(a[1]!=0.0)||(a[2]!=0.0)) { _have_ambient = true; } @@ -361,7 +361,7 @@ analyze_renderstate(const RenderState *rs) { if (_lighting && (_dlights.size() + _plights.size() + _slights.size())) { if (_material->has_diffuse()) { - Colorf d = _material->get_diffuse(); + LColor d = _material->get_diffuse(); if ((d[0]!=0.0)||(d[1]!=0.0)||(d[2]!=0.0)) { _have_diffuse = true; } @@ -371,7 +371,7 @@ analyze_renderstate(const RenderState *rs) { } if (_lighting && (_material->has_emission())) { - Colorf e = _material->get_emission(); + LColor e = _material->get_emission(); if ((e[0]!=0.0)||(e[1]!=0.0)||(e[2]!=0.0)) { _have_emission = true; } @@ -379,7 +379,7 @@ analyze_renderstate(const RenderState *rs) { if (_lighting && (_dlights.size() + _plights.size() + _slights.size())) { if (_material->has_specular()) { - Colorf s = _material->get_specular(); + LColor s = _material->get_specular(); if ((s[0]!=0.0)||(s[1]!=0.0)||(s[2]!=0.0)) { _have_specular = true; } @@ -1147,8 +1147,8 @@ synthesize_shader(const RenderState *rs) { switch (light_ramp->get_mode()) { case LightRampAttrib::LRT_single_threshold: { - float t = light_ramp->get_threshold(0); - float l0 = light_ramp->get_level(0); + PN_stdfloat t = light_ramp->get_threshold(0); + PN_stdfloat l0 = light_ramp->get_level(0); text << "\t // Single-threshold light ramp\n"; text << "\t float lr_in = dot(tot_diffuse.rgb, float3(0.33,0.34,0.33));\n"; text << "\t float lr_scale = (lr_in < " << t << ") ? 0.0 : (" << l0 << "/lr_in);\n"; @@ -1157,11 +1157,11 @@ synthesize_shader(const RenderState *rs) { } case LightRampAttrib::LRT_double_threshold: { - float t0 = light_ramp->get_threshold(0); - float t1 = light_ramp->get_threshold(1); - float l0 = light_ramp->get_level(0); - float l1 = light_ramp->get_level(1); - float l2 = light_ramp->get_level(2); + PN_stdfloat t0 = light_ramp->get_threshold(0); + PN_stdfloat t1 = light_ramp->get_threshold(1); + PN_stdfloat l0 = light_ramp->get_level(0); + PN_stdfloat l1 = light_ramp->get_level(1); + PN_stdfloat l2 = light_ramp->get_level(2); text << "\t // Double-threshold light ramp\n"; text << "\t float lr_in = dot(tot_diffuse.rgb, float3(0.33,0.34,0.33));\n"; text << "\t float lr_out = " << l0 << "\n"; @@ -1170,6 +1170,8 @@ synthesize_shader(const RenderState *rs) { text << "\t tot_diffuse = tot_diffuse * (lr_out / lr_in);\n"; break; } + default: + break; } } text << "\t // Begin view-space light summation\n"; @@ -1290,7 +1292,7 @@ synthesize_shader(const RenderState *rs) { text << "\t result.rgb = lerp(result, tex" << i << ", tex" << i << ".a).rgb;\n"; break; case TextureStage::M_blend: { - LVecBase4f c = stage->get_color(); + LVecBase4 c = stage->get_color(); text << "\t result.rgb = lerp(result, tex" << i << " * float4(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << "), tex" << i << ".r).rgb;\n"; break; } @@ -1349,6 +1351,8 @@ synthesize_shader(const RenderState *rs) { case RenderAttrib::M_greater: text<<"\t if (result.a <= "<get_color(); + LVecBase4 c = stage->get_color(); csource << "float4(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << ")"; break; } case TextureStage::CS_primary_color: @@ -1551,6 +1555,8 @@ combine_source_as_string(CPT(TextureStage) stage, short num, bool alpha, bool si case TextureStage::CS_last_saved_result: csource << "last_saved_result"; break; + case TextureStage::CS_undefined: + break; } if (c_op == TextureStage::CO_src_color || c_op == TextureStage::CO_one_minus_src_color) { if (single_value) { diff --git a/panda/src/pgraphnodes/spotlight.I b/panda/src/pgraphnodes/spotlight.I index 8bf13ece75..3696f9be5d 100644 --- a/panda/src/pgraphnodes/spotlight.I +++ b/panda/src/pgraphnodes/spotlight.I @@ -1,5 +1,5 @@ // Filename: spotlight.I -// Created by: mike (04Feb99) +// Created by: mike (04eb99) // //////////////////////////////////////////////////////////////////// // @@ -46,7 +46,7 @@ CData(const Spotlight::CData ©) : // light falloff from the center of the spotlight. See // set_exponent(). //////////////////////////////////////////////////////////////////// -INLINE float Spotlight:: +INLINE PN_stdfloat Spotlight:: get_exponent() const { CDReader cdata(_cycler); return cdata->_exponent; @@ -64,7 +64,7 @@ get_exponent() const { // source, regardless of the field-of-view of the lens. //////////////////////////////////////////////////////////////////// INLINE void Spotlight:: -set_exponent(float exponent) { +set_exponent(PN_stdfloat exponent) { CDWriter cdata(_cycler); cdata->_exponent = exponent; } @@ -75,7 +75,7 @@ set_exponent(float exponent) { // Description: Returns the color of specular highlights generated by // the light. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &Spotlight:: +INLINE const LColor &Spotlight:: get_specular_color() const { CDReader cdata(_cycler); return cdata->_specular_color; @@ -88,7 +88,7 @@ get_specular_color() const { // the light. //////////////////////////////////////////////////////////////////// INLINE void Spotlight:: -set_specular_color(const Colorf &color) { +set_specular_color(const LColor &color) { CDWriter cdata(_cycler); cdata->_specular_color = color; } @@ -101,7 +101,7 @@ set_specular_color(const Colorf &color) { // and quadratic terms based on the distance from the // point to the vertex. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &Spotlight:: +INLINE const LVecBase3 &Spotlight:: get_attenuation() const { CDReader cdata(_cycler); return cdata->_attenuation; @@ -116,7 +116,7 @@ get_attenuation() const { // point to the vertex. //////////////////////////////////////////////////////////////////// INLINE void Spotlight:: -set_attenuation(const LVecBase3f &attenuation) { +set_attenuation(const LVecBase3 &attenuation) { CDWriter cdata(_cycler); cdata->_attenuation = attenuation; } diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index f7a61a8e8c..d44b944ab8 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -43,7 +43,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void Spotlight::CData:: write_datagram(BamWriter *, Datagram &dg) const { - dg.add_float32(_exponent); + dg.add_stdfloat(_exponent); _specular_color.write_datagram(dg); _attenuation.write_datagram(dg); } @@ -57,7 +57,7 @@ write_datagram(BamWriter *, Datagram &dg) const { //////////////////////////////////////////////////////////////////// void Spotlight::CData:: fillin(DatagramIterator &scan, BamReader *) { - _exponent = scan.get_float32(); + _exponent = scan.get_stdfloat(); _specular_color.read_datagram(scan); _attenuation.read_datagram(scan); } @@ -109,7 +109,7 @@ make_copy() const { // most kinds of PandaNodes, this does nothing. //////////////////////////////////////////////////////////////////// void Spotlight:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightLensNode::xform(mat); mark_viz_stale(); } @@ -155,8 +155,8 @@ write(ostream &out, int indent_level) const { // ambient light). //////////////////////////////////////////////////////////////////// bool Spotlight:: -get_vector_to_light(LVector3f &result, const LPoint3f &from_object_point, - const LMatrix4f &to_object_space) { +get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, + const LMatrix4 &to_object_space) { return false; } @@ -179,7 +179,7 @@ get_vector_to_light(LVector3f &result, const LPoint3f &from_object_point, // respectively. //////////////////////////////////////////////////////////////////// PT(Texture) Spotlight:: -make_spot(int pixel_width, float full_radius, Colorf &fg, Colorf &bg) { +make_spot(int pixel_width, PN_stdfloat full_radius, LColor &fg, LColor &bg) { int num_channels; if (fg[0] == fg[1] && fg[1] == fg[2] && bg[0] == bg[1] && bg[1] == bg[2]) { diff --git a/panda/src/pgraphnodes/spotlight.h b/panda/src/pgraphnodes/spotlight.h index 18a393f7a1..0cc9b65509 100644 --- a/panda/src/pgraphnodes/spotlight.h +++ b/panda/src/pgraphnodes/spotlight.h @@ -43,27 +43,27 @@ protected: public: virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void write(ostream &out, int indent_level) const; - virtual bool get_vector_to_light(LVector3f &result, - const LPoint3f &from_object_point, - const LMatrix4f &to_object_space); + virtual bool get_vector_to_light(LVector3 &result, + const LPoint3 &from_object_point, + const LMatrix4 &to_object_space); PUBLISHED: - INLINE float get_exponent() const; - INLINE void set_exponent(float exponent); + INLINE PN_stdfloat get_exponent() const; + INLINE void set_exponent(PN_stdfloat exponent); - INLINE const Colorf &get_specular_color() const; - INLINE void set_specular_color(const Colorf &color); + INLINE const LColor &get_specular_color() const; + INLINE void set_specular_color(const LColor &color); - INLINE const LVecBase3f &get_attenuation() const; - INLINE void set_attenuation(const LVecBase3f &attenuation); + INLINE const LVecBase3 &get_attenuation() const; + INLINE void set_attenuation(const LVecBase3 &attenuation); virtual int get_class_priority() const; - static PT(Texture) make_spot(int pixel_width, float full_radius, - Colorf &fg, Colorf &bg); + static PT(Texture) make_spot(int pixel_width, PN_stdfloat full_radius, + LColor &fg, LColor &bg); public: virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light, @@ -88,9 +88,9 @@ private: return Spotlight::get_class_type(); } - float _exponent; - Colorf _specular_color; - LVecBase3f _attenuation; + PN_stdfloat _exponent; + LColor _specular_color; + LVecBase3 _attenuation; }; PipelineCycler _cycler; diff --git a/panda/src/pgraphnodes/uvScrollNode.I b/panda/src/pgraphnodes/uvScrollNode.I index ddf8e228ab..f3be8c8a02 100644 --- a/panda/src/pgraphnodes/uvScrollNode.I +++ b/panda/src/pgraphnodes/uvScrollNode.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE UvScrollNode:: -UvScrollNode(const string &name, float u_speed, float v_speed, float r_speed) : +UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat r_speed) : PandaNode(name), _u_speed(u_speed), _v_speed(v_speed), @@ -52,7 +52,7 @@ UvScrollNode(const string &name) : // Description: //////////////////////////////////////////////////////////////////// INLINE void UvScrollNode:: -set_u_speed(float u_speed) { +set_u_speed(PN_stdfloat u_speed) { _u_speed = u_speed; } @@ -62,7 +62,7 @@ set_u_speed(float u_speed) { // Description: //////////////////////////////////////////////////////////////////// INLINE void UvScrollNode:: -set_v_speed(float v_speed) { +set_v_speed(PN_stdfloat v_speed) { _v_speed = v_speed; } @@ -72,7 +72,7 @@ set_v_speed(float v_speed) { // Description: //////////////////////////////////////////////////////////////////// INLINE void UvScrollNode:: -set_r_speed(float r_speed) { +set_r_speed(PN_stdfloat r_speed) { _r_speed = r_speed; } @@ -81,7 +81,7 @@ set_r_speed(float r_speed) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float UvScrollNode:: +INLINE PN_stdfloat UvScrollNode:: get_u_speed() const { return _u_speed; } @@ -91,7 +91,7 @@ get_u_speed() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float UvScrollNode:: +INLINE PN_stdfloat UvScrollNode:: get_v_speed() const { return _v_speed; } @@ -101,7 +101,7 @@ get_v_speed() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float UvScrollNode:: +INLINE PN_stdfloat UvScrollNode:: get_r_speed() const { return _r_speed; } diff --git a/panda/src/pgraphnodes/uvScrollNode.cxx b/panda/src/pgraphnodes/uvScrollNode.cxx index b7a5f29eef..651f67fd6e 100644 --- a/panda/src/pgraphnodes/uvScrollNode.cxx +++ b/panda/src/pgraphnodes/uvScrollNode.cxx @@ -59,9 +59,9 @@ register_with_read_factory() { void UvScrollNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); - dg.add_float32(_u_speed); - dg.add_float32(_v_speed); - dg.add_float32(_r_speed); + dg.add_stdfloat(_u_speed); + dg.add_stdfloat(_v_speed); + dg.add_stdfloat(_r_speed); } //////////////////////////////////////////////////////////////////// @@ -95,10 +95,10 @@ void UvScrollNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); - _u_speed = scan.get_float32(); - _v_speed = scan.get_float32(); + _u_speed = scan.get_stdfloat(); + _v_speed = scan.get_stdfloat(); if(manager->get_file_minor_ver() >=22) { - _r_speed = scan.get_float32(); + _r_speed = scan.get_stdfloat(); } } @@ -132,8 +132,8 @@ bool UvScrollNode:: cull_callback(CullTraverser * trav, CullTraverserData &data) { double elapsed = ClockObject::get_global_clock()->get_frame_time() - _start_time; CPT(TransformState) ts = TransformState::make_pos_hpr( - LVecBase3f(cmod(elapsed*_u_speed,1.0)/1.0, cmod(elapsed*_v_speed,1.0)/1.0,0), - LVecBase3f((cmod(elapsed*_r_speed,1.0)/1.0)*360,0,0)); + LVecBase3(cmod(elapsed*_u_speed,1.0)/1.0, cmod(elapsed*_v_speed,1.0)/1.0,0), + LVecBase3((cmod(elapsed*_r_speed,1.0)/1.0)*360,0,0)); CPT(RenderAttrib) tm = TexMatrixAttrib::make(TextureStage::get_default(), ts); CPT(RenderState) rs = RenderState::make_empty()->set_attrib(tm); diff --git a/panda/src/pgraphnodes/uvScrollNode.h b/panda/src/pgraphnodes/uvScrollNode.h index 8a0cfe2508..b756ae709a 100644 --- a/panda/src/pgraphnodes/uvScrollNode.h +++ b/panda/src/pgraphnodes/uvScrollNode.h @@ -28,7 +28,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode { PUBLISHED: - INLINE UvScrollNode(const string &name, float u_speed, float v_speed, float r_speed); + INLINE UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat r_speed); INLINE UvScrollNode(const string &name); protected: @@ -41,17 +41,17 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); PUBLISHED: - INLINE void set_u_speed(float u_speed); - INLINE void set_v_speed(float v_speed); - INLINE void set_r_speed(float r_speed); - INLINE float get_u_speed() const; - INLINE float get_v_speed() const; - INLINE float get_r_speed() const; + INLINE void set_u_speed(PN_stdfloat u_speed); + INLINE void set_v_speed(PN_stdfloat v_speed); + INLINE void set_r_speed(PN_stdfloat r_speed); + INLINE PN_stdfloat get_u_speed() const; + INLINE PN_stdfloat get_v_speed() const; + INLINE PN_stdfloat get_r_speed() const; private: - float _u_speed; - float _v_speed; - float _r_speed; + PN_stdfloat _u_speed; + PN_stdfloat _v_speed; + PN_stdfloat _r_speed; double _start_time; diff --git a/panda/src/pgui/Sources.pp b/panda/src/pgui/Sources.pp index a667619423..e6f6eaeb50 100644 --- a/panda/src/pgui/Sources.pp +++ b/panda/src/pgui/Sources.pp @@ -81,7 +81,7 @@ #define LOCAL_LIBS \ framework putil collide pgraph chan text \ - pnmimage pnmimagetypes event effects gobj display \ + pnmimage pnmimagetypes event gobj display \ mathutil putil express dgraph device tform \ linmath pstatclient panda diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index 0643991f56..aed6d9ea36 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -175,7 +175,7 @@ click(const MouseWatcherParameter ¶m) { // according to the size of the text. //////////////////////////////////////////////////////////////////// void PGButton:: -setup(const string &label, float bevel) { +setup(const string &label, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); clear_state_def(S_ready); clear_state_def(S_depressed); @@ -186,8 +186,8 @@ setup(const string &label, float bevel) { text_node->set_text(label); PT(PandaNode) geom = text_node->generate(); - LVecBase4f frame = text_node->get_card_actual(); - set_frame(frame[0] - 0.4f, frame[1] + 0.4f, frame[2] - 0.15f, frame[3] + 0.15f); + LVecBase4 frame = text_node->get_card_actual(); + set_frame(frame[0] - 0.4, frame[1] + 0.4, frame[2] - 0.15f, frame[3] + 0.15f); PT(PandaNode) ready = new PandaNode("ready"); PT(PandaNode) depressed = new PandaNode("depressed"); @@ -204,14 +204,14 @@ setup(const string &label, float bevel) { style.set_color(0.9f, 0.9f, 0.9f, 1.0f); set_frame_style(S_rollover, style); - inactive->set_attrib(ColorAttrib::make_flat(Colorf(0.8f, 0.8f, 0.8f, 1.0f))); + inactive->set_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.8f, 0.8f, 1.0f))); style.set_color(0.6f, 0.6f, 0.6f, 1.0f); set_frame_style(S_inactive, style); style.set_type(PGFrameStyle::T_bevel_in); style.set_color(0.8f, 0.8f, 0.8f, 1.0f); set_frame_style(S_depressed, style); - depressed->set_transform(TransformState::make_pos(LVector3f(0.05f, 0.0f, -0.05f))); + depressed->set_transform(TransformState::make_pos(LVector3(0.05f, 0.0f, -0.05f))); get_state_def(S_ready).attach_new_node(ready, 1); get_state_def(S_depressed).attach_new_node(depressed, 1); @@ -245,7 +245,7 @@ setup(const NodePath &ready, const NodePath &depressed, instance_to_state_def(S_inactive, inactive); // Set the button frame size. - LPoint3f min_point, max_point; + LPoint3 min_point, max_point; ready.calc_tight_bounds(min_point, max_point); set_frame(min_point[0], max_point[0], min_point[2], max_point[2]); diff --git a/panda/src/pgui/pgButton.h b/panda/src/pgui/pgButton.h index b09f6d8b6c..837294f5c1 100644 --- a/panda/src/pgui/pgButton.h +++ b/panda/src/pgui/pgButton.h @@ -58,7 +58,7 @@ PUBLISHED: S_inactive }; - void setup(const string &label, float bevel = 0.1f); + void setup(const string &label, PN_stdfloat bevel = 0.1f); INLINE void setup(const NodePath &ready); INLINE void setup(const NodePath &ready, const NodePath &depressed); INLINE void setup(const NodePath &ready, const NodePath &depressed, diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index 32e5327672..28881c5c84 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -161,7 +161,7 @@ get_cursor_position() const { // Description: Returns the node position x of the cursor //////////////////////////////////////////////////////////////////// -INLINE float PGEntry:: +INLINE PN_stdfloat PGEntry:: get_cursor_X() const { LightReMutexHolder holder(_lock); return _cursor_def.get_x(); @@ -173,7 +173,7 @@ get_cursor_X() const { // Description: Returns the node position y of the cursor //////////////////////////////////////////////////////////////////// -INLINE float PGEntry:: +INLINE PN_stdfloat PGEntry:: get_cursor_Y() const { LightReMutexHolder holder(_lock); return _cursor_def.get_y(); @@ -225,7 +225,7 @@ get_max_chars() const { // is essentially _max_width * _num_lines). //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: -set_max_width(float max_width) { +set_max_width(PN_stdfloat max_width) { LightReMutexHolder holder(_lock); _max_width = max_width; _text_geom_stale = true; @@ -238,7 +238,7 @@ set_max_width(float max_width) { // that may be typed into the entry, or 0 if there is no // limit. See set_max_width(). //////////////////////////////////////////////////////////////////// -INLINE float PGEntry:: +INLINE PN_stdfloat PGEntry:: get_max_width() const { LightReMutexHolder holder(_lock); return _max_width; @@ -281,7 +281,7 @@ get_num_lines() const { // steady. //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: -set_blink_rate(float blink_rate) { +set_blink_rate(PN_stdfloat blink_rate) { LightReMutexHolder holder(_lock); _blink_rate = blink_rate; } @@ -292,7 +292,7 @@ set_blink_rate(float blink_rate) { // Description: Returns the number of times per second the cursor // will blink, or 0 if the cursor is not to blink. //////////////////////////////////////////////////////////////////// -INLINE float PGEntry:: +INLINE PN_stdfloat PGEntry:: get_blink_rate() const { LightReMutexHolder holder(_lock); return _blink_rate; diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index b35b3bc1a0..8caa331d86 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -153,7 +153,7 @@ make_copy() const { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void PGEntry:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); PGItem::xform(mat); _text_render_root.set_mat(_text_render_root.get_mat() * mat); @@ -371,7 +371,7 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { // the end). int r = _num_lines - 1; int c = _text.get_num_cols(r); - float last_line_width = + PN_stdfloat last_line_width = _text.get_xpos(r, c) - _text.get_xpos(r, 0); too_long = (last_line_width > _max_width); } @@ -394,7 +394,7 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { // Ok, the user is putting multiple spaces on the // end of a line; we need to make sure the line does // not grow too wide. Measure the line's width. - float current_line_width = + PN_stdfloat current_line_width = _text.get_xpos(r, c + 1) - _text.get_xpos(r, 0); if (current_line_width > _max_width) { // We have to reject the space, but we don't treat @@ -561,21 +561,21 @@ cursormove() { // of the entry, based on the TextNode in effect. //////////////////////////////////////////////////////////////////// void PGEntry:: -setup(float width, int num_lines) { +setup(PN_stdfloat width, int num_lines) { LightReMutexHolder holder(_lock); setup_minimal(width, num_lines); TextNode *text_node = get_text_def(S_focus); - float line_height = text_node->get_line_height(); + PN_stdfloat line_height = text_node->get_line_height(); // Determine the four corners of the frame. - LPoint3f ll(0.0f, 0.0f, -0.3f * line_height - (line_height * (num_lines - 1))); - LPoint3f ur(width, 0.0f, line_height); - LPoint3f lr(ur[0], 0.0f, ll[2]); - LPoint3f ul(ll[0], 0.0f, ur[2]); + LPoint3 ll(0.0f, 0.0f, -0.3 * line_height - (line_height * (num_lines - 1))); + LPoint3 ur(width, 0.0f, line_height); + LPoint3 lr(ur[0], 0.0f, ll[2]); + LPoint3 ul(ll[0], 0.0f, ur[2]); // Transform each corner by the TextNode's transform. - LMatrix4f mat = text_node->get_transform(); + LMatrix4 mat = text_node->get_transform(); ll = ll * mat; ur = ur * mat; lr = lr * mat; @@ -584,7 +584,7 @@ setup(float width, int num_lines) { // And get the new minmax to define the frame. We do all this work // instead of just using the lower-left and upper-right corners, // just in case the text was rotated. - LVecBase4f frame; + LVecBase4 frame; frame[0] = min(min(ll[0], ur[0]), min(lr[0], ul[0])); frame[1] = max(max(ll[0], ur[0]), max(lr[0], ul[0])); frame[2] = min(min(ll[2], ur[2]), min(lr[2], ul[2])); @@ -632,7 +632,7 @@ setup(float width, int num_lines) { // decoration. //////////////////////////////////////////////////////////////////// void PGEntry:: -setup_minimal(float width, int num_lines) { +setup_minimal(PN_stdfloat width, int num_lines) { LightReMutexHolder holder(_lock); set_text(string()); _cursor_position = 0; @@ -644,7 +644,7 @@ setup_minimal(float width, int num_lines) { _accept_enabled = true; TextNode *text_node = get_text_def(S_focus); - float line_height = text_node->get_line_height(); + PN_stdfloat line_height = text_node->get_line_height(); // Set up a default cursor: a vertical bar. clear_cursor_def(); @@ -844,8 +844,8 @@ update_text() { if (get_overflow_mode() && _num_lines == 1){ // We determine the minimum required padding: - float cursor_graphic_pos = _text.get_xpos(0, _cursor_position); - float min_padding = (cursor_graphic_pos - _max_width); + PN_stdfloat cursor_graphic_pos = _text.get_xpos(0, _cursor_position); + PN_stdfloat min_padding = (cursor_graphic_pos - _max_width); // If the current padding would produce a caret outside the text entry, // we relocate it. @@ -875,8 +875,8 @@ update_text() { _current_text.set_x(_current_text.get_x() - _current_padding); _current_text.set_scissor(NodePath(this), - LPoint3f(0, 0, -0.5), LPoint3f(_max_width, 0, -0.5), - LPoint3f(_max_width, 0, 1.5), LPoint3f(0, 0, 1.5)); + LPoint3(0, 0, -0.5), LPoint3(_max_width, 0, -0.5), + LPoint3(_max_width, 0, 1.5), LPoint3(0, 0, 1.5)); } _text_geom_stale = false; @@ -911,7 +911,7 @@ update_cursor() { // Determine the row and column of the cursor. int row, column; - float xpos, ypos; + PN_stdfloat xpos, ypos; if (_obscure_mode) { _obscure_text.calc_r_c(row, column, _cursor_position); xpos = _obscure_text.get_xpos(row, column); diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index 6dd2aa5099..b2ad6350f4 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -49,7 +49,7 @@ protected: public: virtual PandaNode *make_copy() const; - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual void press(const MouseWatcherParameter ¶m, bool background); @@ -70,8 +70,8 @@ PUBLISHED: S_inactive }; - void setup(float width, int num_lines); - void setup_minimal(float width, int num_lines); + void setup(PN_stdfloat width, int num_lines); + void setup_minimal(PN_stdfloat width, int num_lines); INLINE bool set_text(const string &text); INLINE string get_plain_text() const; @@ -85,18 +85,18 @@ PUBLISHED: INLINE void set_cursor_position(int position); INLINE int get_cursor_position() const; - INLINE float get_cursor_X() const; - INLINE float get_cursor_Y() const; + INLINE PN_stdfloat get_cursor_X() const; + INLINE PN_stdfloat get_cursor_Y() const; INLINE void set_max_chars(int max_chars); INLINE int get_max_chars() const; - INLINE void set_max_width(float max_width); - INLINE float get_max_width() const; + INLINE void set_max_width(PN_stdfloat max_width); + INLINE PN_stdfloat get_max_width() const; INLINE void set_num_lines(int num_lines); INLINE int get_num_lines() const; - INLINE void set_blink_rate(float blink_rate); - INLINE float get_blink_rate() const; + INLINE void set_blink_rate(PN_stdfloat blink_rate); + INLINE PN_stdfloat get_blink_rate() const; INLINE NodePath get_cursor_def(); INLINE void clear_cursor_def(); @@ -163,7 +163,7 @@ private: size_t _candidate_cursor_pos; int _max_chars; - float _max_width; + PN_stdfloat _max_width; int _num_lines; bool _accept_enabled; @@ -197,7 +197,7 @@ private: bool _obscure_mode; bool _overflow_mode; - float _current_padding; + PN_stdfloat _current_padding; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgui/pgFrameStyle.I b/panda/src/pgui/pgFrameStyle.I index 107426d36c..2968bfcc92 100644 --- a/panda/src/pgui/pgFrameStyle.I +++ b/panda/src/pgui/pgFrameStyle.I @@ -93,8 +93,8 @@ get_type() const { // Description: Sets the dominant color of the frame. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_color(float r, float g, float b, float a) { - set_color(Colorf(r, g, b, a)); +set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -103,7 +103,7 @@ set_color(float r, float g, float b, float a) { // Description: Sets the dominant color of the frame. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _color = color; } @@ -112,7 +112,7 @@ set_color(const Colorf &color) { // Access: Published // Description: Returns the dominant color of the frame. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &PGFrameStyle:: +INLINE const LColor &PGFrameStyle:: get_color() const { return _color; } @@ -169,8 +169,8 @@ clear_texture() { // units are in screen units. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_width(float x, float y) { - set_width(LVecBase2f(x, y)); +set_width(PN_stdfloat x, PN_stdfloat y) { + set_width(LVecBase2(x, y)); } //////////////////////////////////////////////////////////////////// @@ -182,7 +182,7 @@ set_width(float x, float y) { // units are in screen units. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_width(const LVecBase2f &width) { +set_width(const LVecBase2 &width) { _width = width; } @@ -194,7 +194,7 @@ set_width(const LVecBase2f &width) { // width of the bevel for T_bevel_in or T_bevel_out. // The units are in screen units. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase2f &PGFrameStyle:: +INLINE const LVecBase2 &PGFrameStyle:: get_width() const { return _width; } @@ -208,8 +208,8 @@ get_width() const { // indicated by set_width. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_uv_width(float u, float v) { - set_uv_width(LVecBase2f(u, v)); +set_uv_width(PN_stdfloat u, PN_stdfloat v) { + set_uv_width(LVecBase2(u, v)); } //////////////////////////////////////////////////////////////////// @@ -221,7 +221,7 @@ set_uv_width(float u, float v) { // indicated by set_width. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_uv_width(const LVecBase2f &uv_width) { +set_uv_width(const LVecBase2 &uv_width) { _uv_width = uv_width; } @@ -230,7 +230,7 @@ set_uv_width(const LVecBase2f &uv_width) { // Access: Published // Description: See set_uv_width(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase2f &PGFrameStyle:: +INLINE const LVecBase2 &PGFrameStyle:: get_uv_width() const { return _uv_width; } @@ -245,8 +245,8 @@ get_uv_width() const { // frame border. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_visible_scale(float x, float y) { - set_visible_scale(LVecBase2f(x, y)); +set_visible_scale(PN_stdfloat x, PN_stdfloat y) { + set_visible_scale(LVecBase2(x, y)); } //////////////////////////////////////////////////////////////////// @@ -259,7 +259,7 @@ set_visible_scale(float x, float y) { // frame border. //////////////////////////////////////////////////////////////////// INLINE void PGFrameStyle:: -set_visible_scale(const LVecBase2f &visible_scale) { +set_visible_scale(const LVecBase2 &visible_scale) { _visible_scale = visible_scale; } @@ -272,7 +272,7 @@ set_visible_scale(const LVecBase2f &visible_scale) { // will affect the size of the visible frame // representation within the actual frame border. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase2f &PGFrameStyle:: +INLINE const LVecBase2 &PGFrameStyle:: get_visible_scale() const { return _visible_scale; } diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index 57937e1a6c..6f5053e44e 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -30,7 +30,7 @@ // we'll have a reason to make this a parameter of the frame style one // day, but for now it's hardcoded to fit the entire texture over the // rectangular frame. -static const LVecBase4f uv_range = LVecBase4f(0.0f, 1.0f, 0.0f, 1.0f); +static const LVecBase4 uv_range = LVecBase4(0.0f, 1.0f, 0.0f, 1.0f); ostream & operator << (ostream &out, PGFrameStyle::Type type) { @@ -68,11 +68,11 @@ operator << (ostream &out, PGFrameStyle::Type type) { // of frame style. This simply subtracts the border // width for those frame styles that include a border. //////////////////////////////////////////////////////////////////// -LVecBase4f PGFrameStyle:: -get_internal_frame(const LVecBase4f &frame) const { - LPoint2f center((frame[0] + frame[1]) / 2.0f, +LVecBase4 PGFrameStyle:: +get_internal_frame(const LVecBase4 &frame) const { + LPoint2 center((frame[0] + frame[1]) / 2.0f, (frame[2] + frame[3]) / 2.0f); - LVecBase4f scaled_frame + LVecBase4 scaled_frame ((frame[0] - center[0]) * _visible_scale[0] + center[0], (frame[1] - center[0]) * _visible_scale[0] + center[0], (frame[2] - center[1]) * _visible_scale[1] + center[1], @@ -87,7 +87,7 @@ get_internal_frame(const LVecBase4f &frame) const { break; } - return LVecBase4f(scaled_frame[0] + _width[0], + return LVecBase4(scaled_frame[0] + _width[0], scaled_frame[1] - _width[0], scaled_frame[2] + _width[1], scaled_frame[3] - _width[1]); @@ -101,7 +101,7 @@ get_internal_frame(const LVecBase4f &frame) const { void PGFrameStyle:: output(ostream &out) const { out << _type << " color = " << _color << " width = " << _width; - if (_visible_scale != LVecBase2f(1.0f, 1.0f)) { + if (_visible_scale != LVecBase2(1.0f, 1.0f)) { out << "visible_scale = " << get_visible_scale(); } if (has_texture()) { @@ -118,16 +118,16 @@ output(ostream &out) const { // transform. //////////////////////////////////////////////////////////////////// bool PGFrameStyle:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { // All we can do is scale the X and Y bevel sizes. // Extract the X and Z axes from the matrix. - LVector3f x, z; + LVector3 x, z; mat.get_row3(x, 0); - float x_scale = x.length(); + PN_stdfloat x_scale = x.length(); mat.get_row3(z, 2); - float z_scale = z.length(); + PN_stdfloat z_scale = z.length(); _width[0] *= x_scale; _width[1] *= z_scale; @@ -160,13 +160,13 @@ xform(const LMatrix4f &mat) { // or an empty NodePath if nothing is generated. //////////////////////////////////////////////////////////////////// NodePath PGFrameStyle:: -generate_into(const NodePath &parent, const LVecBase4f &frame, +generate_into(const NodePath &parent, const LVecBase4 &frame, int sort) { PT(PandaNode) new_node; - LPoint2f center((frame[0] + frame[1]) / 2.0f, + LPoint2 center((frame[0] + frame[1]) / 2.0f, (frame[2] + frame[3]) / 2.0f); - LVecBase4f scaled_frame + LVecBase4 scaled_frame ((frame[0] - center[0]) * _visible_scale[0] + center[0], (frame[1] - center[0]) * _visible_scale[0] + center[0], (frame[2] - center[1]) * _visible_scale[1] + center[1], @@ -220,13 +220,13 @@ generate_into(const NodePath &parent, const LVecBase4f &frame, // frame. //////////////////////////////////////////////////////////////////// PT(PandaNode) PGFrameStyle:: -generate_flat_geom(const LVecBase4f &frame) { +generate_flat_geom(const LVecBase4 &frame) { PT(GeomNode) gnode = new GeomNode("flat"); - float left = frame[0]; - float right = frame[1]; - float bottom = frame[2]; - float top = frame[3]; + PN_stdfloat left = frame[0]; + PN_stdfloat right = frame[1]; + PN_stdfloat bottom = frame[2]; + PN_stdfloat top = frame[3]; CPT(GeomVertexFormat) format; if (has_texture()) { @@ -239,10 +239,10 @@ generate_flat_geom(const LVecBase4f &frame) { ("PGFrame", format, Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); if (has_texture()) { // Generate UV's. @@ -252,10 +252,10 @@ generate_flat_geom(const LVecBase4f &frame) { top = uv_range[3]; GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - texcoord.add_data2f(left, top); - texcoord.add_data2f(left, bottom); - texcoord.add_data2f(right, top); - texcoord.add_data2f(right, bottom); + texcoord.add_data2(left, top); + texcoord.add_data2(left, bottom); + texcoord.add_data2(right, top); + texcoord.add_data2(right, bottom); } PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); @@ -280,7 +280,7 @@ generate_flat_geom(const LVecBase4f &frame) { // or T_bevel_out frame. //////////////////////////////////////////////////////////////////// PT(PandaNode) PGFrameStyle:: -generate_bevel_geom(const LVecBase4f &frame, bool in) { +generate_bevel_geom(const LVecBase4 &frame, bool in) { // // Colors: // @@ -340,23 +340,23 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) { PT(GeomNode) gnode = new GeomNode("bevel"); - float left = frame[0]; - float right = frame[1]; - float bottom = frame[2]; - float top = frame[3]; + PN_stdfloat left = frame[0]; + PN_stdfloat right = frame[1]; + PN_stdfloat bottom = frame[2]; + PN_stdfloat top = frame[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float inner_left = min(left + _width[0], cx); - float inner_right = max(right - _width[0], cx); - float inner_bottom = min(bottom + _width[1], cy); - float inner_top = max(top - _width[1], cy); + PN_stdfloat inner_left = min(left + _width[0], cx); + PN_stdfloat inner_right = max(right - _width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _width[1], cy); + PN_stdfloat inner_top = max(top - _width[1], cy); - float left_color_scale = 1.2; - float right_color_scale = 0.8; - float bottom_color_scale = 0.7; - float top_color_scale = 1.3; + PN_stdfloat left_color_scale = 1.2; + PN_stdfloat right_color_scale = 0.8; + PN_stdfloat bottom_color_scale = 0.7; + PN_stdfloat top_color_scale = 1.3; if (in) { right_color_scale = 1.2; @@ -366,24 +366,24 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) { } // Clamp all colors at white, and don't scale the alpha. - Colorf cleft(min(_color[0] * left_color_scale, 1.0f), - min(_color[1] * left_color_scale, 1.0f), - min(_color[2] * left_color_scale, 1.0f), + LColor cleft(min(_color[0] * left_color_scale, (PN_stdfloat)1.0), + min(_color[1] * left_color_scale, (PN_stdfloat)1.0), + min(_color[2] * left_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf cright(min(_color[0] * right_color_scale, 1.0f), - min(_color[1] * right_color_scale, 1.0f), - min(_color[2] * right_color_scale, 1.0f), + LColor cright(min(_color[0] * right_color_scale, (PN_stdfloat)1.0), + min(_color[1] * right_color_scale, (PN_stdfloat)1.0), + min(_color[2] * right_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf cbottom(min(_color[0] * bottom_color_scale, 1.0f), - min(_color[1] * bottom_color_scale, 1.0f), - min(_color[2] * bottom_color_scale, 1.0f), + LColor cbottom(min(_color[0] * bottom_color_scale, (PN_stdfloat)1.0), + min(_color[1] * bottom_color_scale, (PN_stdfloat)1.0), + min(_color[2] * bottom_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf ctop(min(_color[0] * top_color_scale, 1.0f), - min(_color[1] * top_color_scale, 1.0f), - min(_color[2] * top_color_scale, 1.0f), + LColor ctop(min(_color[0] * top_color_scale, (PN_stdfloat)1.0), + min(_color[1] * top_color_scale, (PN_stdfloat)1.0), + min(_color[2] * top_color_scale, (PN_stdfloat)1.0), _color[3]); CPT(GeomVertexFormat) format; @@ -401,39 +401,39 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); // Tristrip 1. - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_top)); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cleft); - color.add_data4f(cleft); - color.add_data4f(ctop); - color.add_data4f(ctop); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_top)); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cleft); + color.add_data4(cleft); + color.add_data4(ctop); + color.add_data4(ctop); strip->add_next_vertices(8); strip->close_primitive(); // Tristrip 2. - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_top)); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(_color); - color.add_data4f(_color); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_top)); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(_color); + color.add_data4(_color); strip->add_next_vertices(6); strip->close_primitive(); @@ -441,35 +441,35 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) { if (has_texture()) { // Generate UV's. - float left = uv_range[0]; - float right = uv_range[1]; - float bottom = uv_range[2]; - float top = uv_range[3]; + PN_stdfloat left = uv_range[0]; + PN_stdfloat right = uv_range[1]; + PN_stdfloat bottom = uv_range[2]; + PN_stdfloat top = uv_range[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float inner_left = min(left + _uv_width[0], cx); - float inner_right = max(right - _uv_width[0], cx); - float inner_bottom = min(bottom + _uv_width[1], cy); - float inner_top = max(top - _uv_width[1], cy); + PN_stdfloat inner_left = min(left + _uv_width[0], cx); + PN_stdfloat inner_right = max(right - _uv_width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _uv_width[1], cy); + PN_stdfloat inner_top = max(top - _uv_width[1], cy); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - texcoord.add_data2f(right, bottom); - texcoord.add_data2f(inner_right, inner_bottom); - texcoord.add_data2f(left, bottom); - texcoord.add_data2f(inner_left, inner_bottom); - texcoord.add_data2f(left, top); - texcoord.add_data2f(inner_left, inner_top); - texcoord.add_data2f(right, top); - texcoord.add_data2f(inner_right, inner_top); + texcoord.add_data2(right, bottom); + texcoord.add_data2(inner_right, inner_bottom); + texcoord.add_data2(left, bottom); + texcoord.add_data2(inner_left, inner_bottom); + texcoord.add_data2(left, top); + texcoord.add_data2(inner_left, inner_top); + texcoord.add_data2(right, top); + texcoord.add_data2(inner_right, inner_top); - texcoord.add_data2f(right, bottom); - texcoord.add_data2f(right, top); - texcoord.add_data2f(inner_right, inner_bottom); - texcoord.add_data2f(inner_right, inner_top); - texcoord.add_data2f(inner_left, inner_bottom); - texcoord.add_data2f(inner_left, inner_top); + texcoord.add_data2(right, bottom); + texcoord.add_data2(right, top); + texcoord.add_data2(inner_right, inner_bottom); + texcoord.add_data2(inner_right, inner_top); + texcoord.add_data2(inner_left, inner_bottom); + texcoord.add_data2(inner_left, inner_top); } PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); @@ -492,7 +492,7 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) { // T_ridge frame. //////////////////////////////////////////////////////////////////// PT(PandaNode) PGFrameStyle:: -generate_groove_geom(const LVecBase4f &frame, bool in) { +generate_groove_geom(const LVecBase4 &frame, bool in) { // // Colors: // @@ -593,55 +593,55 @@ generate_groove_geom(const LVecBase4f &frame, bool in) { PT(GeomNode) gnode = new GeomNode("groove"); - float left = frame[0]; - float right = frame[1]; - float bottom = frame[2]; - float top = frame[3]; + PN_stdfloat left = frame[0]; + PN_stdfloat right = frame[1]; + PN_stdfloat bottom = frame[2]; + PN_stdfloat top = frame[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float mid_left = min(left + 0.5f * _width[0], cx); - float mid_right = max(right - 0.5f * _width[0], cx); - float mid_bottom = min(bottom + 0.5f * _width[1], cy); - float mid_top = max(top - 0.5f * _width[1], cy); + PN_stdfloat mid_left = min(left + 0.5f * _width[0], cx); + PN_stdfloat mid_right = max(right - 0.5f * _width[0], cx); + PN_stdfloat mid_bottom = min(bottom + 0.5f * _width[1], cy); + PN_stdfloat mid_top = max(top - 0.5f * _width[1], cy); - float inner_left = min(left + _width[0], cx); - float inner_right = max(right - _width[0], cx); - float inner_bottom = min(bottom + _width[1], cy); - float inner_top = max(top - _width[1], cy); + PN_stdfloat inner_left = min(left + _width[0], cx); + PN_stdfloat inner_right = max(right - _width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _width[1], cy); + PN_stdfloat inner_top = max(top - _width[1], cy); - float left_color_scale = 1.2f; - float right_color_scale = 0.8f; - float bottom_color_scale = 0.7f; - float top_color_scale = 1.3f; + PN_stdfloat left_color_scale = 1.2; + PN_stdfloat right_color_scale = 0.8f; + PN_stdfloat bottom_color_scale = 0.7f; + PN_stdfloat top_color_scale = 1.3; if (in) { - right_color_scale = 1.2f; + right_color_scale = 1.2; left_color_scale = 0.8f; top_color_scale = 0.7f; - bottom_color_scale = 1.3f; + bottom_color_scale = 1.3; } // Clamp all colors at white, and don't scale the alpha. - Colorf cleft(min(_color[0] * left_color_scale, 1.0f), - min(_color[1] * left_color_scale, 1.0f), - min(_color[2] * left_color_scale, 1.0f), + LColor cleft(min(_color[0] * left_color_scale, (PN_stdfloat)1.0), + min(_color[1] * left_color_scale, (PN_stdfloat)1.0), + min(_color[2] * left_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf cright(min(_color[0] * right_color_scale, 1.0f), - min(_color[1] * right_color_scale, 1.0f), - min(_color[2] * right_color_scale, 1.0f), + LColor cright(min(_color[0] * right_color_scale, (PN_stdfloat)1.0), + min(_color[1] * right_color_scale, (PN_stdfloat)1.0), + min(_color[2] * right_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf cbottom(min(_color[0] * bottom_color_scale, 1.0f), - min(_color[1] * bottom_color_scale, 1.0f), - min(_color[2] * bottom_color_scale, 1.0f), + LColor cbottom(min(_color[0] * bottom_color_scale, (PN_stdfloat)1.0), + min(_color[1] * bottom_color_scale, (PN_stdfloat)1.0), + min(_color[2] * bottom_color_scale, (PN_stdfloat)1.0), _color[3]); - Colorf ctop(min(_color[0] * top_color_scale, 1.0f), - min(_color[1] * top_color_scale, 1.0f), - min(_color[2] * top_color_scale, 1.0f), + LColor ctop(min(_color[0] * top_color_scale, (PN_stdfloat)1.0), + min(_color[1] * top_color_scale, (PN_stdfloat)1.0), + min(_color[2] * top_color_scale, (PN_stdfloat)1.0), _color[3]); CPT(GeomVertexFormat) format; @@ -658,64 +658,64 @@ generate_groove_geom(const LVecBase4f &frame, bool in) { PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); // Tristrip 1. - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_bottom)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(mid_left, 0.0f, mid_bottom)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(mid_left, 0.0f, mid_top)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_top)); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cbottom); - color.add_data4f(cleft); - color.add_data4f(cleft); - color.add_data4f(ctop); - color.add_data4f(ctop); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(mid_left, 0.0f, mid_bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(mid_left, 0.0f, mid_top)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_top)); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cbottom); + color.add_data4(cleft); + color.add_data4(cleft); + color.add_data4(ctop); + color.add_data4(ctop); strip->add_next_vertices(8); strip->close_primitive(); // Tristrip 2. - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(mid_left, 0.0f, mid_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(mid_left, 0.0f, mid_top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_top)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_top)); - color.add_data4f(ctop); - color.add_data4f(ctop); - color.add_data4f(ctop); - color.add_data4f(ctop); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cbottom); - color.add_data4f(cbottom); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(mid_left, 0.0f, mid_bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(mid_left, 0.0f, mid_top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_top)); + color.add_data4(ctop); + color.add_data4(ctop); + color.add_data4(ctop); + color.add_data4(ctop); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cbottom); + color.add_data4(cbottom); strip->add_next_vertices(8); strip->close_primitive(); // Tristrip 3. - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_bottom)); - vertex.add_data3f(LPoint3f::rfu(mid_right, 0.0f, mid_top)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_top)); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cright); - color.add_data4f(cleft); - color.add_data4f(cleft); - color.add_data4f(_color); - color.add_data4f(_color); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_bottom)); + vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_top)); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cright); + color.add_data4(cleft); + color.add_data4(cleft); + color.add_data4(_color); + color.add_data4(_color); strip->add_next_vertices(8); strip->close_primitive(); @@ -724,51 +724,51 @@ generate_groove_geom(const LVecBase4f &frame, bool in) { if (has_texture()) { // Generate UV's. - float left = uv_range[0]; - float right = uv_range[1]; - float bottom = uv_range[2]; - float top = uv_range[3]; + PN_stdfloat left = uv_range[0]; + PN_stdfloat right = uv_range[1]; + PN_stdfloat bottom = uv_range[2]; + PN_stdfloat top = uv_range[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float mid_left = min(left + 0.5f * _width[0], cx); - float mid_right = max(right - 0.5f * _width[0], cx); - float mid_bottom = min(bottom + 0.5f * _width[1], cy); - float mid_top = max(top - 0.5f * _width[1], cy); + PN_stdfloat mid_left = min(left + 0.5f * _width[0], cx); + PN_stdfloat mid_right = max(right - 0.5f * _width[0], cx); + PN_stdfloat mid_bottom = min(bottom + 0.5f * _width[1], cy); + PN_stdfloat mid_top = max(top - 0.5f * _width[1], cy); - float inner_left = min(left + _width[0], cx); - float inner_right = max(right - _width[0], cx); - float inner_bottom = min(bottom + _width[1], cy); - float inner_top = max(top - _width[1], cy); + PN_stdfloat inner_left = min(left + _width[0], cx); + PN_stdfloat inner_right = max(right - _width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _width[1], cy); + PN_stdfloat inner_top = max(top - _width[1], cy); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - texcoord.add_data2f(right, bottom); - texcoord.add_data2f(mid_right, mid_bottom); - texcoord.add_data2f(left, bottom); - texcoord.add_data2f(mid_left, mid_bottom); - texcoord.add_data2f(left, top); - texcoord.add_data2f(mid_left, mid_top); - texcoord.add_data2f(right, top); - texcoord.add_data2f(mid_right, mid_top); + texcoord.add_data2(right, bottom); + texcoord.add_data2(mid_right, mid_bottom); + texcoord.add_data2(left, bottom); + texcoord.add_data2(mid_left, mid_bottom); + texcoord.add_data2(left, top); + texcoord.add_data2(mid_left, mid_top); + texcoord.add_data2(right, top); + texcoord.add_data2(mid_right, mid_top); - texcoord.add_data2f(mid_right, mid_bottom); - texcoord.add_data2f(inner_right, inner_bottom); - texcoord.add_data2f(mid_left, mid_bottom); - texcoord.add_data2f(inner_left, inner_bottom); - texcoord.add_data2f(mid_left, mid_top); - texcoord.add_data2f(inner_left, inner_top); - texcoord.add_data2f(mid_right, mid_top); - texcoord.add_data2f(inner_right, inner_top); + texcoord.add_data2(mid_right, mid_bottom); + texcoord.add_data2(inner_right, inner_bottom); + texcoord.add_data2(mid_left, mid_bottom); + texcoord.add_data2(inner_left, inner_bottom); + texcoord.add_data2(mid_left, mid_top); + texcoord.add_data2(inner_left, inner_top); + texcoord.add_data2(mid_right, mid_top); + texcoord.add_data2(inner_right, inner_top); - texcoord.add_data2f(right, bottom); - texcoord.add_data2f(right, top); - texcoord.add_data2f(mid_right, mid_bottom); - texcoord.add_data2f(mid_right, mid_top); - texcoord.add_data2f(inner_right, inner_bottom); - texcoord.add_data2f(inner_right, inner_top); - texcoord.add_data2f(inner_left, inner_bottom); - texcoord.add_data2f(inner_left, inner_top); + texcoord.add_data2(right, bottom); + texcoord.add_data2(right, top); + texcoord.add_data2(mid_right, mid_bottom); + texcoord.add_data2(mid_right, mid_top); + texcoord.add_data2(inner_right, inner_bottom); + texcoord.add_data2(inner_right, inner_top); + texcoord.add_data2(inner_left, inner_bottom); + texcoord.add_data2(inner_left, inner_top); } PT(Geom) geom = new Geom(vdata); @@ -791,7 +791,7 @@ generate_groove_geom(const LVecBase4f &frame, bool in) { // T_texture_border frame. //////////////////////////////////////////////////////////////////// PT(PandaNode) PGFrameStyle:: -generate_texture_border_geom(const LVecBase4f &frame) { +generate_texture_border_geom(const LVecBase4 &frame) { // // Vertices: // @@ -821,18 +821,18 @@ generate_texture_border_geom(const LVecBase4f &frame) { PT(GeomNode) gnode = new GeomNode("flat"); - float left = frame[0]; - float right = frame[1]; - float bottom = frame[2]; - float top = frame[3]; + PN_stdfloat left = frame[0]; + PN_stdfloat right = frame[1]; + PN_stdfloat bottom = frame[2]; + PN_stdfloat top = frame[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float inner_left = min(left + _width[0], cx); - float inner_right = max(right - _width[0], cx); - float inner_bottom = min(bottom + _width[1], cy); - float inner_top = max(top - _width[1], cy); + PN_stdfloat inner_left = min(left + _width[0], cx); + PN_stdfloat inner_right = max(right - _width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _width[1], cy); + PN_stdfloat inner_top = max(top - _width[1], cy); CPT(GeomVertexFormat) format; if (has_texture()) { @@ -847,63 +847,63 @@ generate_texture_border_geom(const LVecBase4f &frame) { GeomVertexWriter vertex(vdata, InternalName::get_vertex()); // verts 0,1,2,3 - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_top)); // verts 4,5,6,7 - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_top)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, top)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_top)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, inner_top)); // verts 8,9,10,11 - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(left, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_left, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(left, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_left, 0.0f, bottom)); // verts 12,13,14,15 - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(inner_right, 0.0f, bottom)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, inner_bottom)); - vertex.add_data3f(LPoint3f::rfu(right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, bottom)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, inner_bottom)); + vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); if (has_texture()) { // Generate UV's. - float left = uv_range[0]; - float right = uv_range[1]; - float bottom = uv_range[2]; - float top = uv_range[3]; + PN_stdfloat left = uv_range[0]; + PN_stdfloat right = uv_range[1]; + PN_stdfloat bottom = uv_range[2]; + PN_stdfloat top = uv_range[3]; - float cx = (left + right) * 0.5; - float cy = (top + bottom) * 0.5; + PN_stdfloat cx = (left + right) * 0.5; + PN_stdfloat cy = (top + bottom) * 0.5; - float inner_left = min(left + _uv_width[0], cx); - float inner_right = max(right - _uv_width[0], cx); - float inner_bottom = min(bottom + _uv_width[1], cy); - float inner_top = max(top - _uv_width[1], cy); + PN_stdfloat inner_left = min(left + _uv_width[0], cx); + PN_stdfloat inner_right = max(right - _uv_width[0], cx); + PN_stdfloat inner_bottom = min(bottom + _uv_width[1], cy); + PN_stdfloat inner_top = max(top - _uv_width[1], cy); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); // verts 0,1,2,3 - texcoord.add_data2f(left, top); - texcoord.add_data2f(left, inner_top); - texcoord.add_data2f(inner_left, top); - texcoord.add_data2f(inner_left, inner_top); + texcoord.add_data2(left, top); + texcoord.add_data2(left, inner_top); + texcoord.add_data2(inner_left, top); + texcoord.add_data2(inner_left, inner_top); // verts 4,5,6,7 - texcoord.add_data2f(inner_right, top); - texcoord.add_data2f(inner_right, inner_top); - texcoord.add_data2f(right, top); - texcoord.add_data2f(right, inner_top); + texcoord.add_data2(inner_right, top); + texcoord.add_data2(inner_right, inner_top); + texcoord.add_data2(right, top); + texcoord.add_data2(right, inner_top); // verts 8,9,10,11 - texcoord.add_data2f(left, inner_bottom); - texcoord.add_data2f(left, bottom); - texcoord.add_data2f(inner_left, inner_bottom); - texcoord.add_data2f(inner_left, bottom); + texcoord.add_data2(left, inner_bottom); + texcoord.add_data2(left, bottom); + texcoord.add_data2(inner_left, inner_bottom); + texcoord.add_data2(inner_left, bottom); // verts 12,13,14,15 - texcoord.add_data2f(inner_right, inner_bottom); - texcoord.add_data2f(inner_right, bottom); - texcoord.add_data2f(right, inner_bottom); - texcoord.add_data2f(right, bottom); + texcoord.add_data2(inner_right, inner_bottom); + texcoord.add_data2(inner_right, bottom); + texcoord.add_data2(right, inner_bottom); + texcoord.add_data2(right, bottom); } PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); diff --git a/panda/src/pgui/pgFrameStyle.h b/panda/src/pgui/pgFrameStyle.h index 3d156c06b4..5df91dc130 100644 --- a/panda/src/pgui/pgFrameStyle.h +++ b/panda/src/pgui/pgFrameStyle.h @@ -49,49 +49,49 @@ PUBLISHED: INLINE void set_type(Type type); INLINE Type get_type() const; - INLINE void set_color(float r, float g, float b, float a); - INLINE void set_color(const Colorf &color); - INLINE const Colorf &get_color() const; + INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_color(const LColor &color); + INLINE const LColor &get_color() const; INLINE void set_texture(Texture *texture); INLINE bool has_texture() const; INLINE Texture *get_texture() const; INLINE void clear_texture(); - INLINE void set_width(float x, float y); - INLINE void set_width(const LVecBase2f &width); - INLINE const LVecBase2f &get_width() const; + INLINE void set_width(PN_stdfloat x, PN_stdfloat y); + INLINE void set_width(const LVecBase2 &width); + INLINE const LVecBase2 &get_width() const; - INLINE void set_uv_width(float u, float v); - INLINE void set_uv_width(const LVecBase2f &uv_width); - INLINE const LVecBase2f &get_uv_width() const; + INLINE void set_uv_width(PN_stdfloat u, PN_stdfloat v); + INLINE void set_uv_width(const LVecBase2 &uv_width); + INLINE const LVecBase2 &get_uv_width() const; - INLINE void set_visible_scale(float x, float y); - INLINE void set_visible_scale(const LVecBase2f &visible_scale); - INLINE const LVecBase2f &get_visible_scale() const; + INLINE void set_visible_scale(PN_stdfloat x, PN_stdfloat y); + INLINE void set_visible_scale(const LVecBase2 &visible_scale); + INLINE const LVecBase2 &get_visible_scale() const; - LVecBase4f get_internal_frame(const LVecBase4f &frame) const; + LVecBase4 get_internal_frame(const LVecBase4 &frame) const; void output(ostream &out) const; public: - bool xform(const LMatrix4f &mat); - NodePath generate_into(const NodePath &parent, const LVecBase4f &frame, + bool xform(const LMatrix4 &mat); + NodePath generate_into(const NodePath &parent, const LVecBase4 &frame, int sort = 0); private: - PT(PandaNode) generate_flat_geom(const LVecBase4f &frame); - PT(PandaNode) generate_bevel_geom(const LVecBase4f &frame, bool in); - PT(PandaNode) generate_groove_geom(const LVecBase4f &frame, bool in); - PT(PandaNode) generate_texture_border_geom(const LVecBase4f &frame); + PT(PandaNode) generate_flat_geom(const LVecBase4 &frame); + PT(PandaNode) generate_bevel_geom(const LVecBase4 &frame, bool in); + PT(PandaNode) generate_groove_geom(const LVecBase4 &frame, bool in); + PT(PandaNode) generate_texture_border_geom(const LVecBase4 &frame); private: Type _type; - Colorf _color; + LColor _color; PT(Texture) _texture; - LVecBase2f _width; - LVecBase2f _uv_width; - LVecBase2f _visible_scale; + LVecBase2 _width; + LVecBase2 _uv_width; + LVecBase2 _visible_scale; }; INLINE ostream &operator << (ostream &out, const PGFrameStyle &pfs); diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index 7f369ebf71..41bdfa0988 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -97,8 +97,8 @@ get_notify() const { // rectangle of the visible geometry of the item. //////////////////////////////////////////////////////////////////// INLINE void PGItem:: -set_frame(float left, float right, float bottom, float top) { - set_frame(LVecBase4f(left, right, bottom, top)); +set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_frame(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ set_frame(float left, float right, float bottom, float top) { // rectangle of the visible geometry of the item. //////////////////////////////////////////////////////////////////// INLINE void PGItem:: -set_frame(const LVecBase4f &frame) { +set_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); if (!_has_frame || _frame != frame) { _has_frame = true; @@ -127,7 +127,7 @@ set_frame(const LVecBase4f &frame) { // set_frame(). It is an error to call this if // has_frame() returns false. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &PGItem:: +INLINE const LVecBase4 &PGItem:: get_frame() const { LightReMutexHolder holder(_lock); nassertr(has_frame(), _frame); @@ -579,7 +579,7 @@ get_focus_item() { // Access: Published, Static // Description: Returns the inverse of the frame transform matrix //////////////////////////////////////////////////////////////////// -INLINE LMatrix4f PGItem:: +INLINE LMatrix4 PGItem:: get_frame_inv_xform() const { LightReMutexHolder holder(_lock); return _frame_inv_xform; @@ -590,8 +590,8 @@ get_frame_inv_xform() const { // Access: Private, Static // Description: Computes the area of the indicated frame. //////////////////////////////////////////////////////////////////// -INLINE float PGItem:: -compute_area(const LVecBase4f &frame) { +INLINE PN_stdfloat PGItem:: +compute_area(const LVecBase4 &frame) { return (frame[1] - frame[0]) * (frame[3] - frame[2]); } @@ -605,9 +605,9 @@ compute_area(const LVecBase4f &frame) { // appropriately. //////////////////////////////////////////////////////////////////// INLINE void PGItem:: -compare_largest(const LVecBase4f *&largest, float &largest_area, - const LVecBase4f *new_frame) { - float new_area = compute_area(*new_frame); +compare_largest(const LVecBase4 *&largest, PN_stdfloat &largest_area, + const LVecBase4 *new_frame) { + PN_stdfloat new_area = compute_area(*new_frame); if (new_area > largest_area) { largest = new_frame; largest_area = new_area; diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 11d90b4f78..967a5bb8fa 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -47,7 +47,7 @@ PGItem::BackgroundFocus PGItem::_background_focus; // Description: Returns true if the 2-d v1 is to the right of v2. //////////////////////////////////////////////////////////////////// INLINE bool -is_right(const LVector2f &v1, const LVector2f &v2) { +is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 0; } @@ -222,7 +222,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { DCAST_INTO_R(pg_trav, trav, true); CPT(TransformState) net_transform = data.get_net_transform(trav); - const LMatrix4f &transform = net_transform->get_mat(); + const LMatrix4 &transform = net_transform->get_mat(); // Consider the cull bin this object is in. Since the binning // affects the render order, we want bins that render later to @@ -384,11 +384,11 @@ r_prepare_scene(const RenderState *state, // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void PGItem:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); // Transform the frame. - LPoint3f ll(_frame[0], 0.0f, _frame[2]); - LPoint3f ur(_frame[1], 0.0f, _frame[3]); + LPoint3 ll(_frame[0], 0.0f, _frame[2]); + LPoint3 ur(_frame[1], 0.0f, _frame[3]); ll = ll * mat; ur = ur * mat; _frame.set(ll[0], ur[0], ll[2], ur[2]); @@ -422,17 +422,17 @@ xform(const LMatrix4f &mat) { // false if it is empty or completely clipped. //////////////////////////////////////////////////////////////////// bool PGItem:: -activate_region(const LMatrix4f &transform, int sort, +activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa) { LightReMutexHolder holder(_lock); // Transform all four vertices, and get the new bounding box. This // way the region works (mostly) even if has been rotated. - LPoint3f ll = LPoint3f::rfu(_frame[0], 0.0f, _frame[2]) * transform; - LPoint3f lr = LPoint3f::rfu(_frame[1], 0.0f, _frame[2]) * transform; - LPoint3f ul = LPoint3f::rfu(_frame[0], 0.0f, _frame[3]) * transform; - LPoint3f ur = LPoint3f::rfu(_frame[1], 0.0f, _frame[3]) * transform; - LVector3f up = LVector3f::up(); + LPoint3 ll = LPoint3::rfu(_frame[0], 0.0f, _frame[2]) * transform; + LPoint3 lr = LPoint3::rfu(_frame[1], 0.0f, _frame[2]) * transform; + LPoint3 ul = LPoint3::rfu(_frame[0], 0.0f, _frame[3]) * transform; + LPoint3 ur = LPoint3::rfu(_frame[1], 0.0f, _frame[3]) * transform; + LVector3 up = LVector3::up(); int up_axis; if (up[1]) { up_axis = 1; @@ -443,7 +443,7 @@ activate_region(const LMatrix4f &transform, int sort, else { up_axis = 0; } - LVector3f right = LVector3f::right(); + LVector3 right = LVector3::right(); int right_axis; if (right[0]) { right_axis = 0; @@ -455,22 +455,22 @@ activate_region(const LMatrix4f &transform, int sort, right_axis = 1; } - LVecBase4f frame; + LVecBase4 frame; if (cpa != (ClipPlaneAttrib *)NULL && cpa->get_num_on_planes() != 0) { // Apply the clip plane(s) and/or scissor region now that we are // here in world space. - pvector points; + pvector points; points.reserve(4); - points.push_back(LPoint2f(ll[right_axis], ll[up_axis])); - points.push_back(LPoint2f(lr[right_axis], lr[up_axis])); - points.push_back(LPoint2f(ur[right_axis], ur[up_axis])); - points.push_back(LPoint2f(ul[right_axis], ul[up_axis])); + points.push_back(LPoint2(ll[right_axis], ll[up_axis])); + points.push_back(LPoint2(lr[right_axis], lr[up_axis])); + points.push_back(LPoint2(ur[right_axis], ur[up_axis])); + points.push_back(LPoint2(ul[right_axis], ul[up_axis])); int num_on_planes = cpa->get_num_on_planes(); for (int i = 0; i < num_on_planes; ++i) { NodePath plane_path = cpa->get_on_plane(i); - Planef plane = DCAST(PlaneNode, plane_path.node())->get_plane(); + LPlane plane = DCAST(PlaneNode, plane_path.node())->get_plane(); plane.xform(plane_path.get_net_transform()->get_mat()); // We ignore the forward axis, assuming the frame is still in @@ -484,7 +484,7 @@ activate_region(const LMatrix4f &transform, int sort, return false; } - pvector::iterator pi; + pvector::iterator pi; pi = points.begin(); frame.set((*pi)[0], (*pi)[0], (*pi)[1], (*pi)[1]); ++pi; @@ -505,7 +505,7 @@ activate_region(const LMatrix4f &transform, int sort, if (sa != (ScissorAttrib *)NULL) { // Also restrict it to within the scissor region. - const LVecBase4f &sf = sa->get_frame(); + const LVecBase4 &sf = sa->get_frame(); // Expand sf from 0..1 to -1..1. frame.set(max(frame[0], sf[0] * 2.0f - 1.0f), min(frame[1], sf[1] * 2.0f - 1.0f), @@ -1222,20 +1222,20 @@ play_sound(const string &event) { // bars and buttons. //////////////////////////////////////////////////////////////////// void PGItem:: -reduce_region(LVecBase4f &frame, PGItem *obscurer) const { +reduce_region(LVecBase4 &frame, PGItem *obscurer) const { if (obscurer != (PGItem *)NULL && !obscurer->is_overall_hidden()) { - LVecBase4f oframe = get_relative_frame(obscurer); + LVecBase4 oframe = get_relative_frame(obscurer); // Determine the four rectangular regions on the four sides of the // obscuring region. - LVecBase4f right(max(frame[0], oframe[1]), frame[1], frame[2], frame[3]); - LVecBase4f left(frame[0], min(frame[1], oframe[0]), frame[2], frame[3]); - LVecBase4f above(frame[0], frame[1], max(frame[2], oframe[3]), frame[3]); - LVecBase4f below(frame[0], frame[1], frame[2], min(frame[3], oframe[2])); + LVecBase4 right(max(frame[0], oframe[1]), frame[1], frame[2], frame[3]); + LVecBase4 left(frame[0], min(frame[1], oframe[0]), frame[2], frame[3]); + LVecBase4 above(frame[0], frame[1], max(frame[2], oframe[3]), frame[3]); + LVecBase4 below(frame[0], frame[1], frame[2], min(frame[3], oframe[2])); // Now choose the largest of those four. - const LVecBase4f *largest = &right; - float largest_area = compute_area(*largest); + const LVecBase4 *largest = &right; + PN_stdfloat largest_area = compute_area(*largest); compare_largest(largest, largest_area, &left); compare_largest(largest, largest_area, &above); compare_largest(largest, largest_area, &below); @@ -1247,34 +1247,34 @@ reduce_region(LVecBase4f &frame, PGItem *obscurer) const { //////////////////////////////////////////////////////////////////// // Function: PGItem::get_relative_frame // Access: Protected -// Description: Returns the LVecBase4f frame of the indicated item, +// Description: Returns the LVecBase4 frame of the indicated item, // converted into this item's coordinate space. // Presumably, item is a child of this node. //////////////////////////////////////////////////////////////////// -LVecBase4f PGItem:: +LVecBase4 PGItem:: get_relative_frame(PGItem *item) const { NodePath this_np = NodePath::any_path((PGItem *)this); NodePath item_np = this_np.find_path_to(item); if (item_np.is_empty()) { item_np = NodePath::any_path(item); } - const LVecBase4f &orig_frame = item->get_frame(); - LMatrix4f transform = item_np.get_mat(this_np); + const LVecBase4 &orig_frame = item->get_frame(); + LMatrix4 transform = item_np.get_mat(this_np); // Transform the item's frame into the PGScrollFrame's // coordinate space. Transform all four vertices, and get the // new bounding box. This way the region works (mostly) even if // has been rotated. - LPoint3f ll(orig_frame[0], 0.0f, orig_frame[2]); - LPoint3f lr(orig_frame[1], 0.0f, orig_frame[2]); - LPoint3f ul(orig_frame[0], 0.0f, orig_frame[3]); - LPoint3f ur(orig_frame[1], 0.0f, orig_frame[3]); + LPoint3 ll(orig_frame[0], 0.0f, orig_frame[2]); + LPoint3 lr(orig_frame[1], 0.0f, orig_frame[2]); + LPoint3 ul(orig_frame[0], 0.0f, orig_frame[3]); + LPoint3 ur(orig_frame[1], 0.0f, orig_frame[3]); ll = ll * transform; lr = lr * transform; ul = ul * transform; ur = ur * transform; - return LVecBase4f(min(min(ll[0], lr[0]), min(ul[0], ur[0])), + return LVecBase4(min(min(ll[0], lr[0]), min(ul[0], ur[0])), max(max(ll[0], lr[0]), max(ul[0], ur[0])), min(min(ll[2], lr[2]), min(ul[2], ur[2])), max(max(ll[2], lr[2]), max(ul[2], ur[2]))); @@ -1286,13 +1286,13 @@ get_relative_frame(PGItem *item) const { // Description: Converts from the 2-d mouse coordinates into the // coordinate space of the item. //////////////////////////////////////////////////////////////////// -LPoint3f PGItem:: -mouse_to_local(const LPoint2f &mouse_point) const { +LPoint3 PGItem:: +mouse_to_local(const LPoint2 &mouse_point) const { // This is ambiguous if the PGItem has multiple instances. Why // would you do that, anyway? NodePath this_np((PGItem *)this); CPT(TransformState) inv_transform = NodePath().get_transform(this_np); - return inv_transform->get_mat().xform_point(LVector3f::rfu(mouse_point[0], 0, mouse_point[1])); + return inv_transform->get_mat().xform_point(LVector3::rfu(mouse_point[0], 0, mouse_point[1])); } //////////////////////////////////////////////////////////////////// @@ -1377,17 +1377,17 @@ mark_frames_stale() { // false otherwise. //////////////////////////////////////////////////////////////////// bool PGItem:: -clip_frame(pvector &source_points, const Planef &plane) const { +clip_frame(pvector &source_points, const LPlane &plane) const { if (source_points.empty()) { return true; } - LPoint3f from3d; - LVector3f delta3d; - if (!plane.intersects_plane(from3d, delta3d, Planef(LVector3f(0, 1, 0), LPoint3f::zero()))) { + LPoint3 from3d; + LVector3 delta3d; + if (!plane.intersects_plane(from3d, delta3d, LPlane(LVector3(0, 1, 0), LPoint3::zero()))) { // The clipping plane is parallel to the polygon. The polygon is // either all in or all out. - if (plane.dist_to_plane(LPoint3f::zero()) < 0.0) { + if (plane.dist_to_plane(LPoint3::zero()) < 0.0) { // A point within the polygon is behind the clipping plane: the // polygon is all in. return true; @@ -1397,12 +1397,12 @@ clip_frame(pvector &source_points, const Planef &plane) const { // Project the line of intersection into the X-Z plane. Now we have // a 2-d clipping line. - LPoint2f from2d(from3d[0], from3d[2]); - LVector2f delta2d(delta3d[0], delta3d[2]); + LPoint2 from2d(from3d[0], from3d[2]); + LVector2 delta2d(delta3d[0], delta3d[2]); - float a = -delta2d[1]; - float b = delta2d[0]; - float c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; + PN_stdfloat a = -delta2d[1]; + PN_stdfloat b = delta2d[0]; + PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; // Now walk through the points. Any point on the left of our line // gets removed, and the line segment clipped at the point of @@ -1411,15 +1411,15 @@ clip_frame(pvector &source_points, const Planef &plane) const { // We might increase the number of vertices by as many as 1, if the // plane clips off exactly one corner. (We might also decrease the // number of vertices, or keep them the same number.) - pvector new_points; + pvector new_points; new_points.reserve(source_points.size() + 1); - LPoint2f last_point = source_points.back(); + LPoint2 last_point = source_points.back(); bool last_is_in = is_right(last_point - from2d, delta2d); bool all_in = last_is_in; - pvector::const_iterator pi; + pvector::const_iterator pi; for (pi = source_points.begin(); pi != source_points.end(); ++pi) { - const LPoint2f &this_point = (*pi); + const LPoint2 &this_point = (*pi); bool this_is_in = is_right(this_point - from2d, delta2d); // There appears to be a compiler bug in gcc 4.0: we need to @@ -1428,11 +1428,11 @@ clip_frame(pvector &source_points, const Planef &plane) const { if (crossed_over) { // We have just crossed over the clipping line. Find the point // of intersection. - LVector2f d = this_point - last_point; - float denom = (a * d[0] + b * d[1]); + LVector2 d = this_point - last_point; + PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { - float t = -(a * last_point[0] + b * last_point[1] + c) / denom; - LPoint2f p = last_point + t * d; + PN_stdfloat t = -(a * last_point[0] + b * last_point[1] + c) / denom; + LPoint2 p = last_point + t * d; new_points.push_back(p); last_is_in = this_is_in; diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index 6a222b1422..fcc2e30283 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -82,8 +82,8 @@ protected: Thread *current_thread); public: - virtual void xform(const LMatrix4f &mat); - bool activate_region(const LMatrix4f &transform, int sort, + virtual void xform(const LMatrix4 &mat); + bool activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa); INLINE PGMouseWatcherRegion *get_region() const; @@ -110,9 +110,9 @@ public: INLINE PGItemNotify *get_notify() const; PUBLISHED: - INLINE void set_frame(float left, float right, float bottom, float top); - INLINE void set_frame(const LVecBase4f &frame); - INLINE const LVecBase4f &get_frame() const; + INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_frame(const LVecBase4 &frame); + INLINE const LVecBase4 &get_frame() const; INLINE bool has_frame() const; INLINE void clear_frame(); @@ -166,7 +166,7 @@ PUBLISHED: INLINE string get_release_event(const ButtonHandle &button) const; INLINE string get_keystroke_event() const; - INLINE LMatrix4f get_frame_inv_xform() const; + INLINE LMatrix4 get_frame_inv_xform() const; #ifdef HAVE_AUDIO void set_sound(const string &event, AudioSound *sound); @@ -183,10 +183,10 @@ PUBLISHED: protected: void play_sound(const string &event); - void reduce_region(LVecBase4f &clip, PGItem *obscurer) const; - void reduce_region(LVecBase4f &frame, float px, float py) const; - LVecBase4f get_relative_frame(PGItem *item) const; - LPoint3f mouse_to_local(const LPoint2f &mouse_point) const; + void reduce_region(LVecBase4 &clip, PGItem *obscurer) const; + void reduce_region(LVecBase4 &frame, PN_stdfloat px, PN_stdfloat py) const; + LVecBase4 get_relative_frame(PGItem *item) const; + LPoint3 mouse_to_local(const LPoint2 &mouse_point) const; virtual void frame_changed(); @@ -195,12 +195,12 @@ private: void update_frame(int state); void mark_frames_stale(); - INLINE static float compute_area(const LVecBase4f &frame); - INLINE static void compare_largest(const LVecBase4f *&largest, - float &largest_area, - const LVecBase4f *new_frame); + INLINE static PN_stdfloat compute_area(const LVecBase4 &frame); + INLINE static void compare_largest(const LVecBase4 *&largest, + PN_stdfloat &largest_area, + const LVecBase4 *new_frame); - bool clip_frame(pvector &source_points, const Planef &plane) const; + bool clip_frame(pvector &source_points, const LPlane &plane) const; protected: LightReMutex _lock; @@ -209,7 +209,7 @@ private: PGItemNotify *_notify; bool _has_frame; - LVecBase4f _frame; + LVecBase4 _frame; int _state; enum Flags { F_active = 0x01, @@ -220,7 +220,7 @@ private: PT(PGMouseWatcherRegion) _region; - LMatrix4f _frame_inv_xform; + LMatrix4 _frame_inv_xform; class StateDef { public: diff --git a/panda/src/pgui/pgScrollFrame.I b/panda/src/pgui/pgScrollFrame.I index c5015bea03..aa5e72acf3 100644 --- a/panda/src/pgui/pgScrollFrame.I +++ b/panda/src/pgui/pgScrollFrame.I @@ -21,8 +21,8 @@ // we can see only a portion of at any given time. //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: -set_virtual_frame(float left, float right, float bottom, float top) { - set_virtual_frame(LVecBase4f(left, right, bottom, top)); +set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_virtual_frame(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -33,7 +33,7 @@ set_virtual_frame(float left, float right, float bottom, float top) { // we can see only a portion of at any given time. //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: -set_virtual_frame(const LVecBase4f &frame) { +set_virtual_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); _has_virtual_frame = true; _virtual_frame = frame; @@ -51,7 +51,7 @@ set_virtual_frame(const LVecBase4f &frame) { // See set_virtual_frame(). If has_virtual_frame() is // false, this returns the item's clip frame. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &PGScrollFrame:: +INLINE const LVecBase4 &PGScrollFrame:: get_virtual_frame() const { LightReMutexHolder holder(_lock); return _has_virtual_frame ? _virtual_frame : get_clip_frame(); diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index f1b8520719..defe06517f 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -128,7 +128,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void PGScrollFrame:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); PGVirtualFrame::xform(mat); @@ -143,9 +143,9 @@ xform(const LMatrix4f &mat) { // dimensions, and the indicated virtual frame. //////////////////////////////////////////////////////////////////// void PGScrollFrame:: -setup(float width, float height, - float left, float right, float bottom, float top, - float slider_width, float bevel) { +setup(PN_stdfloat width, PN_stdfloat height, + PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top, + PN_stdfloat slider_width, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -178,14 +178,14 @@ setup(float width, float height, // Create new slider bars. PT(PGSliderBar) horizontal_slider = new PGSliderBar("horizontal"); horizontal_slider->setup_scroll_bar(false, width - slider_width - bevel * 2, slider_width, bevel); - horizontal_slider->set_transform(TransformState::make_pos(LVector3f::rfu(width / 2.0f - slider_width / 2.0f, 0, slider_width / 2.0f + bevel))); + horizontal_slider->set_transform(TransformState::make_pos(LVector3::rfu(width / 2.0f - slider_width / 2.0f, 0, slider_width / 2.0f + bevel))); add_child(horizontal_slider); set_horizontal_slider(horizontal_slider); PT(PGSliderBar) vertical_slider = new PGSliderBar("vertical"); vertical_slider->setup_scroll_bar(true, width - slider_width - bevel * 2, slider_width, bevel); add_child(vertical_slider); - vertical_slider->set_transform(TransformState::make_pos(LVector3f::rfu(width - slider_width / 2.0f - bevel, 0, width / 2.0f + slider_width / 2.0f))); + vertical_slider->set_transform(TransformState::make_pos(LVector3::rfu(width - slider_width / 2.0f - bevel, 0, width / 2.0f + slider_width / 2.0f))); set_vertical_slider(vertical_slider); set_manage_pieces(true); @@ -203,24 +203,24 @@ remanage() { LightReMutexHolder holder(_lock); _needs_remanage = false; - const LVecBase4f &frame = get_frame(); - LVecBase4f clip = get_frame_style(get_state()).get_internal_frame(frame); + const LVecBase4 &frame = get_frame(); + LVecBase4 clip = get_frame_style(get_state()).get_internal_frame(frame); // Determine which scroll bars we have in the frame. bool got_horizontal = false; - float horizontal_width = 0.0f; + PN_stdfloat horizontal_width = 0.0f; if (_horizontal_slider != (PGSliderBar *)NULL) { got_horizontal = true; - const LVecBase4f &slider_frame = _horizontal_slider->get_frame(); + const LVecBase4 &slider_frame = _horizontal_slider->get_frame(); horizontal_width = slider_frame[3] - slider_frame[2]; } bool got_vertical = false; - float vertical_width = 0.0f; + PN_stdfloat vertical_width = 0.0f; if (_vertical_slider != (PGSliderBar *)NULL) { got_vertical = true; - const LVecBase4f &slider_frame = _vertical_slider->get_frame(); + const LVecBase4 &slider_frame = _vertical_slider->get_frame(); vertical_width = slider_frame[1] - slider_frame[0]; } @@ -228,13 +228,13 @@ remanage() { // Should we hide or show either of the scroll bars? TODO. // Start by figuring out what our maximum clipping area will be. - float clip_width = clip[1] - clip[0]; - float clip_height = clip[3] - clip[2]; + PN_stdfloat clip_width = clip[1] - clip[0]; + PN_stdfloat clip_height = clip[3] - clip[2]; // And our virtual frame too. - const LVecBase4f &virtual_frame = get_virtual_frame(); - float virtual_width = virtual_frame[1] - virtual_frame[0]; - float virtual_height = virtual_frame[3] - virtual_frame[2]; + const LVecBase4 &virtual_frame = get_virtual_frame(); + PN_stdfloat virtual_width = virtual_frame[1] - virtual_frame[0]; + PN_stdfloat virtual_height = virtual_frame[3] - virtual_frame[2]; if (virtual_width <= clip_width && virtual_height <= clip_height) { @@ -385,7 +385,7 @@ recompute_clip() { _needs_recompute_canvas = true; // Figure out how to remove the scroll bars from the clip region. - LVecBase4f clip = get_frame_style(get_state()).get_internal_frame(get_frame()); + LVecBase4 clip = get_frame_style(get_state()).get_internal_frame(get_frame()); reduce_region(clip, _horizontal_slider); reduce_region(clip, _vertical_slider); @@ -411,17 +411,17 @@ recompute_canvas() { LightReMutexHolder holder(_lock); _needs_recompute_canvas = false; - const LVecBase4f &clip = get_clip_frame(); + const LVecBase4 &clip = get_clip_frame(); - float x = interpolate_canvas(clip[0], clip[1], + PN_stdfloat x = interpolate_canvas(clip[0], clip[1], _virtual_frame[0], _virtual_frame[1], _horizontal_slider); - float y = interpolate_canvas(clip[3], clip[2], + PN_stdfloat y = interpolate_canvas(clip[3], clip[2], _virtual_frame[3], _virtual_frame[2], _vertical_slider); - get_canvas_node()->set_transform(TransformState::make_pos(LVector3f::rfu(x, 0, y))); + get_canvas_node()->set_transform(TransformState::make_pos(LVector3::rfu(x, 0, y))); } //////////////////////////////////////////////////////////////////// @@ -431,18 +431,18 @@ recompute_canvas() { // applied to the virtual canvas node, based on the // corresponding slider bar's position. //////////////////////////////////////////////////////////////////// -float PGScrollFrame:: -interpolate_canvas(float clip_min, float clip_max, - float canvas_min, float canvas_max, +PN_stdfloat PGScrollFrame:: +interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, + PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar) { LightReMutexHolder holder(_lock); - float t = 0.0f; + PN_stdfloat t = 0.0f; if (slider_bar != (PGSliderBar *)NULL) { t = slider_bar->get_ratio(); } - float min = clip_min - canvas_min; - float max = clip_max - canvas_max; + PN_stdfloat min = clip_min - canvas_min; + PN_stdfloat max = clip_max - canvas_max; return min + t * (max - min); } diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index cca856fc98..430e0927f8 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -47,16 +47,16 @@ protected: public: virtual PandaNode *make_copy() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); PUBLISHED: - void setup(float width, float height, - float left, float right, float bottom, float top, - float slider_width, float bevel); + void setup(PN_stdfloat width, PN_stdfloat height, + PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top, + PN_stdfloat slider_width, PN_stdfloat bevel); - INLINE void set_virtual_frame(float left, float right, float bottom, float top); - INLINE void set_virtual_frame(const LVecBase4f &virtual_frame); - INLINE const LVecBase4f &get_virtual_frame() const; + INLINE void set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_virtual_frame(const LVecBase4 &virtual_frame); + INLINE const LVecBase4 &get_virtual_frame() const; INLINE bool has_virtual_frame() const; INLINE void clear_virtual_frame(); @@ -89,8 +89,8 @@ private: void recompute_clip(); void recompute_canvas(); - float interpolate_canvas(float clip_min, float clip_max, - float canvas_min, float canvas_max, + PN_stdfloat interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, + PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar); private: @@ -98,10 +98,10 @@ private: bool _needs_recompute_clip; bool _needs_recompute_canvas; - LVecBase4f _orig_clip_frame; + LVecBase4 _orig_clip_frame; bool _has_virtual_frame; - LVecBase4f _virtual_frame; + LVecBase4 _virtual_frame; bool _manage_pieces; bool _auto_hide; diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index ec548b63ba..2edbf25c66 100755 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -59,7 +59,7 @@ get_notify() const { // directly. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_axis(const LVector3f &axis) { +set_axis(const LVector3 &axis) { LightReMutexHolder holder(_lock); _axis = axis; _needs_remanage = true; @@ -72,7 +72,7 @@ set_axis(const LVector3f &axis) { // Description: Returns the axis of the slider bar's motion. See // set_axis(). //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &PGSliderBar:: +INLINE const LVector3 &PGSliderBar:: get_axis() const { LightReMutexHolder holder(_lock); return _axis; @@ -84,7 +84,7 @@ get_axis() const { // Description: Sets the minimum and maxmimum value for the slider. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_range(float min_value, float max_value) { +set_range(PN_stdfloat min_value, PN_stdfloat max_value) { LightReMutexHolder holder(_lock); nassertv(min_value != max_value); _min_value = min_value; @@ -102,7 +102,7 @@ set_range(float min_value, float max_value) { // Description: Returns the value when the slider is all the way to // the left. //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_min_value() const { LightReMutexHolder holder(_lock); return _min_value; @@ -114,7 +114,7 @@ get_min_value() const { // Description: Returns the value when the slider is all the way to // the right. //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_max_value() const { LightReMutexHolder holder(_lock); return _max_value; @@ -127,7 +127,7 @@ get_max_value() const { // user clicks on the left or right buttons. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_scroll_size(float value) { +set_scroll_size(PN_stdfloat value) { LightReMutexHolder holder(_lock); _scroll_value = value; _needs_recompute = true; @@ -138,7 +138,7 @@ set_scroll_size(float value) { // Access: Published // Description: Returns the value last set by set_scroll_size(). //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_scroll_size() const { LightReMutexHolder holder(_lock); return _scroll_value; @@ -154,7 +154,7 @@ get_scroll_size() const { // size of the thumb button. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_page_size(float value) { +set_page_size(PN_stdfloat value) { LightReMutexHolder holder(_lock); _page_value = value; _needs_recompute = true; @@ -165,7 +165,7 @@ set_page_size(float value) { // Access: Published // Description: Returns the value last set by set_page_size(). //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_page_size() const { LightReMutexHolder holder(_lock); return _page_value; @@ -179,7 +179,7 @@ get_page_size() const { // get_min_value() and get_max_value(). //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_value(float value) { +set_value(PN_stdfloat value) { LightReMutexHolder holder(_lock); set_ratio((value - _min_value) / (_max_value - _min_value)); } @@ -189,7 +189,7 @@ set_value(float value) { // Access: Published // Description: Returns the current value of the slider. //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_value() const { LightReMutexHolder holder(_lock); return get_ratio() * (_max_value - _min_value) + _min_value; @@ -202,7 +202,7 @@ get_value() const { // the range 0 .. 1. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -set_ratio(float ratio) { +set_ratio(PN_stdfloat ratio) { LightReMutexHolder holder(_lock); if (!is_button_down()) { internal_set_ratio(ratio); @@ -215,7 +215,7 @@ set_ratio(float ratio) { // Description: Returns the current value of the slider, expressed in // the range 0 .. 1. //////////////////////////////////////////////////////////////////// -INLINE float PGSliderBar:: +INLINE PN_stdfloat PGSliderBar:: get_ratio() const { LightReMutexHolder holder(_lock); return _ratio; @@ -477,8 +477,8 @@ get_adjust_event() const { // is currently manipulating the slider. //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: -internal_set_ratio(float ratio) { - _ratio = max(min(ratio, 1.0f), 0.0f); +internal_set_ratio(PN_stdfloat ratio) { + _ratio = max(min(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0); _needs_reposition = true; adjust(); } diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index 02e00e8c32..a6ef1e9963 100755 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -230,7 +230,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // kinds of nodes, this does nothing. //////////////////////////////////////////////////////////////////// void PGSliderBar:: -xform(const LMatrix4f &mat) { +xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); PGItem::xform(mat); _axis = _axis * mat; @@ -279,17 +279,17 @@ adjust() { // dimension, and the width is the y dimension). //////////////////////////////////////////////////////////////////// void PGSliderBar:: -setup_scroll_bar(bool vertical, float length, float width, float bevel) { +setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); if (vertical) { set_frame(-width / 2.0f, width / 2.0f, -length / 2.0f, length / 2.0f); - _axis = LVector3f::rfu(0.0f, 0.0f, -1.0f); + _axis = LVector3::rfu(0.0f, 0.0f, -1.0f); } else { set_frame(-length / 2.0f, length / 2.0f, -width / 2.0f, width / 2.0f); - _axis = LVector3f::rfu(1.0f, 0.0f, 0.0f); + _axis = LVector3::rfu(1.0f, 0.0f, 0.0f); } PGFrameStyle style; @@ -353,17 +353,17 @@ setup_scroll_bar(bool vertical, float length, float width, float bevel) { // has a distinctive look. //////////////////////////////////////////////////////////////////// void PGSliderBar:: -setup_slider(bool vertical, float length, float width, float bevel) { +setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); if (vertical) { set_frame(-width / 2.0f, width / 2.0f, -length / 2.0f, length / 2.0f); - _axis = LVector3f::rfu(0.0f, 0.0f, -1.0f); + _axis = LVector3::rfu(0.0f, 0.0f, -1.0f); } else { set_frame(-length / 2.0f, length / 2.0f, -width / 2.0f, width / 2.0f); - _axis = LVector3f::rfu(1.0f, 0.0f, 0.0f); + _axis = LVector3::rfu(1.0f, 0.0f, 0.0f); } PGFrameStyle style; @@ -437,9 +437,9 @@ remanage() { LightReMutexHolder holder(_lock); _needs_remanage = false; - const LVecBase4f &frame = get_frame(); + const LVecBase4 &frame = get_frame(); - float width, length; + PN_stdfloat width, length; if (fabs(_axis[0]) > fabs(_axis[1] + _axis[2])) { // The slider is X-dominant. width = frame[3] - frame[2]; @@ -451,7 +451,7 @@ remanage() { length = frame[3] - frame[2]; } - LVector3f center = LVector3f::rfu((frame[0] + frame[1]) / 2.0f, + LVector3 center = LVector3::rfu((frame[0] + frame[1]) / 2.0f, 0.0f, (frame[2] + frame[3]) / 2.0f); @@ -504,7 +504,7 @@ recompute() { _thumb_start.set(0.0f, 0.0f, 0.0f); } else { - LVecBase4f frame = get_frame(); + LVecBase4 frame = get_frame(); reduce_region(frame, _left_button); reduce_region(frame, _right_button); @@ -514,7 +514,7 @@ recompute() { _min_x = frame[0]; _max_x = frame[1]; - float trough_width = _max_x - _min_x; + PN_stdfloat trough_width = _max_x - _min_x; if (_thumb_button == (PGButton *)NULL) { _thumb_width = 0.0f; @@ -522,12 +522,12 @@ recompute() { _thumb_start.set(0.0f, 0.0f, 0.0f); } else { - const LVecBase4f &thumb_frame = _thumb_button->get_frame(); + const LVecBase4 &thumb_frame = _thumb_button->get_frame(); if (_resize_thumb) { // If we're allowed to adjust the thumb's size, we don't need to // find out how wide it is. - _thumb_width = trough_width * min(1.0f, _page_ratio); + _thumb_width = trough_width * min((PN_stdfloat)1.0, _page_ratio); _thumb_button->set_frame(-_thumb_width / 2.0f, _thumb_width / 2.0f, thumb_frame[2], thumb_frame[3]); } else { @@ -545,7 +545,7 @@ recompute() { // The slider runs backwards: right to left. _thumb_start = (thumb_frame[1] - _max_x) * _axis; } - _thumb_start += LVector3f::rfu(0.0f, 0.0f, (frame[2] + frame[3]) / 2.0f); + _thumb_start += LVector3::rfu(0.0f, 0.0f, (frame[2] + frame[3]) / 2.0f); } } else { @@ -555,7 +555,7 @@ recompute() { _min_x = frame[2]; _max_x = frame[3]; - float trough_width = _max_x - _min_x; + PN_stdfloat trough_width = _max_x - _min_x; if (_thumb_button == (PGButton *)NULL) { _thumb_width = 0.0f; @@ -563,12 +563,12 @@ recompute() { _thumb_start.set(0.0f, 0.0f, 0.0f); } else { - const LVecBase4f &thumb_frame = _thumb_button->get_frame(); + const LVecBase4 &thumb_frame = _thumb_button->get_frame(); if (_resize_thumb) { // If we're allowed to adjust the thumb's size, we don't need to // find out how wide it is. - _thumb_width = trough_width * min(1.0f, _page_ratio); + _thumb_width = trough_width * min((PN_stdfloat)1.0, _page_ratio); _thumb_button->set_frame(thumb_frame[0], thumb_frame[1], -_thumb_width / 2.0f, _thumb_width / 2.0f); } else { @@ -586,7 +586,7 @@ recompute() { // The slider runs backwards: top to bottom. _thumb_start = (thumb_frame[3] - _max_x) * _axis; } - _thumb_start += LVector3f::rfu((frame[0] + frame[1]) / 2.0f, 0.0f, 0.0f); + _thumb_start += LVector3::rfu((frame[0] + frame[1]) / 2.0f, 0.0f, 0.0f); } } } @@ -716,10 +716,10 @@ void PGSliderBar:: reposition() { _needs_reposition = false; - float t = get_ratio(); + PN_stdfloat t = get_ratio(); if (_thumb_button != (PGButton *)NULL) { - LPoint3f pos = (t * _range_x) * _axis + _thumb_start; + LPoint3 pos = (t * _range_x) * _axis + _thumb_start; CPT(TransformState) transform = TransformState::make_pos(pos); CPT(TransformState) orig_transform = _thumb_button->get_transform(); @@ -743,10 +743,10 @@ reposition() { void PGSliderBar:: advance_scroll() { if (_scroll_button_held == _left_button) { - internal_set_ratio(max(_ratio - _scroll_ratio, 0.0f)); + internal_set_ratio(max(_ratio - _scroll_ratio, (PN_stdfloat)0.0)); } else if (_scroll_button_held == _right_button) { - internal_set_ratio(min(_ratio + _scroll_ratio, 1.0f)); + internal_set_ratio(min(_ratio + _scroll_ratio, (PN_stdfloat)1.0)); } _next_advance_time = @@ -764,10 +764,10 @@ void PGSliderBar:: advance_page() { // Is the mouse position left or right of the current thumb // position? - LPoint3f mouse = mouse_to_local(_mouse_pos) - _thumb_start; - float target_ratio = mouse.dot(_axis) / _range_x; + LPoint3 mouse = mouse_to_local(_mouse_pos) - _thumb_start; + PN_stdfloat target_ratio = mouse.dot(_axis) / _range_x; - float t; + PN_stdfloat t; if (target_ratio < _ratio) { t = max(_ratio - _page_ratio + _scroll_ratio, target_ratio); @@ -797,7 +797,7 @@ begin_drag() { recompute(); } if (_range_x != 0.0f) { - float current_x = mouse_to_local(_mouse_pos).dot(_axis); + PN_stdfloat current_x = mouse_to_local(_mouse_pos).dot(_axis); _drag_start_x = current_x - get_ratio() * _range_x; _dragging = true; } @@ -815,7 +815,7 @@ continue_drag() { recompute(); } if (_range_x != 0.0f) { - float current_x = mouse_to_local(_mouse_pos).dot(_axis); + PN_stdfloat current_x = mouse_to_local(_mouse_pos).dot(_axis); internal_set_ratio((current_x - _drag_start_x) / _range_x); } } diff --git a/panda/src/pgui/pgSliderBar.h b/panda/src/pgui/pgSliderBar.h index 5aaa5c0340..8cd4efe19c 100755 --- a/panda/src/pgui/pgSliderBar.h +++ b/panda/src/pgui/pgSliderBar.h @@ -42,7 +42,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); - virtual void xform(const LMatrix4f &mat); + virtual void xform(const LMatrix4 &mat); virtual void press(const MouseWatcherParameter ¶m, bool background); virtual void release(const MouseWatcherParameter ¶m, bool background); @@ -54,27 +54,27 @@ public: INLINE PGSliderBarNotify *get_notify() const; PUBLISHED: - void setup_scroll_bar(bool vertical, float length, float width, float bevel); - void setup_slider(bool vertical, float length, float width, float bevel); + void setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel); + void setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel); - INLINE void set_axis(const LVector3f &axis); - INLINE const LVector3f &get_axis() const; + INLINE void set_axis(const LVector3 &axis); + INLINE const LVector3 &get_axis() const; - INLINE void set_range(float min_value, float max_value); - INLINE float get_min_value() const; - INLINE float get_max_value() const; + INLINE void set_range(PN_stdfloat min_value, PN_stdfloat max_value); + INLINE PN_stdfloat get_min_value() const; + INLINE PN_stdfloat get_max_value() const; - INLINE void set_scroll_size(float scroll_size); - INLINE float get_scroll_size() const; + INLINE void set_scroll_size(PN_stdfloat scroll_size); + INLINE PN_stdfloat get_scroll_size() const; - INLINE void set_page_size(float page_size); - INLINE float get_page_size() const; + INLINE void set_page_size(PN_stdfloat page_size); + INLINE PN_stdfloat get_page_size() const; - INLINE void set_value(float value); - INLINE float get_value() const; + INLINE void set_value(PN_stdfloat value); + INLINE PN_stdfloat get_value() const; - INLINE void set_ratio(float ratio); - INLINE float get_ratio() const; + INLINE void set_ratio(PN_stdfloat ratio); + INLINE PN_stdfloat get_ratio() const; INLINE bool is_button_down() const; @@ -115,7 +115,7 @@ protected: virtual void item_move(PGItem *item, const MouseWatcherParameter ¶m); private: - INLINE void internal_set_ratio(float ratio); + INLINE void internal_set_ratio(PN_stdfloat ratio); void reposition(); void advance_scroll(); @@ -129,27 +129,27 @@ private: bool _needs_recompute; bool _needs_reposition; - float _min_value, _max_value; - float _scroll_value, _scroll_ratio; - float _page_value, _page_ratio; - float _ratio; + PN_stdfloat _min_value, _max_value; + PN_stdfloat _scroll_value, _scroll_ratio; + PN_stdfloat _page_value, _page_ratio; + PN_stdfloat _ratio; bool _resize_thumb; bool _manage_pieces; - LVector3f _axis; + LVector3 _axis; PT(PGButton) _thumb_button; PT(PGButton) _left_button; PT(PGButton) _right_button; - float _min_x, _max_x, _thumb_width, _range_x; - LPoint3f _thumb_start; + PN_stdfloat _min_x, _max_x, _thumb_width, _range_x; + LPoint3 _thumb_start; PGItem *_scroll_button_held; bool _mouse_button_page; - LPoint2f _mouse_pos; + LPoint2 _mouse_pos; double _next_advance_time; bool _dragging; - float _drag_start_x; + PN_stdfloat _drag_start_x; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgui/pgVirtualFrame.I b/panda/src/pgui/pgVirtualFrame.I index e388313650..9dfaba3bd8 100644 --- a/panda/src/pgui/pgVirtualFrame.I +++ b/panda/src/pgui/pgVirtualFrame.I @@ -24,8 +24,8 @@ // room for scroll bars). //////////////////////////////////////////////////////////////////// INLINE void PGVirtualFrame:: -set_clip_frame(float left, float right, float bottom, float top) { - set_clip_frame(LVecBase4f(left, right, bottom, top)); +set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_clip_frame(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ set_clip_frame(float left, float right, float bottom, float top) { // See set_clip_frame(). If has_clip_frame() is // false, this returns the item's actual frame. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &PGVirtualFrame:: +INLINE const LVecBase4 &PGVirtualFrame:: get_clip_frame() const { LightReMutexHolder holder(_lock); return _has_clip_frame ? _clip_frame : get_frame(); diff --git a/panda/src/pgui/pgVirtualFrame.cxx b/panda/src/pgui/pgVirtualFrame.cxx index 3def951f11..eb728f471b 100644 --- a/panda/src/pgui/pgVirtualFrame.cxx +++ b/panda/src/pgui/pgVirtualFrame.cxx @@ -130,14 +130,14 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, // dimensions. //////////////////////////////////////////////////////////////////// void PGVirtualFrame:: -setup(float width, float height) { +setup(PN_stdfloat width, PN_stdfloat height) { LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); set_frame(0, width, 0, height); - float bevel = 0.05f; + PN_stdfloat bevel = 0.05f; PGFrameStyle style; style.set_width(bevel, bevel); @@ -161,17 +161,17 @@ setup(float width, float height) { // room for scroll bars). //////////////////////////////////////////////////////////////////// void PGVirtualFrame:: -set_clip_frame(const LVecBase4f &frame) { +set_clip_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); if (!_has_clip_frame || _clip_frame != frame) { _has_clip_frame = true; _clip_frame = frame; CPT(RenderEffect) scissor_effect = ScissorEffect::make_node - (LPoint3f(_clip_frame[0], _clip_frame[2], _clip_frame[2]), - LPoint3f(_clip_frame[1], _clip_frame[2], _clip_frame[2]), - LPoint3f(_clip_frame[1], _clip_frame[3], _clip_frame[3]), - LPoint3f(_clip_frame[0], _clip_frame[3], _clip_frame[3])); + (LPoint3(_clip_frame[0], _clip_frame[2], _clip_frame[2]), + LPoint3(_clip_frame[1], _clip_frame[2], _clip_frame[2]), + LPoint3(_clip_frame[1], _clip_frame[3], _clip_frame[3]), + LPoint3(_clip_frame[0], _clip_frame[3], _clip_frame[3])); _canvas_parent->set_effect(scissor_effect); clip_frame_changed(); diff --git a/panda/src/pgui/pgVirtualFrame.h b/panda/src/pgui/pgVirtualFrame.h index c04875f05f..803fb12b8e 100644 --- a/panda/src/pgui/pgVirtualFrame.h +++ b/panda/src/pgui/pgVirtualFrame.h @@ -59,11 +59,11 @@ protected: Thread *current_thread); PUBLISHED: - void setup(float width, float height); + void setup(PN_stdfloat width, PN_stdfloat height); - INLINE void set_clip_frame(float left, float right, float bottom, float top); - void set_clip_frame(const LVecBase4f &clip_frame); - INLINE const LVecBase4f &get_clip_frame() const; + INLINE void set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + void set_clip_frame(const LVecBase4 &clip_frame); + INLINE const LVecBase4 &get_clip_frame() const; INLINE bool has_clip_frame() const; void clear_clip_frame(); @@ -81,7 +81,7 @@ private: private: bool _has_clip_frame; - LVecBase4f _clip_frame; + LVecBase4 _clip_frame; PT(ModelNode) _canvas_node; PT(ModelNode) _canvas_parent; diff --git a/panda/src/pgui/pgWaitBar.I b/panda/src/pgui/pgWaitBar.I index e241b5d59e..b598272450 100644 --- a/panda/src/pgui/pgWaitBar.I +++ b/panda/src/pgui/pgWaitBar.I @@ -19,7 +19,7 @@ // Description: Sets the value at which the WaitBar indicates 100%. //////////////////////////////////////////////////////////////////// INLINE void PGWaitBar:: -set_range(float range) { +set_range(PN_stdfloat range) { LightReMutexHolder holder(_lock); _range = range; _bar_state = -1; @@ -30,7 +30,7 @@ set_range(float range) { // Access: Published // Description: Returns the value at which the WaitBar indicates 100%. //////////////////////////////////////////////////////////////////// -INLINE float PGWaitBar:: +INLINE PN_stdfloat PGWaitBar:: get_range() const { LightReMutexHolder holder(_lock); return _range; @@ -43,7 +43,7 @@ get_range() const { // between 0 and get_range(). //////////////////////////////////////////////////////////////////// INLINE void PGWaitBar:: -set_value(float value) { +set_value(PN_stdfloat value) { LightReMutexHolder holder(_lock); _value = value; _bar_state = -1; @@ -54,7 +54,7 @@ set_value(float value) { // Access: Published // Description: Returns the current value of the bar. //////////////////////////////////////////////////////////////////// -INLINE float PGWaitBar:: +INLINE PN_stdfloat PGWaitBar:: get_value() const { LightReMutexHolder holder(_lock); return _value; @@ -65,7 +65,7 @@ get_value() const { // Access: Published // Description: Returns the percentage complete. //////////////////////////////////////////////////////////////////// -INLINE float PGWaitBar:: +INLINE PN_stdfloat PGWaitBar:: get_percent() const { LightReMutexHolder holder(_lock); return (_value / _range) * 100.0f; diff --git a/panda/src/pgui/pgWaitBar.cxx b/panda/src/pgui/pgWaitBar.cxx index c7a85e6df9..55d8872d55 100644 --- a/panda/src/pgui/pgWaitBar.cxx +++ b/panda/src/pgui/pgWaitBar.cxx @@ -110,14 +110,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // with the indicated maximum range. //////////////////////////////////////////////////////////////////// void PGWaitBar:: -setup(float width, float height, float range) { +setup(PN_stdfloat width, PN_stdfloat height, PN_stdfloat range) { LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); set_frame(-0.5f * width, 0.5f * width, -0.5f * height, 0.5f * height); - float bevel = 0.05f; + PN_stdfloat bevel = 0.05f; PGFrameStyle style; style.set_width(bevel, bevel); @@ -157,18 +157,18 @@ update() { nassertv(!root.is_empty()); PGFrameStyle style = get_frame_style(state); - const LVecBase4f &frame = get_frame(); - const LVecBase2f &width = style.get_width(); + const LVecBase4 &frame = get_frame(); + const LVecBase2 &width = style.get_width(); // Put the bar within the item's frame's border. - LVecBase4f bar_frame(frame[0] + width[0], + LVecBase4 bar_frame(frame[0] + width[0], frame[1] - width[0], frame[2] + width[1], frame[3] - width[1]); // And scale the bar according to our value. - float frac = _value / _range; - frac = max(min(frac, 1.0f), 0.0f); + PN_stdfloat frac = _value / _range; + frac = max(min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); bar_frame[1] = bar_frame[0] + frac * (bar_frame[1] - bar_frame[0]); _bar = _bar_style.generate_into(root, bar_frame, 1); diff --git a/panda/src/pgui/pgWaitBar.h b/panda/src/pgui/pgWaitBar.h index 7322f54c86..41603ab551 100644 --- a/panda/src/pgui/pgWaitBar.h +++ b/panda/src/pgui/pgWaitBar.h @@ -39,15 +39,15 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); PUBLISHED: - void setup(float width, float height, float range); + void setup(PN_stdfloat width, PN_stdfloat height, PN_stdfloat range); - INLINE void set_range(float range); - INLINE float get_range() const; + INLINE void set_range(PN_stdfloat range); + INLINE PN_stdfloat get_range() const; - INLINE void set_value(float value); - INLINE float get_value() const; + INLINE void set_value(PN_stdfloat value); + INLINE PN_stdfloat get_value() const; - INLINE float get_percent() const; + INLINE PN_stdfloat get_percent() const; INLINE void set_bar_style(const PGFrameStyle &style); INLINE PGFrameStyle get_bar_style() const; @@ -55,7 +55,7 @@ PUBLISHED: private: void update(); - float _range, _value; + PN_stdfloat _range, _value; int _bar_state; PGFrameStyle _bar_style; NodePath _bar; diff --git a/panda/src/physics/actorNode.I b/panda/src/physics/actorNode.I index a7f7c1947e..15b8edb1ba 100644 --- a/panda/src/physics/actorNode.I +++ b/panda/src/physics/actorNode.I @@ -18,7 +18,7 @@ // Description : //////////////////////////////////////////////////////////////////// INLINE void ActorNode:: -set_contact_vector(const LVector3f &contact_vector) { +set_contact_vector(const LVector3 &contact_vector) { _contact_vector=contact_vector; } @@ -27,7 +27,7 @@ set_contact_vector(const LVector3f &contact_vector) { // Access : Public // Description : //////////////////////////////////////////////////////////////////// -INLINE const LVector3f &ActorNode:: +INLINE const LVector3 &ActorNode:: get_contact_vector() const { return _contact_vector; } diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index 34bbbb8b27..653c213ea4 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -28,7 +28,7 @@ TypeHandle ActorNode::_type_handle; ActorNode:: ActorNode(const string &name) : PhysicalNode(name) { - _contact_vector = LVector3f::zero(); + _contact_vector = LVector3::zero(); add_physical(new Physical(1, true)); _mass_center = get_physical(0)->get_phys_body(); _mass_center->set_active(true); @@ -47,7 +47,7 @@ ActorNode(const string &name) : ActorNode:: ActorNode(const ActorNode ©) : PhysicalNode(copy) { - _contact_vector = LVector3f::zero(); + _contact_vector = LVector3::zero(); _ok_to_callback = true; _mass_center = get_physical(0)->get_phys_body(); _transform_limit = copy._transform_limit; @@ -71,7 +71,7 @@ ActorNode:: //////////////////////////////////////////////////////////////////// void ActorNode:: update_transform() { - LMatrix4f lcs = _mass_center->get_lcs(); + LMatrix4 lcs = _mass_center->get_lcs(); // lock the callback so that this doesn't call transform_changed. _ok_to_callback = false; @@ -88,7 +88,7 @@ update_transform() { //////////////////////////////////////////////////////////////////// void ActorNode:: test_transform(const TransformState *ts) const { - LPoint3f pos(ts->get_pos()); + LPoint3 pos(ts->get_pos()); nassertv(pos[0] < _transform_limit); nassertv(pos[0] > -_transform_limit); nassertv(pos[1] < _transform_limit); diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index 1c9a3cb766..b64ade98aa 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -35,21 +35,21 @@ PUBLISHED: PhysicsObject *get_physics_object() { return _mass_center; } - void set_contact_vector(const LVector3f &contact_vector); - const LVector3f &get_contact_vector() const; + void set_contact_vector(const LVector3 &contact_vector); + const LVector3 &get_contact_vector() const; // update the parent scene graph node with PhysicsObject information // i.e. copy from PhysicsObject to PandaNode void update_transform(); - void set_transform_limit(float limit) { _transform_limit = limit; }; + void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; virtual void write(ostream &out, unsigned int indent=0) const; private: PhysicsObject *_mass_center; - LVector3f _contact_vector; + LVector3 _contact_vector; bool _ok_to_callback; - float _transform_limit; + PN_stdfloat _transform_limit; // node hook if the client changes the node's transform. // i.e. copy from PandaNode to PhysicsObject diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 61b0ba7698..9c80144b0a 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -45,7 +45,7 @@ AngularEulerIntegrator:: void AngularEulerIntegrator:: child_integrate(Physical *physical, AngularForceVector& forces, - float dt) { + PN_stdfloat dt) { // Loop through each object in the set. This processing occurs in // O(pf) time, where p is the number of physical objects and f is // the number of forces. Unfortunately, no precomputation of forces @@ -69,12 +69,12 @@ child_integrate(Physical *physical, continue; } - LRotationf accum_quat(0, 0, 0, 0); + LRotation accum_quat(0, 0, 0, 0); // set up the traversal stuff. AngularForceVector::const_iterator f_cur; - LRotationf f; + LRotation f; // global forces f_cur = forces.begin(); @@ -92,7 +92,7 @@ child_integrate(Physical *physical, accum_quat += f; } - LOrientationf orientation = current_object->get_orientation(); + LOrientation orientation = current_object->get_orientation(); // local forces f_cur = physical->get_angular_forces().begin(); for (; f_cur != physical->get_angular_forces().end(); ++f_cur) { @@ -116,13 +116,13 @@ child_integrate(Physical *physical, accum_quat = current_object->get_inertial_tensor() * accum_quat; // derive this into the angular velocity vector. - LRotationf rot_quat = current_object->get_rotation(); + LRotation rot_quat = current_object->get_rotation(); #if 0 rot_quat += accum_quat * dt; if (rot_quat.normalize()) { - LOrientationf old_orientation = current_object->get_orientation(); - LOrientationf new_orientation = old_orientation * rot_quat; + LOrientation old_orientation = current_object->get_orientation(); + LOrientation new_orientation = old_orientation * rot_quat; new_orientation.normalize(); // and write the results back. @@ -131,7 +131,7 @@ child_integrate(Physical *physical, } #else //accum_quat*=viscosityDamper; - //LOrientationf orientation = current_object->get_orientation(); + //LOrientation orientation = current_object->get_orientation(); //accum_quat.normalize(); // x = x + v * t + 0.5 * a * t * t diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 76254ee586..6c43dbc8bc 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -33,7 +33,7 @@ PUBLISHED: private: virtual void child_integrate(Physical *physical, AngularForceVector& forces, - float dt); + PN_stdfloat dt); }; #endif // EULERINTEGRATOR_H diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 746c282840..857bbd5d06 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -50,9 +50,9 @@ AngularForce:: // Access : public // Description : access query //////////////////////////////////////////////////////////////////// -LRotationf AngularForce:: +LRotation AngularForce:: get_quat(const PhysicsObject *po) { - LRotationf v = get_child_quat(po); + LRotation v = get_child_quat(po); return v; } diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index 71b21d8e39..3a66db58d4 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -26,7 +26,7 @@ PUBLISHED: virtual ~AngularForce(); virtual AngularForce *make_copy() const = 0; - LRotationf get_quat(const PhysicsObject *po); + LRotation get_quat(const PhysicsObject *po); virtual bool is_linear() const; virtual void output(ostream &out) const; @@ -37,7 +37,7 @@ protected: AngularForce(const AngularForce ©); private: - virtual LRotationf get_child_quat(const PhysicsObject *po) = 0; + virtual LRotation get_child_quat(const PhysicsObject *po) = 0; public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/angularIntegrator.cxx b/panda/src/physics/angularIntegrator.cxx index 319bc22f70..00c47e9572 100644 --- a/panda/src/physics/angularIntegrator.cxx +++ b/panda/src/physics/angularIntegrator.cxx @@ -42,7 +42,7 @@ AngularIntegrator:: //////////////////////////////////////////////////////////////////// void AngularIntegrator:: integrate(Physical *physical, AngularForceVector& forces, - float dt) { + PN_stdfloat dt) { // intercept in case we want to censor/adjust values if (dt > _max_angular_dt) { dt = _max_angular_dt; diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index f7e8c4146f..f8fa857b9c 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -31,7 +31,7 @@ PUBLISHED: public: void integrate(Physical *physical, AngularForceVector &forces, - float dt); + PN_stdfloat dt); PUBLISHED: virtual void output(ostream &out) const; @@ -46,7 +46,7 @@ private: // this allows baseAngularIntegrator to censor/modify data that the // actual integration function receives. virtual void child_integrate(Physical *physical, AngularForceVector &forces, - float dt) = 0; + PN_stdfloat dt) = 0; }; #endif // ANGULARINTEGRATOR_H diff --git a/panda/src/physics/angularVectorForce.I b/panda/src/physics/angularVectorForce.I index 7964a24fd8..9e5d69a46e 100644 --- a/panda/src/physics/angularVectorForce.I +++ b/panda/src/physics/angularVectorForce.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void AngularVectorForce:: -set_quat(const LRotationf &v) { +set_quat(const LRotation &v) { _fvec = v; } @@ -26,15 +26,15 @@ set_quat(const LRotationf &v) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void AngularVectorForce:: -set_hpr(float h, float p, float r) { - _fvec.set_hpr(LVecBase3f(h, p, r)); +set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + _fvec.set_hpr(LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// // Function : get_local_quat // Access : public //////////////////////////////////////////////////////////////////// -INLINE LRotationf AngularVectorForce:: +INLINE LRotation AngularVectorForce:: get_local_quat() const { return _fvec; } diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index 9fc486e3ff..8cce5b3ef7 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -22,7 +22,7 @@ TypeHandle AngularVectorForce::_type_handle; // Description : constructor //////////////////////////////////////////////////////////////////// AngularVectorForce:: -AngularVectorForce(const LRotationf &vec) : +AngularVectorForce(const LRotation &vec) : AngularForce(), _fvec(vec) { } @@ -32,9 +32,9 @@ AngularVectorForce(const LRotationf &vec) : // Description : constructor //////////////////////////////////////////////////////////////////// AngularVectorForce:: -AngularVectorForce(float h, float p, float r) : +AngularVectorForce(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) : AngularForce() { - _fvec.set_hpr(LVecBase3f(h, p, r)); + _fvec.set_hpr(LVecBase3(h, p, r)); } //////////////////////////////////////////////////////////////////// @@ -72,7 +72,7 @@ make_copy() const { // Access : private, virtual // Description : query //////////////////////////////////////////////////////////////////// -LRotationf AngularVectorForce:: +LRotation AngularVectorForce:: get_child_quat(const PhysicsObject *) { return _fvec; } diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index 77063096e9..5ea41be148 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -24,23 +24,23 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS AngularVectorForce : public AngularForce { PUBLISHED: - AngularVectorForce(const LRotationf& quat); - AngularVectorForce(float h, float p, float r); + AngularVectorForce(const LRotation& quat); + AngularVectorForce(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); AngularVectorForce(const AngularVectorForce ©); virtual ~AngularVectorForce(); - INLINE void set_quat(const LRotationf& quat); - INLINE void set_hpr(float h, float p, float r); - INLINE LRotationf get_local_quat() const; + INLINE void set_quat(const LRotation& quat); + INLINE void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE LRotation get_local_quat() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; private: - LRotationf _fvec; + LRotation _fvec; virtual AngularForce *make_copy() const; - virtual LRotationf get_child_quat(const PhysicsObject *po); + virtual LRotation get_child_quat(const PhysicsObject *po); public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/baseIntegrator.I b/panda/src/physics/baseIntegrator.I index cc484b3baf..62a42969bb 100644 --- a/panda/src/physics/baseIntegrator.I +++ b/panda/src/physics/baseIntegrator.I @@ -16,7 +16,7 @@ // Function : get_precomputed_linear_matrices // Access : protected //////////////////////////////////////////////////////////////////// -INLINE const pvector< LMatrix4f > &BaseIntegrator:: +INLINE const pvector< LMatrix4 > &BaseIntegrator:: get_precomputed_linear_matrices() const { return _precomputed_linear_matrices; } @@ -25,7 +25,7 @@ get_precomputed_linear_matrices() const { // Function : get_precomputed_angular_matrices // Access : protected //////////////////////////////////////////////////////////////////// -INLINE const pvector< LMatrix4f > &BaseIntegrator:: +INLINE const pvector< LMatrix4 > &BaseIntegrator:: get_precomputed_angular_matrices() const { return _precomputed_angular_matrices; } diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index def7c2e742..7062e9b692 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -35,7 +35,7 @@ class Physical; //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS BaseIntegrator : public ReferenceCount { public: - typedef pvector MatrixVector; + typedef pvector MatrixVector; typedef pvector LinearForceVector; typedef pvector AngularForceVector; diff --git a/panda/src/physics/linearControlForce.I b/panda/src/physics/linearControlForce.I index d6c4541c10..c224407ad6 100755 --- a/panda/src/physics/linearControlForce.I +++ b/panda/src/physics/linearControlForce.I @@ -48,7 +48,7 @@ get_physics_object() const { // Description : encapsulating wrapper //////////////////////////////////////////////////////////////////// INLINE void LinearControlForce:: -set_vector(const LVector3f& v) { +set_vector(const LVector3& v) { _fvec = v; } @@ -58,7 +58,7 @@ set_vector(const LVector3f& v) { // Description : piecewise encapsulating wrapper //////////////////////////////////////////////////////////////////// INLINE void LinearControlForce:: -set_vector(float x, float y, float z) { +set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _fvec.set(x, y, z); } @@ -67,7 +67,7 @@ set_vector(float x, float y, float z) { // Access : Public // Description : //////////////////////////////////////////////////////////////////// -INLINE LVector3f LinearControlForce:: +INLINE LVector3 LinearControlForce:: get_local_vector() const { return _fvec; } diff --git a/panda/src/physics/linearControlForce.cxx b/panda/src/physics/linearControlForce.cxx index 4bb026ba81..7762320617 100755 --- a/panda/src/physics/linearControlForce.cxx +++ b/panda/src/physics/linearControlForce.cxx @@ -27,7 +27,7 @@ TypeHandle LinearControlForce::_type_handle; // Description : Vector Constructor //////////////////////////////////////////////////////////////////// LinearControlForce:: -LinearControlForce(const PhysicsObject *po, float a, bool mass) : +LinearControlForce(const PhysicsObject *po, PN_stdfloat a, bool mass) : LinearForce(a, mass), _physics_object(po), _fvec(0.0f, 0.0f, 0.0f) { @@ -69,12 +69,12 @@ make_copy() { // Access : Public // Description : vector access //////////////////////////////////////////////////////////////////// -LVector3f LinearControlForce:: +LVector3 LinearControlForce:: get_child_vector(const PhysicsObject *po) { if (_physics_object != 0 && po == _physics_object) { return _fvec; } else { - return LVector3f::zero(); + return LVector3::zero(); } } diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index 55db0f5df4..d443253993 100755 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -28,7 +28,7 @@ //////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearControlForce : public LinearForce { PUBLISHED: - LinearControlForce(const PhysicsObject *po = 0, float a = 1.0f, + LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f, bool mass = false); LinearControlForce(const LinearControlForce ©); virtual ~LinearControlForce(); @@ -37,20 +37,20 @@ PUBLISHED: INLINE void set_physics_object(const PhysicsObject *po); INLINE CPT(PhysicsObject) get_physics_object() const; - INLINE void set_vector(const LVector3f& v); - INLINE void set_vector(float x, float y, float z); + INLINE void set_vector(const LVector3& v); + INLINE void set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); - INLINE LVector3f get_local_vector() const; + INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; private: CPT(PhysicsObject) _physics_object; - LVector3f _fvec; + LVector3 _fvec; virtual LinearForce *make_copy(); - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/linearCylinderVortexForce.I b/panda/src/physics/linearCylinderVortexForce.I index f07b8f6b49..6f080753bc 100644 --- a/panda/src/physics/linearCylinderVortexForce.I +++ b/panda/src/physics/linearCylinderVortexForce.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void LinearCylinderVortexForce:: -set_radius(float radius) { +set_radius(PN_stdfloat radius) { _radius = radius; } @@ -26,7 +26,7 @@ set_radius(float radius) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void LinearCylinderVortexForce:: -set_length(float length) { +set_length(PN_stdfloat length) { _length = length; } @@ -35,7 +35,7 @@ set_length(float length) { // Access : public //////////////////////////////////////////////////////////////////// INLINE void LinearCylinderVortexForce:: -set_coef(float coef) { +set_coef(PN_stdfloat coef) { _coef = coef; } @@ -43,7 +43,7 @@ set_coef(float coef) { // Function : get_radius // Access : public //////////////////////////////////////////////////////////////////// -INLINE float LinearCylinderVortexForce:: +INLINE PN_stdfloat LinearCylinderVortexForce:: get_radius() const { return _radius; } @@ -52,7 +52,7 @@ get_radius() const { // Function : get_length // Access : public //////////////////////////////////////////////////////////////////// -INLINE float LinearCylinderVortexForce:: +INLINE PN_stdfloat LinearCylinderVortexForce:: get_length() const { return _length; } @@ -61,7 +61,7 @@ get_length() const { // Function : get_coef // Access : public //////////////////////////////////////////////////////////////////// -INLINE float LinearCylinderVortexForce:: +INLINE PN_stdfloat LinearCylinderVortexForce:: get_coef() const { return _coef; } diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index 3faa7a1dc6..d6531751e0 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -15,6 +15,7 @@ #include "config_physics.h" #include "linearCylinderVortexForce.h" #include "nearly_zero.h" +#include "cmath.h" TypeHandle LinearCylinderVortexForce::_type_handle; @@ -24,8 +25,8 @@ TypeHandle LinearCylinderVortexForce::_type_handle; // Description : Simple Constructor //////////////////////////////////////////////////////////////////// LinearCylinderVortexForce:: -LinearCylinderVortexForce(float radius, float length, float coef, - float a, bool md) : +LinearCylinderVortexForce(PN_stdfloat radius, PN_stdfloat length, PN_stdfloat coef, + PN_stdfloat a, bool md) : LinearForce(a, md), _radius(radius), _length(length), _coef(coef) { } @@ -68,26 +69,26 @@ make_copy() { // Description : returns the centripetal force vector for the // passed-in object //////////////////////////////////////////////////////////////////// -LVector3f LinearCylinderVortexForce:: +LVector3 LinearCylinderVortexForce:: get_child_vector(const PhysicsObject *po) { // get the force-space transform- this MUST be the relative matrix // from the point's local coordinate system to the attached node's // local system. - // LMatrix4f force_space_xform = LMatrix4f::ident_mat(); - LVector3f force_vec(0.0f, 0.0f, 0.0f); + // LMatrix4 force_space_xform = LMatrix4::ident_mat(); + LVector3 force_vec(0.0f, 0.0f, 0.0f); // project the point into force_space - LPoint3f point = po->get_position(); + LPoint3 point = po->get_position(); // clip along length if (point[2] < 0.0f || point[2] > _length) return force_vec; // clip to radius - float x_squared = point[0] * point[0]; - float y_squared = point[1] * point[1]; - float dist_squared = x_squared + y_squared; - float radius_squared = _radius * _radius; + PN_stdfloat x_squared = point[0] * point[0]; + PN_stdfloat y_squared = point[1] * point[1]; + PN_stdfloat dist_squared = x_squared + y_squared; + PN_stdfloat radius_squared = _radius * _radius; // squared space increases monotonically wrt linear space, // so there's no need to sqrt to check inside/outside this disc. @@ -97,21 +98,21 @@ get_child_vector(const PhysicsObject *po) { if IS_NEARLY_ZERO(dist_squared) return force_vec; - float r = sqrtf(dist_squared); + PN_stdfloat r = csqrt(dist_squared); if IS_NEARLY_ZERO(r) return force_vec; - LVector3f tangential = point; + LVector3 tangential = point; tangential[2] = 0.0f; tangential.normalize(); - tangential = tangential.cross(LVector3f(0,0,1)); + tangential = tangential.cross(LVector3(0,0,1)); - LVector3f centripetal = -point; + LVector3 centripetal = -point; centripetal[2] = 0.0f; centripetal.normalize(); - LVector3f combined = tangential + centripetal; + LVector3 combined = tangential + centripetal; combined.normalize(); // a = v^2 / r diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index 683fe46b7a..8a24bafe3e 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -29,33 +29,33 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearCylinderVortexForce : public LinearForce { PUBLISHED: - LinearCylinderVortexForce(float radius = 1.0f, - float length = 0.0f, - float coef = 1.0f, - float a = 1.0f, + LinearCylinderVortexForce(PN_stdfloat radius = 1.0f, + PN_stdfloat length = 0.0f, + PN_stdfloat coef = 1.0f, + PN_stdfloat a = 1.0f, bool md = false); LinearCylinderVortexForce(const LinearCylinderVortexForce ©); virtual ~LinearCylinderVortexForce(); - INLINE void set_coef(float coef); - INLINE float get_coef() const; + INLINE void set_coef(PN_stdfloat coef); + INLINE PN_stdfloat get_coef() const; - INLINE void set_radius(float radius); - INLINE float get_radius() const; + INLINE void set_radius(PN_stdfloat radius); + INLINE PN_stdfloat get_radius() const; - INLINE void set_length(float length); - INLINE float get_length() const; + INLINE void set_length(PN_stdfloat length); + INLINE PN_stdfloat get_length() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; private: - float _radius; - float _length; - float _coef; + PN_stdfloat _radius; + PN_stdfloat _length; + PN_stdfloat _coef; virtual LinearForce *make_copy(); - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/linearDistanceForce.I b/panda/src/physics/linearDistanceForce.I index 12333679a9..ac7746e91a 100644 --- a/panda/src/physics/linearDistanceForce.I +++ b/panda/src/physics/linearDistanceForce.I @@ -28,7 +28,7 @@ set_falloff_type(FalloffType ft) { // Description : set the radius //////////////////////////////////////////////////////////////////// INLINE void LinearDistanceForce:: -set_radius(float r) { +set_radius(PN_stdfloat r) { _radius = r; } @@ -38,7 +38,7 @@ set_radius(float r) { // Description : set the force center //////////////////////////////////////////////////////////////////// INLINE void LinearDistanceForce:: -set_force_center(const LPoint3f& p) { +set_force_center(const LPoint3& p) { _force_center = p; } @@ -57,7 +57,7 @@ get_falloff_type() const { // Access : public // Description : radius query //////////////////////////////////////////////////////////////////// -INLINE float LinearDistanceForce:: +INLINE PN_stdfloat LinearDistanceForce:: get_radius() const { return _radius; } @@ -67,7 +67,7 @@ get_radius() const { // Access : public // Description : force_center query //////////////////////////////////////////////////////////////////// -INLINE LPoint3f LinearDistanceForce:: +INLINE LPoint3 LinearDistanceForce:: get_force_center() const { return _force_center; } @@ -77,9 +77,9 @@ get_force_center() const { // Access : private // Description : calculate the term based on falloff //////////////////////////////////////////////////////////////////// -INLINE float LinearDistanceForce:: +INLINE PN_stdfloat LinearDistanceForce:: get_scalar_term() const { - float r = _radius; + PN_stdfloat r = _radius; if (_falloff == FT_ONE_OVER_R_SQUARED) r = r * r; else if (_falloff == FT_ONE_OVER_R_CUBED) diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index 0b90f10119..e3aa7368f9 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -22,7 +22,7 @@ TypeHandle LinearDistanceForce::_type_handle; // Description : Simple constructor //////////////////////////////////////////////////////////////////// LinearDistanceForce:: -LinearDistanceForce(const LPoint3f& p, FalloffType ft, float r, float a, bool m) : +LinearDistanceForce(const LPoint3& p, FalloffType ft, PN_stdfloat r, PN_stdfloat a, bool m) : LinearForce(a, m), _force_center(p), _falloff(ft), _radius(r) { diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 0ba7a06d6f..2d1fb10a26 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -31,30 +31,30 @@ PUBLISHED: FT_ONE_OVER_R_CUBED }; - INLINE void set_radius(float r); + INLINE void set_radius(PN_stdfloat r); INLINE void set_falloff_type(FalloffType ft); - INLINE void set_force_center(const LPoint3f& p); + INLINE void set_force_center(const LPoint3& p); - INLINE float get_radius() const; + INLINE PN_stdfloat get_radius() const; INLINE FalloffType get_falloff_type() const; - INLINE LPoint3f get_force_center() const; + INLINE LPoint3 get_force_center() const; - INLINE float get_scalar_term() const; + INLINE PN_stdfloat get_scalar_term() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; private: - LPoint3f _force_center; + LPoint3 _force_center; FalloffType _falloff; - float _radius; + PN_stdfloat _radius; virtual LinearForce *make_copy() = 0; - virtual LVector3f get_child_vector(const PhysicsObject *po) = 0; + virtual LVector3 get_child_vector(const PhysicsObject *po) = 0; protected: - LinearDistanceForce(const LPoint3f& p, FalloffType ft, float r, float a, + LinearDistanceForce(const LPoint3& p, FalloffType ft, PN_stdfloat r, PN_stdfloat a, bool m); LinearDistanceForce(const LinearDistanceForce ©); virtual ~LinearDistanceForce(); diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 9c1aedd6a5..ec026f59a9 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -54,7 +54,7 @@ LinearEulerIntegrator:: void LinearEulerIntegrator:: child_integrate(Physical *physical, LinearForceVector& forces, - float dt) { + PN_stdfloat dt) { // perform the precomputation. Note that the vector returned by // get_precomputed_matrices() has the matrices loaded in order of force // type: first global, then local. If you're using this as a guide to write @@ -70,7 +70,7 @@ child_integrate(Physical *physical, #endif // NDEBUG // Get the greater of the local or global viscosity: - float viscosityDamper=1.0f-physical->get_viscosity(); + PN_stdfloat viscosityDamper=1.0f-physical->get_viscosity(); // Loop through each object in the set. This processing occurs in O(pf) time, // where p is the number of physical objects and f is the number of @@ -95,18 +95,18 @@ child_integrate(Physical *physical, continue; } - LVector3f md_accum_vec; // mass dependent accumulation vector. - LVector3f non_md_accum_vec; - LVector3f accel_vec; - LVector3f vel_vec; + LVector3 md_accum_vec; // mass dependent accumulation vector. + LVector3 non_md_accum_vec; + LVector3 accel_vec; + LVector3 vel_vec; // reset the accumulation vectors for this object md_accum_vec.set(0.0f, 0.0f, 0.0f); non_md_accum_vec.set(0.0f, 0.0f, 0.0f); // run through each acting force and sum it - LVector3f f; - // LMatrix4f force_to_object_xform; + LVector3 f; + // LMatrix4 force_to_object_xform; LinearForceVector::const_iterator f_cur; @@ -156,9 +156,9 @@ child_integrate(Physical *physical, } // get this object's physical info - LPoint3f pos = current_object->get_position(); + LPoint3 pos = current_object->get_position(); vel_vec = current_object->get_velocity(); - float mass = current_object->get_mass(); + PN_stdfloat mass = current_object->get_mass(); // we want 'a' in F = ma // get it by computing F / m @@ -171,7 +171,7 @@ child_integrate(Physical *physical, vel_vec += accel_vec * dt; // cap terminal velocity - float len = vel_vec.length(); + PN_stdfloat len = vel_vec.length(); if (len > current_object->get_terminal_velocity()) { //cout << "Capping terminal velocity at: " << current_object->get_terminal_velocity() << endl; diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index 2827da2e8d..311532ed50 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -33,7 +33,7 @@ PUBLISHED: private: virtual void child_integrate(Physical *physical, LinearForceVector& forces, - float dt); + PN_stdfloat dt); }; #endif // EULERINTEGRATOR_H diff --git a/panda/src/physics/linearForce.I b/panda/src/physics/linearForce.I index 70d66ff615..2c09236f4a 100644 --- a/panda/src/physics/linearForce.I +++ b/panda/src/physics/linearForce.I @@ -17,7 +17,7 @@ // Access : Public //////////////////////////////////////////////////////////////////// INLINE void LinearForce:: -set_amplitude(float a) { +set_amplitude(PN_stdfloat a) { _amplitude = a; } @@ -25,7 +25,7 @@ set_amplitude(float a) { // Function : get_amplitude // Access : Public //////////////////////////////////////////////////////////////////// -INLINE float LinearForce:: +INLINE PN_stdfloat LinearForce:: get_amplitude() const { return _amplitude; } @@ -63,7 +63,7 @@ set_vector_masks(bool x, bool y, bool z) { // Function : set_vector_masks // Access : Public //////////////////////////////////////////////////////////////////// -INLINE LVector3f LinearForce:: +INLINE LVector3 LinearForce:: get_vector_masks() { - return LVector3f(_x_mask, _y_mask, _z_mask); + return LVector3(_x_mask, _y_mask, _z_mask); } diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index 68cd74f0e7..d687fdb99d 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -27,7 +27,7 @@ TypeHandle LinearForce::_type_handle; // Description : Default/component-based constructor //////////////////////////////////////////////////////////////////// LinearForce:: -LinearForce(float a, bool mass) : +LinearForce(PN_stdfloat a, bool mass) : BaseForce(true), _amplitude(a), _mass_dependent(mass), _x_mask(true), _y_mask(true), _z_mask(true) { @@ -61,10 +61,10 @@ LinearForce:: // Function : get_vector // Access : Public //////////////////////////////////////////////////////////////////// -LVector3f LinearForce:: +LVector3 LinearForce:: get_vector(const PhysicsObject *po) { - LVector3f child_vector = get_child_vector(po) * _amplitude; - nassertr(!child_vector.is_nan(), LVector3f::zero()); + LVector3 child_vector = get_child_vector(po) * _amplitude; + nassertr(!child_vector.is_nan(), LVector3::zero()); if (_x_mask == false) child_vector[0] = 0.0f; diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index a567386e01..c47591c8cf 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -26,16 +26,16 @@ class EXPCL_PANDAPHYSICS LinearForce : public BaseForce { PUBLISHED: ~LinearForce(); - INLINE void set_amplitude(const float a); + INLINE void set_amplitude(const PN_stdfloat a); INLINE void set_mass_dependent(bool m); - INLINE float get_amplitude() const; + INLINE PN_stdfloat get_amplitude() const; INLINE bool get_mass_dependent() const; INLINE void set_vector_masks(bool x, bool y, bool z); - INLINE LVector3f get_vector_masks(); + INLINE LVector3 get_vector_masks(); - LVector3f get_vector(const PhysicsObject *po); + LVector3 get_vector(const PhysicsObject *po); virtual LinearForce *make_copy() = 0; @@ -45,18 +45,18 @@ PUBLISHED: virtual void write(ostream &out, unsigned int indent=0) const; protected: - LinearForce(float a, bool mass); + LinearForce(PN_stdfloat a, bool mass); LinearForce(const LinearForce& copy); private: - float _amplitude; + PN_stdfloat _amplitude; bool _mass_dependent; bool _x_mask; bool _y_mask; bool _z_mask; - virtual LVector3f get_child_vector(const PhysicsObject *po) = 0; + virtual LVector3 get_child_vector(const PhysicsObject *po) = 0; public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/linearFrictionForce.I b/panda/src/physics/linearFrictionForce.I index 2653f8647a..8011e15717 100644 --- a/panda/src/physics/linearFrictionForce.I +++ b/panda/src/physics/linearFrictionForce.I @@ -17,7 +17,7 @@ // Access : public //////////////////////////////////////////////////////////////////// INLINE void LinearFrictionForce:: -set_coef(float coef) { +set_coef(PN_stdfloat coef) { // friction shouldn't be outside of [0, 1] if (coef < 0.0f) { coef = 0.0f; @@ -31,7 +31,7 @@ set_coef(float coef) { // Function : get_coef // Access : public //////////////////////////////////////////////////////////////////// -INLINE float LinearFrictionForce:: +INLINE PN_stdfloat LinearFrictionForce:: get_coef() const { return _coef; } diff --git a/panda/src/physics/linearFrictionForce.cxx b/panda/src/physics/linearFrictionForce.cxx index 981119d059..85ca8bb948 100644 --- a/panda/src/physics/linearFrictionForce.cxx +++ b/panda/src/physics/linearFrictionForce.cxx @@ -23,7 +23,7 @@ TypeHandle LinearFrictionForce::_type_handle; // Description : Constructor //////////////////////////////////////////////////////////////////// LinearFrictionForce:: -LinearFrictionForce(float coef, float a, bool m) : +LinearFrictionForce(PN_stdfloat coef, PN_stdfloat a, bool m) : LinearForce(a, m) { set_coef(coef); } @@ -63,16 +63,16 @@ make_copy() { // Access : Public // Description : Constructor //////////////////////////////////////////////////////////////////// -LVector3f LinearFrictionForce:: +LVector3 LinearFrictionForce:: get_child_vector(const PhysicsObject* po) { - LVector3f v = po->get_velocity(); + LVector3 v = po->get_velocity(); assert(_coef>=0.0f && _coef<=1.0f); // Create a force vector in the opposite direction of v: - LVector3f friction = v * -_coef; + LVector3 friction = v * -_coef; physics_debug(" v "< _max_linear_dt) diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index 7113af9a2a..82e036d406 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -32,7 +32,7 @@ PUBLISHED: public: void integrate(Physical *physical, LinearForceVector &forces, - float dt); + PN_stdfloat dt); PUBLISHED: virtual void output(ostream &out) const; @@ -48,7 +48,7 @@ private: // actual integration function receives. virtual void child_integrate(Physical *physical, LinearForceVector &forces, - float dt) = 0; + PN_stdfloat dt) = 0; }; #endif // LINEARINTEGRATOR_H diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index ce9bf70fd4..e380c0b035 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -22,7 +22,7 @@ TypeHandle LinearJitterForce::_type_handle; // Description : constructor //////////////////////////////////////////////////////////////////// LinearJitterForce:: -LinearJitterForce(float a, bool mass) : +LinearJitterForce(PN_stdfloat a, bool mass) : LinearRandomForce(a, mass) { } @@ -60,7 +60,7 @@ make_copy() { // Access : Public // Description : random value //////////////////////////////////////////////////////////////////// -LVector3f LinearJitterForce:: +LVector3 LinearJitterForce:: get_child_vector(const PhysicsObject *) { return random_unit_vector(); } diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index 131c9c6697..8d0967eb43 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -24,7 +24,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearJitterForce : public LinearRandomForce { PUBLISHED: - LinearJitterForce(float a = 1.0f, bool m = false); + LinearJitterForce(PN_stdfloat a = 1.0f, bool m = false); LinearJitterForce(const LinearJitterForce ©); virtual ~LinearJitterForce(); @@ -32,7 +32,7 @@ PUBLISHED: virtual void write(ostream &out, unsigned int indent=0) const; private: - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); virtual LinearForce *make_copy(); public: diff --git a/panda/src/physics/linearNoiseForce.I b/panda/src/physics/linearNoiseForce.I index d3261ae4d6..324d230ff3 100644 --- a/panda/src/physics/linearNoiseForce.I +++ b/panda/src/physics/linearNoiseForce.I @@ -28,7 +28,7 @@ prn_lookup(int index) const { // Description : Hashes a point, returns a prn //////////////////////////////////////////////////////////////////// INLINE unsigned char LinearNoiseForce:: -get_prn_entry(const LPoint3f& point) const { +get_prn_entry(const LPoint3& point) const { return prn_lookup((int)(point[0] + prn_lookup((int)(point[1] + prn_lookup((int)point[2]))))); } @@ -38,7 +38,7 @@ get_prn_entry(const LPoint3f& point) const { // Description : Hashes a point, returns a prn (piecewise) //////////////////////////////////////////////////////////////////// INLINE unsigned char LinearNoiseForce:: -get_prn_entry(const float x, const float y, const float z) const { +get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const { return prn_lookup((int)(x + prn_lookup((int)(y + prn_lookup((int)z))))); } @@ -47,8 +47,8 @@ get_prn_entry(const float x, const float y, const float z) const { // Access : Private // Description : Hashes a point, returns a gradient vector //////////////////////////////////////////////////////////////////// -INLINE LVector3f& LinearNoiseForce:: -get_lattice_entry(const LPoint3f& point) { +INLINE LVector3& LinearNoiseForce:: +get_lattice_entry(const LPoint3& point) { return _gradient_table[get_prn_entry(point)]; } @@ -57,8 +57,8 @@ get_lattice_entry(const LPoint3f& point) { // Access : Private // Description : Hashes a point, returns a gradient vector (piecewise) //////////////////////////////////////////////////////////////////// -INLINE LVector3f& LinearNoiseForce:: -get_lattice_entry(const float x, const float y, const float z) { +INLINE LVector3& LinearNoiseForce:: +get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) { return _gradient_table[get_prn_entry(x, y, z)]; } @@ -68,8 +68,8 @@ get_lattice_entry(const float x, const float y, const float z) { // Description : Smooths a parameterized interpolation using // 2x^3 - 3x^2 //////////////////////////////////////////////////////////////////// -INLINE float LinearNoiseForce:: -cubic_step(const float x) const { +INLINE PN_stdfloat LinearNoiseForce:: +cubic_step(const PN_stdfloat x) const { return x * x * ((2 * x) - 3); } @@ -78,7 +78,7 @@ cubic_step(const float x) const { // Access : Private // Description : Vector linear interpolation //////////////////////////////////////////////////////////////////// -INLINE LVector3f LinearNoiseForce:: -vlerp(const float t, const LVector3f& v0, const LVector3f& v1) const { +INLINE LVector3 LinearNoiseForce:: +vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const { return v0 + ((v1 - v0) * t); } diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index c1f50307f8..e687599aa5 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -24,7 +24,7 @@ ConfigVariableInt LinearNoiseForce::_random_seed bool LinearNoiseForce::_initialized = false; unsigned char LinearNoiseForce::_prn_table[256]; -LVector3f LinearNoiseForce::_gradient_table[256]; +LVector3 LinearNoiseForce::_gradient_table[256]; TypeHandle LinearNoiseForce::_type_handle; @@ -40,7 +40,7 @@ init_noise_tables() { // to init with the same seed. srand(_random_seed); - LVector3f *gtable = _gradient_table; + LVector3 *gtable = _gradient_table; for (int i = 0; i < 256; ++i) { // fill the 1d array _prn_table[i] = rand() & 255; @@ -56,7 +56,7 @@ init_noise_tables() { // Description : constructor //////////////////////////////////////////////////////////////////// LinearNoiseForce:: -LinearNoiseForce(float a, bool mass) : +LinearNoiseForce(PN_stdfloat a, bool mass) : LinearRandomForce(a, mass) { if (_initialized == false) { init_noise_tables(); @@ -99,13 +99,13 @@ make_copy() { // Description : Returns the noise value based on the object's // position. //////////////////////////////////////////////////////////////////// -LVector3f LinearNoiseForce:: +LVector3 LinearNoiseForce:: get_child_vector(const PhysicsObject *po) { - LPoint3f p = po->get_position(); + LPoint3 p = po->get_position(); // get all of the components int int_x, int_y, int_z; - float frac_x, frac_y, frac_z; + PN_stdfloat frac_x, frac_y, frac_z; int_x = (int) p[0]; frac_x = p[0] - int_x; @@ -117,14 +117,14 @@ get_child_vector(const PhysicsObject *po) { frac_z = p[2] - int_z; // apply the cubic smoother to the fractional values - float cubic_x, cubic_y, cubic_z; + PN_stdfloat cubic_x, cubic_y, cubic_z; cubic_x = cubic_step(frac_x); cubic_y = cubic_step(frac_y); cubic_z = cubic_step(frac_z); // trilinear interpolation into the cube (over, in, down) - LVector3f temp0, temp1, temp2, temp3; + LVector3 temp0, temp1, temp2, temp3; // x direction temp0 = vlerp(cubic_x, get_lattice_entry(p), diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index df382d76e5..a88d8206d1 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearNoiseForce : public LinearRandomForce { PUBLISHED: - LinearNoiseForce(float a = 1.0f, bool m = false); + LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false); LinearNoiseForce(const LinearNoiseForce ©); virtual ~LinearNoiseForce(); @@ -38,21 +38,21 @@ public: private: static unsigned char _prn_table[256]; - static LVector3f _gradient_table[256]; + static LVector3 _gradient_table[256]; static bool _initialized; - INLINE float cubic_step(const float x) const; - INLINE LVector3f vlerp(const float t, const LVector3f& v0, const LVector3f& v1) const; + INLINE PN_stdfloat cubic_step(const PN_stdfloat x) const; + INLINE LVector3 vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const; - INLINE unsigned char get_prn_entry(const LPoint3f& point) const; - INLINE unsigned char get_prn_entry(const float x, const float y, const float z) const; + INLINE unsigned char get_prn_entry(const LPoint3& point) const; + INLINE unsigned char get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const; - INLINE LVector3f& get_lattice_entry(const LPoint3f& point); - INLINE LVector3f& get_lattice_entry(const float x, const float y, const float z); + INLINE LVector3& get_lattice_entry(const LPoint3& point); + INLINE LVector3& get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z); INLINE unsigned char prn_lookup(int index) const; - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); virtual LinearForce *make_copy(); public: diff --git a/panda/src/physics/linearRandomForce.I b/panda/src/physics/linearRandomForce.I index 0cf8addc55..ba4b9f2e85 100644 --- a/panda/src/physics/linearRandomForce.I +++ b/panda/src/physics/linearRandomForce.I @@ -17,14 +17,14 @@ // Access : Protected // Description : generates a random unit vector //////////////////////////////////////////////////////////////////// -INLINE LVector3f LinearRandomForce:: +INLINE LVector3 LinearRandomForce:: random_unit_vector() { - float z, r, theta; + PN_stdfloat z, r, theta; - z = 1.0f - (2.0f * bounded_rand()); - r = sqrtf(1.0f - (z * z)); - theta = 2.0f * 3.1415926f * bounded_rand(); + z = 1.0 - (2.0 * bounded_rand()); + r = csqrt(1.0 - (z * z)); + theta = 2.0 * MathNumbers::pi * bounded_rand(); - return LVector3f(r * cosf(theta), r * sinf(theta), z); + return LVector3(r * ccos(theta), r * csin(theta), z); } diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index 8ff883fa15..cad1fdcbb3 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -22,7 +22,7 @@ TypeHandle LinearRandomForce::_type_handle; // Description : vector constructor //////////////////////////////////////////////////////////////////// LinearRandomForce:: -LinearRandomForce(float a, bool mass) : +LinearRandomForce(PN_stdfloat a, bool mass) : LinearForce(a, mass) { } @@ -50,9 +50,9 @@ LinearRandomForce:: // Access : Protected // Description : Returns a float in [0, 1] //////////////////////////////////////////////////////////////////// -float LinearRandomForce:: +PN_stdfloat LinearRandomForce:: bounded_rand() { - return ((float)rand() / (float)RAND_MAX); + return ((PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index c58172aab9..abeab21ee5 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -16,8 +16,8 @@ #define LINEARRANDOMFORCE_H #include -#include - +#include "cmath.h" +#include "mathNumbers.h" #include "linearForce.h" //////////////////////////////////////////////////////////////////// @@ -32,13 +32,13 @@ PUBLISHED: virtual void write(ostream &out, unsigned int indent=0) const; protected: - static float bounded_rand(); - static LVector3f random_unit_vector(); + static PN_stdfloat bounded_rand(); + static LVector3 random_unit_vector(); - LinearRandomForce(float a = 1.0f, bool m = false); + LinearRandomForce(PN_stdfloat a = 1.0f, bool m = false); LinearRandomForce(const LinearRandomForce ©); - virtual LVector3f get_child_vector(const PhysicsObject *po) = 0; + virtual LVector3 get_child_vector(const PhysicsObject *po) = 0; virtual LinearForce *make_copy() = 0; public: diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index 7e3875b7a6..f5ce9744dc 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -22,7 +22,7 @@ TypeHandle LinearSinkForce::_type_handle; // Description : Simple constructor //////////////////////////////////////////////////////////////////// LinearSinkForce:: -LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a, +LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a, bool mass) : LinearDistanceForce(p, f, r, a, mass) { } @@ -34,7 +34,7 @@ LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a, //////////////////////////////////////////////////////////////////// LinearSinkForce:: LinearSinkForce() : - LinearDistanceForce(LPoint3f(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, + LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 1.0f, 1.0f, true) { } @@ -72,7 +72,7 @@ make_copy() { // Access : Public // Description : virtual force query //////////////////////////////////////////////////////////////////// -LVector3f LinearSinkForce:: +LVector3 LinearSinkForce:: get_child_vector(const PhysicsObject *po) { return (get_force_center() - po->get_position()) * get_scalar_term(); } diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 1c6c777c40..863cb49116 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearSinkForce : public LinearDistanceForce { PUBLISHED: - LinearSinkForce(const LPoint3f& p, FalloffType f, float r, float a = 1.0f, + LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, bool m = true); LinearSinkForce(); LinearSinkForce(const LinearSinkForce ©); @@ -33,7 +33,7 @@ PUBLISHED: virtual void write(ostream &out, unsigned int indent=0) const; private: - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); virtual LinearForce *make_copy(); public: diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 3793d21ac9..b139df80fc 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -22,7 +22,7 @@ TypeHandle LinearSourceForce::_type_handle; // Description : Simple constructor //////////////////////////////////////////////////////////////////// LinearSourceForce:: -LinearSourceForce(const LPoint3f& p, FalloffType f, float r, float a, +LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a, bool mass) : LinearDistanceForce(p, f, r, a, mass) { } @@ -34,7 +34,7 @@ LinearSourceForce(const LPoint3f& p, FalloffType f, float r, float a, //////////////////////////////////////////////////////////////////// LinearSourceForce:: LinearSourceForce() : - LinearDistanceForce(LPoint3f(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, + LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 1.0f, 1.0f, true) { } @@ -72,7 +72,7 @@ make_copy() { // Access : Public // Description : virtual force query //////////////////////////////////////////////////////////////////// -LVector3f LinearSourceForce:: +LVector3 LinearSourceForce:: get_child_vector(const PhysicsObject *po) { return (po->get_position() - get_force_center()) * get_scalar_term(); } diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index 39620ffbbd..ec08a2564c 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearSourceForce : public LinearDistanceForce { PUBLISHED: - LinearSourceForce(const LPoint3f& p, FalloffType f, float r, float a = 1.0f, + LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, bool mass = true); LinearSourceForce(); LinearSourceForce(const LinearSourceForce ©); @@ -33,7 +33,7 @@ PUBLISHED: virtual void write(ostream &out, unsigned int indent=0) const; private: - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); virtual LinearForce *make_copy(); public: diff --git a/panda/src/physics/linearUserDefinedForce.I b/panda/src/physics/linearUserDefinedForce.I index 8fc4b8294f..36e7b84b31 100644 --- a/panda/src/physics/linearUserDefinedForce.I +++ b/panda/src/physics/linearUserDefinedForce.I @@ -17,6 +17,6 @@ // Access : public //////////////////////////////////////////////////////////////////// void LinearUserDefinedForce:: -set_proc(LVector3f (*proc)(const PhysicsObject *)) { +set_proc(LVector3 (*proc)(const PhysicsObject *)) { _proc = proc; } diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index fe0f4d20ba..703f4b2ebb 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -22,8 +22,8 @@ TypeHandle LinearUserDefinedForce::_type_handle; // Description : constructor //////////////////////////////////////////////////////////////////// LinearUserDefinedForce:: -LinearUserDefinedForce(LVector3f (*proc)(const PhysicsObject *), - float a, bool md) : +LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *), + PN_stdfloat a, bool md) : LinearForce(a, md), _proc(proc) { @@ -64,7 +64,7 @@ make_copy() { // Access : private, virtual // Description : force builder //////////////////////////////////////////////////////////////////// -LVector3f LinearUserDefinedForce:: +LVector3 LinearUserDefinedForce:: get_child_vector(const PhysicsObject *po) { return _proc(po); } diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 542b1919ba..51dd6f74ce 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -29,21 +29,21 @@ //////////////////////////////////////////////////////////////////// class LinearUserDefinedForce : public LinearForce { PUBLISHED: - LinearUserDefinedForce(LVector3f (*proc)(const PhysicsObject *) = NULL, - float a = 1.0f, - bool md = false); + LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = NULL, + PN_stdfloat a = 1.0f, + bool md = false); LinearUserDefinedForce(const LinearUserDefinedForce ©); virtual ~LinearUserDefinedForce(); - INLINE void set_proc(LVector3f (*proc)(const PhysicsObject *)); + INLINE void set_proc(LVector3 (*proc)(const PhysicsObject *)); virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; private: - LVector3f (*_proc)(const PhysicsObject *po); + LVector3 (*_proc)(const PhysicsObject *po); - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); virtual LinearForce *make_copy(); public: diff --git a/panda/src/physics/linearVectorForce.I b/panda/src/physics/linearVectorForce.I index 7717b3de7f..b14a6e67f0 100644 --- a/panda/src/physics/linearVectorForce.I +++ b/panda/src/physics/linearVectorForce.I @@ -18,7 +18,7 @@ // Description : encapsulating wrapper //////////////////////////////////////////////////////////////////// INLINE void LinearVectorForce:: -set_vector(const LVector3f& v) { +set_vector(const LVector3& v) { _fvec = v; } @@ -28,7 +28,7 @@ set_vector(const LVector3f& v) { // Description : piecewise encapsulating wrapper //////////////////////////////////////////////////////////////////// INLINE void LinearVectorForce:: -set_vector(float x, float y, float z) { +set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _fvec.set(x, y, z); } @@ -37,7 +37,7 @@ set_vector(float x, float y, float z) { // Access : Public // Description : //////////////////////////////////////////////////////////////////// -INLINE LVector3f LinearVectorForce:: +INLINE LVector3 LinearVectorForce:: get_local_vector() const { return _fvec; } diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index a7688fc0cd..a74921c3b5 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -27,7 +27,7 @@ TypeHandle LinearVectorForce::_type_handle; // Description : Vector Constructor //////////////////////////////////////////////////////////////////// LinearVectorForce:: -LinearVectorForce(const LVector3f& vec, float a, bool mass) : +LinearVectorForce(const LVector3& vec, PN_stdfloat a, bool mass) : LinearForce(a, mass), _fvec(vec) { } @@ -38,7 +38,7 @@ LinearVectorForce(const LVector3f& vec, float a, bool mass) : // Description : Default/Piecewise constructor //////////////////////////////////////////////////////////////////// LinearVectorForce:: -LinearVectorForce(float x, float y, float z, float a, bool mass) : +LinearVectorForce(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat a, bool mass) : LinearForce(a, mass) { _fvec.set(x, y, z); } @@ -78,7 +78,7 @@ make_copy() { // Access : Public // Description : vector access //////////////////////////////////////////////////////////////////// -LVector3f LinearVectorForce:: +LVector3 LinearVectorForce:: get_child_vector(const PhysicsObject *) { return _fvec; } diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index 81e2da4a8f..a48fb78064 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -24,16 +24,16 @@ //////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS LinearVectorForce : public LinearForce { PUBLISHED: - LinearVectorForce(const LVector3f& vec, float a = 1.0f, bool mass = false); + LinearVectorForce(const LVector3& vec, PN_stdfloat a = 1.0f, bool mass = false); LinearVectorForce(const LinearVectorForce ©); - LinearVectorForce(float x = 0.0f, float y = 0.0f, float z = 0.0f, - float a = 1.0f, bool mass = false); + LinearVectorForce(PN_stdfloat x = 0.0f, PN_stdfloat y = 0.0f, PN_stdfloat z = 0.0f, + PN_stdfloat a = 1.0f, bool mass = false); virtual ~LinearVectorForce(); - INLINE void set_vector(const LVector3f& v); - INLINE void set_vector(float x, float y, float z); + INLINE void set_vector(const LVector3& v); + INLINE void set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); - INLINE LVector3f get_local_vector() const; + INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; @@ -42,10 +42,10 @@ public: INLINE LinearVectorForce& operator += (const LinearVectorForce &other); private: - LVector3f _fvec; + LVector3 _fvec; virtual LinearForce *make_copy(); - virtual LVector3f get_child_vector(const PhysicsObject *po); + virtual LVector3 get_child_vector(const PhysicsObject *po); public: static TypeHandle get_class_type() { diff --git a/panda/src/physics/physical.I b/panda/src/physics/physical.I index 40d10e7e8d..1e1e8a49a1 100644 --- a/panda/src/physics/physical.I +++ b/panda/src/physics/physical.I @@ -222,7 +222,7 @@ get_angular_force(int index) const { // Description : Set the local viscosity. //////////////////////////////////////////////////////////////////// INLINE void Physical:: -set_viscosity(float viscosity) { +set_viscosity(PN_stdfloat viscosity) { _viscosity=viscosity; } @@ -231,7 +231,7 @@ set_viscosity(float viscosity) { // Access : Public // Description : Get the local viscosity. //////////////////////////////////////////////////////////////////// -INLINE float Physical:: +INLINE PN_stdfloat Physical:: get_viscosity() const { //zzzzzzzzzzzzzzzz return max(_viscosity, get_physics_manager()->get_viscosity()); return _viscosity; diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index 56458d8f82..090ff8c7ea 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -71,8 +71,8 @@ PUBLISHED: INLINE PT(AngularForce) get_angular_force(int index) const; MAKE_SEQ(get_angular_forces, get_num_angular_forces, get_angular_force); - INLINE void set_viscosity(float viscosity); - INLINE float get_viscosity() const; + INLINE void set_viscosity(PN_stdfloat viscosity); + INLINE PN_stdfloat get_viscosity() const; const PhysicsObjectCollection get_objects() const; @@ -94,7 +94,7 @@ public: friend class PhysicalNode; protected: - float _viscosity; + PN_stdfloat _viscosity; // containers PhysicsObject::Vector _physics_objects; LinearForceVector _linear_forces; diff --git a/panda/src/physics/physicsCollisionHandler.I b/panda/src/physics/physicsCollisionHandler.I index 2f98a4ffa8..9dd459b619 100755 --- a/panda/src/physics/physicsCollisionHandler.I +++ b/panda/src/physics/physicsCollisionHandler.I @@ -14,31 +14,31 @@ INLINE void PhysicsCollisionHandler:: -set_almost_stationary_speed(float speed) { +set_almost_stationary_speed(PN_stdfloat speed) { _almost_stationary_speed = speed; } -INLINE float PhysicsCollisionHandler:: +INLINE PN_stdfloat PhysicsCollisionHandler:: get_almost_stationary_speed() { return _almost_stationary_speed; } INLINE void PhysicsCollisionHandler:: -set_static_friction_coef(float coef) { +set_static_friction_coef(PN_stdfloat coef) { _static_friction_coef = coef; } -INLINE float PhysicsCollisionHandler:: +INLINE PN_stdfloat PhysicsCollisionHandler:: get_static_friction_coef() { return _static_friction_coef; } INLINE void PhysicsCollisionHandler:: -set_dynamic_friction_coef(float coef) { +set_dynamic_friction_coef(PN_stdfloat coef) { _dynamic_friction_coef = coef; } -INLINE float PhysicsCollisionHandler:: +INLINE PN_stdfloat PhysicsCollisionHandler:: get_dynamic_friction_coef() { return _dynamic_friction_coef; } diff --git a/panda/src/physics/physicsCollisionHandler.cxx b/panda/src/physics/physicsCollisionHandler.cxx index 9b8ada6848..64d2cdbf15 100755 --- a/panda/src/physics/physicsCollisionHandler.cxx +++ b/panda/src/physics/physicsCollisionHandler.cxx @@ -52,10 +52,10 @@ PhysicsCollisionHandler:: // account for friction. //////////////////////////////////////////////////////////////////// void PhysicsCollisionHandler:: -apply_friction(ColliderDef &def, LVector3f& vel, const LVector3f& force, - float angle) { - if (vel!=LVector3f::zero()) { - float friction_coefficient=0.0f; +apply_friction(ColliderDef &def, LVector3& vel, const LVector3& force, + PN_stdfloat angle) { + if (vel!=LVector3::zero()) { + PN_stdfloat friction_coefficient=0.0f; // Determine the friction: if (vel.length()<_almost_stationary_speed) { physics_debug(" static friction"); @@ -66,14 +66,14 @@ apply_friction(ColliderDef &def, LVector3f& vel, const LVector3f& force, } // Apply the friction: physics_debug(" vel pre friction "<1.0f) { cerr<<"\n\nfriction error "<get_dt(); + PN_stdfloat dt=ClockObject::get_global_clock()->get_dt(); vel *= (1.0f-friction) * dt * dt; #else vel *= 1.0f-friction; @@ -88,10 +88,10 @@ apply_friction(ColliderDef &def, LVector3f& vel, const LVector3f& force, // Description: //////////////////////////////////////////////////////////////////// void PhysicsCollisionHandler:: -apply_net_shove(ColliderDef &def, const LVector3f& net_shove, - const LVector3f &force) { +apply_net_shove(ColliderDef &def, const LVector3& net_shove, + const LVector3 &force) { CollisionHandlerPusher::apply_net_shove(def, net_shove, force); - if (force == LVector3f::zero()) { + if (force == LVector3::zero()) { return; } if (def._target.is_empty()) { @@ -99,19 +99,19 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove, } ActorNode *actor; DCAST_INTO_V(actor, def._target.node()); - LVector3f vel=actor->get_physics_object()->get_velocity(); - if (vel == LVector3f::zero()) { + LVector3 vel=actor->get_physics_object()->get_velocity(); + if (vel == LVector3::zero()) { return; } physics_debug("apply_linear_force() {"); physics_debug(" vel "<0.0f) { @@ -194,7 +194,7 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove, // Description: //////////////////////////////////////////////////////////////////// void PhysicsCollisionHandler:: -apply_linear_force(ColliderDef &def, const LVector3f &force) { +apply_linear_force(ColliderDef &def, const LVector3 &force) { } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physics/physicsCollisionHandler.h b/panda/src/physics/physicsCollisionHandler.h index d6cc63a860..a1933f2e3f 100755 --- a/panda/src/physics/physicsCollisionHandler.h +++ b/panda/src/physics/physicsCollisionHandler.h @@ -32,26 +32,26 @@ PUBLISHED: virtual ~PhysicsCollisionHandler(); // These setters and getter are a bit of a hack: - INLINE void set_almost_stationary_speed(float speed); - INLINE float get_almost_stationary_speed(); + INLINE void set_almost_stationary_speed(PN_stdfloat speed); + INLINE PN_stdfloat get_almost_stationary_speed(); - INLINE void set_static_friction_coef(float coef); - INLINE float get_static_friction_coef(); + INLINE void set_static_friction_coef(PN_stdfloat coef); + INLINE PN_stdfloat get_static_friction_coef(); - INLINE void set_dynamic_friction_coef(float coef); - INLINE float get_dynamic_friction_coef(); + INLINE void set_dynamic_friction_coef(PN_stdfloat coef); + INLINE PN_stdfloat get_dynamic_friction_coef(); protected: - float _almost_stationary_speed; - float _static_friction_coef; - float _dynamic_friction_coef; + PN_stdfloat _almost_stationary_speed; + PN_stdfloat _static_friction_coef; + PN_stdfloat _dynamic_friction_coef; void apply_friction( - ColliderDef &def, LVector3f &vel, const LVector3f& force, float angle); + ColliderDef &def, LVector3 &vel, const LVector3& force, PN_stdfloat angle); virtual void apply_net_shove( - ColliderDef &def, const LVector3f &net_shove, - const LVector3f &force_normal); - virtual void apply_linear_force(ColliderDef &def, const LVector3f &force); + ColliderDef &def, const LVector3 &net_shove, + const LVector3 &force_normal); + virtual void apply_linear_force(ColliderDef &def, const LVector3 &force); virtual bool validate_target(const NodePath &target); diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index e0b84edf6f..d13fcf70f0 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -122,7 +122,7 @@ clear_physicals() { // Description : Set the global viscosity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsManager:: -set_viscosity(float viscosity) { +set_viscosity(PN_stdfloat viscosity) { _viscosity=viscosity; } @@ -131,7 +131,7 @@ set_viscosity(float viscosity) { // Access : Public // Description : Get the global viscosity. //////////////////////////////////////////////////////////////////// -INLINE float PhysicsManager:: +INLINE PN_stdfloat PhysicsManager:: get_viscosity() const { return _viscosity; } diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 6535f9b1a8..fd91a041da 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -139,7 +139,7 @@ remove_physical_node(PhysicalNode *p) { // integration on every attached Physical. //////////////////////////////////////////////////////////////////// void PhysicsManager:: -do_physics(float dt) { +do_physics(PN_stdfloat dt) { // now, run through each physics object in the set. PhysicalsVector::iterator p_cur = _physicals.begin(); for (; p_cur != _physicals.end(); ++p_cur) { @@ -175,7 +175,7 @@ do_physics(float dt) { // associated forces are active. //////////////////////////////////////////////////////////////////// void PhysicsManager:: -do_physics(float dt, Physical *physical) { +do_physics(PN_stdfloat dt, Physical *physical) { nassertv(physical); // do linear diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 833e400f59..4d901de177 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -64,15 +64,15 @@ PUBLISHED: INLINE void clear_angular_forces(); INLINE void clear_physicals(); - INLINE void set_viscosity(float viscosity); - INLINE float get_viscosity() const; + INLINE void set_viscosity(PN_stdfloat viscosity); + INLINE PN_stdfloat get_viscosity() const; void remove_physical(Physical *p); void remove_physical_node(PhysicalNode *p); void remove_linear_force(LinearForce *f); void remove_angular_force(AngularForce *f); - void do_physics(float dt); - void do_physics(float dt, Physical *p); + void do_physics(PN_stdfloat dt); + void do_physics(PN_stdfloat dt, Physical *p); void init_random_seed(); virtual void output(ostream &out) const; @@ -88,7 +88,7 @@ public: static ConfigVariableInt _random_seed; private: - float _viscosity; + PN_stdfloat _viscosity; PhysicalsVector _physicals; LinearForceVector _linear_forces; AngularForceVector _angular_forces; diff --git a/panda/src/physics/physicsObject.I b/panda/src/physics/physicsObject.I index c066029eb6..2666883b4e 100644 --- a/panda/src/physics/physicsObject.I +++ b/panda/src/physics/physicsObject.I @@ -18,7 +18,7 @@ // Description : Set the mass in slugs (or kilograms). //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_mass(float m) { +set_mass(PN_stdfloat m) { nassertv(m > 0); _mass = m; } @@ -30,7 +30,7 @@ set_mass(float m) { // the center of mass. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_position(const LPoint3f &pos) { +set_position(const LPoint3 &pos) { nassertv(!pos.is_nan()); _position = pos; } @@ -41,8 +41,8 @@ set_position(const LPoint3f &pos) { // Description : Piecewise position assignment //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_position(float x, float y, float z) { - nassertv(!LPoint3f(x, y, z).is_nan()); +set_position(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + nassertv(!LPoint3(x, y, z).is_nan()); _position.set(x, y, z); } @@ -54,7 +54,7 @@ set_position(float x, float y, float z) { // position. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -reset_position(const LPoint3f &pos) { +reset_position(const LPoint3 &pos) { nassertv(!pos.is_nan()); _position = pos; _last_position = pos; @@ -68,10 +68,10 @@ reset_position(const LPoint3f &pos) { // velocity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -reset_orientation(const LOrientationf &orientation) { +reset_orientation(const LOrientation &orientation) { nassertv(!orientation.is_nan()); _orientation = orientation; - _rotation = LRotationf::ident_quat(); + _rotation = LRotation::ident_quat(); } //////////////////////////////////////////////////////////////////// @@ -80,7 +80,7 @@ reset_orientation(const LOrientationf &orientation) { // Description : Last position assignment //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_last_position(const LPoint3f &pos) { +set_last_position(const LPoint3 &pos) { _last_position = pos; } @@ -90,7 +90,7 @@ set_last_position(const LPoint3f &pos) { // Description : Vector velocity assignment //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_velocity(const LVector3f &vel) { +set_velocity(const LVector3 &vel) { nassertv(!vel.is_nan()); _velocity = vel; } @@ -101,8 +101,8 @@ set_velocity(const LVector3f &vel) { // Description : Piecewise velocity assignment //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_velocity(float x, float y, float z) { - nassertv(!LVector3f(x, y, z).is_nan()); +set_velocity(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + nassertv(!LVector3(x, y, z).is_nan()); _velocity.set(x, y, z); } @@ -115,7 +115,7 @@ set_velocity(float x, float y, float z) { // value to be the new angular velocity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -add_local_torque(const LRotationf &torque) { +add_local_torque(const LRotation &torque) { nassertv(!torque.is_nan()); _rotation+=_orientation.xform(torque); } @@ -129,9 +129,9 @@ add_local_torque(const LRotationf &torque) { // be the new velocity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -add_local_impulse(const LVector3f &impulse) { +add_local_impulse(const LVector3 &impulse) { nassertv(!impulse.is_nan()); - _velocity+=_orientation.xform(impulse); + _velocity += _orientation.xform(impulse); } //////////////////////////////////////////////////////////////////// @@ -143,7 +143,7 @@ add_local_impulse(const LVector3f &impulse) { // value to be the new angular velocity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -add_torque(const LRotationf &torque) { +add_torque(const LRotation &torque) { nassertv(!torque.is_nan()); _rotation+=torque; } @@ -157,7 +157,7 @@ add_torque(const LRotationf &torque) { // be the new velocity. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -add_impulse(const LVector3f &impulse) { +add_impulse(const LVector3 &impulse) { nassertv(!impulse.is_nan()); _velocity+=impulse; } @@ -178,7 +178,7 @@ set_active(bool flag) { // Description : tv assignment //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_terminal_velocity(float tv) { +set_terminal_velocity(PN_stdfloat tv) { _terminal_velocity = tv; } @@ -187,7 +187,7 @@ set_terminal_velocity(float tv) { // Access : Public // Description : Get the mass in slugs (or kilograms). //////////////////////////////////////////////////////////////////// -INLINE float PhysicsObject:: +INLINE PN_stdfloat PhysicsObject:: get_mass() const { return _mass; } @@ -197,7 +197,7 @@ get_mass() const { // Access : Public // Description : Position Query //////////////////////////////////////////////////////////////////// -INLINE LPoint3f PhysicsObject:: +INLINE LPoint3 PhysicsObject:: get_position() const { return _position; } @@ -208,7 +208,7 @@ get_position() const { // Description : Get the position of the physics object at the start // of the most recent do_physics. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f PhysicsObject:: +INLINE LPoint3 PhysicsObject:: get_last_position() const { return _last_position; } @@ -218,7 +218,7 @@ get_last_position() const { // Access : Public // Description : Velocity Query per second //////////////////////////////////////////////////////////////////// -INLINE LVector3f PhysicsObject:: +INLINE LVector3 PhysicsObject:: get_velocity() const { return _velocity; } @@ -228,7 +228,7 @@ get_velocity() const { // Access : Public // Description : Velocity Query over the last dt //////////////////////////////////////////////////////////////////// -INLINE LVector3f PhysicsObject:: +INLINE LVector3 PhysicsObject:: get_implicit_velocity() const { return _position-_last_position; } @@ -248,7 +248,7 @@ get_active() const { // Access : Public // Description : tv query //////////////////////////////////////////////////////////////////// -INLINE float PhysicsObject:: +INLINE PN_stdfloat PhysicsObject:: get_terminal_velocity() const { return _terminal_velocity; } @@ -259,7 +259,7 @@ get_terminal_velocity() const { // Description : //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_orientation(const LOrientationf &orientation) { +set_orientation(const LOrientation &orientation) { nassertv(!orientation.is_nan()); _orientation = orientation; } @@ -270,7 +270,7 @@ set_orientation(const LOrientationf &orientation) { // Description : set rotation as a quaternion delta per second. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: -set_rotation(const LRotationf &rotation) { +set_rotation(const LRotation &rotation) { nassertv(!rotation.is_nan()); _rotation = rotation; } @@ -280,7 +280,7 @@ set_rotation(const LRotationf &rotation) { // Access : Public // Description : get current orientation. //////////////////////////////////////////////////////////////////// -INLINE LOrientationf PhysicsObject:: +INLINE LOrientation PhysicsObject:: get_orientation() const { return _orientation; } @@ -290,7 +290,7 @@ get_orientation() const { // Access : Public // Description : get rotation per second. //////////////////////////////////////////////////////////////////// -INLINE LRotationf PhysicsObject:: +INLINE LRotation PhysicsObject:: get_rotation() const { return _rotation; } diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 416164e80f..a58b1cc8e1 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -35,7 +35,7 @@ PhysicsObject() : _last_position = _position; _velocity.set(0.0f, 0.0f, 0.0f); _orientation.set(1.0 ,0.0f, 0.0f, 0.0f); - _rotation = LRotationf::ident_quat(); + _rotation = LRotation::ident_quat(); } //////////////////////////////////////////////////////////////////// @@ -99,8 +99,8 @@ make_copy() const { // offset and force are in local coordinates. //////////////////////////////////////////////////////////////////// void PhysicsObject:: -add_local_impact(const LPoint3f &offset_from_center_of_mass, - const LVector3f &force) { +add_local_impact(const LPoint3 &offset_from_center_of_mass, + const LVector3 &force) { nassertv(!offset_from_center_of_mass.is_nan()); nassertv(!force.is_nan()); add_impact( @@ -120,26 +120,26 @@ add_local_impact(const LPoint3f &offset_from_center_of_mass, // offset and force are in global (or parent) coordinates. //////////////////////////////////////////////////////////////////// void PhysicsObject:: -add_impact(const LPoint3f &offset, - const LVector3f &force) { +add_impact(const LPoint3 &offset, + const LVector3 &force) { nassertv(!offset.is_nan()); nassertv(!force.is_nan()); - LVector3f a = offset; - LVector3f b = force; + LVector3 a = offset; + LVector3 b = force; a.normalize(); b.normalize(); a = a.cross(b); - float angle = a.length(); + PN_stdfloat angle = a.length(); if (angle) { - LRotationf torque; - float spin = force.length()*0.1f; // todo: this should account for - // impact distance and mass. + LRotation torque; + PN_stdfloat spin = force.length()*0.1; // todo: this should account for + // impact distance and mass. a.normalize(); assert(IS_THRESHOLD_EQUAL(a.length(), 1.0f, 0.001f)); torque.set_from_axis_angle(spin, a); add_torque(torque); } - LVector3f impulse = (1.0f - angle) * force; + LVector3 impulse = (1.0f - angle) * force; add_impulse(impulse); } @@ -149,9 +149,9 @@ add_impact(const LPoint3f &offset, // Description : returns a transform matrix to this object's // local coordinate system. //////////////////////////////////////////////////////////////////// -LMatrix4f PhysicsObject:: +LMatrix4 PhysicsObject:: get_lcs() const { - LMatrix4f m = LMatrix4f::translate_mat(_position); + LMatrix4 m = LMatrix4::translate_mat(_position); if (_oriented) { m=m*_orientation; } @@ -165,9 +165,9 @@ get_lcs() const { // Description : returns a transform matrix that represents the // object's willingness to be forced. //////////////////////////////////////////////////////////////////// -LMatrix4f PhysicsObject:: +LMatrix4 PhysicsObject:: get_inertial_tensor() const { - return LMatrix4f::ident_mat(); + return LMatrix4::ident_mat(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index ba3e3eee21..6d4b4e40a4 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -41,52 +41,52 @@ PUBLISHED: INLINE void set_active(bool flag); INLINE bool get_active() const; - INLINE void set_mass(float); - INLINE float get_mass() const; + INLINE void set_mass(PN_stdfloat); + INLINE PN_stdfloat get_mass() const; - //INLINE void set_center_of_mass(const LPoint3f &pos); use set_position. - INLINE void set_position(const LPoint3f &pos); - INLINE void set_position(float x, float y, float z); - INLINE LPoint3f get_position() const; + //INLINE void set_center_of_mass(const LPoint3 &pos); use set_position. + INLINE void set_position(const LPoint3 &pos); + INLINE void set_position(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE LPoint3 get_position() const; - INLINE void reset_position(const LPoint3f &pos); + INLINE void reset_position(const LPoint3 &pos); - INLINE void set_last_position(const LPoint3f &pos); - INLINE LPoint3f get_last_position() const; + INLINE void set_last_position(const LPoint3 &pos); + INLINE LPoint3 get_last_position() const; - INLINE void set_velocity(const LVector3f &vel); - INLINE void set_velocity(float x, float y, float z); - INLINE LVector3f get_velocity() const; - INLINE LVector3f get_implicit_velocity() const; + INLINE void set_velocity(const LVector3 &vel); + INLINE void set_velocity(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE LVector3 get_velocity() const; + INLINE LVector3 get_implicit_velocity() const; // Global instantanious forces - INLINE void add_torque(const LRotationf &torque); - INLINE void add_impulse(const LVector3f &impulse); + INLINE void add_torque(const LRotation &torque); + INLINE void add_impulse(const LVector3 &impulse); virtual void add_impact( - const LPoint3f &offset_from_center_of_mass, const LVector3f &impulse); + const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse); // Local instantanious forces - INLINE void add_local_torque(const LRotationf &torque); - INLINE void add_local_impulse(const LVector3f &impulse); + INLINE void add_local_torque(const LRotation &torque); + INLINE void add_local_impulse(const LVector3 &impulse); virtual void add_local_impact( - const LPoint3f &offset_from_center_of_mass, const LVector3f &impulse); + const LPoint3 &offset_from_center_of_mass, const LVector3 &impulse); - INLINE void set_terminal_velocity(float tv); - INLINE float get_terminal_velocity() const; + INLINE void set_terminal_velocity(PN_stdfloat tv); + INLINE PN_stdfloat get_terminal_velocity() const; INLINE void set_oriented(bool flag); INLINE bool get_oriented() const; - INLINE void set_orientation(const LOrientationf &orientation); - INLINE LOrientationf get_orientation() const; + INLINE void set_orientation(const LOrientation &orientation); + INLINE LOrientation get_orientation() const; - INLINE void reset_orientation(const LOrientationf &orientation); + INLINE void reset_orientation(const LOrientation &orientation); - INLINE void set_rotation(const LRotationf &rotation); - INLINE LRotationf get_rotation() const; + INLINE void set_rotation(const LRotation &rotation); + INLINE LRotation get_rotation() const; - virtual LMatrix4f get_inertial_tensor() const; - virtual LMatrix4f get_lcs() const; + virtual LMatrix4 get_inertial_tensor() const; + virtual LMatrix4 get_lcs() const; virtual PhysicsObject *make_copy() const; #ifndef NDEBUG @@ -103,16 +103,16 @@ PUBLISHED: private: // physical - LPoint3f _position; // aka _center_of_mass - LPoint3f _last_position; - LVector3f _velocity; // aka _linear_velocity + LPoint3 _position; // aka _center_of_mass + LPoint3 _last_position; + LVector3 _velocity; // aka _linear_velocity // angular - LOrientationf _orientation; - LRotationf _rotation; // aka _angular_velocity + LOrientation _orientation; + LRotation _rotation; // aka _angular_velocity - float _terminal_velocity; - float _mass; + PN_stdfloat _terminal_velocity; + PN_stdfloat _mass; bool _process_me; bool _oriented; diff --git a/panda/src/physics/test_physics.cxx b/panda/src/physics/test_physics.cxx index 8a75766cd6..397feae89f 100644 --- a/panda/src/physics/test_physics.cxx +++ b/panda/src/physics/test_physics.cxx @@ -40,7 +40,7 @@ int main(int argc, char **argv) { physics_manager.attach_physical(&nf_b); int steps=16; - float delta_time=1.0f/(float)steps; + PN_stdfloat delta_time=1.0f/(PN_stdfloat)steps; while (steps--) { cout << "ball: " << nf_b.get_phys_body()->get_position() << endl; cout << "nf: " << nf.get_vector(nf_b.get_phys_body()) << endl; @@ -57,7 +57,7 @@ int main(int argc, char **argv) { for (PhysicsObject::Vector::const_iterator co=b.get_object_vector().begin(); co != b.get_object_vector().end(); ++i, ++co) { - (*co)->set_position(i * 2.0f, float(i), 0.0f); + (*co)->set_position(i * 2.0f, PN_stdfloat(i), 0.0f); (*co)->set_velocity(5.0f, 0.0f, 30.0f); (*co)->set_active(true); (*co)->set_mass(1.0f); diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 207222234e..6ddda1ba2f 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -234,13 +234,13 @@ alpha_fill_val(xelval alpha) { // Input must be a color image. //////////////////////////////////////////////////////////////////// void PNMImage:: -remix_channels(const LMatrix4f &conv) { +remix_channels(const LMatrix4 &conv) { int nchannels = get_num_channels(); nassertv((nchannels >= 3) && (nchannels <= 4)); for (int y = 0; y < get_y_size(); y++) { for (int x = 0; x < get_x_size(); x++) { - LVector3f inv(get_red(x,y),get_green(x,y),get_blue(x,y)); - LVector3f outv(conv.xform_point(inv)); + LVector3 inv(get_red(x,y),get_green(x,y),get_blue(x,y)); + LVector3 outv(conv.xform_point(inv)); set_xel(x,y,outv[0],outv[1],outv[2]); } } diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index f0c8fd9552..2e59b44593 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -81,7 +81,7 @@ PUBLISHED: INLINE void fill(double red, double green, double blue); INLINE void fill(double gray = 0.0); - void remix_channels(const LMatrix4f &conv); + void remix_channels(const LMatrix4 &conv); void fill_val(xelval red, xelval green, xelval blue); INLINE void fill_val(xelval gray = 0); diff --git a/panda/src/pnmtext/freetypeFont.I b/panda/src/pnmtext/freetypeFont.I index 2acb3c295c..0ecc93536a 100644 --- a/panda/src/pnmtext/freetypeFont.I +++ b/panda/src/pnmtext/freetypeFont.I @@ -35,7 +35,7 @@ INLINE FreetypeFont:: // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool FreetypeFont:: -set_point_size(float point_size) { +set_point_size(PN_stdfloat point_size) { _point_size = point_size; return reset_scale(); } @@ -45,7 +45,7 @@ set_point_size(float point_size) { // Access: Public // Description: Returns the point size of the font. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_point_size() const { return _point_size; } @@ -66,7 +66,7 @@ get_point_size() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool FreetypeFont:: -set_pixels_per_unit(float pixels_per_unit) { +set_pixels_per_unit(PN_stdfloat pixels_per_unit) { _requested_pixels_per_unit = pixels_per_unit; return reset_scale(); } @@ -77,7 +77,7 @@ set_pixels_per_unit(float pixels_per_unit) { // Description: Returns the resolution of the texture map. See // set_pixels_per_unit(). //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_pixels_per_unit() const { return _tex_pixels_per_unit; } @@ -91,7 +91,7 @@ get_pixels_per_unit() const { // specify pixels_per_unit(). //////////////////////////////////////////////////////////////////// INLINE bool FreetypeFont:: -set_pixel_size(float pixel_size) { +set_pixel_size(PN_stdfloat pixel_size) { return set_pixels_per_unit(pixel_size * _points_per_unit / _point_size); } @@ -101,7 +101,7 @@ set_pixel_size(float pixel_size) { // Description: Returns the size of the font in pixels, as it appears // in the texture. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_pixel_size() const { return _tex_pixels_per_unit * _point_size / _points_per_unit; } @@ -123,7 +123,7 @@ get_pixel_size() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool FreetypeFont:: -set_scale_factor(float scale_factor) { +set_scale_factor(PN_stdfloat scale_factor) { _requested_scale_factor = scale_factor; return reset_scale(); } @@ -134,7 +134,7 @@ set_scale_factor(float scale_factor) { // Description: Returns the antialiasing scale factor. See // set_scale_factor(). //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_scale_factor() const { return _scale_factor; } @@ -194,7 +194,7 @@ get_font_pixel_size() const { // Description: Returns the number of units high each line of text // is. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_line_height() const { return _line_height; } @@ -204,7 +204,7 @@ get_line_height() const { // Access: Public // Description: Returns the number of units wide a space is. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_space_advance() const { return _space_advance; } @@ -216,7 +216,7 @@ get_space_advance() const { // unit high. This is an arbitrary Panda convention for // text, and is set to 10.0. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_points_per_unit() { return _points_per_unit; } @@ -227,7 +227,7 @@ get_points_per_unit() { // Description: Returns the number of points in one inch. This is a // universal typographic convention. //////////////////////////////////////////////////////////////////// -INLINE float FreetypeFont:: +INLINE PN_stdfloat FreetypeFont:: get_points_per_inch() { return _points_per_inch; } diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index e7d6110acb..c2a5d176b1 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -24,10 +24,10 @@ // This constant determines how big a particular point size font // appears to be. By convention, 10 points is 1 unit (e.g. 1 foot) // high. -const float FreetypeFont::_points_per_unit = 10.0f; +const PN_stdfloat FreetypeFont::_points_per_unit = 10.0f; // A universal typographic convention. -const float FreetypeFont::_points_per_inch = 72.0f; +const PN_stdfloat FreetypeFont::_points_per_inch = 72.0f; //////////////////////////////////////////////////////////////////// // Function: FreetypeFont::Constructor @@ -272,7 +272,7 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { for (int xi = 0; xi < bitmap.width; xi++) { - image.set_gray(xi, yi, (float)buffer_row[xi] / (bitmap.num_grays - 1)); + image.set_gray(xi, yi, (PN_stdfloat)buffer_row[xi] / (bitmap.num_grays - 1)); } buffer_row += bitmap.pitch; } @@ -309,7 +309,7 @@ reset_scale() { _pixel_height = 0; _pixel_width = 0; - float units_per_inch = (_points_per_inch / _points_per_unit); + PN_stdfloat units_per_inch = (_points_per_inch / _points_per_unit); _dpi = (int)(_font_pixels_per_unit * units_per_inch); _char_size = (int)(_point_size * 64); diff --git a/panda/src/pnmtext/freetypeFont.h b/panda/src/pnmtext/freetypeFont.h index bedb37f122..9352701a4d 100644 --- a/panda/src/pnmtext/freetypeFont.h +++ b/panda/src/pnmtext/freetypeFont.h @@ -50,28 +50,28 @@ protected: PUBLISHED: INLINE ~FreetypeFont(); - INLINE bool set_point_size(float point_size); - INLINE float get_point_size() const; + INLINE bool set_point_size(PN_stdfloat point_size); + INLINE PN_stdfloat get_point_size() const; - INLINE bool set_pixels_per_unit(float pixels_per_unit); - INLINE float get_pixels_per_unit() const; + INLINE bool set_pixels_per_unit(PN_stdfloat pixels_per_unit); + INLINE PN_stdfloat get_pixels_per_unit() const; - INLINE bool set_pixel_size(float pixel_size); - INLINE float get_pixel_size() const; + INLINE bool set_pixel_size(PN_stdfloat pixel_size); + INLINE PN_stdfloat get_pixel_size() const; - INLINE bool set_scale_factor(float scale_factor); - INLINE float get_scale_factor() const; + INLINE bool set_scale_factor(PN_stdfloat scale_factor); + INLINE PN_stdfloat get_scale_factor() const; INLINE void set_native_antialias(bool native_antialias); INLINE bool get_native_antialias() const; INLINE int get_font_pixel_size() const; - INLINE float get_line_height() const; - INLINE float get_space_advance() const; + INLINE PN_stdfloat get_line_height() const; + INLINE PN_stdfloat get_space_advance() const; - INLINE static float get_points_per_unit(); - INLINE static float get_points_per_inch(); + INLINE static PN_stdfloat get_points_per_unit(); + INLINE static PN_stdfloat get_points_per_inch(); protected: INLINE FT_Face acquire_face() const; @@ -84,17 +84,17 @@ private: bool reset_scale(); protected: - float _point_size; - float _requested_pixels_per_unit; - float _tex_pixels_per_unit; - float _requested_scale_factor; - float _scale_factor; + PN_stdfloat _point_size; + PN_stdfloat _requested_pixels_per_unit; + PN_stdfloat _tex_pixels_per_unit; + PN_stdfloat _requested_scale_factor; + PN_stdfloat _scale_factor; bool _native_antialias; - float _font_pixels_per_unit; + PN_stdfloat _font_pixels_per_unit; int _font_pixel_size; - float _line_height; - float _space_advance; + PN_stdfloat _line_height; + PN_stdfloat _space_advance; PT(FreetypeFace) _face; int _char_size; @@ -103,8 +103,8 @@ protected: int _pixel_height; protected: - static const float _points_per_unit; - static const float _points_per_inch; + static const PN_stdfloat _points_per_unit; + static const PN_stdfloat _points_per_inch; }; #include "freetypeFont.I" diff --git a/panda/src/pnmtext/pnmTextGlyph.cxx b/panda/src/pnmtext/pnmTextGlyph.cxx index 1c726fece0..309d773c97 100644 --- a/panda/src/pnmtext/pnmTextGlyph.cxx +++ b/panda/src/pnmtext/pnmTextGlyph.cxx @@ -49,7 +49,7 @@ PNMTextGlyph:: // other pixels alone. //////////////////////////////////////////////////////////////////// void PNMTextGlyph:: -place(PNMImage &dest_image, int xp, int yp, const Colorf &fg) { +place(PNMImage &dest_image, int xp, int yp, const LColor &fg) { if (!_image.is_valid()) { // If we have no image, do nothing. return; @@ -97,8 +97,8 @@ place(PNMImage &dest_image, int xp, int yp, const Colorf &fg) { // called earlier. //////////////////////////////////////////////////////////////////// void PNMTextGlyph:: -place(PNMImage &dest_image, int xp, int yp, const Colorf &fg, - const Colorf &interior) { +place(PNMImage &dest_image, int xp, int yp, const LColor &fg, + const LColor &interior) { if (!_image.is_valid()) { // If we have no image, do nothing. return; diff --git a/panda/src/pnmtext/pnmTextGlyph.h b/panda/src/pnmtext/pnmTextGlyph.h index 4ba0de8210..d2cb7c559b 100644 --- a/panda/src/pnmtext/pnmTextGlyph.h +++ b/panda/src/pnmtext/pnmTextGlyph.h @@ -32,9 +32,9 @@ PUBLISHED: INLINE int get_advance() const; void place(PNMImage &dest_image, int xp, int yp, - const Colorf &fg); + const LColor &fg); void place(PNMImage &dest_image, int xp, int yp, - const Colorf &fg, const Colorf &interior); + const LColor &fg, const LColor &interior); INLINE int get_left() const; INLINE int get_right() const; diff --git a/panda/src/pnmtext/pnmTextMaker.I b/panda/src/pnmtext/pnmTextMaker.I index 0662d62255..9cd0e9044b 100644 --- a/panda/src/pnmtext/pnmTextMaker.I +++ b/panda/src/pnmtext/pnmTextMaker.I @@ -85,7 +85,7 @@ get_interior_flag() const { // will show as. //////////////////////////////////////////////////////////////////// INLINE void PNMTextMaker:: -set_fg(const Colorf &fg) { +set_fg(const LColor &fg) { _fg = fg; } @@ -95,7 +95,7 @@ set_fg(const Colorf &fg) { // Description: Returns the foreground color of text that will be // generated by future calls to generate_into(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &PNMTextMaker:: +INLINE const LColor &PNMTextMaker:: get_fg() const { return _fg; } @@ -109,7 +109,7 @@ get_fg() const { // interior_flag is true. //////////////////////////////////////////////////////////////////// INLINE void PNMTextMaker:: -set_interior(const Colorf &interior) { +set_interior(const LColor &interior) { _interior = interior; } @@ -119,7 +119,7 @@ set_interior(const Colorf &interior) { // Description: Returns the color that will be used to render the // interior portions of hollow fonts. //////////////////////////////////////////////////////////////////// -INLINE const Colorf &PNMTextMaker:: +INLINE const LColor &PNMTextMaker:: get_interior() const { return _interior; } diff --git a/panda/src/pnmtext/pnmTextMaker.h b/panda/src/pnmtext/pnmTextMaker.h index 6db847bf2e..4f61b9b49a 100644 --- a/panda/src/pnmtext/pnmTextMaker.h +++ b/panda/src/pnmtext/pnmTextMaker.h @@ -57,11 +57,11 @@ PUBLISHED: INLINE void set_interior_flag(bool interior_flag); INLINE bool get_interior_flag() const; - INLINE void set_fg(const Colorf &fg); - INLINE const Colorf &get_fg() const; + INLINE void set_fg(const LColor &fg); + INLINE const LColor &get_fg() const; - INLINE void set_interior(const Colorf &interior); - INLINE const Colorf &get_interior() const; + INLINE void set_interior(const LColor &interior); + INLINE const LColor &get_interior() const; INLINE int generate_into(const string &text, PNMImage &dest_image, int x, int y); @@ -84,8 +84,8 @@ private: Alignment _align; bool _interior_flag; - Colorf _fg; - Colorf _interior; + LColor _fg; + LColor _interior; }; #include "pnmTextMaker.I" diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index bf5457451a..9ad8d9ba69 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -51,7 +51,7 @@ get_client_name() const { // thread. //////////////////////////////////////////////////////////////////// INLINE void PStatClient:: -set_max_rate(float rate) { +set_max_rate(PN_stdfloat rate) { get_impl()->set_max_rate(rate); } @@ -62,7 +62,7 @@ set_max_rate(float rate) { // sent to the server per second, per thread. See // set_max_rate(). //////////////////////////////////////////////////////////////////// -INLINE float PStatClient:: +INLINE PN_stdfloat PStatClient:: get_max_rate() const { return get_impl()->get_max_rate(); } diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index c6d4500881..26bc6de7a4 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -744,7 +744,7 @@ start(int collector_index, int thread_index) { // instead, call PStatCollector::start(). //////////////////////////////////////////////////////////////////// void PStatClient:: -start(int collector_index, int thread_index, float as_of) { +start(int collector_index, int thread_index, PN_stdfloat as_of) { #ifdef _DEBUG nassertv(collector_index >= 0 && collector_index < AtomicAdjust::get(_num_collectors)); nassertv(thread_index >= 0 && thread_index < AtomicAdjust::get(_num_threads)); @@ -815,7 +815,7 @@ stop(int collector_index, int thread_index) { // instead, call PStatCollector::stop(). //////////////////////////////////////////////////////////////////// void PStatClient:: -stop(int collector_index, int thread_index, float as_of) { +stop(int collector_index, int thread_index, PN_stdfloat as_of) { #ifdef _DEBUG nassertv(collector_index >= 0 && collector_index < AtomicAdjust::get(_num_collectors)); nassertv(thread_index >= 0 && thread_index < AtomicAdjust::get(_num_threads)); diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 8d7448e40e..4f5c812547 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -62,8 +62,8 @@ public: PUBLISHED: INLINE void set_client_name(const string &name); INLINE string get_client_name() const; - INLINE void set_max_rate(float rate); - INLINE float get_max_rate() const; + INLINE void set_max_rate(PN_stdfloat rate); + INLINE PN_stdfloat get_max_rate() const; INLINE int get_num_collectors() const; PStatCollector get_collector(int index) const; @@ -118,9 +118,9 @@ private: bool is_started(int collector_index, int thread_index) const; void start(int collector_index, int thread_index); - void start(int collector_index, int thread_index, float as_of); + void start(int collector_index, int thread_index, PN_stdfloat as_of); void stop(int collector_index, int thread_index); - void stop(int collector_index, int thread_index, float as_of); + void stop(int collector_index, int thread_index, PN_stdfloat as_of); void clear_level(int collector_index, int thread_index); void set_level(int collector_index, int thread_index, double level); @@ -208,7 +208,7 @@ private: PStatFrameData _frame_data; bool _is_active; int _frame_number; - float _next_packet; + PN_stdfloat _next_packet; bool _thread_active; BitArray _active_collectors; // no longer used. diff --git a/panda/src/pstatclient/pStatClientImpl.I b/panda/src/pstatclient/pStatClientImpl.I index 6e453364df..b73148f74d 100644 --- a/panda/src/pstatclient/pStatClientImpl.I +++ b/panda/src/pstatclient/pStatClientImpl.I @@ -51,7 +51,7 @@ get_client_name() const { // thread. //////////////////////////////////////////////////////////////////// INLINE void PStatClientImpl:: -set_max_rate(float rate) { +set_max_rate(PN_stdfloat rate) { _max_rate = rate; } @@ -62,7 +62,7 @@ set_max_rate(float rate) { // sent to the server per second, per thread. See // set_max_rate(). //////////////////////////////////////////////////////////////////// -INLINE float PStatClientImpl:: +INLINE PN_stdfloat PStatClientImpl:: get_max_rate() const { return _max_rate; } diff --git a/panda/src/pstatclient/pStatClientImpl.cxx b/panda/src/pstatclient/pStatClientImpl.cxx index d04153b31a..c6e1f618ad 100644 --- a/panda/src/pstatclient/pStatClientImpl.cxx +++ b/panda/src/pstatclient/pStatClientImpl.cxx @@ -190,7 +190,7 @@ new_frame(int thread_index) { return; } - float frame_start = get_real_time(); + PN_stdfloat frame_start = get_real_time(); int frame_number = -1; PStatFrameData frame_data; @@ -245,11 +245,11 @@ transmit_frame_data(int thread_index, int frame_number, // server. Check that enough time has elapsed for us to send a // new packet. If not, we'll drop this packet on the floor and // send a new one next time around. - float now = get_real_time(); + PN_stdfloat now = get_real_time(); if (now >= thread->_next_packet) { // We don't want to send more than _max_rate UDP-size packets // per second, per thread. - float packet_delay = 1.0 / _max_rate; + PN_stdfloat packet_delay = 1.0 / _max_rate; // Send new data. NetDatagram datagram; @@ -299,7 +299,7 @@ transmit_frame_data(int thread_index, int frame_number, int packet_ratio = (datagram.get_length() + maximum_udp_datagram - 1) / maximum_udp_datagram; - packet_delay *= (float)packet_ratio; + packet_delay *= (PN_stdfloat)packet_ratio; } thread->_next_packet = now + packet_delay; diff --git a/panda/src/pstatclient/pStatClientImpl.h b/panda/src/pstatclient/pStatClientImpl.h index d6009b1f2f..dd69741ba0 100644 --- a/panda/src/pstatclient/pStatClientImpl.h +++ b/panda/src/pstatclient/pStatClientImpl.h @@ -59,8 +59,8 @@ public: INLINE void set_client_name(const string &name); INLINE string get_client_name() const; - INLINE void set_max_rate(float rate); - INLINE float get_max_rate() const; + INLINE void set_max_rate(PN_stdfloat rate); + INLINE PN_stdfloat get_max_rate() const; INLINE double get_real_time() const; @@ -110,10 +110,10 @@ private: string _hostname; string _client_name; - float _max_rate; + PN_stdfloat _max_rate; - float _tcp_count_factor; - float _udp_count_factor; + PN_stdfloat _tcp_count_factor; + PN_stdfloat _udp_count_factor; unsigned int _tcp_count; unsigned int _udp_count; }; diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index 6eb89d8234..a4dec38c2b 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -485,7 +485,7 @@ start(const PStatThread &thread) { // a monotonically increasing series of time values. //////////////////////////////////////////////////////////////////// INLINE void PStatCollector:: -start(const PStatThread &thread, float as_of) { +start(const PStatThread &thread, PN_stdfloat as_of) { _client->start(_index, thread._index, as_of); } @@ -509,7 +509,7 @@ stop(const PStatThread &thread) { // a monotonically increasing series of time values. //////////////////////////////////////////////////////////////////// INLINE void PStatCollector:: -stop(const PStatThread &thread, float as_of) { +stop(const PStatThread &thread, PN_stdfloat as_of) { _client->stop(_index, thread._index, as_of); } diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 986df5c76a..983a282619 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -92,9 +92,9 @@ PUBLISHED: INLINE bool is_active(const PStatThread &thread); INLINE bool is_started(const PStatThread &thread); INLINE void start(const PStatThread &thread); - INLINE void start(const PStatThread &thread, float as_of); + INLINE void start(const PStatThread &thread, PN_stdfloat as_of); INLINE void stop(const PStatThread &thread); - INLINE void stop(const PStatThread &thread, float as_of); + INLINE void stop(const PStatThread &thread, PN_stdfloat as_of); INLINE void clear_level(const PStatThread &thread); INLINE void set_level(const PStatThread &thread, double level); @@ -137,9 +137,9 @@ PUBLISHED: INLINE bool is_active(const PStatThread &) { return false; } INLINE void start(const PStatThread &) { } - INLINE void start(const PStatThread &, float) { } + INLINE void start(const PStatThread &, PN_stdfloat) { } INLINE void stop(const PStatThread &) { } - INLINE void stop(const PStatThread &, float) { } + INLINE void stop(const PStatThread &, PN_stdfloat) { } INLINE void clear_level(const PStatThread &) { } INLINE void set_level(const PStatThread &, double) { } diff --git a/panda/src/pstatclient/pStatCollectorDef.cxx b/panda/src/pstatclient/pStatCollectorDef.cxx index fe7ee87a4c..0d15f1b5fe 100644 --- a/panda/src/pstatclient/pStatCollectorDef.cxx +++ b/panda/src/pstatclient/pStatCollectorDef.cxx @@ -87,13 +87,13 @@ write_datagram(Datagram &destination) const { destination.add_int16(_index); destination.add_string(_name); destination.add_int16(_parent_index); - destination.add_float32(_suggested_color.r); - destination.add_float32(_suggested_color.g); - destination.add_float32(_suggested_color.b); + destination.add_stdfloat(_suggested_color.r); + destination.add_stdfloat(_suggested_color.g); + destination.add_stdfloat(_suggested_color.b); destination.add_int16(_sort); destination.add_string(_level_units); - destination.add_float32(_suggested_scale); - destination.add_float32(_factor); + destination.add_stdfloat(_suggested_scale); + destination.add_stdfloat(_factor); } //////////////////////////////////////////////////////////////////// @@ -106,11 +106,11 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) { _index = source.get_int16(); _name = source.get_string(); _parent_index = source.get_int16(); - _suggested_color.r = source.get_float32(); - _suggested_color.g = source.get_float32(); - _suggested_color.b = source.get_float32(); + _suggested_color.r = source.get_stdfloat(); + _suggested_color.g = source.get_stdfloat(); + _suggested_color.b = source.get_stdfloat(); _sort = source.get_int16(); _level_units = source.get_string(); - _suggested_scale = source.get_float32(); - _factor = source.get_float32(); + _suggested_scale = source.get_stdfloat(); + _factor = source.get_stdfloat(); } diff --git a/panda/src/pstatclient/pStatCollectorDef.h b/panda/src/pstatclient/pStatCollectorDef.h index dd46b63718..10456b8cc6 100644 --- a/panda/src/pstatclient/pStatCollectorDef.h +++ b/panda/src/pstatclient/pStatCollectorDef.h @@ -16,6 +16,7 @@ #define PSTATCOLLECTORDEF_H #include "pandabase.h" +#include "numeric_types.h" class Datagram; class DatagramIterator; @@ -37,7 +38,7 @@ public: void read_datagram(DatagramIterator &source, PStatClientVersion *version); struct ColorDef { - float r, g, b; + PN_stdfloat r, g, b; }; int _index; diff --git a/panda/src/pstatclient/pStatFrameData.I b/panda/src/pstatclient/pStatFrameData.I index 52cd0f29af..07b4f360cd 100644 --- a/panda/src/pstatclient/pStatFrameData.I +++ b/panda/src/pstatclient/pStatFrameData.I @@ -77,7 +77,7 @@ swap(PStatFrameData &other) { // data. //////////////////////////////////////////////////////////////////// INLINE void PStatFrameData:: -add_start(int index, float time) { +add_start(int index, PN_stdfloat time) { #ifdef _DEBUG nassertv((index & 0x7fff) == index); #endif @@ -94,7 +94,7 @@ add_start(int index, float time) { // data. //////////////////////////////////////////////////////////////////// INLINE void PStatFrameData:: -add_stop(int index, float time) { +add_stop(int index, PN_stdfloat time) { #ifdef _DEBUG nassertv((index & 0x7fff) == index); #endif @@ -111,7 +111,7 @@ add_stop(int index, float time) { // collector to the frame data. //////////////////////////////////////////////////////////////////// INLINE void PStatFrameData:: -add_level(int index, float level) { +add_level(int index, PN_stdfloat level) { #ifdef _DEBUG nassertv((index & 0xffff) == index); #endif @@ -128,7 +128,7 @@ add_level(int index, float level) { // data. This will generally be the time of the start // of the frame. //////////////////////////////////////////////////////////////////// -INLINE float PStatFrameData:: +INLINE PN_stdfloat PStatFrameData:: get_start() const { if (is_empty()) { return 0.0; @@ -144,7 +144,7 @@ get_start() const { // data. This will generally be the time of the end // of the frame. //////////////////////////////////////////////////////////////////// -INLINE float PStatFrameData:: +INLINE PN_stdfloat PStatFrameData:: get_end() const { nassertr(!is_empty(), 0.0); @@ -156,7 +156,7 @@ get_end() const { // Access: Public // Description: Returns the total time elapsed for the frame. //////////////////////////////////////////////////////////////////// -INLINE float PStatFrameData:: +INLINE PN_stdfloat PStatFrameData:: get_net_time() const { nassertr(!is_empty(), 0.0); @@ -206,7 +206,7 @@ is_start(int n) const { // guaranteed to be shared among all events returned // from a given client). //////////////////////////////////////////////////////////////////// -INLINE float PStatFrameData:: +INLINE PN_stdfloat PStatFrameData:: get_time(int n) const { nassertr(n >= 0 && n < (int)_time_data.size(), 0); return _time_data[n]._value; @@ -240,7 +240,7 @@ get_level_collector(int n) const { // Access: Public // Description: Returns the height of the nth level value. //////////////////////////////////////////////////////////////////// -INLINE float PStatFrameData:: +INLINE PN_stdfloat PStatFrameData:: get_level(int n) const { nassertr(n >= 0 && n < (int)_level_data.size(), 0); return _level_data[n]._value; diff --git a/panda/src/pstatclient/pStatFrameData.cxx b/panda/src/pstatclient/pStatFrameData.cxx index 2a5b1cb445..a4f63d1aea 100644 --- a/panda/src/pstatclient/pStatFrameData.cxx +++ b/panda/src/pstatclient/pStatFrameData.cxx @@ -52,12 +52,12 @@ write_datagram(Datagram &destination, PStatClient *client) const { destination.add_uint16(_time_data.size()); for (di = _time_data.begin(); di != _time_data.end(); ++di) { destination.add_uint16((*di)._index); - destination.add_float32((*di)._value); + destination.add_stdfloat((*di)._value); } destination.add_uint16(_level_data.size()); for (di = _level_data.begin(); di != _level_data.end(); ++di) { destination.add_uint16((*di)._index); - destination.add_float32((*di)._value); + destination.add_stdfloat((*di)._value); } return true; @@ -78,7 +78,7 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) { nassertv(source.get_remaining_size() > 0); DataPoint dp; dp._index = source.get_uint16(); - dp._value = source.get_float32(); + dp._value = source.get_stdfloat(); _time_data.push_back(dp); } int level_size = source.get_uint16(); @@ -86,7 +86,7 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) { nassertv(source.get_remaining_size() > 0); DataPoint dp; dp._index = source.get_uint16(); - dp._value = source.get_float32(); + dp._value = source.get_stdfloat(); _level_data.push_back(dp); } nassertv(source.get_remaining_size() == 0); diff --git a/panda/src/pstatclient/pStatFrameData.h b/panda/src/pstatclient/pStatFrameData.h index 490f9a70de..ba2939dc59 100644 --- a/panda/src/pstatclient/pStatFrameData.h +++ b/panda/src/pstatclient/pStatFrameData.h @@ -41,24 +41,24 @@ public: INLINE void clear(); INLINE void swap(PStatFrameData &other); - INLINE void add_start(int index, float time); - INLINE void add_stop(int index, float time); - INLINE void add_level(int index, float level); + INLINE void add_start(int index, PN_stdfloat time); + INLINE void add_stop(int index, PN_stdfloat time); + INLINE void add_level(int index, PN_stdfloat level); void sort_time(); - INLINE float get_start() const; - INLINE float get_end() const; - INLINE float get_net_time() const; + INLINE PN_stdfloat get_start() const; + INLINE PN_stdfloat get_end() const; + INLINE PN_stdfloat get_net_time() const; INLINE int get_num_events() const; INLINE int get_time_collector(int n) const; INLINE bool is_start(int n) const; - INLINE float get_time(int n) const; + INLINE PN_stdfloat get_time(int n) const; INLINE int get_num_levels() const; INLINE int get_level_collector(int n) const; - INLINE float get_level(int n) const; + INLINE PN_stdfloat get_level(int n) const; bool write_datagram(Datagram &destination, PStatClient *client) const; void read_datagram(DatagramIterator &source, PStatClientVersion *version); @@ -69,7 +69,7 @@ private: INLINE bool operator < (const DataPoint &other) const; int _index; - float _value; + PN_stdfloat _value; }; typedef pvector Data; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index d65d50f141..cc68a9d788 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -90,7 +90,7 @@ struct TimeCollectorProperties { bool is_active; const char *name; ColorDef color; - float suggested_scale; + PN_stdfloat suggested_scale; }; struct LevelCollectorProperties { @@ -98,8 +98,8 @@ struct LevelCollectorProperties { const char *name; ColorDef color; const char *units; - float suggested_scale; - float inv_factor; + PN_stdfloat suggested_scale; + PN_stdfloat inv_factor; }; static TimeCollectorProperties time_properties[] = { diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index c8c0df0148..44b3cff2ba 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -36,8 +36,8 @@ void signal_handler(int) { struct SampleData { const char *category; - float min_ms; - float max_ms; + PN_stdfloat min_ms; + PN_stdfloat max_ms; bool is_level; }; @@ -75,7 +75,7 @@ SampleData *datasets[NUM_DATASETS] = { class WaitRequest { public: - float _time; + PN_stdfloat _time; int _index; bool _start; @@ -121,7 +121,7 @@ main(int argc, char *argv[]) { ds_index = atoi(argv[3]); } else { // Pick a random Dataset. - ds_index = (int)((float)NUM_DATASETS * rand() / (RAND_MAX + 1.0)); + ds_index = (int)((PN_stdfloat)NUM_DATASETS * rand() / (RAND_MAX + 1.0)); } if (ds_index < 0 || ds_index >= NUM_DATASETS) { nout << "Invalid dataset; choose a number in the range 0 to " @@ -144,9 +144,9 @@ main(int argc, char *argv[]) { while (!user_interrupted && client->is_connected()) { PStatClient::main_tick(); - float total_ms = 0.0; - float now = client->get_real_time(); - float start = now; + PN_stdfloat total_ms = 0.0; + PN_stdfloat now = client->get_real_time(); + PN_stdfloat start = now; typedef pvector Wait; Wait wait; @@ -155,12 +155,12 @@ main(int argc, char *argv[]) { for (i = 0; i < (int)_collectors.size(); i++) { if (ds[i].is_level) { // Make up an amount to add/delete to the level this frame. - float increment = ds[i].max_ms * (rand() / (RAND_MAX + 1.0) - 0.5); + PN_stdfloat increment = ds[i].max_ms * (rand() / (RAND_MAX + 1.0) - 0.5); _collectors[i].add_level(increment); } else { // A bit of random jitter so the collectors might overlap some. - float jitter_ms = (5.0 * rand() / (RAND_MAX + 1.0)); + PN_stdfloat jitter_ms = (5.0 * rand() / (RAND_MAX + 1.0)); WaitRequest wr; wr._time = now + jitter_ms / 1000.0; @@ -168,8 +168,8 @@ main(int argc, char *argv[]) { wr._start = true; wait.push_back(wr); - float ms_range = ds[i].max_ms - ds[i].min_ms; - float ms = (float)ds[i].min_ms + + PN_stdfloat ms_range = ds[i].max_ms - ds[i].min_ms; + PN_stdfloat ms = (PN_stdfloat)ds[i].min_ms + (ms_range * rand() / (RAND_MAX + 1.0)); now += ms / 1000.0; total_ms += ms; diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index fefb375f2b..9abcbadd70 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -57,7 +57,6 @@ nodeCachedReferenceCount.h nodeCachedReferenceCount.I \ pbitops.I pbitops.h \ portalMask.h \ - pta_double.h \ pta_ushort.h \ pythonCallbackObject.h pythonCallbackObject.I \ simpleHashMap.I simpleHashMap.h \ @@ -67,7 +66,7 @@ typedWritable.h typedWritableReferenceCount.I \ typedWritableReferenceCount.h updateSeq.I updateSeq.h \ uniqueIdAllocator.h \ - vector_double.h vector_typedWritable.h \ + vector_typedWritable.h \ vector_ushort.h vector_writable.h \ writableConfigurable.h \ writableParam.I writableParam.h @@ -106,7 +105,6 @@ nameUniquifier.cxx \ nodeCachedReferenceCount.cxx \ pbitops.cxx \ - pta_double.cxx \ pta_ushort.cxx \ pythonCallbackObject.cxx \ simpleHashMap.cxx \ @@ -115,7 +113,6 @@ timedCycle.cxx typedWritable.cxx \ typedWritableReferenceCount.cxx updateSeq.cxx \ uniqueIdAllocator.cxx \ - vector_double.cxx \ vector_typedWritable.cxx \ vector_ushort.cxx vector_writable.cxx \ writableConfigurable.cxx writableParam.cxx @@ -168,7 +165,6 @@ nodeCachedReferenceCount.h nodeCachedReferenceCount.I \ portalMask.h \ pbitops.I pbitops.h \ - pta_double.h \ pta_ushort.h \ pythonCallbackObject.h pythonCallbackObject.I \ simpleHashMap.I simpleHashMap.h \ @@ -178,7 +174,7 @@ typedWritable.h typedWritableReferenceCount.I \ typedWritableReferenceCount.h updateSeq.I updateSeq.h \ uniqueIdAllocator.h \ - vector_double.h vector_typedWritable.h \ + vector_typedWritable.h \ vector_ushort.h vector_writable.h \ writableConfigurable.h writableParam.I \ writableParam.h diff --git a/panda/src/putil/animInterface.cxx b/panda/src/putil/animInterface.cxx index 77cf9dcb3e..515c54027a 100644 --- a/panda/src/putil/animInterface.cxx +++ b/panda/src/putil/animInterface.cxx @@ -175,16 +175,16 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void AnimInterface::CData:: write_datagram(BamWriter *, Datagram &dg) const { - dg.add_float32(_frame_rate); + dg.add_stdfloat(_frame_rate); dg.add_uint8(_play_mode); - dg.add_float32(_start_time); - dg.add_float32(_start_frame); - dg.add_float32(_play_frames); + dg.add_stdfloat(_start_time); + dg.add_stdfloat(_start_frame); + dg.add_stdfloat(_play_frames); dg.add_int32(_from_frame); dg.add_int32(_to_frame); - dg.add_float32(_play_rate); + dg.add_stdfloat(_play_rate); dg.add_bool(_paused); - dg.add_float32(_paused_f); + dg.add_stdfloat(_paused_f); } //////////////////////////////////////////////////////////////////// @@ -196,17 +196,17 @@ write_datagram(BamWriter *, Datagram &dg) const { //////////////////////////////////////////////////////////////////// void AnimInterface::CData:: fillin(DatagramIterator &scan, BamReader *) { - _frame_rate = scan.get_float32(); + _frame_rate = scan.get_stdfloat(); _play_mode = (PlayMode)scan.get_uint8(); - _start_time = scan.get_float32(); - _start_frame = scan.get_float32(); - _play_frames = scan.get_float32(); + _start_time = scan.get_stdfloat(); + _start_frame = scan.get_stdfloat(); + _play_frames = scan.get_stdfloat(); _from_frame = scan.get_int32(); _to_frame = scan.get_int32(); - _play_rate = scan.get_float32(); + _play_rate = scan.get_stdfloat(); _effective_frame_rate = _frame_rate * _play_rate; _paused = scan.get_bool(); - _paused_f = scan.get_float32(); + _paused_f = scan.get_stdfloat(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index 8cda59ce5d..45a4adb511 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -33,7 +33,7 @@ static const unsigned short _bam_major_ver = 6; // Bumped to major version 6 on 2/11/06 to factor out PandaNode::CData. static const unsigned short _bam_first_minor_ver = 14; -static const unsigned short _bam_minor_ver = 26; +static const unsigned short _bam_minor_ver = 27; // Bumped to minor version 14 on 12/19/07 to change default ColorAttrib. // Bumped to minor version 15 on 4/9/08 to add TextureAttrib::_implicit_sort. // Bumped to minor version 16 on 5/13/08 to add Texture::_quality_level. @@ -47,6 +47,7 @@ static const unsigned short _bam_minor_ver = 26; // Bumped to minor version 24 on 5/4/10 to add internal TexMatrixAttrib overrides. // Bumped to minor version 25 on 6/22/11 to add support for caching movie files. // Bumped to minor version 26 on 8/5/11 to add multiview (stereo) Textures. +// Bumped to minor version 27 on 10/9/11 to add stdfloat_double. #endif diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I index 71eb0b911d..00770e8df4 100644 --- a/panda/src/putil/bamReader.I +++ b/panda/src/putil/bamReader.I @@ -120,6 +120,22 @@ get_file_endian() const { return _file_endian; } +//////////////////////////////////////////////////////////////////// +// Function: BamReader::get_file_stdfloat_double +// Access: Published +// Description: Returns true if the file stores all "standard" +// floats as 64-bit doubles, or false if they are 32-bit +// floats. This is determined by the compilation flags +// of the version of Panda that generated this file. +// +// If this doesn't match the current version of Panda, +// the file cannot be read. +//////////////////////////////////////////////////////////////////// +INLINE bool BamReader:: +get_file_stdfloat_double() const { + return _file_stdfloat_double; +} + //////////////////////////////////////////////////////////////////// // Function: BamReader::get_current_major_ver // Access: Published diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index f170b1bebe..4d91bfc7bd 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -137,17 +137,29 @@ init() { _file_endian = (BamEndian)scan.get_uint8(); - if (bam_cat.is_debug()) { - bam_cat.debug() - << "Bam file is version " << _file_major << "." << _file_minor - << ".\n"; - if (_file_minor != _bam_minor_ver) { - bam_cat.debug() - << "(Current version is " << _bam_major_ver << "." << _bam_minor_ver - << ".)\n"; + _file_stdfloat_double = false; + if (_file_minor >= 27) { + _file_stdfloat_double = scan.get_bool(); + } + +#ifndef STDFLOAT_DOUBLE + bool need_stdfloat_double = false; +#else + bool need_stdfloat_double = true; +#endif + if (_file_stdfloat_double != need_stdfloat_double) { + if (_file_stdfloat_double) { + bam_cat.error() + << "This bam file was written with 64-bit floats.\n"; + bam_cat.error() + << "This program can only read bam files with 32-bit floats.\n"; + } else { + bam_cat.error() + << "This bam file was written with 32-bit floats.\n"; + bam_cat.error() + << "This program can only read bam files with 64-bit floats.\n"; } - bam_cat.debug() - << "Endian preference is " << _file_endian << "\n"; + return false; } return true; diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index 6b2bff07c4..30a9dd157c 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -155,6 +155,7 @@ PUBLISHED: INLINE int get_file_major_ver() const; INLINE int get_file_minor_ver() const; INLINE BamEndian get_file_endian() const; + INLINE bool get_file_stdfloat_double() const; INLINE int get_current_major_ver() const; INLINE int get_current_minor_ver() const; @@ -330,6 +331,7 @@ private: int _file_major, _file_minor; BamEndian _file_endian; + bool _file_stdfloat_double; static const int _cur_major; static const int _cur_minor; }; diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index 89152ee150..06e235825a 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -55,6 +55,20 @@ get_file_endian() const { return _file_endian; } +//////////////////////////////////////////////////////////////////// +// Function: BamWriter::get_file_stdfloat_double +// Access: Published +// Description: Returns true if the file will store all "standard" +// floats as 64-bit doubles, or false if they are 32-bit +// floats. This isn't runtime settable; it's based on +// the compilation flags of the version of Panda that +// generated this file. +//////////////////////////////////////////////////////////////////// +INLINE bool BamWriter:: +get_file_stdfloat_double() const { + return _file_stdfloat_double; +} + //////////////////////////////////////////////////////////////////// // Function: BamWriter::get_file_texture_mode // Access: Published diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index 4301b58504..32fc683709 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -45,6 +45,11 @@ BamWriter(DatagramSink *target) : _long_pta_id = false; _file_endian = bam_endian; +#ifndef STDFLOAT_DOUBLE + _file_stdfloat_double = false; +#else + _file_stdfloat_double = true; +#endif _file_texture_mode = bam_texture_mode; } @@ -120,6 +125,7 @@ init() { header.add_uint16(_bam_major_ver); header.add_uint16(_bam_minor_ver); header.add_uint8(_file_endian); + header.add_bool(_file_stdfloat_double); if (!_target->put_datagram(header)) { util_cat.error() diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index d7be292ca9..8db23684eb 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -85,6 +85,7 @@ PUBLISHED: void flush(); INLINE BamEndian get_file_endian() const; + INLINE bool get_file_stdfloat_double() const; INLINE BamTextureMode get_file_texture_mode() const; INLINE void set_file_texture_mode(BamTextureMode file_texture_mode); @@ -114,6 +115,7 @@ private: bool flush_queue(); BamEndian _file_endian; + bool _file_stdfloat_double; BamTextureMode _file_texture_mode; // This is the set of all TypeHandles already written. diff --git a/panda/src/putil/ioPtaDatagramFloat.cxx b/panda/src/putil/ioPtaDatagramFloat.cxx index eb82e816b1..856bb8d047 100644 --- a/panda/src/putil/ioPtaDatagramFloat.cxx +++ b/panda/src/putil/ioPtaDatagramFloat.cxx @@ -24,10 +24,10 @@ // Description: //////////////////////////////////////////////////////////////////// void IoPtaDatagramFloat:: -write_datagram(BamWriter *, Datagram &dest, CPTA_float array) { +write_datagram(BamWriter *, Datagram &dest, CPTA_stdfloat array) { dest.add_uint32(array.size()); for (int i = 0; i < (int)array.size(); ++i) { - dest.add_float32(array[i]); + dest.add_stdfloat(array[i]); } } @@ -36,13 +36,13 @@ write_datagram(BamWriter *, Datagram &dest, CPTA_float array) { // Access: Public, Static // Description: //////////////////////////////////////////////////////////////////// -PTA_float IoPtaDatagramFloat:: +PTA_stdfloat IoPtaDatagramFloat:: read_datagram(BamReader *, DatagramIterator &source) { - PTA_float array; + PTA_stdfloat array; int size = source.get_uint32(); for (int i = 0; i < size; ++i) { - array.push_back(source.get_float32()); + array.push_back(source.get_stdfloat()); } return array; diff --git a/panda/src/putil/ioPtaDatagramFloat.h b/panda/src/putil/ioPtaDatagramFloat.h index f09ce878b2..555f072251 100644 --- a/panda/src/putil/ioPtaDatagramFloat.h +++ b/panda/src/putil/ioPtaDatagramFloat.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "pointerToArray.h" -#include "pta_float.h" +#include "pta_stdfloat.h" class BamReader; class BamWriter; @@ -27,7 +27,7 @@ class DatagramIterator; //////////////////////////////////////////////////////////////////// // Class : IoPtaDatagramFloat -// Description : This class is used to read and write a PTA_float +// Description : This class is used to read and write a PTA_stdfloat // from a Datagram, in support of Bam. It's not // intended to be constructed; it's just a convenient // place to scope these static methods which should be @@ -35,8 +35,8 @@ class DatagramIterator; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PUTIL IoPtaDatagramFloat { public: - static void write_datagram(BamWriter *manager, Datagram &dest, CPTA_float array); - static PTA_float read_datagram(BamReader *manager, DatagramIterator &source); + static void write_datagram(BamWriter *manager, Datagram &dest, CPTA_stdfloat array); + static PTA_stdfloat read_datagram(BamReader *manager, DatagramIterator &source); }; typedef IoPtaDatagramFloat IPD_float; diff --git a/panda/src/putil/putil_composite2.cxx b/panda/src/putil/putil_composite2.cxx index a5ccc4bf79..256accfc64 100644 --- a/panda/src/putil/putil_composite2.cxx +++ b/panda/src/putil/putil_composite2.cxx @@ -13,7 +13,6 @@ #include "nameUniquifier.cxx" #include "nodeCachedReferenceCount.cxx" #include "pbitops.cxx" -#include "pta_double.cxx" #include "pta_ushort.cxx" #include "pythonCallbackObject.cxx" #include "simpleHashMap.cxx" @@ -24,7 +23,6 @@ #include "typedWritableReferenceCount.cxx" #include "updateSeq.cxx" #include "uniqueIdAllocator.cxx" -#include "vector_double.cxx" #include "vector_typedWritable.cxx" #include "vector_ushort.cxx" #include "vector_writable.cxx" diff --git a/panda/src/putil/string_utils.cxx b/panda/src/putil/string_utils.cxx index 17577828b8..d8ed734477 100644 --- a/panda/src/putil/string_utils.cxx +++ b/panda/src/putil/string_utils.cxx @@ -408,8 +408,8 @@ string_to_double(const string &str, double &result) { // otherwise. //////////////////////////////////////////////////////////////////// bool -string_to_float(const string &str, float &result) { +string_to_float(const string &str, PN_stdfloat &result) { string tail; - result = (float)string_to_double(str, tail); + result = (PN_stdfloat)string_to_double(str, tail); return tail.empty(); } diff --git a/panda/src/putil/string_utils.h b/panda/src/putil/string_utils.h index e52e51536b..d3452f54f6 100644 --- a/panda/src/putil/string_utils.h +++ b/panda/src/putil/string_utils.h @@ -58,7 +58,7 @@ EXPCL_PANDA_PUTIL int string_to_int(const string &str, string &tail); EXPCL_PANDA_PUTIL bool string_to_int(const string &str, int &result); EXPCL_PANDA_PUTIL double string_to_double(const string &str, string &tail); EXPCL_PANDA_PUTIL bool string_to_double(const string &str, double &result); -EXPCL_PANDA_PUTIL bool string_to_float(const string &str, float &result); +EXPCL_PANDA_PUTIL bool string_to_float(const string &str, PN_stdfloat &result); // Convenience function to make a string from anything that has an // ostream operator. diff --git a/panda/src/putil/timedCycle.I b/panda/src/putil/timedCycle.I index a5912239ec..4604824d1e 100644 --- a/panda/src/putil/timedCycle.I +++ b/panda/src/putil/timedCycle.I @@ -34,7 +34,7 @@ TimedCycle() : // Description: //////////////////////////////////////////////////////////////////// INLINE TimedCycle:: -TimedCycle(float cycle_time, int element_count) : +TimedCycle(PN_stdfloat cycle_time, int element_count) : _cycle_time(cycle_time), _current_child(0), _element_count(element_count) @@ -62,7 +62,7 @@ set_element_count(int element_count) // Description: Set the number of elements being cycled through //////////////////////////////////////////////////////////////////// INLINE void TimedCycle:: -set_cycle_time(float cycle_time) +set_cycle_time(PN_stdfloat cycle_time) { nassertv(cycle_time > 0); if (_next_switch == -1) diff --git a/panda/src/putil/timedCycle.cxx b/panda/src/putil/timedCycle.cxx index d9ddf54f3d..69a420337c 100644 --- a/panda/src/putil/timedCycle.cxx +++ b/panda/src/putil/timedCycle.cxx @@ -24,7 +24,7 @@ //////////////////////////////////////////////////////////////////// void TimedCycle:: write_datagram(Datagram &me) { - me.add_float32(_cycle_time); + me.add_stdfloat(_cycle_time); me.add_uint16(_element_count); } @@ -37,7 +37,7 @@ write_datagram(Datagram &me) { //////////////////////////////////////////////////////////////////// void TimedCycle:: fillin(DatagramIterator &scan) { - _cycle_time = scan.get_float32(); + _cycle_time = scan.get_stdfloat(); _element_count = scan.get_uint16(); _inv_cycle_time = 1. / _cycle_time; diff --git a/panda/src/putil/timedCycle.h b/panda/src/putil/timedCycle.h index 934d5f9ff8..41926e31a7 100644 --- a/panda/src/putil/timedCycle.h +++ b/panda/src/putil/timedCycle.h @@ -37,10 +37,10 @@ class EXPCL_PANDA_PUTIL TimedCycle { public: INLINE TimedCycle(); - INLINE TimedCycle(float cycle_time, int element_count); + INLINE TimedCycle(PN_stdfloat cycle_time, int element_count); INLINE void set_element_count(int element_count); - INLINE void set_cycle_time(float cycle_time); + INLINE void set_cycle_time(PN_stdfloat cycle_time); INLINE int next_element(); public: @@ -49,8 +49,8 @@ public: private: ClockObject* _global_clock; - float _cycle_time; - float _inv_cycle_time; + PN_stdfloat _cycle_time; + PN_stdfloat _inv_cycle_time; double _next_switch; int _current_child; int _element_count; diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index eea78f5041..35c4eb2aeb 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -222,9 +222,9 @@ free(PN_uint32 id) { // Description: return the decimal fraction of the pool that is used. // The range is 0 to 1.0 (e.g. 75% would be 0.75). //////////////////////////////////////////////////////////////////// -float UniqueIdAllocator:: +PN_stdfloat UniqueIdAllocator:: fraction_used() const { - return float(_size-_free)/_size; + return PN_stdfloat(_size-_free)/_size; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/putil/uniqueIdAllocator.h b/panda/src/putil/uniqueIdAllocator.h index 40baab7cb8..47dbf9e0af 100644 --- a/panda/src/putil/uniqueIdAllocator.h +++ b/panda/src/putil/uniqueIdAllocator.h @@ -50,7 +50,7 @@ PUBLISHED: void initial_reserve_id(PN_uint32 id); void free(PN_uint32 index); - float fraction_used() const; + PN_stdfloat fraction_used() const; void output(ostream &out) const; void write(ostream &out) const; diff --git a/panda/src/recorder/mouseRecorder.cxx b/panda/src/recorder/mouseRecorder.cxx index bb2c08266d..a71031409c 100644 --- a/panda/src/recorder/mouseRecorder.cxx +++ b/panda/src/recorder/mouseRecorder.cxx @@ -40,8 +40,8 @@ MouseRecorder(const string &name) : _live_button_events = new ButtonEventList; _save_button_events = new ButtonEventList; - _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); } //////////////////////////////////////////////////////////////////// @@ -130,8 +130,8 @@ void MouseRecorder:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { bool has_mouse = false; - LPoint2f mouse_xy; - LPoint2f mouse_pixel_xy; + LPoint2 mouse_xy; + LPoint2 mouse_pixel_xy; _live_button_events->clear(); diff --git a/panda/src/recorder/mouseRecorder.h b/panda/src/recorder/mouseRecorder.h index e7ab2bae8a..9e95405d27 100644 --- a/panda/src/recorder/mouseRecorder.h +++ b/panda/src/recorder/mouseRecorder.h @@ -66,8 +66,8 @@ private: int _button_events_output; bool _has_mouse; - LPoint2f _mouse_xy; - LPoint2f _mouse_pixel_xy; + LPoint2 _mouse_xy; + LPoint2 _mouse_pixel_xy; PT(ButtonEventList) _live_button_events; PT(ButtonEventList) _save_button_events; diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index bb640d708a..c909dc3f24 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -80,7 +80,7 @@ SpeedTreeNode(const string &name) : // we'll change this to match whatever set of trees we're holding, // though it probably doesn't really matter too much. //set_internal_bounds(new OmniBoundingVolume); - // set_internal_bounds(new BoundingSphere(LPoint3f::zero(), 10.0f)); + // set_internal_bounds(new BoundingSphere(LPoint3::zero(), 10.0f)); // Intialize the render params. First, get the shader directory. Filename shaders_dir = speedtree_shaders_dir; @@ -389,11 +389,11 @@ add_instances_from(const SpeedTreeNode *other, const TransformState *transform) //////////////////////////////////////////////////////////////////// void SpeedTreeNode:: add_random_instances(const STTree *tree, int quantity, - float x_min, float x_max, - float y_min, float y_max, - float scale_min, float scale_max, - float height_min, float height_max, - float slope_min, float slope_max, + PN_stdfloat x_min, PN_stdfloat x_max, + PN_stdfloat y_min, PN_stdfloat y_max, + PN_stdfloat scale_min, PN_stdfloat scale_max, + PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat slope_min, PN_stdfloat slope_max, Randomizer &randomizer) { InstanceList &instance_list = add_tree(tree); _needs_repopulate = true; @@ -533,14 +533,14 @@ add_from_stf(istream &in, const Filename &pathname, int num_instances; in >> num_instances; for (int ni = 0; ni < num_instances && in && !in.eof(); ++ni) { - LPoint3f pos; - float rotate, scale; + LPoint3 pos; + PN_stdfloat rotate, scale; in >> pos[0] >> pos[1] >> pos[2] >> rotate >> scale; if (!speedtree_5_2_stf) { // 5.1 or earlier stf files also included these additional // values, which we will ignore: - float height_min, height_max, slope_min, slope_max; + PN_stdfloat height_min, height_max, slope_min, slope_max; in >> height_min >> height_max >> slope_min >> slope_max; } @@ -667,7 +667,7 @@ snap_to_terrain() { if (_terrain != (STTerrain *)NULL) { for (int i = 0; i < num_instances; ++i) { STTransform trans = instance_list->get_instance(i); - LPoint3f pos = trans.get_pos(); + LPoint3 pos = trans.get_pos(); pos[2] = _terrain->get_height(pos[0], pos[1]); trans.set_pos(pos); instance_list->set_instance(i, trans); @@ -675,7 +675,7 @@ snap_to_terrain() { } else { for (int i = 0; i < num_instances; ++i) { STTransform trans = instance_list->get_instance(i); - LPoint3f pos = trans.get_pos(); + LPoint3 pos = trans.get_pos(); pos[2] = 0.0f; trans.set_pos(pos); instance_list->set_instance(i, trans); @@ -761,7 +761,7 @@ reload_config() { // Gusts are controlled internally. //////////////////////////////////////////////////////////////////// void SpeedTreeNode:: -set_wind(double strength, const LVector3f &direction) { +set_wind(double strength, const LVector3 &direction) { _forest_render.SetGlobalWindStrength(strength); _forest_render.SetGlobalWindDirection(SpeedTree::Vec3(direction[0], direction[1], direction[2])); } @@ -986,12 +986,12 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { CPT(TransformState) orig_modelview = data.get_modelview_transform(trav); CPT(TransformState) modelview = gsg->get_cs_transform()->compose(orig_modelview); CPT(TransformState) camera_transform = modelview->invert_compose(TransformState::make_identity()); - const LMatrix4f &modelview_mat = modelview->get_mat(); - const LPoint3f &camera_pos = camera_transform->get_pos(); + const LMatrix4 &modelview_mat = modelview->get_mat(); + const LPoint3 &camera_pos = camera_transform->get_pos(); const Lens *lens = trav->get_scene()->get_lens(); - LMatrix4f projection_mat = - LMatrix4f::convert_mat(gsg->get_internal_coordinate_system(), lens->get_coordinate_system()) * + LMatrix4 projection_mat = + LMatrix4::convert_mat(gsg->get_internal_coordinate_system(), lens->get_coordinate_system()) * lens->get_projection_mat(); _view.Set(SpeedTree::Vec3(camera_pos[0], camera_pos[1], camera_pos[2]), @@ -1016,10 +1016,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // directional light; we look for a directional light in the // lighting state and pass its direction and color to SpeedTree. We // also accumulate the ambient light colors. - Colorf ambient_color(0.0f, 0.0f, 0.0f, 0.0f); + LColor ambient_color(0.0f, 0.0f, 0.0f, 0.0f); DirectionalLight *dlight = NULL; NodePath dlight_np; - Colorf diffuse_color; + LColor diffuse_color; int diffuse_priority = 0; const LightAttrib *la = DCAST(LightAttrib, state->get_attrib(LightAttrib::get_class_slot())); @@ -1044,7 +1044,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (dlight != (DirectionalLight *)NULL) { CPT(TransformState) transform = dlight_np.get_transform(trav->get_scene()->get_scene_root().get_parent()); - LVector3f dir = dlight->get_direction() * transform->get_mat(); + LVector3 dir = dlight->get_direction() * transform->get_mat(); dir.normalize(); _light_dir = SpeedTree::Vec3(dir[0], dir[1], dir[2]); diffuse_color = dlight->get_color(); @@ -1068,7 +1068,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { _forest_render.SetLightDir(_light_dir); - SpeedTree::st_float32 updated_splits[SpeedTree::c_nMaxNumShadowMaps]; + SpeedTree::st_stdfloat updated_splits[SpeedTree::c_nMaxNumShadowMaps]; memset(updated_splits, 0, sizeof(updated_splits)); for (int smi = 0; smi < (int)_shadow_infos.size(); ++smi) { updated_splits[smi] = _shadow_infos[smi]._shadow_split; @@ -1185,8 +1185,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, const SpeedTree::Vec3 &emin = extents.Min(); const SpeedTree::Vec3 &emax = extents.Max(); - internal_bounds = new BoundingBox(LPoint3f(emin[0], emin[1], emin[2]), - LPoint3f(emax[0], emax[1], emax[2])); + internal_bounds = new BoundingBox(LPoint3(emin[0], emin[1], emin[2]), + LPoint3(emax[0], emax[1], emax[2])); } //////////////////////////////////////////////////////////////////// @@ -1398,7 +1398,7 @@ update_terrain_cells() { SpeedTree::TTerrainCellArray &cells = _visible_terrain.m_aCellsToUpdate; int num_tile_res = _terrain_render.GetMaxTileRes(); - float cell_size = _terrain_render.GetCellSize(); + PN_stdfloat cell_size = _terrain_render.GetCellSize(); // A temporary vertex data object for populating terrain. PT(GeomVertexData) vertex_data = diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index 12183b5e11..6c7d168c87 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -117,11 +117,11 @@ PUBLISHED: void add_instances_from(const SpeedTreeNode *other); void add_instances_from(const SpeedTreeNode *other, const TransformState *transform); void add_random_instances(const STTree *tree, int quantity, - float x_min, float x_max, - float y_min, float y_max, - float scale_min, float scale_max, - float height_min, float height_max, - float slope_min, float slope_max, + PN_stdfloat x_min, PN_stdfloat x_max, + PN_stdfloat y_min, PN_stdfloat y_max, + PN_stdfloat scale_min, PN_stdfloat scale_max, + PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat slope_min, PN_stdfloat slope_max, Randomizer &randomizer = Randomizer()); bool add_from_stf(const Filename &stf_filename, @@ -140,7 +140,7 @@ PUBLISHED: void reload_config(); - void set_wind(double strength, const LVector3f &direction); + void set_wind(double strength, const LVector3 &direction); INLINE void set_time_delta(double delta); INLINE double get_time_delta() const; @@ -250,7 +250,7 @@ private: SpeedTree::CView _light_view; SpeedTree::SForestCullResultsRender _light_cull; - float _shadow_split; + PN_stdfloat _shadow_split; }; typedef pvector ShadowInfos; ShadowInfos _shadow_infos; diff --git a/panda/src/speedtree/stBasicTerrain.I b/panda/src/speedtree/stBasicTerrain.I index 10576a04b8..f256689e32 100644 --- a/panda/src/speedtree/stBasicTerrain.I +++ b/panda/src/speedtree/stBasicTerrain.I @@ -46,7 +46,7 @@ get_height_map() const { // Increasing this number spreads the heightmap out over // a greater area. //////////////////////////////////////////////////////////////////// -INLINE float STBasicTerrain:: +INLINE PN_stdfloat STBasicTerrain:: get_size() const { return _size; } @@ -57,8 +57,8 @@ get_size() const { // Description: Convenience function to calculate the linear // interpolation from A to B. //////////////////////////////////////////////////////////////////// -INLINE float STBasicTerrain:: -interpolate(float a, float b, float t) { +INLINE PN_stdfloat STBasicTerrain:: +interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t) { return (a + (b - a) * t); } @@ -95,7 +95,7 @@ reset(int width, int height) { //////////////////////////////////////////////////////////////////// template ValueType STBasicTerrain::InterpolationData:: -get_nearest_neighbor(float u, float v) const { +get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v) const { int u = int(u * _width + 0.5f); int v = int(v * _height + 0.5f); int index = u + v * _width; @@ -111,22 +111,22 @@ get_nearest_neighbor(float u, float v) const { //////////////////////////////////////////////////////////////////// template ValueType STBasicTerrain::InterpolationData:: -calc_bilinear_interpolation(float u, float v) const { +calc_bilinear_interpolation(PN_stdfloat u, PN_stdfloat v) const { u -= cfloor(u); v -= cfloor(v); - u *= (float)_width; - v *= (float)_height; + u *= (PN_stdfloat)_width; + v *= (PN_stdfloat)_height; const int lower_x = int(u); const int lower_y = int(v); const int higher_x = (lower_x + 1) % _width; const int higher_y = (lower_y + 1) % _height; - const float ratio_x = u - float(lower_x); - const float ratio_y = v - float(lower_y); - const float inv_ratio_x = 1.0f - ratio_x; - const float inv_ratio_y = 1.0f - ratio_y; + const PN_stdfloat ratio_x = u - PN_stdfloat(lower_x); + const PN_stdfloat ratio_y = v - PN_stdfloat(lower_y); + const PN_stdfloat inv_ratio_x = 1.0f - ratio_x; + const PN_stdfloat inv_ratio_y = 1.0f - ratio_y; nassertr(lower_x + lower_y * _width >= 0 && higher_x + higher_y * _width < (int)_data.size(), 0); @@ -147,14 +147,14 @@ calc_bilinear_interpolation(float u, float v) const { //////////////////////////////////////////////////////////////////// template ValueType STBasicTerrain::InterpolationData:: -calc_smooth(float u, float v, float radius) const { +calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius) const { ValueType retval = 0; if (radius <= 0.0f) { retval = calc_bilinear_interpolation(u, v); } else { - const float test_points[9][2] = { + const PN_stdfloat test_points[9][2] = { { 0.0f * radius, 0.0f * radius }, { 0.8f * radius, 0.0f * radius }, { -0.8f * radius, 0.0f * radius }, @@ -166,10 +166,10 @@ calc_smooth(float u, float v, float radius) const { { -0.25f * radius, -0.25f * radius } }; - float total_weight = 0.0f; + PN_stdfloat total_weight = 0.0f; for (int i = 0; i < 9; ++i) { - const float *test_point = test_points[i]; - float weight = (1.0f - sqrt((test_point[0] * test_point[0]) + (test_point[1] * test_point[1]))); + const PN_stdfloat *test_point = test_points[i]; + PN_stdfloat weight = (1.0f - sqrt((test_point[0] * test_point[0]) + (test_point[1] * test_point[1]))); total_weight += weight; retval += weight * calc_bilinear_interpolation(u + test_point[0], v + test_point[1]); } diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index bf483e62f9..d9b2374acc 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -88,9 +88,9 @@ clear() { CPT(GeomVertexFormat) format = GeomVertexFormat::register_format (new GeomVertexArrayFormat(InternalName::get_vertex(), 3, - GeomEnums::NT_float32, GeomEnums::C_point, + GeomEnums::NT_stdfloat, GeomEnums::C_point, InternalName::get_texcoord(), 3, - GeomEnums::NT_float32, GeomEnums::C_texcoord)); + GeomEnums::NT_stdfloat, GeomEnums::C_texcoord)); set_vertex_format(format); } @@ -161,7 +161,7 @@ setup_terrain(istream &in, const Filename &pathname) { if (keyword == "area") { // "area" defines the size of the terrain in square kilometers. // We apply speedtree_area_scale to convert that to local units. - float area; + PN_stdfloat area; in >> area; _size = csqrt(area) * speedtree_area_scale; @@ -169,7 +169,7 @@ setup_terrain(istream &in, const Filename &pathname) { in >> _height_scale; } else if (keyword == "normalmap_b_scale") { - float normalmap_b_scale; + PN_stdfloat normalmap_b_scale; in >> normalmap_b_scale; } else if (keyword == "heightmap") { @@ -184,18 +184,18 @@ setup_terrain(istream &in, const Filename &pathname) { } else if (keyword == "color") { // color means the overall color of the previous texture. - float r, g, b; + PN_stdfloat r, g, b; in >> r >> g >> b; if (!_splat_layers.empty()) { _splat_layers.back()._color.set(r, g, b, 1.0f); } } else if (keyword == "ambient" || keyword == "diffuse" || keyword == "specular" || keyword == "emissive") { - float r, g, b; + PN_stdfloat r, g, b; in >> r >> g >> b; } else if (keyword == "shininess") { - float s; + PN_stdfloat s; in >> s; } else { @@ -268,8 +268,8 @@ load_data() { // terrain, where x and y are unbounded and may refer to // any 2-d point in space. //////////////////////////////////////////////////////////////////// -float STBasicTerrain:: -get_height(float x, float y) const { +PN_stdfloat STBasicTerrain:: +get_height(PN_stdfloat x, PN_stdfloat y) const { return _height_data.calc_bilinear_interpolation(x / _size, y / _size); } @@ -281,8 +281,8 @@ get_height(float x, float y) const { // the specified radius, centered at point (x, y) of the // terrain. //////////////////////////////////////////////////////////////////// -float STBasicTerrain:: -get_smooth_height(float x, float y, float radius) const { +PN_stdfloat STBasicTerrain:: +get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const { return _height_data.calc_smooth(x / _size, y / _size, radius / _size); } @@ -295,8 +295,8 @@ get_smooth_height(float x, float y, float radius) const { // is used for determining the legal points to place // trees and grass. //////////////////////////////////////////////////////////////////// -float STBasicTerrain:: -get_slope(float x, float y) const { +PN_stdfloat STBasicTerrain:: +get_slope(PN_stdfloat x, PN_stdfloat y) const { return _slope_data.calc_bilinear_interpolation(x / _size, y / _size); } @@ -319,25 +319,25 @@ get_slope(float x, float y) const { //////////////////////////////////////////////////////////////////// void STBasicTerrain:: fill_vertices(GeomVertexData *data, - float start_x, float start_y, - float size_xy, int num_xy) const { + PN_stdfloat start_x, PN_stdfloat start_y, + PN_stdfloat size_xy, int num_xy) const { nassertv(data->get_format() == _vertex_format); GeomVertexWriter vertex(data, InternalName::get_vertex()); GeomVertexWriter texcoord(data, InternalName::get_texcoord()); - float vertex_scale = 1.0 / (float)(num_xy - 1); - float texcoord_scale = 1.0 / _size; + PN_stdfloat vertex_scale = 1.0 / (PN_stdfloat)(num_xy - 1); + PN_stdfloat texcoord_scale = 1.0 / _size; for (int xi = 0; xi < num_xy; ++xi) { - float xt = xi * vertex_scale; - float x = start_x + xt * size_xy; + PN_stdfloat xt = xi * vertex_scale; + PN_stdfloat x = start_x + xt * size_xy; for (int yi = 0; yi < num_xy; ++yi) { - float yt = yi * vertex_scale; - float y = start_y + yt * size_xy; + PN_stdfloat yt = yi * vertex_scale; + PN_stdfloat y = start_y + yt * size_xy; - float z = get_height(x, y); + PN_stdfloat z = get_height(x, y); - vertex.set_data3f(x, y, z); - texcoord.set_data3f(x * texcoord_scale, -y * texcoord_scale, 1.0f); + vertex.set_data3(x, y, z); + texcoord.set_data3(x * texcoord_scale, -y * texcoord_scale, 1.0f); } } } @@ -381,12 +381,12 @@ read_height_map() { _min_height = FLT_MAX; _max_height = FLT_MIN; - float scalar = _size * _height_scale / image.get_num_channels(); + PN_stdfloat scalar = _size * _height_scale / image.get_num_channels(); int pi = 0; for (int yi = image.get_y_size() - 1; yi >= 0; --yi) { for (int xi = 0; xi < image.get_x_size(); ++xi) { Colord rgba = image.get_xel_a(xi, yi); - float v = rgba[0] + rgba[1] + rgba[2] + rgba[3]; + PN_stdfloat v = rgba[0] + rgba[1] + rgba[2] + rgba[3]; v *= scalar; _height_data._data[pi] = v; ++pi; @@ -407,15 +407,15 @@ read_height_map() { // corresponding values for _slope_data. //////////////////////////////////////////////////////////////////// void STBasicTerrain:: -compute_slope(float smoothing) { +compute_slope(PN_stdfloat smoothing) { nassertv(!_height_data._data.empty()); int width = _height_data._width; int height = _height_data._height; _slope_data.reset(width, height); - float u_spacing = _size / (float)width; - float v_spacing = _size / (float)height; + PN_stdfloat u_spacing = _size / (PN_stdfloat)width; + PN_stdfloat v_spacing = _size / (PN_stdfloat)height; for (int i = 0; i < width; ++i) { int left = (i + width - 1) % width; @@ -425,8 +425,8 @@ compute_slope(float smoothing) { int top = (j + height - 1) % height; int bottom = (j + 1) % height; - float slope = 0.0f; - float this_height = _height_data._data[i + j * width]; + PN_stdfloat slope = 0.0f; + PN_stdfloat this_height = _height_data._data[i + j * width]; slope += catan2(cabs(this_height - _height_data._data[right + j * width]), u_spacing); slope += catan2(cabs(this_height - _height_data._data[left + j * width]), u_spacing); slope += catan2(cabs(this_height - _height_data._data[i + top * width]), v_spacing); @@ -443,12 +443,12 @@ compute_slope(float smoothing) { if (smoothing > 0.0f) { // Create a temporary array for smoothing data. - InterpolationData smoothing_data; + InterpolationData smoothing_data; smoothing_data.reset(width, height); - float *smoothed = &smoothing_data._data[0]; + PN_stdfloat *smoothed = &smoothing_data._data[0]; int steps = int(smoothing); - float last_interpolation = smoothing - steps; + PN_stdfloat last_interpolation = smoothing - steps; ++steps; for (int si = 0; si < steps; ++si) { diff --git a/panda/src/speedtree/stBasicTerrain.h b/panda/src/speedtree/stBasicTerrain.h index e07ac55e16..529282bbbd 100644 --- a/panda/src/speedtree/stBasicTerrain.h +++ b/panda/src/speedtree/stBasicTerrain.h @@ -43,23 +43,23 @@ PUBLISHED: virtual void load_data(); - INLINE float get_size() const; - virtual float get_height(float x, float y) const; - virtual float get_smooth_height(float x, float y, float radius) const; - virtual float get_slope(float x, float y) const; + INLINE PN_stdfloat get_size() const; + virtual PN_stdfloat get_height(PN_stdfloat x, PN_stdfloat y) const; + virtual PN_stdfloat get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const; + virtual PN_stdfloat get_slope(PN_stdfloat x, PN_stdfloat y) const; virtual void fill_vertices(GeomVertexData *data, - float start_x, float start_y, - float size_xy, int num_xy) const; + PN_stdfloat start_x, PN_stdfloat start_y, + PN_stdfloat size_xy, int num_xy) const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; protected: bool read_height_map(); - void compute_slope(float smoothing); + void compute_slope(PN_stdfloat smoothing); - INLINE float interpolate(float a, float b, float t); + INLINE PN_stdfloat interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t); private: static void read_quoted_filename(Filename &result, istream &in, @@ -72,9 +72,9 @@ protected: InterpolationData(); void reset(int width, int height); - ValueType get_nearest_neighbor(float u, float v) const; - ValueType calc_bilinear_interpolation(float u, float v) const; - ValueType calc_smooth(float u, float v, float radius) const; + ValueType get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v) const; + ValueType calc_bilinear_interpolation(PN_stdfloat u, PN_stdfloat v) const; + ValueType calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius) const; bool is_present() const; int _width; @@ -84,12 +84,12 @@ protected: protected: Filename _height_map; - float _size; - float _height_scale; + PN_stdfloat _size; + PN_stdfloat _height_scale; - InterpolationData _height_data; - //InterpolationData _normal_data; - InterpolationData _slope_data; + InterpolationData _height_data; + //InterpolationData _normal_data; + InterpolationData _slope_data; //InterpolationData _ao_data; public: diff --git a/panda/src/speedtree/stTerrain.I b/panda/src/speedtree/stTerrain.I index 1879c03848..0b47765903 100644 --- a/panda/src/speedtree/stTerrain.I +++ b/panda/src/speedtree/stTerrain.I @@ -81,7 +81,7 @@ get_splat_layer(int n) const { // This is an arbitrary UV scale that is applied to each // layer individually, by the terrain shader. //////////////////////////////////////////////////////////////////// -INLINE float STTerrain:: +INLINE PN_stdfloat STTerrain:: get_splat_layer_tiling(int n) const { nassertr(n >= 0 && n < (int)_splat_layers.size(), 0.0f); return _splat_layers[n]._tiling; @@ -94,7 +94,7 @@ get_splat_layer_tiling(int n) const { // is used just to match the color of the grass to its // terrain. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &STTerrain:: +INLINE const LVecBase4 &STTerrain:: get_splat_layer_color(int n) const { nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._color); return _splat_layers[n]._color; @@ -120,7 +120,7 @@ get_vertex_format() { // returned by get_height(). This is used as a culling // optimization. //////////////////////////////////////////////////////////////////// -INLINE float STTerrain:: +INLINE PN_stdfloat STTerrain:: get_min_height() const { return _min_height; } @@ -132,7 +132,7 @@ get_min_height() const { // returned by get_height(). This is used as a culling // optimization. //////////////////////////////////////////////////////////////////// -INLINE float STTerrain:: +INLINE PN_stdfloat STTerrain:: get_max_height() const { return _max_height; } diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index 2e6ce6777b..b3d3a2d526 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -97,8 +97,8 @@ load_data() { // terrain, where x and y are unbounded and may refer to // any 2-d point in space. //////////////////////////////////////////////////////////////////// -float STTerrain:: -get_height(float x, float y) const { +PN_stdfloat STTerrain:: +get_height(PN_stdfloat x, PN_stdfloat y) const { return 0.0f; } @@ -110,8 +110,8 @@ get_height(float x, float y) const { // the specified radius, centered at point (x, y) of the // terrain. //////////////////////////////////////////////////////////////////// -float STTerrain:: -get_smooth_height(float x, float y, float radius) const { +PN_stdfloat STTerrain:: +get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const { return get_height(x, y); } @@ -124,8 +124,8 @@ get_smooth_height(float x, float y, float radius) const { // is used for determining the legal points to place // trees and grass. //////////////////////////////////////////////////////////////////// -float STTerrain:: -get_slope(float x, float y) const { +PN_stdfloat STTerrain:: +get_slope(PN_stdfloat x, PN_stdfloat y) const { return 0.0f; } @@ -136,15 +136,15 @@ get_slope(float x, float y) const { // y) fall within the requested limits, false otherwise. //////////////////////////////////////////////////////////////////// bool STTerrain:: -placement_is_acceptable(float x, float y, - float height_min, float height_max, - float slope_min, float slope_max) { - float height = get_height(x, y); +placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, + PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat slope_min, PN_stdfloat slope_max) { + PN_stdfloat height = get_height(x, y); if (height < height_min || height > height_max) { return false; } - float slope = get_slope(x, y); + PN_stdfloat slope = get_slope(x, y); if (slope < slope_min || slope > slope_max) { return false; } @@ -171,8 +171,8 @@ placement_is_acceptable(float x, float y, //////////////////////////////////////////////////////////////////// void STTerrain:: fill_vertices(GeomVertexData *data, - float start_x, float start_y, - float size_xy, int num_xy) const { + PN_stdfloat start_x, PN_stdfloat start_y, + PN_stdfloat size_xy, int num_xy) const { } //////////////////////////////////////////////////////////////////// @@ -285,7 +285,7 @@ bool STTerrain:: convert_vertex_column(SpeedTree::SVertexAttribDesc &st_attrib, const GeomVertexColumn *column) { switch (column->get_numeric_type()) { - case GeomEnums::NT_float32: + case GeomEnums::NT_stdfloat: st_attrib.m_eDataType = SpeedTree::VERTEX_ATTRIB_TYPE_FLOAT; break; diff --git a/panda/src/speedtree/stTerrain.h b/panda/src/speedtree/stTerrain.h index d002451797..080cc31f31 100644 --- a/panda/src/speedtree/stTerrain.h +++ b/panda/src/speedtree/stTerrain.h @@ -53,25 +53,25 @@ PUBLISHED: INLINE int get_num_splat_layers() const; INLINE const Filename &get_splat_layer(int n) const; - INLINE float get_splat_layer_tiling(int n) const; - INLINE const LVecBase4f &get_splat_layer_color(int n) const; + INLINE PN_stdfloat get_splat_layer_tiling(int n) const; + INLINE const LVecBase4 &get_splat_layer_color(int n) const; INLINE const GeomVertexFormat *get_vertex_format(); - INLINE float get_min_height() const; - INLINE float get_max_height() const; + INLINE PN_stdfloat get_min_height() const; + INLINE PN_stdfloat get_max_height() const; - virtual float get_height(float x, float y) const=0; - virtual float get_smooth_height(float x, float y, float radius) const; - virtual float get_slope(float x, float y) const; + virtual PN_stdfloat get_height(PN_stdfloat x, PN_stdfloat y) const=0; + virtual PN_stdfloat get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const; + virtual PN_stdfloat get_slope(PN_stdfloat x, PN_stdfloat y) const; - bool placement_is_acceptable(float x, float y, - float height_min, float height_max, - float slope_min, float slope_max); + bool placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, + PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat slope_min, PN_stdfloat slope_max); virtual void fill_vertices(GeomVertexData *data, - float start_x, float start_y, - float size_xy, int num_xy) const; + PN_stdfloat start_x, PN_stdfloat start_y, + PN_stdfloat size_xy, int num_xy) const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; @@ -92,8 +92,8 @@ protected: class SplatLayer { public: Filename _filename; - float _tiling; - LVecBase4f _color; + PN_stdfloat _tiling; + LVecBase4 _color; }; typedef pvector SplatLayers; @@ -107,8 +107,8 @@ protected: CPT(GeomVertexFormat) _vertex_format; VertexAttribs _st_vertex_attribs; - float _min_height; - float _max_height; + PN_stdfloat _min_height; + PN_stdfloat _max_height; public: static TypeHandle get_class_type() { diff --git a/panda/src/speedtree/stTransform.I b/panda/src/speedtree/stTransform.I index c421982e65..8289720ec1 100644 --- a/panda/src/speedtree/stTransform.I +++ b/panda/src/speedtree/stTransform.I @@ -32,7 +32,7 @@ STTransform() : // Description: Construct a transform with componentwise inputs. //////////////////////////////////////////////////////////////////// INLINE STTransform:: -STTransform(const LPoint3f &pos, float rotate, float scale) : +STTransform(const LPoint3 &pos, PN_stdfloat rotate, PN_stdfloat scale) : _pos(pos), _rotate(rotate), _scale(scale) @@ -45,7 +45,7 @@ STTransform(const LPoint3f &pos, float rotate, float scale) : // Description: Construct a transform with componentwise inputs. //////////////////////////////////////////////////////////////////// INLINE STTransform:: -STTransform(float x, float y, float z, float rotate, float scale) : +STTransform(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat rotate, PN_stdfloat scale) : _pos(x, y, z), _rotate(rotate), _scale(scale) @@ -115,8 +115,8 @@ operator SpeedTree::CInstance () const { INLINE STTransform:: operator CPT(TransformState) () const { return TransformState::make_pos_hpr_scale(_pos, - LVecBase3f(_rotate, 0.0f, 0.0f), - LVecBase3f(_scale, _scale, _scale)); + LVecBase3(_rotate, 0.0f, 0.0f), + LVecBase3(_scale, _scale, _scale)); } //////////////////////////////////////////////////////////////////// @@ -135,7 +135,7 @@ ident_mat() { // Description: Replaces the translation component. //////////////////////////////////////////////////////////////////// INLINE void STTransform:: -set_pos(const LPoint3f &pos) { +set_pos(const LPoint3 &pos) { _pos = pos; } @@ -144,7 +144,7 @@ set_pos(const LPoint3f &pos) { // Access: Published // Description: Returns the translation component. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &STTransform:: +INLINE const LPoint3 &STTransform:: get_pos() const { return _pos; } @@ -157,7 +157,7 @@ get_pos() const { // axis. //////////////////////////////////////////////////////////////////// INLINE void STTransform:: -set_rotate(float rotate) { +set_rotate(PN_stdfloat rotate) { _rotate = rotate; } @@ -167,7 +167,7 @@ set_rotate(float rotate) { // Description: Returns the rotation component, in degrees // counter-clockwise around the vertical axis. //////////////////////////////////////////////////////////////////// -INLINE float STTransform:: +INLINE PN_stdfloat STTransform:: get_rotate() const { return _rotate; } @@ -179,7 +179,7 @@ get_rotate() const { // scale value. //////////////////////////////////////////////////////////////////// INLINE void STTransform:: -set_scale(float scale) { +set_scale(PN_stdfloat scale) { _scale = scale; } @@ -189,7 +189,7 @@ set_scale(float scale) { // Description: Returns the scale component, as a uniform scale // value. //////////////////////////////////////////////////////////////////// -INLINE float STTransform:: +INLINE PN_stdfloat STTransform:: get_scale() const { return _scale; } @@ -202,8 +202,8 @@ get_scale() const { //////////////////////////////////////////////////////////////////// INLINE void STTransform:: operator *= (const STTransform &other) { - LQuaternionf quat; - quat.set_hpr(LVecBase3f(_rotate, 0.0f, 0.0f)); + LQuaternion quat; + quat.set_hpr(LVecBase3(_rotate, 0.0f, 0.0f)); _pos += quat.xform(other.get_pos()) * _scale; _rotate += other._rotate; _scale *= other._scale; diff --git a/panda/src/speedtree/stTransform.cxx b/panda/src/speedtree/stTransform.cxx index 56464a8e33..a6bcf5a535 100644 --- a/panda/src/speedtree/stTransform.cxx +++ b/panda/src/speedtree/stTransform.cxx @@ -35,7 +35,7 @@ STTransform(const TransformState *trans) { nassertv(trans->has_components()); _pos = trans->get_pos(); - const LVecBase3f &hpr = trans->get_hpr(); + const LVecBase3 &hpr = trans->get_hpr(); nassertv(IS_NEARLY_ZERO(hpr[1]) && IS_NEARLY_ZERO(hpr[2])); _rotate = hpr[0]; @@ -62,8 +62,8 @@ output(ostream &out) const { void STTransform:: write_datagram(BamWriter *manager, Datagram &dg) { _pos.write_datagram(dg); - dg.add_float32(_rotate); - dg.add_float32(_scale); + dg.add_stdfloat(_rotate); + dg.add_stdfloat(_scale); } //////////////////////////////////////////////////////////////////// @@ -76,6 +76,6 @@ write_datagram(BamWriter *manager, Datagram &dg) { void STTransform:: fillin(DatagramIterator &scan, BamReader *manager) { _pos.read_datagram(scan); - _rotate = scan.get_float32(); - _scale = scan.get_float32(); + _rotate = scan.get_stdfloat(); + _scale = scan.get_stdfloat(); } diff --git a/panda/src/speedtree/stTransform.h b/panda/src/speedtree/stTransform.h index 91404c95c5..aa6954fd5e 100644 --- a/panda/src/speedtree/stTransform.h +++ b/panda/src/speedtree/stTransform.h @@ -30,8 +30,8 @@ class EXPCL_PANDASPEEDTREE STTransform { PUBLISHED: INLINE STTransform(); STTransform(const TransformState *trans); - INLINE STTransform(const LPoint3f &pos, float rotate = 0.0f, float scale = 1.0f); - INLINE STTransform(float x, float y, float z, float rotate, float scale); + INLINE STTransform(const LPoint3 &pos, PN_stdfloat rotate = 0.0f, PN_stdfloat scale = 1.0f); + INLINE STTransform(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat rotate, PN_stdfloat scale); INLINE STTransform(const STTransform ©); INLINE void operator = (const STTransform ©); @@ -43,12 +43,12 @@ public: PUBLISHED: INLINE static const STTransform &ident_mat(); - INLINE void set_pos(const LPoint3f &pos); - INLINE const LPoint3f &get_pos() const; - INLINE void set_rotate(float rotate); - INLINE float get_rotate() const; - INLINE void set_scale(float scale); - INLINE float get_scale() const; + INLINE void set_pos(const LPoint3 &pos); + INLINE const LPoint3 &get_pos() const; + INLINE void set_rotate(PN_stdfloat rotate); + INLINE PN_stdfloat get_rotate() const; + INLINE void set_scale(PN_stdfloat scale); + INLINE PN_stdfloat get_scale() const; INLINE void operator *= (const STTransform &other); INLINE STTransform operator * (const STTransform &other) const; @@ -60,9 +60,9 @@ public: void fillin(DatagramIterator &scan, BamReader *manager); public: - LPoint3f _pos; - float _rotate; - float _scale; + LPoint3 _pos; + PN_stdfloat _rotate; + PN_stdfloat _scale; static STTransform _ident_mat; }; diff --git a/panda/src/testbed/Sources.pp b/panda/src/testbed/Sources.pp index 72a8673b27..5fd2c27e4d 100644 --- a/panda/src/testbed/Sources.pp +++ b/panda/src/testbed/Sources.pp @@ -5,7 +5,7 @@ #define LOCAL_LIBS \ framework putil collide pgraph chan text \ - pnmimage pnmimagetypes pnmtext event effects gobj display \ + pnmimage pnmimagetypes pnmtext event gobj display \ mathutil putil express dgraph device tform \ linmath pstatclient panda diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index e49123666d..a85cc1662f 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -20,7 +20,7 @@ #include "pvector.h" #include "panda_getopt.h" -#define RANDFRAC (rand()/(float)(RAND_MAX)) +#define RANDFRAC (rand()/(PN_stdfloat)(RAND_MAX)) class GriddedFilename { public: @@ -32,20 +32,20 @@ typedef pvector GriddedFilenames; typedef struct { // for rot moving - float xcenter,ycenter; - float xoffset,yoffset; - float ang1,ang1_vel; - float ang2,ang2_vel; + PN_stdfloat xcenter,ycenter; + PN_stdfloat xoffset,yoffset; + PN_stdfloat ang1,ang1_vel; + PN_stdfloat ang2,ang2_vel; - float radius; + PN_stdfloat radius; // for moving - float xstart,ystart; - float xend,yend; - float xdel,ydel,timedel; + PN_stdfloat xstart,ystart; + PN_stdfloat xend,yend; + PN_stdfloat xdel,ydel,timedel; double starttime,endtime; double vel; - LMatrix4f rotmat; + LMatrix4 rotmat; PandaNode *node; } gridded_file_info; @@ -59,8 +59,8 @@ static int gridwidth; // cells/side #define MIN_WANDERAREA_DIMENSION 120.0f -static float grid_pos_offset; // origin of grid -static float wander_area_pos_offset; +static PN_stdfloat grid_pos_offset; // origin of grid +static PN_stdfloat wander_area_pos_offset; static GriddedMotionType gridmotiontype = None; @@ -71,13 +71,13 @@ move_gridded_stuff(GriddedMotionType gridmotiontype, gridded_file_info *InfoArr, int size) { double now = ClockObject::get_global_clock()->get_frame_time(); - LMatrix4f tmat1,tmat2,xfm_mat; + LMatrix4 tmat1,tmat2,xfm_mat; for(int i = 0; i < size; i++) { double time_delta = (now-InfoArr[i].starttime); #define DO_FP_MODULUS(VAL,MAXVAL) \ - {if(VAL > MAXVAL) {int idivresult = (int)(VAL / (float)MAXVAL); VAL=VAL-idivresult*MAXVAL;} else \ - if(VAL < -MAXVAL) {int idivresult = (int)(VAL / (float)MAXVAL); VAL=VAL+idivresult*MAXVAL;}} + {if(VAL > MAXVAL) {int idivresult = (int)(VAL / (PN_stdfloat)MAXVAL); VAL=VAL-idivresult*MAXVAL;} else \ + if(VAL < -MAXVAL) {int idivresult = (int)(VAL / (PN_stdfloat)MAXVAL); VAL=VAL+idivresult*MAXVAL;}} // probably should use panda lerps for this stuff, but I don't understand how @@ -89,21 +89,21 @@ move_gridded_stuff(GriddedMotionType gridmotiontype, DO_FP_MODULUS(InfoArr[i].ang2,360.0); // xforms happen left to right - LVector2f new_center = LVector2f(InfoArr[i].radius,0.0) * - LMatrix3f::rotate_mat(InfoArr[i].ang1); + LVector2 new_center = LVector2(InfoArr[i].radius,0.0) * + LMatrix3::rotate_mat(InfoArr[i].ang1); - LVector3f translate_vec(InfoArr[i].xcenter+new_center._v.v._0, + LVector3 translate_vec(InfoArr[i].xcenter+new_center._v.v._0, InfoArr[i].ycenter+new_center._v.v._1, 0.0); - const LVector3f rotation_axis(0.0, 0.0, 1.0); + const LVector3 rotation_axis(0.0, 0.0, 1.0); - tmat1 = LMatrix4f::rotate_mat_normaxis(InfoArr[i].ang2,rotation_axis); - tmat2 = LMatrix4f::translate_mat(translate_vec); + tmat1 = LMatrix4::rotate_mat_normaxis(InfoArr[i].ang2,rotation_axis); + tmat2 = LMatrix4::translate_mat(translate_vec); xfm_mat = tmat1 * tmat2; } else { - float xpos,ypos; + PN_stdfloat xpos,ypos; if(now>InfoArr[i].endtime) { InfoArr[i].starttime = now; @@ -114,26 +114,26 @@ move_gridded_stuff(GriddedMotionType gridmotiontype, InfoArr[i].xend = RANDFRAC*fabs(2.0*wander_area_pos_offset) + wander_area_pos_offset; InfoArr[i].yend = RANDFRAC*fabs(2.0*wander_area_pos_offset) + wander_area_pos_offset; - float xdel = InfoArr[i].xdel = InfoArr[i].xend-InfoArr[i].xstart; - float ydel = InfoArr[i].ydel = InfoArr[i].yend-InfoArr[i].ystart; + PN_stdfloat xdel = InfoArr[i].xdel = InfoArr[i].xend-InfoArr[i].xstart; + PN_stdfloat ydel = InfoArr[i].ydel = InfoArr[i].yend-InfoArr[i].ystart; InfoArr[i].endtime = now + csqrt(xdel*xdel+ydel*ydel)/InfoArr[i].vel; InfoArr[i].timedel = InfoArr[i].endtime - InfoArr[i].starttime; - const LVector3f rotate_axis(0.0, 0.0, 1.0); + const LVector3 rotate_axis(0.0, 0.0, 1.0); - float ang = rad_2_deg(atan2(-xdel,ydel)); + PN_stdfloat ang = rad_2_deg(atan2(-xdel,ydel)); - InfoArr[i].rotmat= LMatrix4f::rotate_mat_normaxis(ang,rotate_axis); + InfoArr[i].rotmat= LMatrix4::rotate_mat_normaxis(ang,rotate_axis); } else { - float timefrac= time_delta/InfoArr[i].timedel; + PN_stdfloat timefrac= time_delta/InfoArr[i].timedel; xpos = InfoArr[i].xdel*timefrac+InfoArr[i].xstart; ypos = InfoArr[i].ydel*timefrac+InfoArr[i].ystart; } - LVector3f translate_vec(xpos, ypos, 0.0); - LMatrix4f tmat2 = LMatrix4f::translate_mat(translate_vec); + LVector3 translate_vec(xpos, ypos, 0.0); + LMatrix4 tmat2 = LMatrix4::translate_mat(translate_vec); xfm_mat = InfoArr[i].rotmat * tmat2; } @@ -243,13 +243,13 @@ load_gridded_models(WindowFramework *window, } grid_pos_offset = -gridwidth*GRIDCELLSIZE/2.0; - wander_area_pos_offset = -max((float)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); + wander_area_pos_offset = -max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); // Now walk through the list again, copying models into the scene // graph as we go. - float xpos = grid_pos_offset; - float ypos = grid_pos_offset; + PN_stdfloat xpos = grid_pos_offset; + PN_stdfloat ypos = grid_pos_offset; srand( (unsigned)time( NULL ) ); double now = ClockObject::get_global_clock()->get_frame_time(); @@ -282,7 +282,7 @@ load_gridded_models(WindowFramework *window, gridded_file_info info; info.node = model.node(); - LMatrix4f xfm_mat,tmat1,tmat2; + LMatrix4 xfm_mat,tmat1,tmat2; if(gridmotiontype==Rotation) { @@ -316,17 +316,17 @@ load_gridded_models(WindowFramework *window, } // xforms happen left to right - LVector2f new_center = LVector2f(info.radius,0.0) * - LMatrix3f::rotate_mat(info.ang1); + LVector2 new_center = LVector2(info.radius,0.0) * + LMatrix3::rotate_mat(info.ang1); - const LVector3f rotate_axis(0.0, 0.0, 1.0); + const LVector3 rotate_axis(0.0, 0.0, 1.0); - LVector3f translate_vec(xpos+new_center._v.v._0, + LVector3 translate_vec(xpos+new_center._v.v._0, ypos+new_center._v.v._1, 0.0); tmat1.set_rotate_mat_normaxis(info.ang2,rotate_axis); - tmat2 = LMatrix4f::translate_mat(translate_vec); + tmat2 = LMatrix4::translate_mat(translate_vec); xfm_mat = tmat1 * tmat2; } else if(gridmotiontype==LinearMotion) { @@ -343,25 +343,25 @@ load_gridded_models(WindowFramework *window, info.starttime = now; - float xdel = info.xdel = info.xend-info.xstart; - float ydel = info.ydel = info.yend-info.ystart; + PN_stdfloat xdel = info.xdel = info.xend-info.xstart; + PN_stdfloat ydel = info.ydel = info.yend-info.ystart; info.endtime = csqrt(xdel*xdel+ydel*ydel)/info.vel; info.timedel = info.endtime - info.starttime; - const LVector3f rotate_axis(0.0, 0.0, 1.0); - float ang = rad_2_deg(atan2(-xdel,ydel)); + const LVector3 rotate_axis(0.0, 0.0, 1.0); + PN_stdfloat ang = rad_2_deg(atan2(-xdel,ydel)); info.rotmat.set_rotate_mat_normaxis(ang,rotate_axis); - LVector3f translate_vec(xpos, ypos, 0.0); - LMatrix4f tmat2 = LMatrix4f::translate_mat(translate_vec); + LVector3 translate_vec(xpos, ypos, 0.0); + LMatrix4 tmat2 = LMatrix4::translate_mat(translate_vec); xfm_mat = info.rotmat * tmat2; } else { - LVector3f translate_vec(xpos, ypos, 0.0); - xfm_mat = LMatrix4f::translate_mat(translate_vec); + LVector3 translate_vec(xpos, ypos, 0.0); + xfm_mat = LMatrix4::translate_mat(translate_vec); } info.node->set_transform(TransformState::make_mat(xfm_mat)); diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 16b20c75e0..52548cc2e8 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -152,7 +152,7 @@ event_0(const Event *event, void *) { // Make the clear color on the buffer be yellow, so it's obviously // different from the main scene's background color. - buffer->set_clear_color(Colorf(1, 1, 0, 0)); + buffer->set_clear_color(LColor(1, 1, 0, 0)); // Apply the offscreen buffer's texture to a card in the main // window. @@ -304,7 +304,7 @@ main(int argc, char *argv[]) { loading_np.set_scale(0.125f); loading->set_text_color(1.0f, 1.0f, 1.0f, 1.0f); loading->set_shadow_color(0.0f, 0.0f, 0.0f, 1.0f); - loading->set_shadow(0.04f, 0.04f); + loading->set_shadow(0.04, 0.04); loading->set_align(TextNode::A_center); loading->set_text("Loading..."); diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index cb69b34b98..63ce9138a6 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -57,22 +57,22 @@ event_T(const Event *, void *data) { white_center.fill(1.0f, 1.0f, 1.0f); for (int yi = 0; yi < num_quads_side; yi++) { - float y0 = (float)yi / (float)num_quads_side; - float y1 = (float)(yi + 1) / (float)num_quads_side; + PN_stdfloat y0 = (PN_stdfloat)yi / (PN_stdfloat)num_quads_side; + PN_stdfloat y1 = (PN_stdfloat)(yi + 1) / (PN_stdfloat)num_quads_side; // Map the x, y vertices onto a sphere just for fun. - float px0 = ccos((y0 - 0.5f) * MathNumbers::pi_f); - float px1 = ccos((y1 - 0.5f) * MathNumbers::pi_f); - float py0 = csin((y0 - 0.5f) * MathNumbers::pi_f); - float py1 = csin((y1 - 0.5f) * MathNumbers::pi_f); + PN_stdfloat px0 = ccos((y0 - 0.5f) * MathNumbers::pi_f); + PN_stdfloat px1 = ccos((y1 - 0.5f) * MathNumbers::pi_f); + PN_stdfloat py0 = csin((y0 - 0.5f) * MathNumbers::pi_f); + PN_stdfloat py1 = csin((y1 - 0.5f) * MathNumbers::pi_f); for (int xi = 0; xi < num_quads_side; xi++) { - float x0 = (float)xi / (float)num_quads_side; - float x1 = (float)(xi + 1) / (float)num_quads_side; + PN_stdfloat x0 = (PN_stdfloat)xi / (PN_stdfloat)num_quads_side; + PN_stdfloat x1 = (PN_stdfloat)(xi + 1) / (PN_stdfloat)num_quads_side; - float hx0 = ccos(x0 * MathNumbers::pi_f * 2.0f); - float hx1 = ccos(x1 * MathNumbers::pi_f * 2.0f); - float hy0 = csin(x0 * MathNumbers::pi_f * 2.0f); - float hy1 = csin(x1 * MathNumbers::pi_f * 2.0f); + PN_stdfloat hx0 = ccos(x0 * MathNumbers::pi_f * 2.0f); + PN_stdfloat hx1 = ccos(x1 * MathNumbers::pi_f * 2.0f); + PN_stdfloat hy0 = csin(x0 * MathNumbers::pi_f * 2.0f); + PN_stdfloat hy1 = csin(x1 * MathNumbers::pi_f * 2.0f); PNMImage bogus_image(tex_x_size, tex_y_size); bogus_image.fill(x0, (xi + yi) & 1, y0); diff --git a/panda/src/text/dynamicTextFont.I b/panda/src/text/dynamicTextFont.I index c94a457ba6..74bc828cf1 100644 --- a/panda/src/text/dynamicTextFont.I +++ b/panda/src/text/dynamicTextFont.I @@ -37,7 +37,7 @@ get_name() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool DynamicTextFont:: -set_point_size(float point_size) { +set_point_size(PN_stdfloat point_size) { // If this assertion fails, you didn't call clear() first. RTFM. nassertr(get_num_pages() == 0, false); @@ -49,7 +49,7 @@ set_point_size(float point_size) { // Access: Published // Description: Returns the point size of the font. //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_point_size() const { return FreetypeFont::get_point_size(); } @@ -70,7 +70,7 @@ get_point_size() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool DynamicTextFont:: -set_pixels_per_unit(float pixels_per_unit) { +set_pixels_per_unit(PN_stdfloat pixels_per_unit) { // If this assertion fails, you didn't call clear() first. RTFM. nassertr(get_num_pages() == 0, false); @@ -83,7 +83,7 @@ set_pixels_per_unit(float pixels_per_unit) { // Description: Returns the resolution of the texture map. See // set_pixels_per_unit(). //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_pixels_per_unit() const { return FreetypeFont::get_pixels_per_unit(); } @@ -106,7 +106,7 @@ get_pixels_per_unit() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE bool DynamicTextFont:: -set_scale_factor(float scale_factor) { +set_scale_factor(PN_stdfloat scale_factor) { // If this assertion fails, you didn't call clear() first. RTFM. nassertr(get_num_pages() == 0, false); @@ -119,7 +119,7 @@ set_scale_factor(float scale_factor) { // Description: Returns the antialiasing scale factor. See // set_scale_factor(). //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_scale_factor() const { return FreetypeFont::get_scale_factor(); } @@ -182,7 +182,7 @@ get_font_pixel_size() const { // Description: Returns the number of units high each line of text // is. //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_line_height() const { return TextFont::get_line_height(); } @@ -192,7 +192,7 @@ get_line_height() const { // Access: Published // Description: Returns the number of units wide a space is. //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_space_advance() const { return TextFont::get_space_advance(); } @@ -236,7 +236,7 @@ get_texture_margin() const { // texture). //////////////////////////////////////////////////////////////////// INLINE void DynamicTextFont:: -set_poly_margin(float poly_margin) { +set_poly_margin(PN_stdfloat poly_margin) { _poly_margin = poly_margin; } @@ -247,7 +247,7 @@ set_poly_margin(float poly_margin) { // included around each glyph in the generated polygons. // See set_poly_margin(). //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_poly_margin() const { return _poly_margin; } @@ -421,7 +421,7 @@ get_winding_order() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE void DynamicTextFont:: -set_fg(const Colorf &fg) { +set_fg(const LColor &fg) { // If this assertion fails, you didn't call clear() first. RTFM. nassertv(get_num_pages() == 0); @@ -436,7 +436,7 @@ set_fg(const Colorf &fg) { // font as they are rendered into the font texture. // See set_fg(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &DynamicTextFont:: +INLINE const LColor &DynamicTextFont:: get_fg() const { return _fg; } @@ -462,7 +462,7 @@ get_fg() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE void DynamicTextFont:: -set_bg(const Colorf &bg) { +set_bg(const LColor &bg) { // If this assertion fails, you didn't call clear() first. RTFM. nassertv(get_num_pages() == 0); @@ -477,7 +477,7 @@ set_bg(const Colorf &bg) { // font as they are rendered into the font texture. // See set_bg(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &DynamicTextFont:: +INLINE const LColor &DynamicTextFont:: get_bg() const { return _bg; } @@ -505,8 +505,8 @@ get_bg() const { // calling clear(). //////////////////////////////////////////////////////////////////// INLINE void DynamicTextFont:: -set_outline(const Colorf &outline_color, float outline_width, - float outline_feather) { +set_outline(const LColor &outline_color, PN_stdfloat outline_width, + PN_stdfloat outline_feather) { // If this assertion fails, you didn't call clear() first. RTFM. nassertv(get_num_pages() == 0); @@ -523,7 +523,7 @@ set_outline(const Colorf &outline_color, float outline_width, // font as they are rendered into the font texture. // See set_outline(). //////////////////////////////////////////////////////////////////// -INLINE const Colorf &DynamicTextFont:: +INLINE const LColor &DynamicTextFont:: get_outline_color() const { return _outline_color; } @@ -535,7 +535,7 @@ get_outline_color() const { // font, as the number of points beyond each letter. // See set_outline(). //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_outline_width() const { return _outline_width; } @@ -547,7 +547,7 @@ get_outline_width() const { // font, as a value in the range 0.0 to 1.0. // See set_outline(). //////////////////////////////////////////////////////////////////// -INLINE float DynamicTextFont:: +INLINE PN_stdfloat DynamicTextFont:: get_outline_feather() const { return _outline_feather; } @@ -570,7 +570,7 @@ get_tex_format() const { // Description: //////////////////////////////////////////////////////////////////// INLINE DynamicTextFont::ContourPoint:: -ContourPoint(const LPoint2f &p, const LVector2f &in, const LVector2f &out) : +ContourPoint(const LPoint2 &p, const LVector2 &in, const LVector2 &out) : _p(p), _in(in), _out(out) { } @@ -581,7 +581,7 @@ ContourPoint(const LPoint2f &p, const LVector2f &in, const LVector2f &out) : // Description: //////////////////////////////////////////////////////////////////// INLINE DynamicTextFont::ContourPoint:: -ContourPoint(float px, float py, float tx, float ty) : +ContourPoint(PN_stdfloat px, PN_stdfloat py, PN_stdfloat tx, PN_stdfloat ty) : _p(px, py), _in(tx, ty), _out(tx, ty) { } @@ -596,11 +596,11 @@ ContourPoint(float px, float py, float tx, float ty) : // together. //////////////////////////////////////////////////////////////////// INLINE void DynamicTextFont::ContourPoint:: -connect_to(const LVector2f &out) { +connect_to(const LVector2 &out) { _out = out; if (_in.dot(_out) > 0.7071) { // Less than 45 degrees of difference: smooth them. - LVector2f av = (_in + _out) * 0.5f; + LVector2 av = (_in + _out) * 0.5f; av.normalize(); _in = av; _out = av; diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 9794868535..6fb954e450 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -420,8 +420,8 @@ determine_tex_format() { _tex_format = Texture::F_alpha; if (!_has_outline && - _fg == Colorf(1.0f, 1.0f, 1.0f, 1.0f) && - _bg == Colorf(1.0f, 1.0f, 1.0f, 0.0f)) { + _fg == LColor(1.0f, 1.0f, 1.0f, 1.0f) && + _bg == LColor(1.0f, 1.0f, 1.0f, 0.0f)) { // This is the standard font color. It can be copied directly // without any need for special processing. _needs_image_processing = false; @@ -460,7 +460,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { return NULL; } - float advance = slot->advance.x / 64.0; + PN_stdfloat advance = slot->advance.x / 64.0; if (_render_mode != RM_texture && slot->format == ft_glyph_format_outline) { @@ -560,8 +560,8 @@ make_glyph(int character, FT_Face face, int glyph_index) { } else { DynamicTextGlyph *glyph; - float tex_x_size = bitmap.width; - float tex_y_size = bitmap.rows; + PN_stdfloat tex_x_size = bitmap.width; + PN_stdfloat tex_y_size = bitmap.rows; int outline = 0; @@ -591,7 +591,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { reduced.quick_filter_from(image); // convert the outline width from points to tex_pixels. - float outline_pixels = _outline_width / _points_per_unit * _tex_pixels_per_unit; + PN_stdfloat outline_pixels = _outline_width / _points_per_unit * _tex_pixels_per_unit; outline = (int)ceil(outline_pixels); int_x_size += outline * 2; @@ -711,18 +711,18 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { if (_has_outline) { // Gaussian blur the glyph to generate an outline. PNMImage outline(image.get_x_size(), image.get_y_size(), PNMImage::CT_grayscale); - float outline_pixels = _outline_width / _points_per_unit * _tex_pixels_per_unit; + PN_stdfloat outline_pixels = _outline_width / _points_per_unit * _tex_pixels_per_unit; outline.gaussian_filter_from(outline_pixels * 0.707, image); // Filter the resulting outline to make a harder edge. Square // _outline_feather first to make the range more visually linear // (this approximately compensates for the Gaussian falloff of // the feathered edge). - float f = _outline_feather * _outline_feather; + PN_stdfloat f = _outline_feather * _outline_feather; for (int yi = 0; yi < outline.get_y_size(); yi++) { for (int xi = 0; xi < outline.get_x_size(); xi++) { - float v = outline.get_gray(xi, yi); + PN_stdfloat v = outline.get_gray(xi, yi); if (v == 0.0f) { // Do nothing. } else if (v >= f) { @@ -756,8 +756,8 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { //////////////////////////////////////////////////////////////////// void DynamicTextFont:: blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, - const Colorf &fg) { - Colorf fgv = fg * 255.0f; + const LColor &fg) { + LColor fgv = fg * 255.0f; int num_components = glyph->_page->get_num_components(); if (num_components == 1) { @@ -772,7 +772,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, nassertv(texture_row != (unsigned char *)NULL); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi; - float t = (float)image.get_gray(xi, yi); + PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); tr[0] = (unsigned char)(tr[0] + t * (fgv[ci] - tr[0])); } } @@ -785,7 +785,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, nassertv(texture_row != (unsigned char *)NULL); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 2; - float t = (float)image.get_gray(xi, yi); + PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); tr[0] = (unsigned char)(tr[0] + t * (fgv[0] - tr[0])); tr[1] = (unsigned char)(tr[1] + t * (fgv[3] - tr[1])); } @@ -799,7 +799,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, nassertv(texture_row != (unsigned char *)NULL); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 3; - float t = (float)image.get_gray(xi, yi); + PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); tr[0] = (unsigned char)(tr[0] + t * (fgv[2] - tr[0])); tr[1] = (unsigned char)(tr[1] + t * (fgv[1] - tr[1])); tr[2] = (unsigned char)(tr[2] + t * (fgv[0] - tr[2])); @@ -814,7 +814,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, nassertv(texture_row != (unsigned char *)NULL); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 4; - float t = (float)image.get_gray(xi, yi); + PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); tr[0] = (unsigned char)(tr[0] + t * (fgv[2] - tr[0])); tr[1] = (unsigned char)(tr[1] + t * (fgv[1] - tr[1])); tr[2] = (unsigned char)(tr[2] + t * (fgv[0] - tr[2])); @@ -906,8 +906,8 @@ render_wireframe_contours(DynamicTextGlyph *glyph) { Points::const_iterator pi; for (pi = contour._points.begin(); pi != contour._points.end(); ++pi) { - const LPoint2f &p = (*pi)._p; - vertex.add_data3f(p[0], 0.0f, p[1]); + const LPoint2 &p = (*pi)._p; + vertex.add_data3(p[0], 0.0f, p[1]); } lines->add_next_vertices(contour._points.size()); @@ -946,9 +946,9 @@ render_polygon_contours(DynamicTextGlyph *glyph, bool face, bool extrude) { t.clear_polygon(); contour._start_vertex = t.get_num_vertices(); for (size_t i = 0; i < contour._points.size() - 1; ++i) { - const LPoint2f &p = contour._points[i]._p; - vertex.add_data3f(p[0], 0.0f, p[1]); - normal.add_data3f(0.0f, -1.0f, 0.0f); + const LPoint2 &p = contour._points[i]._p; + vertex.add_data3(p[0], 0.0f, p[1]); + normal.add_data3(0.0f, -1.0f, 0.0f); int vi = t.add_vertex(p[0], p[1]); t.add_polygon_vertex(vi); } @@ -1001,15 +1001,15 @@ render_polygon_contours(DynamicTextGlyph *glyph, bool face, bool extrude) { for (size_t i = 0; i < contour._points.size(); ++i) { const ContourPoint &cp = contour._points[i]; - const LPoint2f &p = cp._p; - const LVector2f &t_in = cp._in; - const LVector2f &t_out = cp._out; + const LPoint2 &p = cp._p; + const LVector2 &t_in = cp._in; + const LVector2 &t_out = cp._out; - LVector3f n_in(t_in[1], 0.0f, -t_in[0]); - vertex.add_data3f(p[0], 1.0f, p[1]); - vertex.add_data3f(p[0], 0.0f, p[1]); - normal.add_data3f(n_in); - normal.add_data3f(n_in); + LVector3 n_in(t_in[1], 0.0f, -t_in[0]); + vertex.add_data3(p[0], 1.0f, p[1]); + vertex.add_data3(p[0], 0.0f, p[1]); + normal.add_data3(n_in); + normal.add_data3(n_in); if (i != 0) { int vi = vertex.get_write_row(); @@ -1026,11 +1026,11 @@ render_polygon_contours(DynamicTextGlyph *glyph, bool face, bool extrude) { if (i != contour._points.size() - 1 && !t_in.almost_equal(t_out)) { // If the out tangent is different from the in tangent, we // need to store new vertices for the next quad. - LVector3f n_out(t_out[1], 0.0f, -t_out[0]); - vertex.add_data3f(p[0], 1.0f, p[1]); - vertex.add_data3f(p[0], 0.0f, p[1]); - normal.add_data3f(n_out); - normal.add_data3f(n_out); + LVector3 n_out(t_out[1], 0.0f, -t_out[0]); + vertex.add_data3(p[0], 1.0f, p[1]); + vertex.add_data3(p[0], 0.0f, p[1]); + normal.add_data3(n_out); + normal.add_data3(n_out); } } } @@ -1042,9 +1042,9 @@ render_polygon_contours(DynamicTextGlyph *glyph, bool face, bool extrude) { for (ci = _contours.begin(); ci != _contours.end(); ++ci) { Contour &contour = (*ci); for (size_t i = 0; i < contour._points.size() - 1; ++i) { - const LPoint2f &p = contour._points[i]._p; - vertex.add_data3f(p[0], 1.0f, p[1]); - normal.add_data3f(0.0f, 1.0f, 0.0f); + const LPoint2 &p = contour._points[i]._p; + vertex.add_data3(p[0], 1.0f, p[1]); + normal.add_data3(0.0f, 1.0f, 0.0f); } } @@ -1100,8 +1100,8 @@ outline_move_to(const FT_Vector *to, void *user) { DynamicTextFont *self = (DynamicTextFont *)user; // Convert from 26.6 pixel units to Panda units. - float scale = 1.0f / (64.0f * self->_font_pixels_per_unit); - LPoint2f p = LPoint2f(to->x, to->y) * scale; + PN_stdfloat scale = 1.0f / (64.0f * self->_font_pixels_per_unit); + LPoint2 p = LPoint2(to->x, to->y) * scale; if (self->_contours.empty() || !self->_contours.back()._points.empty()) { @@ -1123,20 +1123,20 @@ outline_line_to(const FT_Vector *to, void *user) { nassertr(!self->_contours.empty(), 1); // Convert from 26.6 pixel units to Panda units. - float scale = 1.0f / (64.0f * self->_font_pixels_per_unit); - LPoint2f p = LPoint2f(to->x, to->y) * scale; + PN_stdfloat scale = 1.0f / (64.0f * self->_font_pixels_per_unit); + LPoint2 p = LPoint2(to->x, to->y) * scale; // Compute the tangent: this is just the vector from the last point. - LVector2f t = (p - self->_q); + LVector2 t = (p - self->_q); t.normalize(); if (self->_contours.back()._points.empty()) { - self->_contours.back()._points.push_back(ContourPoint(self->_q, LVector2f::zero(), t)); + self->_contours.back()._points.push_back(ContourPoint(self->_q, LVector2::zero(), t)); } else { self->_contours.back()._points.back().connect_to(t); } - self->_contours.back()._points.push_back(ContourPoint(p, t, LVector2f::zero())); + self->_contours.back()._points.push_back(ContourPoint(p, t, LVector2::zero())); self->_q = p; return 0; } @@ -1154,19 +1154,19 @@ outline_conic_to(const FT_Vector *control, nassertr(!self->_contours.empty(), 1); // Convert from 26.6 pixel units to Panda units. - float scale = 1.0f / (64.0f * self->_font_pixels_per_unit); + PN_stdfloat scale = 1.0f / (64.0f * self->_font_pixels_per_unit); - LPoint2f c = LPoint2f(control->x, control->y) * scale; - LPoint2f p = LPoint2f(to->x, to->y) * scale; + LPoint2 c = LPoint2(control->x, control->y) * scale; + LPoint2 p = LPoint2(to->x, to->y) * scale; // The NurbsCurveEvaluator will evaluate the Bezier segment for us. NurbsCurveEvaluator nce; nce.local_object(); nce.set_order(3); nce.reset(3); - nce.set_vertex(0, LVecBase3f(self->_q[0], self->_q[1], 0.0f)); - nce.set_vertex(1, LVecBase3f(c[0], c[1], 0.0f)); - nce.set_vertex(2, LVecBase3f(p[0], p[1], 0.0f)); + nce.set_vertex(0, LVecBase3(self->_q[0], self->_q[1], 0.0f)); + nce.set_vertex(1, LVecBase3(c[0], c[1], 0.0f)); + nce.set_vertex(2, LVecBase3(p[0], p[1], 0.0f)); self->_q = p; @@ -1187,21 +1187,21 @@ outline_cubic_to(const FT_Vector *control1, const FT_Vector *control2, nassertr(!self->_contours.empty(), 1); // Convert from 26.6 pixel units to Panda units. - float scale = 1.0f / (64.0f * self->_font_pixels_per_unit); + PN_stdfloat scale = 1.0f / (64.0f * self->_font_pixels_per_unit); - LPoint2f c1 = LPoint2f(control1->x, control1->y) * scale; - LPoint2f c2 = LPoint2f(control2->x, control2->y) * scale; - LPoint2f p = LPoint2f(to->x, to->y) * scale; + LPoint2 c1 = LPoint2(control1->x, control1->y) * scale; + LPoint2 c2 = LPoint2(control2->x, control2->y) * scale; + LPoint2 p = LPoint2(to->x, to->y) * scale; // The NurbsCurveEvaluator will evaluate the Bezier segment for us. NurbsCurveEvaluator nce; nce.local_object(); nce.set_order(4); nce.reset(4); - nce.set_vertex(0, LVecBase3f(self->_q[0], self->_q[1], 0.0f)); - nce.set_vertex(1, LVecBase3f(c1[0], c1[1], 0.0f)); - nce.set_vertex(2, LVecBase3f(c2[0], c2[1], 0.0f)); - nce.set_vertex(3, LVecBase3f(p[0], p[1], 0.0f)); + nce.set_vertex(0, LVecBase3(self->_q[0], self->_q[1], 0.0f)); + nce.set_vertex(1, LVecBase3(c1[0], c1[1], 0.0f)); + nce.set_vertex(2, LVecBase3(c2[0], c2[1], 0.0f)); + nce.set_vertex(3, LVecBase3(p[0], p[1], 0.0f)); self->_q = p; @@ -1234,10 +1234,10 @@ outline_nurbs(NurbsCurveResult *ncr) { } for (int i = start; i < num_samples; ++i) { - float st = ncr->get_sample_t(i); - const LPoint3f &p = ncr->get_sample_point(i); + PN_stdfloat st = ncr->get_sample_t(i); + const LPoint3 &p = ncr->get_sample_point(i); - float st0 = st, st1 = st; + PN_stdfloat st0 = st, st1 = st; if (i > 0) { st0 = ncr->get_sample_t(i - 1) * 0.1f + st * 0.9f; } @@ -1247,14 +1247,14 @@ outline_nurbs(NurbsCurveResult *ncr) { // Compute the tangent by deltaing nearby points. Don't evaluate // the tangent from the NURBS, since that doesn't appear to be // reliable. - LPoint3f p0, p1; + LPoint3 p0, p1; ncr->eval_point(st0, p0); ncr->eval_point(st1, p1); - LVector3f t = p1 - p0; + LVector3 t = p1 - p0; t.normalize(); if (needs_connect) { - _contours.back()._points.back().connect_to(LVector2f(t[0], t[1])); + _contours.back()._points.back().connect_to(LVector2(t[0], t[1])); needs_connect = false; } diff --git a/panda/src/text/dynamicTextFont.h b/panda/src/text/dynamicTextFont.h index 06e3373676..f379960b08 100644 --- a/panda/src/text/dynamicTextFont.h +++ b/panda/src/text/dynamicTextFont.h @@ -51,27 +51,27 @@ PUBLISHED: INLINE const string &get_name() const; - INLINE bool set_point_size(float point_size); - INLINE float get_point_size() const; + INLINE bool set_point_size(PN_stdfloat point_size); + INLINE PN_stdfloat get_point_size() const; - INLINE bool set_pixels_per_unit(float pixels_per_unit); - INLINE float get_pixels_per_unit() const; + INLINE bool set_pixels_per_unit(PN_stdfloat pixels_per_unit); + INLINE PN_stdfloat get_pixels_per_unit() const; - INLINE bool set_scale_factor(float scale_factor); - INLINE float get_scale_factor() const; + INLINE bool set_scale_factor(PN_stdfloat scale_factor); + INLINE PN_stdfloat get_scale_factor() const; INLINE void set_native_antialias(bool native_antialias); INLINE bool get_native_antialias() const; INLINE int get_font_pixel_size() const; - INLINE float get_line_height() const; - INLINE float get_space_advance() const; + INLINE PN_stdfloat get_line_height() const; + INLINE PN_stdfloat get_space_advance() const; INLINE void set_texture_margin(int texture_margin); INLINE int get_texture_margin() const; - INLINE void set_poly_margin(float poly_margin); - INLINE float get_poly_margin() const; + INLINE void set_poly_margin(PN_stdfloat poly_margin); + INLINE PN_stdfloat get_poly_margin() const; INLINE void set_page_size(int x_size, int y_size); INLINE int get_page_x_size() const; @@ -89,15 +89,15 @@ PUBLISHED: INLINE void set_winding_order(WindingOrder winding_order); INLINE WindingOrder get_winding_order() const; - INLINE void set_fg(const Colorf &fg); - INLINE const Colorf &get_fg() const; - INLINE void set_bg(const Colorf &bg); - INLINE const Colorf &get_bg() const; - INLINE void set_outline(const Colorf &outline_color, float outline_width, - float outline_feather); - INLINE const Colorf &get_outline_color() const; - INLINE float get_outline_width() const; - INLINE float get_outline_feather() const; + INLINE void set_fg(const LColor &fg); + INLINE const LColor &get_fg() const; + INLINE void set_bg(const LColor &bg); + INLINE const LColor &get_bg() const; + INLINE void set_outline(const LColor &outline_color, PN_stdfloat outline_width, + PN_stdfloat outline_feather); + INLINE const LColor &get_outline_color() const; + INLINE PN_stdfloat get_outline_width() const; + INLINE PN_stdfloat get_outline_feather() const; INLINE Texture::Format get_tex_format() const; int get_num_pages() const; @@ -120,7 +120,7 @@ private: void copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph); void copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph); void blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, - const Colorf &fg); + const LColor &fg); DynamicTextGlyph *slot_glyph(int character, int x_size, int y_size); void render_wireframe_contours(DynamicTextGlyph *glyph); @@ -136,7 +136,7 @@ private: int outline_nurbs(NurbsCurveResult *ncr); int _texture_margin; - float _poly_margin; + PN_stdfloat _poly_margin; int _page_x_size, _page_y_size; Texture::FilterType _minfilter; @@ -146,9 +146,9 @@ private: RenderMode _render_mode; WindingOrder _winding_order; - Colorf _fg, _bg, _outline_color; - float _outline_width; - float _outline_feather; + LColor _fg, _bg, _outline_color; + PN_stdfloat _outline_width; + PN_stdfloat _outline_feather; bool _has_outline; Texture::Format _tex_format; bool _needs_image_processing; @@ -171,12 +171,12 @@ private: class ContourPoint { public: - INLINE ContourPoint(const LPoint2f &p, const LVector2f &in, - const LVector2f &out); - INLINE ContourPoint(float px, float py, float tx, float ty); - INLINE void connect_to(const LVector2f &out); - LPoint2f _p; - LVector2f _in, _out; // tangents into and out of the vertex. + INLINE ContourPoint(const LPoint2 &p, const LVector2 &in, + const LVector2 &out); + INLINE ContourPoint(PN_stdfloat px, PN_stdfloat py, PN_stdfloat tx, PN_stdfloat ty); + INLINE void connect_to(const LVector2 &out); + LPoint2 _p; + LVector2 _in, _out; // tangents into and out of the vertex. }; typedef pvector Points; @@ -189,7 +189,7 @@ private: typedef pvector Contours; Contours _contours; - LPoint2f _q; // The "current point". + LPoint2 _q; // The "current point". public: static TypeHandle get_class_type() { diff --git a/panda/src/text/dynamicTextGlyph.I b/panda/src/text/dynamicTextGlyph.I index 4048e3b02c..c6bc155f67 100644 --- a/panda/src/text/dynamicTextGlyph.I +++ b/panda/src/text/dynamicTextGlyph.I @@ -39,7 +39,7 @@ DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, // and no Geom. //////////////////////////////////////////////////////////////////// INLINE DynamicTextGlyph:: -DynamicTextGlyph(int character, float advance) : +DynamicTextGlyph(int character, PN_stdfloat advance) : TextGlyph(character), _page((DynamicTextPage *)NULL), _x(0), _y(0), diff --git a/panda/src/text/dynamicTextGlyph.cxx b/panda/src/text/dynamicTextGlyph.cxx index eda3d931b1..dd1c1f02e9 100644 --- a/panda/src/text/dynamicTextGlyph.cxx +++ b/panda/src/text/dynamicTextGlyph.cxx @@ -95,9 +95,9 @@ erase(DynamicTextFont *font) { // the pen should be advanced after drawing this glyph. //////////////////////////////////////////////////////////////////// void DynamicTextGlyph:: -make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin, - float tex_x_size, float tex_y_size, - float font_pixels_per_unit, float tex_pixels_per_unit) { +make_geom(int bitmap_top, int bitmap_left, PN_stdfloat advance, PN_stdfloat poly_margin, + PN_stdfloat tex_x_size, PN_stdfloat tex_y_size, + PN_stdfloat font_pixels_per_unit, PN_stdfloat tex_pixels_per_unit) { nassertv(_page != (DynamicTextPage *)NULL); // This function should not be called twice. @@ -107,21 +107,21 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin, tex_y_size += _margin * 2; // Determine the corners of the rectangle in geometric units. - float tex_poly_margin = poly_margin / tex_pixels_per_unit; - float origin_y = bitmap_top / font_pixels_per_unit; - float origin_x = bitmap_left / font_pixels_per_unit; - float top = origin_y + tex_poly_margin; - float left = origin_x - tex_poly_margin; - float bottom = origin_y - tex_y_size / tex_pixels_per_unit - tex_poly_margin; - float right = origin_x + tex_x_size / tex_pixels_per_unit + tex_poly_margin; + PN_stdfloat tex_poly_margin = poly_margin / tex_pixels_per_unit; + PN_stdfloat origin_y = bitmap_top / font_pixels_per_unit; + PN_stdfloat origin_x = bitmap_left / font_pixels_per_unit; + PN_stdfloat top = origin_y + tex_poly_margin; + PN_stdfloat left = origin_x - tex_poly_margin; + PN_stdfloat bottom = origin_y - tex_y_size / tex_pixels_per_unit - tex_poly_margin; + PN_stdfloat right = origin_x + tex_x_size / tex_pixels_per_unit + tex_poly_margin; // And the corresponding corners in UV units. We add 0.5f to center // the UV in the middle of its texel, to minimize roundoff errors // when we are close to 1-to-1 pixel size. - float uv_top = 1.0f - ((float)(_y - poly_margin) + 0.5f) / _page->get_y_size(); - float uv_left = ((float)(_x - poly_margin) + 0.5f) / _page->get_x_size(); - float uv_bottom = 1.0f - ((float)(_y + poly_margin + tex_y_size) + 0.5f) / _page->get_y_size(); - float uv_right = ((float)(_x + poly_margin + tex_x_size) + 0.5f) / _page->get_x_size(); + PN_stdfloat uv_top = 1.0f - ((PN_stdfloat)(_y - poly_margin) + 0.5f) / _page->get_y_size(); + PN_stdfloat uv_left = ((PN_stdfloat)(_x - poly_margin) + 0.5f) / _page->get_x_size(); + PN_stdfloat uv_bottom = 1.0f - ((PN_stdfloat)(_y + poly_margin + tex_y_size) + 0.5f) / _page->get_y_size(); + PN_stdfloat uv_right = ((PN_stdfloat)(_x + poly_margin + tex_x_size) + 0.5f) / _page->get_x_size(); // Create a corresponding triangle pair. We use a pair of indexed // triangles rather than a single triangle strip, to avoid the bad // vertex duplication behavior with lots of two-triangle strips. @@ -131,15 +131,15 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin, GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - vertex.add_data3f(left, 0, top); - vertex.add_data3f(left, 0, bottom); - vertex.add_data3f(right, 0, top); - vertex.add_data3f(right, 0, bottom); + vertex.add_data3(left, 0, top); + vertex.add_data3(left, 0, bottom); + vertex.add_data3(right, 0, top); + vertex.add_data3(right, 0, bottom); - texcoord.add_data2f(uv_left, uv_top); - texcoord.add_data2f(uv_left, uv_bottom); - texcoord.add_data2f(uv_right, uv_top); - texcoord.add_data2f(uv_right, uv_bottom); + texcoord.add_data2(uv_left, uv_top); + texcoord.add_data2(uv_left, uv_bottom); + texcoord.add_data2(uv_right, uv_top); + texcoord.add_data2(uv_right, uv_bottom); PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); tris->add_vertex(0); @@ -162,7 +162,7 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin, _state = RenderState::make(TextureAttrib::make(_page), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); - _state = _state->add_attrib(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), -1); + _state = _state->add_attrib(ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 1.0f)), -1); _advance = advance / font_pixels_per_unit; } diff --git a/panda/src/text/dynamicTextGlyph.h b/panda/src/text/dynamicTextGlyph.h index 5470b7143e..46e57c45e5 100644 --- a/panda/src/text/dynamicTextGlyph.h +++ b/panda/src/text/dynamicTextGlyph.h @@ -36,7 +36,7 @@ public: INLINE DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, int x_size, int y_size, int margin); - INLINE DynamicTextGlyph(int character, float advance); + INLINE DynamicTextGlyph(int character, PN_stdfloat advance); private: INLINE DynamicTextGlyph(const DynamicTextGlyph ©); INLINE void operator = (const DynamicTextGlyph ©); @@ -47,9 +47,9 @@ public: INLINE bool intersects(int x, int y, int x_size, int y_size) const; unsigned char *get_row(int y); void erase(DynamicTextFont *font); - void make_geom(int top, int left, float advance, float poly_margin, - float tex_x_size, float tex_y_size, - float font_pixels_per_unit, float tex_pixels_per_unit); + void make_geom(int top, int left, PN_stdfloat advance, PN_stdfloat poly_margin, + PN_stdfloat tex_x_size, PN_stdfloat tex_y_size, + PN_stdfloat font_pixels_per_unit, PN_stdfloat tex_pixels_per_unit); void set_geom(GeomVertexData *vdata, GeomPrimitive *prim, const RenderState *state); virtual bool is_whitespace() const; diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index 8d724adfcb..7d3b5764bb 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -95,7 +95,7 @@ slot_glyph(int character, int x_size, int y_size, int margin) { // indicated color. //////////////////////////////////////////////////////////////////// void DynamicTextPage:: -fill_region(int x, int y, int x_size, int y_size, const Colorf &color) { +fill_region(int x, int y, int x_size, int y_size, const LColor &color) { nassertv(x >= 0 && x + x_size <= _x_size && y >= 0 && y + y_size <= _y_size); int num_components = get_num_components(); if (num_components == 1) { diff --git a/panda/src/text/dynamicTextPage.h b/panda/src/text/dynamicTextPage.h index efa89b537c..780e65cb5e 100644 --- a/panda/src/text/dynamicTextPage.h +++ b/panda/src/text/dynamicTextPage.h @@ -43,7 +43,7 @@ public: INLINE int get_x_size() const; INLINE int get_y_size() const; - void fill_region(int x, int y, int x_size, int y_size, const Colorf &color); + void fill_region(int x, int y, int x_size, int y_size, const LColor &color); PUBLISHED: INLINE bool is_empty() const; diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 22c634669e..f0a266c645 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -291,7 +291,7 @@ find_characters(PandaNode *root, const RenderState *net_state) { // Get the first vertex from the "dot" geoset. This will be the // origin of the next character. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); - float width = reader.get_data1f(); + PN_stdfloat width = reader.get_data1f(); _glyphs[character] = new TextGlyph(character, ch, state, width); } @@ -308,7 +308,7 @@ find_characters(PandaNode *root, const RenderState *net_state) { // Get the first vertex from the "dot" geoset. This will be the // design size indicator. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); - _line_height = reader.get_data3f()[2]; + _line_height = reader.get_data3()[2]; _space_advance = 0.25f * _line_height; } diff --git a/panda/src/text/staticTextFont.h b/panda/src/text/staticTextFont.h index f61b01e7f1..fb7d7609d2 100644 --- a/panda/src/text/staticTextFont.h +++ b/panda/src/text/staticTextFont.h @@ -57,7 +57,7 @@ private: typedef pmap Glyphs; Glyphs _glyphs; - float _font_height; + PN_stdfloat _font_height; PT(PandaNode) _font; public: diff --git a/panda/src/text/textAssembler.I b/panda/src/text/textAssembler.I index 2e3de270f1..f6e40e26e6 100644 --- a/panda/src/text/textAssembler.I +++ b/panda/src/text/textAssembler.I @@ -141,7 +141,7 @@ get_properties() const { // Description: Returns the upper-left corner of the assembled text, // in 2-d text coordinates. //////////////////////////////////////////////////////////////////// -INLINE const LVector2f &TextAssembler:: +INLINE const LVector2 &TextAssembler:: get_ul() const { return _ul; } @@ -152,7 +152,7 @@ get_ul() const { // Description: Returns the lower-right corner of the assembled text, // in 2-d text coordinates. //////////////////////////////////////////////////////////////////// -INLINE const LVector2f &TextAssembler:: +INLINE const LVector2 &TextAssembler:: get_lr() const { return _lr; } @@ -257,7 +257,7 @@ get_properties(int n) const { // Description: Returns the width of the character or object at the // indicated position in the pre-wordwrapped string. //////////////////////////////////////////////////////////////////// -INLINE float TextAssembler:: +INLINE PN_stdfloat TextAssembler:: get_width(int n) const { nassertr(n >= 0 && n < (int)_text_string.size(), 0.0f); @@ -338,7 +338,7 @@ get_properties(int r, int c) const { // Description: Returns the width of the character or object at the // indicated position in the indicated row. //////////////////////////////////////////////////////////////////// -INLINE float TextAssembler:: +INLINE PN_stdfloat TextAssembler:: get_width(int r, int c) const { nassertr(r >= 0 && r < (int)_text_block.size(), 0.0f); nassertr(c >= 0 && c < (int)_text_block[r]._string.size(), 0.0f); @@ -355,7 +355,7 @@ get_width(int r, int c) const { // It is legal for r to exceed the index number of the // last row by 1. The value of c is presently ignored. //////////////////////////////////////////////////////////////////// -INLINE float TextAssembler:: +INLINE PN_stdfloat TextAssembler:: get_ypos(int r, int) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0.0f); if (r == (int)_text_block.size()) { @@ -371,7 +371,7 @@ get_ypos(int r, int) const { // Description: Returns the width of a single character, according to // its associated font. //////////////////////////////////////////////////////////////////// -INLINE float TextAssembler:: +INLINE PN_stdfloat TextAssembler:: calc_width(const TextCharacter &tch) { if (tch._graphic != (TextGraphic *)NULL) { return calc_width(tch._graphic, tch._cprops->_properties); diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 4ed763b7ac..3d086862e1 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -37,22 +37,22 @@ #include // for sprintf // This is the factor by which CT_small scales the character down. -static const float small_accent_scale = 0.6f; +static const PN_stdfloat small_accent_scale = 0.6f; // This is the factor by which CT_tiny scales the character down. -static const float tiny_accent_scale = 0.4f; +static const PN_stdfloat tiny_accent_scale = 0.4; // This is the factor by which CT_squash scales the character in X and Y. -static const float squash_accent_scale_x = 0.8f; -static const float squash_accent_scale_y = 0.5f; +static const PN_stdfloat squash_accent_scale_x = 0.8f; +static const PN_stdfloat squash_accent_scale_y = 0.5f; // This is the factor by which CT_small_squash scales the character in X and Y. -static const float small_squash_accent_scale_x = 0.6f; -static const float small_squash_accent_scale_y = 0.3f; +static const PN_stdfloat small_squash_accent_scale_x = 0.6f; +static const PN_stdfloat small_squash_accent_scale_y = 0.3; // This is the factor by which the advance is reduced for the first // character of a two-character ligature. -static const float ligature_advance_scale = 0.6f; +static const PN_stdfloat ligature_advance_scale = 0.6f; //////////////////////////////////////////////////////////////////// @@ -525,7 +525,7 @@ calc_index(int r, int c) const { // last column by 1, and it is legal for r to exceed the // index number of the last row by 1, if c is 0. //////////////////////////////////////////////////////////////////// -float TextAssembler:: +PN_stdfloat TextAssembler:: get_xpos(int r, int c) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0.0f); if (r == (int)_text_block.size()) { @@ -535,7 +535,7 @@ get_xpos(int r, int c) const { } else { nassertr(c >= 0 && c <= (int)_text_block[r]._string.size(), 0.0f); const TextRow &row = _text_block[r]; - float xpos = row._xpos; + PN_stdfloat xpos = row._xpos; for (int i = 0; i < c; ++i) { xpos += calc_width(row._string[i]); } @@ -573,7 +573,7 @@ assemble_text() { const TextProperties *properties = NULL; CPT(RenderState) text_state; CPT(RenderState) shadow_state; - LMatrix4f shadow_xform; + LMatrix4 shadow_xform; bool any_shadow = false; @@ -589,7 +589,7 @@ assemble_text() { properties = placement->_properties; text_state = RenderState::make_empty(); shadow_state = RenderState::make_empty(); - shadow_xform = LMatrix4f::ident_mat(); + shadow_xform = LMatrix4::ident_mat(); if (properties->has_text_color()) { text_state = text_state->add_attrib(ColorAttrib::make_flat(properties->get_text_color())); @@ -612,8 +612,8 @@ assemble_text() { shadow_state = shadow_state->add_attrib(CullBinAttrib::make(properties->get_bin(), properties->get_draw_order() + 1)); } - LVector2f offset = properties->get_shadow(); - shadow_xform = LMatrix4f::translate_mat(offset[0], 0.0f, -offset[1]); + LVector2 offset = properties->get_shadow(); + shadow_xform = LMatrix4::translate_mat(offset[0], 0.0f, -offset[1]); } } @@ -635,11 +635,11 @@ assemble_text() { } if (_dynamic_merge) { - placement->assign_append_to(geom_collector_map, text_state, LMatrix4f::ident_mat()); + placement->assign_append_to(geom_collector_map, text_state, LMatrix4::ident_mat()); } else { placement->assign_to(text_geom_node, text_state); } - placement->copy_graphic_to(text_node, text_state, LMatrix4f::ident_mat()); + placement->copy_graphic_to(text_node, text_state, LMatrix4::ident_mat()); delete placement; } placed_glyphs.clear(); @@ -676,7 +676,7 @@ assemble_text() { // the width of cheesy ligatures and accented // characters, which may not exist in the font as such. //////////////////////////////////////////////////////////////////// -float TextAssembler:: +PN_stdfloat TextAssembler:: calc_width(wchar_t character, const TextProperties &properties) { if (character == ' ') { // A space is a special case. @@ -690,13 +690,13 @@ calc_width(wchar_t character, const TextProperties &properties) { const TextGlyph *second_glyph = NULL; UnicodeLatinMap::AccentType accent_type; int additional_flags; - float glyph_scale; - float advance_scale; + PN_stdfloat glyph_scale; + PN_stdfloat advance_scale; get_character_glyphs(character, &properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); - float advance = 0.0f; + PN_stdfloat advance = 0.0f; if (first_glyph != (TextGlyph *)NULL) { advance = first_glyph->get_advance() * advance_scale; @@ -715,9 +715,9 @@ calc_width(wchar_t character, const TextProperties &properties) { // Access: Published, Static // Description: Returns the width of a single TextGraphic image. //////////////////////////////////////////////////////////////////// -float TextAssembler:: +PN_stdfloat TextAssembler:: calc_width(const TextGraphic *graphic, const TextProperties &properties) { - LVecBase4f frame = graphic->get_frame(); + LVecBase4 frame = graphic->get_frame(); return (frame[1] - frame[0]) * properties.get_glyph_scale() * properties.get_text_scale(); } @@ -780,8 +780,8 @@ has_character(wchar_t character, const TextProperties &properties) { const TextGlyph *second_glyph = NULL; UnicodeLatinMap::AccentType accent_type; int additional_flags; - float glyph_scale; - float advance_scale; + PN_stdfloat glyph_scale; + PN_stdfloat advance_scale; get_character_glyphs(character, &properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); @@ -964,7 +964,7 @@ wordwrap_text() { _text_block.push_back(TextRow(p)); // Preserve any initial whitespace and newlines. - float initial_width = 0.0f; + PN_stdfloat initial_width = 0.0f; while (p < _text_string.size() && isspacew(_text_string[p]._character)) { if (_text_string[p]._character == '\n') { initial_width = 0.0f; @@ -991,17 +991,17 @@ wordwrap_text() { size_t q = p; bool any_spaces = false; size_t last_space = 0; - float last_space_width = 0.0f; + PN_stdfloat last_space_width = 0.0f; bool any_hyphens = false; size_t last_hyphen = 0; bool output_hyphen = false; bool overflow = false; - float wordwrap_width = -1.0f; + PN_stdfloat wordwrap_width = -1.0f; bool last_was_space = false; - float width = initial_width; + PN_stdfloat width = initial_width; while (q < _text_string.size() && _text_string[q]._character != '\n') { if (_text_string[q]._cprops->_properties.has_wordwrap()) { wordwrap_width = _text_string[q]._cprops->_properties.get_wordwrap(); @@ -1196,12 +1196,12 @@ wordwrap_text() { // string, according to the indicated character's // associated font. //////////////////////////////////////////////////////////////////// -float TextAssembler:: +PN_stdfloat TextAssembler:: calc_hyphen_width(const TextCharacter &tch) { TextFont *font = tch._cprops->_properties.get_font(); nassertr(font != (TextFont *)NULL, 0.0f); - float hyphen_width = 0.0f; + PN_stdfloat hyphen_width = 0.0f; wstring text_soft_hyphen_output = get_text_soft_hyphen_output(); wstring::const_iterator wi; for (wi = text_soft_hyphen_output.begin(); @@ -1226,7 +1226,7 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { _lr.set(0.0f, 0.0f); int num_rows = 0; - float ypos = 0.0f; + PN_stdfloat ypos = 0.0f; _next_row_ypos = 0.0f; TextBlock::iterator bi; for (bi = _text_block.begin(); bi != _text_block.end(); ++bi) { @@ -1234,13 +1234,13 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { // First, assemble all the glyphs of this row. PlacedGlyphs row_placed_glyphs; - float row_width, line_height, wordwrap; + PN_stdfloat row_width, line_height, wordwrap; TextProperties::Alignment align; assemble_row(row, row_placed_glyphs, row_width, line_height, align, wordwrap); // Now move the row to its appropriate position. This might // involve a horizontal as well as a vertical translation. - LMatrix4f mat = LMatrix4f::ident_mat(); + LMatrix4 mat = LMatrix4::ident_mat(); if (num_rows == 0) { // If this is the first row, account for its space. @@ -1251,12 +1251,12 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { // line_height from the previous row. ypos -= line_height; } - _lr[1] = ypos - 0.2f * line_height; + _lr[1] = ypos - 0.2 * line_height; // Apply the requested horizontal alignment to the row. //[fabius] added a different concept of text alignment based upon a boxed region where his width is defined by the wordwrap size with the upper left corner starting from 0,0,0 // if the wordwrap size is unspecified the alignment could eventually result wrong. - float xpos; + PN_stdfloat xpos; switch (align) { case TextProperties::A_left: xpos = 0.0f; @@ -1292,7 +1292,7 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { break; } - mat.set_row(3, LVector3f(xpos, 0.0f, ypos)); + mat.set_row(3, LVector3(xpos, 0.0f, ypos)); row._xpos = xpos; row._ypos = ypos; @@ -1325,16 +1325,16 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { void TextAssembler:: assemble_row(TextAssembler::TextRow &row, TextAssembler::PlacedGlyphs &row_placed_glyphs, - float &row_width, float &line_height, - TextProperties::Alignment &align, float &wordwrap) { + PN_stdfloat &row_width, PN_stdfloat &line_height, + TextProperties::Alignment &align, PN_stdfloat &wordwrap) { Thread *current_thread = Thread::get_current_thread(); line_height = 0.0f; - float xpos = 0.0f; + PN_stdfloat xpos = 0.0f; align = TextProperties::A_left; bool underscore = false; - float underscore_start = 0.0f; + PN_stdfloat underscore_start = 0.0f; const TextProperties *underscore_properties = NULL; TextString::const_iterator si; @@ -1369,7 +1369,7 @@ assemble_row(TextAssembler::TextRow &row, // And the height of the row is the maximum of all the fonts used // within the row. if (graphic != (TextGraphic *)NULL) { - LVecBase4f frame = graphic->get_frame(); + LVecBase4 frame = graphic->get_frame(); line_height = max(line_height, frame[3] - frame[2]); } else { //[fabius] this is not the right place to calc line height (see below) @@ -1382,7 +1382,7 @@ assemble_row(TextAssembler::TextRow &row, } else if (character == '\t') { // So is a tab character. - float tab_width = properties->get_tab_width(); + PN_stdfloat tab_width = properties->get_tab_width(); xpos = (floor(xpos / tab_width) + 1.0f) * tab_width; } else if (character == text_soft_hyphen_key) { @@ -1408,20 +1408,20 @@ assemble_row(TextAssembler::TextRow &row, placement->_graphic_model = model->copy_subgraph(); } - LVecBase4f frame = graphic->get_frame(); - float glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); + LVecBase4 frame = graphic->get_frame(); + PN_stdfloat glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); - float advance = (frame[1] - frame[0]); + PN_stdfloat advance = (frame[1] - frame[0]); // Now compute the matrix that will transform the glyph (or // glyphs) into position. - LMatrix4f glyph_xform = LMatrix4f::scale_mat(glyph_scale); + LMatrix4 glyph_xform = LMatrix4::scale_mat(glyph_scale); glyph_xform(3, 0) += (xpos - frame[0]); glyph_xform(3, 2) += (properties->get_glyph_shift() - frame[2]); if (properties->has_slant()) { - LMatrix4f shear(1.0f, 0.0f, 0.0f, 0.0f, + LMatrix4 shear(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, properties->get_slant(), 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); @@ -1440,8 +1440,8 @@ assemble_row(TextAssembler::TextRow &row, const TextGlyph *second_glyph; UnicodeLatinMap::AccentType accent_type; int additional_flags; - float glyph_scale; - float advance_scale; + PN_stdfloat glyph_scale; + PN_stdfloat advance_scale; get_character_glyphs(character, properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); @@ -1467,7 +1467,7 @@ assemble_row(TextAssembler::TextRow &row, GlyphPlacement *placement = new GlyphPlacement; row_placed_glyphs.push_back(placement); - float advance = 0.0f; + PN_stdfloat advance = 0.0f; if (first_glyph != (TextGlyph *)NULL) { PT(Geom) first_char_geom = first_glyph->get_geom(_usage_hint); @@ -1479,7 +1479,7 @@ assemble_row(TextAssembler::TextRow &row, if (second_glyph != (TextGlyph *)NULL) { PT(Geom) second_char_geom = second_glyph->get_geom(_usage_hint); if (second_char_geom != (Geom *)NULL) { - second_char_geom->transform_vertices(LMatrix4f::translate_mat(advance, 0.0f, 0.0f)); + second_char_geom->transform_vertices(LMatrix4::translate_mat(advance, 0.0f, 0.0f)); placement->add_piece(second_char_geom, second_glyph->get_state()); } advance += second_glyph->get_advance(); @@ -1492,19 +1492,19 @@ assemble_row(TextAssembler::TextRow &row, } // Now compute the matrix that will transform the glyph (or // glyphs) into position. - LMatrix4f glyph_xform = LMatrix4f::scale_mat(glyph_scale); + LMatrix4 glyph_xform = LMatrix4::scale_mat(glyph_scale); if (accent_type != UnicodeLatinMap::AT_none || additional_flags != 0) { // If we have some special handling to perform, do so now. // This will probably require the bounding volume of the // glyph, so go get that. - LPoint3f min_vert, max_vert; + LPoint3 min_vert, max_vert; bool found_any = false; placement->calc_tight_bounds(min_vert, max_vert, found_any, current_thread); if (found_any) { - LPoint3f centroid = (min_vert + max_vert) / 2.0f; + LPoint3 centroid = (min_vert + max_vert) / 2.0f; tack_on_accent(accent_type, min_vert, max_vert, centroid, properties, placement); @@ -1520,10 +1520,10 @@ assemble_row(TextAssembler::TextRow &row, // We rotate the character around its centroid, which may // not always be the right point, but it's the best we've // got and it's probably pretty close. - LMatrix4f rotate = - LMatrix4f::translate_mat(-centroid) * - LMatrix4f::rotate_mat_normaxis(180.0f, LVecBase3f(0.0f, -1.0f, 0.0f)) * - LMatrix4f::translate_mat(centroid); + LMatrix4 rotate = + LMatrix4::translate_mat(-centroid) * + LMatrix4::rotate_mat_normaxis(180.0f, LVecBase3(0.0f, -1.0f, 0.0f)) * + LMatrix4::translate_mat(centroid); glyph_xform *= rotate; } } @@ -1533,7 +1533,7 @@ assemble_row(TextAssembler::TextRow &row, glyph_xform(3, 2) += properties->get_glyph_shift(); if (properties->has_slant()) { - LMatrix4f shear(1.0f, 0.0f, 0.0f, 0.0f, + LMatrix4 shear(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, properties->get_slant(), 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); @@ -1565,7 +1565,7 @@ assemble_row(TextAssembler::TextRow &row, nassertv(font != (TextFont *)NULL); if (line_height == 0.0f) { - float glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); + PN_stdfloat glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); line_height = max(line_height, font->get_line_height() * glyph_scale); } } @@ -1579,7 +1579,7 @@ assemble_row(TextAssembler::TextRow &row, //////////////////////////////////////////////////////////////////// void TextAssembler:: draw_underscore(TextAssembler::PlacedGlyphs &row_placed_glyphs, - float underscore_start, float underscore_end, + PN_stdfloat underscore_start, PN_stdfloat underscore_end, const TextProperties *underscore_properties) { CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3cp(); PT(GeomVertexData) vdata = @@ -1588,11 +1588,11 @@ draw_underscore(TextAssembler::PlacedGlyphs &row_placed_glyphs, GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - float y = underscore_properties->get_underscore_height(); - vertex.add_data3f(underscore_start, 0.0f, y); - color.add_data4f(underscore_properties->get_text_color()); - vertex.add_data3f(underscore_end, 0.0f, y); - color.add_data4f(underscore_properties->get_text_color()); + PN_stdfloat y = underscore_properties->get_underscore_height(); + vertex.add_data3(underscore_start, 0.0f, y); + color.add_data4(underscore_properties->get_text_color()); + vertex.add_data3(underscore_end, 0.0f, y); + color.add_data4(underscore_properties->get_text_color()); PT(GeomLines) lines = new GeomLines(Geom::UH_static); lines->add_vertices(0, 1); @@ -1603,7 +1603,7 @@ draw_underscore(TextAssembler::PlacedGlyphs &row_placed_glyphs, GlyphPlacement *placement = new GlyphPlacement; placement->add_piece(geom, RenderState::make_empty()); - placement->_xform = LMatrix4f::ident_mat(); + placement->_xform = LMatrix4::ident_mat(); placement->_properties = underscore_properties; row_placed_glyphs.push_back(placement); @@ -1634,7 +1634,7 @@ get_character_glyphs(int character, const TextProperties *properties, const TextGlyph *&second_glyph, UnicodeLatinMap::AccentType &accent_type, int &additional_flags, - float &glyph_scale, float &advance_scale) { + PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale) { TextFont *font = properties->get_font(); nassertv_always(font != (TextFont *)NULL); @@ -1712,8 +1712,8 @@ get_character_glyphs(int character, const TextProperties *properties, //////////////////////////////////////////////////////////////////// void TextAssembler:: tack_on_accent(UnicodeLatinMap::AccentType accent_type, - const LPoint3f &min_vert, const LPoint3f &max_vert, - const LPoint3f ¢roid, + const LPoint3 &min_vert, const LPoint3 &max_vert, + const LPoint3 ¢roid, const TextProperties *properties, TextAssembler::GlyphPlacement *placement) const { switch (accent_type) { @@ -1857,8 +1857,8 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type, bool TextAssembler:: tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, TextAssembler::CheesyTransform transform, - const LPoint3f &min_vert, const LPoint3f &max_vert, - const LPoint3f ¢roid, + const LPoint3 &min_vert, const LPoint3 &max_vert, + const LPoint3 ¢roid, const TextProperties *properties, TextAssembler::GlyphPlacement *placement) const { TextFont *font = properties->get_font(); @@ -1871,13 +1871,13 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, font->get_glyph(toupper(accent_mark), accent_glyph)) { PT(Geom) accent_geom = accent_glyph->get_geom(_usage_hint); if (accent_geom != (Geom *)NULL) { - LPoint3f min_accent, max_accent; + LPoint3 min_accent, max_accent; bool found_any = false; accent_geom->calc_tight_bounds(min_accent, max_accent, found_any, current_thread); if (found_any) { - float t, u; - LMatrix4f accent_mat; + PN_stdfloat t, u; + LMatrix4 accent_mat; // This gets set to true if the glyph gets mirrored and needs // to have backface culling disabled. @@ -1885,11 +1885,11 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, switch (transform) { case CT_none: - accent_mat = LMatrix4f::ident_mat(); + accent_mat = LMatrix4::ident_mat(); break; case CT_mirror_x: - accent_mat = LMatrix4f::scale_mat(-1.0f, 1.0f, 1.0f); + accent_mat = LMatrix4::scale_mat(-1.0f, 1.0f, 1.0f); t = min_accent[0]; min_accent[0] = -max_accent[0]; max_accent[0] = -t; @@ -1897,7 +1897,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_mirror_y: - accent_mat = LMatrix4f::scale_mat(1.0f, 1.0f, -1.0f); + accent_mat = LMatrix4::scale_mat(1.0f, 1.0f, -1.0f); t = min_accent[2]; min_accent[2] = -max_accent[2]; max_accent[2] = -t; @@ -1905,7 +1905,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_rotate_90: - accent_mat.set_rotate_mat_normaxis(90.0f, LVecBase3f(0.0f, -1.0f, 0.0f)); + accent_mat.set_rotate_mat_normaxis(90.0f, LVecBase3(0.0f, -1.0f, 0.0f)); // rotate min, max t = min_accent[0]; u = max_accent[0]; @@ -1916,7 +1916,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_rotate_180: - accent_mat = LMatrix4f::scale_mat(-1.0f, -1.0f, 1.0f); + accent_mat = LMatrix4::scale_mat(-1.0f, -1.0f, 1.0f); t = min_accent[0]; min_accent[0] = -max_accent[0]; @@ -1927,7 +1927,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_rotate_270: - accent_mat.set_rotate_mat_normaxis(270.0f, LVecBase3f(0.0f, -1.0f, 0.0f)); + accent_mat.set_rotate_mat_normaxis(270.0f, LVecBase3(0.0f, -1.0f, 0.0f)); // rotate min, max t = min_accent[0]; u = max_accent[0]; @@ -1938,7 +1938,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_squash: - accent_mat = LMatrix4f::scale_mat(squash_accent_scale_x, 1.0f, squash_accent_scale_y); + accent_mat = LMatrix4::scale_mat(squash_accent_scale_x, 1.0f, squash_accent_scale_y); min_accent[0] *= squash_accent_scale_x; max_accent[0] *= squash_accent_scale_x; min_accent[2] *= squash_accent_scale_y; @@ -1946,7 +1946,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_squash_mirror_y: - accent_mat = LMatrix4f::scale_mat(squash_accent_scale_x, 1.0f, -squash_accent_scale_y); + accent_mat = LMatrix4::scale_mat(squash_accent_scale_x, 1.0f, -squash_accent_scale_y); min_accent[0] *= squash_accent_scale_x; max_accent[0] *= squash_accent_scale_x; t = min_accent[2]; @@ -1957,8 +1957,8 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, case CT_squash_mirror_diag: accent_mat = - LMatrix4f::rotate_mat_normaxis(270.0f, LVecBase3f(0.0f, -1.0f, 0.0f)) * - LMatrix4f::scale_mat(-squash_accent_scale_x, 1.0f, squash_accent_scale_y); + LMatrix4::rotate_mat_normaxis(270.0f, LVecBase3(0.0f, -1.0f, 0.0f)) * + LMatrix4::scale_mat(-squash_accent_scale_x, 1.0f, squash_accent_scale_y); // rotate min, max t = min_accent[0]; @@ -1971,7 +1971,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_small_squash: - accent_mat = LMatrix4f::scale_mat(small_squash_accent_scale_x, 1.0f, small_squash_accent_scale_y); + accent_mat = LMatrix4::scale_mat(small_squash_accent_scale_x, 1.0f, small_squash_accent_scale_y); min_accent[0] *= small_squash_accent_scale_x; max_accent[0] *= small_squash_accent_scale_x; min_accent[2] *= small_squash_accent_scale_y; @@ -1979,7 +1979,7 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_small_squash_mirror_y: - accent_mat = LMatrix4f::scale_mat(small_squash_accent_scale_x, 1.0f, -small_squash_accent_scale_y); + accent_mat = LMatrix4::scale_mat(small_squash_accent_scale_x, 1.0f, -small_squash_accent_scale_y); min_accent[0] *= small_squash_accent_scale_x; max_accent[0] *= small_squash_accent_scale_x; t = min_accent[2]; @@ -1990,8 +1990,8 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, case CT_small_squash_mirror_diag: accent_mat = - LMatrix4f::rotate_mat_normaxis(270.0f, LVecBase3f(0.0f, -1.0f, 0.0f)) * - LMatrix4f::scale_mat(-small_squash_accent_scale_x, 1.0f, small_squash_accent_scale_y); + LMatrix4::rotate_mat_normaxis(270.0f, LVecBase3(0.0f, -1.0f, 0.0f)) * + LMatrix4::scale_mat(-small_squash_accent_scale_x, 1.0f, small_squash_accent_scale_y); // rotate min, max t = min_accent[0]; @@ -2004,15 +2004,15 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_small: - accent_mat = LMatrix4f::scale_mat(small_accent_scale); + accent_mat = LMatrix4::scale_mat(small_accent_scale); min_accent *= small_accent_scale; max_accent *= small_accent_scale; break; case CT_small_rotate_270: accent_mat = - LMatrix4f::rotate_mat_normaxis(270.0f, LVecBase3f(0.0f, -1.0f, 0.0f)) * - LMatrix4f::scale_mat(small_accent_scale); + LMatrix4::rotate_mat_normaxis(270.0f, LVecBase3(0.0f, -1.0f, 0.0f)) * + LMatrix4::scale_mat(small_accent_scale); // rotate min, max t = min_accent[0]; @@ -2024,13 +2024,13 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; case CT_tiny: - accent_mat = LMatrix4f::scale_mat(tiny_accent_scale); + accent_mat = LMatrix4::scale_mat(tiny_accent_scale); min_accent *= tiny_accent_scale; max_accent *= tiny_accent_scale; break; case CT_tiny_mirror_x: - accent_mat = LMatrix4f::scale_mat(-tiny_accent_scale, 1.0f, tiny_accent_scale); + accent_mat = LMatrix4::scale_mat(-tiny_accent_scale, 1.0f, tiny_accent_scale); t = min_accent[0]; min_accent[0] = -max_accent[0] * tiny_accent_scale; @@ -2042,8 +2042,8 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, case CT_tiny_rotate_270: accent_mat = - LMatrix4f::rotate_mat_normaxis(270.0f, LVecBase3f(0.0f, -1.0f, 0.0f)) * - LMatrix4f::scale_mat(tiny_accent_scale); + LMatrix4::rotate_mat_normaxis(270.0f, LVecBase3(0.0f, -1.0f, 0.0f)) * + LMatrix4::scale_mat(tiny_accent_scale); // rotate min, max t = min_accent[0]; @@ -2055,9 +2055,9 @@ tack_on_accent(char accent_mark, TextAssembler::CheesyPosition position, break; } - LPoint3f accent_centroid = (min_accent + max_accent) / 2.0f; - float accent_height = max_accent[2] - min_accent[2]; - LVector3f trans; + LPoint3 accent_centroid = (min_accent + max_accent) / 2.0f; + PN_stdfloat accent_height = max_accent[2] - min_accent[2]; + LVector3 trans; switch (position) { case CP_above: // A little above the character. @@ -2165,7 +2165,7 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { // and found_any before calling this function. //////////////////////////////////////////////////////////////////// void TextAssembler::GlyphPlacement:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const { Pieces::const_iterator pi; for (pi = _pieces.begin(); pi != _pieces.end(); ++pi) { @@ -2200,8 +2200,8 @@ assign_to(GeomNode *geom_node, const RenderState *state) const { //////////////////////////////////////////////////////////////////// void TextAssembler::GlyphPlacement:: assign_copy_to(GeomNode *geom_node, const RenderState *state, - const LMatrix4f &extra_xform) const { - LMatrix4f new_xform = _xform * extra_xform; + const LMatrix4 &extra_xform) const { + LMatrix4 new_xform = _xform * extra_xform; Pieces::const_iterator pi; for (pi = _pieces.begin(); pi != _pieces.end(); ++pi) { const Geom *geom = (*pi)._geom; @@ -2222,8 +2222,8 @@ assign_copy_to(GeomNode *geom_node, const RenderState *state, void TextAssembler::GlyphPlacement:: assign_append_to(GeomCollectorMap &geom_collector_map, const RenderState *state, - const LMatrix4f &extra_xform) const { - LMatrix4f new_xform = _xform * extra_xform; + const LMatrix4 &extra_xform) const { + LMatrix4 new_xform = _xform * extra_xform; Pieces::const_iterator pi; int p, sp, s, e, i; @@ -2294,9 +2294,9 @@ assign_append_to(GeomCollectorMap &geom_collector_map, //////////////////////////////////////////////////////////////////// void TextAssembler::GlyphPlacement:: copy_graphic_to(PandaNode *node, const RenderState *state, - const LMatrix4f &extra_xform) const { + const LMatrix4 &extra_xform) const { if (_graphic_model != (PandaNode *)NULL) { - LMatrix4f new_xform = _xform * extra_xform; + LMatrix4 new_xform = _xform * extra_xform; // We need an intermediate node to hold the transform and state. PT(PandaNode) intermediate_node = new PandaNode(""); @@ -2377,14 +2377,14 @@ get_primitive(TypeHandle prim_type) { //////////////////////////////////////////////////////////////////// int TextAssembler::GeomCollector:: append_vertex(const GeomVertexData *orig_vdata, int orig_row, - const LMatrix4f &xform) { + const LMatrix4 &xform) { int new_row = _vdata->get_num_rows(); _vdata->copy_row_from(new_row, orig_vdata, orig_row, Thread::get_current_thread()); GeomVertexRewriter vertex_rewriter(_vdata, InternalName::get_vertex()); vertex_rewriter.set_row_unsafe(new_row); - LPoint3f point = vertex_rewriter.get_data3f(); - vertex_rewriter.set_data3f(point * xform); + LPoint3 point = vertex_rewriter.get_data3(); + vertex_rewriter.set_data3(point * xform); return new_row; } diff --git a/panda/src/text/textAssembler.h b/panda/src/text/textAssembler.h index 8abe6c27eb..772fcf0f9f 100644 --- a/panda/src/text/textAssembler.h +++ b/panda/src/text/textAssembler.h @@ -84,24 +84,24 @@ PUBLISHED: INLINE wchar_t get_character(int n) const; INLINE const TextGraphic *get_graphic(int n) const; INLINE const TextProperties &get_properties(int n) const; - INLINE float get_width(int n) const; + INLINE PN_stdfloat get_width(int n) const; INLINE int get_num_rows() const; INLINE int get_num_cols(int r) const; INLINE wchar_t get_character(int r, int c) const; INLINE const TextGraphic *get_graphic(int r, int c) const; INLINE const TextProperties &get_properties(int r, int c) const; - INLINE float get_width(int r, int c) const; - float get_xpos(int r, int c) const; - INLINE float get_ypos(int r, int c) const; + INLINE PN_stdfloat get_width(int r, int c) const; + PN_stdfloat get_xpos(int r, int c) const; + INLINE PN_stdfloat get_ypos(int r, int c) const; PT(PandaNode) assemble_text(); - INLINE const LVector2f &get_ul() const; - INLINE const LVector2f &get_lr() const; + INLINE const LVector2 &get_ul() const; + INLINE const LVector2 &get_lr() const; - static float calc_width(wchar_t character, const TextProperties &properties); - static float calc_width(const TextGraphic *graphic, const TextProperties &properties); + static PN_stdfloat calc_width(wchar_t character, const TextProperties &properties); + static PN_stdfloat calc_width(const TextGraphic *graphic, const TextProperties &properties); static bool has_exact_character(wchar_t character, const TextProperties &properties); static bool has_character(wchar_t character, const TextProperties &properties); @@ -150,8 +150,8 @@ private: TextString _string; int _row_start; bool _got_soft_hyphens; - float _xpos; - float _ypos; + PN_stdfloat _xpos; + PN_stdfloat _ypos; PT(ComputedProperties) _eol_cprops; }; typedef pvector TextBlock; @@ -173,8 +173,8 @@ private: bool wordwrap_text(); - INLINE static float calc_width(const TextCharacter &tch); - static float calc_hyphen_width(const TextCharacter &tch); + INLINE static PN_stdfloat calc_width(const TextCharacter &tch); + static PN_stdfloat calc_hyphen_width(const TextCharacter &tch); // These structures are built up by assemble_paragraph() and // assemble_row(). They represent the actual Geoms as laid out in a @@ -206,7 +206,7 @@ private: INLINE void count_geom(const Geom *geom); GeomPrimitive *get_primitive(TypeHandle prim_type); int append_vertex(const GeomVertexData *orig_vdata, int orig_row, - const LMatrix4f &xform); + const LMatrix4 &xform); void append_geom(GeomNode *geom_node, const RenderState *state); private: @@ -221,20 +221,20 @@ private: class GlyphPlacement { public: INLINE void add_piece(Geom *geom, const RenderState *state); - void calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + void calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const; void assign_to(GeomNode *geom_node, const RenderState *state) const; void assign_copy_to(GeomNode *geom_node, const RenderState *state, - const LMatrix4f &extra_xform) const; + const LMatrix4 &extra_xform) const; void assign_append_to(GeomCollectorMap &geom_collector_map, const RenderState *state, - const LMatrix4f &extra_xform) const; + const LMatrix4 &extra_xform) const; void copy_graphic_to(PandaNode *node, const RenderState *state, - const LMatrix4f &extra_xform) const; + const LMatrix4 &extra_xform) const; Pieces _pieces; PT(PandaNode) _graphic_model; - LMatrix4f _xform; + LMatrix4 _xform; const TextProperties *_properties; }; typedef pvector PlacedGlyphs; @@ -242,8 +242,8 @@ private: void assemble_paragraph(PlacedGlyphs &placed_glyphs); void assemble_row(TextRow &row, PlacedGlyphs &row_placed_glyphs, - float &row_width, float &line_height, - TextProperties::Alignment &align, float &wordwrap); + PN_stdfloat &row_width, PN_stdfloat &line_height, + TextProperties::Alignment &align, PN_stdfloat &wordwrap); // These interfaces are for implementing cheesy accent marks and // ligatures when the font doesn't support them. @@ -276,7 +276,7 @@ private: static void draw_underscore(TextAssembler::PlacedGlyphs &row_placed_glyphs, - float underscore_start, float underscore_end, + PN_stdfloat underscore_start, PN_stdfloat underscore_end, const TextProperties *underscore_properties); static void @@ -285,24 +285,24 @@ private: const TextGlyph *&second_glyph, UnicodeLatinMap::AccentType &accent_type, int &additional_flags, - float &glyph_scale, float &advance_scale); + PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale); void tack_on_accent(UnicodeLatinMap::AccentType accent_type, - const LPoint3f &min_vert, const LPoint3f &max_vert, - const LPoint3f ¢roid, + const LPoint3 &min_vert, const LPoint3 &max_vert, + const LPoint3 ¢roid, const TextProperties *properties, GlyphPlacement *placement) const; bool tack_on_accent(char accent_mark, CheesyPosition position, CheesyTransform transform, - const LPoint3f &min_vert, const LPoint3f &max_vert, - const LPoint3f ¢roid, + const LPoint3 &min_vert, const LPoint3 &max_vert, + const LPoint3 ¢roid, const TextProperties *properties, GlyphPlacement *placement) const; // These are filled in by assemble_paragraph(). - LVector2f _ul; - LVector2f _lr; - float _next_row_ypos; + LVector2 _ul; + LVector2 _lr; + PN_stdfloat _next_row_ypos; TextEncoder *_encoder; Geom::UsageHint _usage_hint; diff --git a/panda/src/text/textFont.I b/panda/src/text/textFont.I index 452e132a0f..d4dc16d88f 100644 --- a/panda/src/text/textFont.I +++ b/panda/src/text/textFont.I @@ -41,7 +41,7 @@ operator bool () const { // Description: Returns the number of units high each line of text // is. //////////////////////////////////////////////////////////////////// -INLINE float TextFont:: +INLINE PN_stdfloat TextFont:: get_line_height() const { return _line_height; } @@ -53,7 +53,7 @@ get_line_height() const { // is. //////////////////////////////////////////////////////////////////// INLINE void TextFont:: -set_line_height(float line_height) { +set_line_height(PN_stdfloat line_height) { _line_height = line_height; } @@ -62,7 +62,7 @@ set_line_height(float line_height) { // Access: Published // Description: Returns the number of units wide a space is. //////////////////////////////////////////////////////////////////// -INLINE float TextFont:: +INLINE PN_stdfloat TextFont:: get_space_advance() const { return _space_advance; } @@ -73,6 +73,6 @@ get_space_advance() const { // Description: Changes the number of units wide a space is. //////////////////////////////////////////////////////////////////// INLINE void TextFont:: -set_space_advance(float space_advance) { +set_space_advance(PN_stdfloat space_advance) { _space_advance = space_advance; } diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index 55a210e914..0a6156e075 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -150,10 +150,10 @@ make_invalid_glyph() { new GeomVertexData("invalid_glyph", vformat, GeomEnums::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(_line_height * 0.2f, 0.0f, _line_height * 0.1f); - vertex.add_data3f(_line_height * 0.5f, 0.0f, _line_height * 0.1f); - vertex.add_data3f(_line_height * 0.5f, 0.0f, _line_height * 0.7f); - vertex.add_data3f(_line_height * 0.2f, 0.0f, _line_height * 0.7f); + vertex.add_data3(_line_height * 0.2, 0.0f, _line_height * 0.1f); + vertex.add_data3(_line_height * 0.5f, 0.0f, _line_height * 0.1f); + vertex.add_data3(_line_height * 0.5f, 0.0f, _line_height * 0.7f); + vertex.add_data3(_line_height * 0.2, 0.0f, _line_height * 0.7f); PT(GeomPrimitive) prim = new GeomLinestrips(GeomEnums::UH_static); prim->add_consecutive_vertices(0, 4); diff --git a/panda/src/text/textFont.h b/panda/src/text/textFont.h index 9c1211890a..190a2e793e 100644 --- a/panda/src/text/textFont.h +++ b/panda/src/text/textFont.h @@ -73,11 +73,11 @@ PUBLISHED: INLINE bool is_valid() const; INLINE operator bool () const; - INLINE float get_line_height() const; - INLINE void set_line_height(float line_height); + INLINE PN_stdfloat get_line_height() const; + INLINE void set_line_height(PN_stdfloat line_height); - INLINE float get_space_advance() const; - INLINE void set_space_advance(float space_advance); + INLINE PN_stdfloat get_space_advance() const; + INLINE void set_space_advance(PN_stdfloat space_advance); virtual void write(ostream &out, int indent_level) const; @@ -93,8 +93,8 @@ private: protected: bool _is_valid; - float _line_height; - float _space_advance; + PN_stdfloat _line_height; + PN_stdfloat _space_advance; PT(TextGlyph) _invalid_glyph; public: diff --git a/panda/src/text/textGlyph.I b/panda/src/text/textGlyph.I index 30865a6813..89852d38ea 100644 --- a/panda/src/text/textGlyph.I +++ b/panda/src/text/textGlyph.I @@ -33,7 +33,7 @@ TextGlyph(int character) : //////////////////////////////////////////////////////////////////// INLINE TextGlyph:: TextGlyph(int character, const Geom *geom, - const RenderState *state, float advance) : + const RenderState *state, PN_stdfloat advance) : _character(character), _geom(geom), _state(state), @@ -126,7 +126,7 @@ get_state() const { // i.e. the approximate width the character takes up on // the line. //////////////////////////////////////////////////////////////////// -INLINE float TextGlyph:: +INLINE PN_stdfloat TextGlyph:: get_advance() const { return _advance; } diff --git a/panda/src/text/textGlyph.h b/panda/src/text/textGlyph.h index 6652f3ba80..ac153d11a8 100644 --- a/panda/src/text/textGlyph.h +++ b/panda/src/text/textGlyph.h @@ -32,7 +32,7 @@ class EXPCL_PANDA_TEXT TextGlyph : public ReferenceCount { public: INLINE TextGlyph(int character); INLINE TextGlyph(int character, const Geom *geom, - const RenderState *state, float advance); + const RenderState *state, PN_stdfloat advance); INLINE TextGlyph(const TextGlyph ©); INLINE void operator = (const TextGlyph ©); virtual ~TextGlyph(); @@ -40,7 +40,7 @@ public: INLINE int get_character() const; INLINE PT(Geom) get_geom(Geom::UsageHint usage_hint) const; INLINE const RenderState *get_state() const; - INLINE float get_advance() const; + INLINE PN_stdfloat get_advance() const; virtual bool is_whitespace() const; @@ -48,7 +48,7 @@ protected: int _character; CPT(Geom) _geom; CPT(RenderState) _state; - float _advance; + PN_stdfloat _advance; }; #include "textGlyph.I" diff --git a/panda/src/text/textGraphic.I b/panda/src/text/textGraphic.I index 874262e190..06bbdbff6e 100644 --- a/panda/src/text/textGraphic.I +++ b/panda/src/text/textGraphic.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE TextGraphic:: TextGraphic() { - _frame = LVecBase4f::zero(); + _frame = LVecBase4::zero(); _instance_flag = false; } @@ -30,7 +30,7 @@ TextGraphic() { // Description: //////////////////////////////////////////////////////////////////// INLINE TextGraphic:: -TextGraphic(const NodePath &model, const LVecBase4f &frame) : +TextGraphic(const NodePath &model, const LVecBase4 &frame) : _model(model), _frame(frame), _instance_flag(false) @@ -43,7 +43,7 @@ TextGraphic(const NodePath &model, const LVecBase4f &frame) : // Description: //////////////////////////////////////////////////////////////////// INLINE TextGraphic:: -TextGraphic(const NodePath &model, float left, float right, float bottom, float top) : +TextGraphic(const NodePath &model, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) : _model(model), _frame(left, right, bottom, top), _instance_flag(false) @@ -87,7 +87,7 @@ set_model(const NodePath &model) { // completely within it, but if it does not, it may // visually overlap with nearby text. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextGraphic:: +INLINE LVecBase4 TextGraphic:: get_frame() const { return _frame; } @@ -99,7 +99,7 @@ get_frame() const { // frame for the graphic. See get_frame(). //////////////////////////////////////////////////////////////////// INLINE void TextGraphic:: -set_frame(const LVecBase4f &frame) { +set_frame(const LVecBase4 &frame) { _frame = frame; } @@ -110,7 +110,7 @@ set_frame(const LVecBase4f &frame) { // frame for the graphic. See get_frame(). //////////////////////////////////////////////////////////////////// INLINE void TextGraphic:: -set_frame(float left, float right, float bottom, float top) { +set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _frame.set(left, right, bottom, top); } diff --git a/panda/src/text/textGraphic.h b/panda/src/text/textGraphic.h index 0761e7ef10..3a032ca2c9 100644 --- a/panda/src/text/textGraphic.h +++ b/panda/src/text/textGraphic.h @@ -43,22 +43,22 @@ class EXPCL_PANDA_TEXT TextGraphic { PUBLISHED: INLINE TextGraphic(); - INLINE TextGraphic(const NodePath &model, const LVecBase4f &frame); - INLINE TextGraphic(const NodePath &model, float left, float right, float bottom, float top); + INLINE TextGraphic(const NodePath &model, const LVecBase4 &frame); + INLINE TextGraphic(const NodePath &model, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); INLINE NodePath get_model() const; INLINE void set_model(const NodePath &model); - INLINE LVecBase4f get_frame() const; - INLINE void set_frame(const LVecBase4f &frame); - INLINE void set_frame(float left, float right, float bottom, float top); + INLINE LVecBase4 get_frame() const; + INLINE void set_frame(const LVecBase4 &frame); + INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); INLINE bool get_instance_flag() const; INLINE void set_instance_flag(bool instance_flag); private: NodePath _model; - LVecBase4f _frame; + LVecBase4 _frame; bool _instance_flag; }; diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index ade8a3d27d..0ed14b862a 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -22,7 +22,7 @@ // commands, in which case the value of this method is // questionable. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_line_height() const { TextFont *font = get_font(); if (font == (TextFont *)NULL) { @@ -99,8 +99,8 @@ has_overflow() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_frame_color(float r, float g, float b, float a) { - set_frame_color(Colorf(r, g, b, a)); +set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_frame_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -109,7 +109,7 @@ set_frame_color(float r, float g, float b, float a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_frame_color(const Colorf &frame_color) { +set_frame_color(const LColor &frame_color) { if (_frame_color != frame_color) { _frame_color = frame_color; invalidate_no_measure(); @@ -121,7 +121,7 @@ set_frame_color(const Colorf &frame_color) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE Colorf TextNode:: +INLINE LColor TextNode:: get_frame_color() const { return _frame_color; } @@ -132,7 +132,7 @@ get_frame_color() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_card_border(float size, float uv_portion) { +set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) { if (!has_card_border() || _card_border_size != size || _card_border_uv_portion != uv_portion) { _flags |= F_has_card_border; _card_border_size = size; @@ -159,7 +159,7 @@ clear_card_border() { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_card_border_size() const { return _card_border_size; } @@ -169,7 +169,7 @@ get_card_border_size() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_card_border_uv_portion() const { return _card_border_uv_portion; } @@ -190,8 +190,8 @@ has_card_border() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_card_color(float r, float g, float b, float a) { - set_card_color(Colorf(r, g, b, a)); +set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_card_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -200,7 +200,7 @@ set_card_color(float r, float g, float b, float a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_card_color(const Colorf &card_color) { +set_card_color(const LColor &card_color) { if (_card_color != card_color) { _card_color = card_color; invalidate_no_measure(); @@ -212,7 +212,7 @@ set_card_color(const Colorf &card_color) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE Colorf TextNode:: +INLINE LColor TextNode:: get_card_color() const { return _card_color; } @@ -279,7 +279,7 @@ get_card_texture() const { // generally be positive. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_frame_as_margin(float left, float right, float bottom, float top) { +set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= (F_has_frame | F_frame_as_margin); _frame_ul.set(left, top); _frame_lr.set(right, bottom); @@ -297,7 +297,7 @@ set_frame_as_margin(float left, float right, float bottom, float top) { // coordinates should generally be positive. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_frame_actual(float left, float right, float bottom, float top) { +set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= F_has_frame; _flags &= ~F_frame_as_margin; _frame_ul.set(left, top); @@ -353,10 +353,10 @@ is_frame_as_margin() const { // values returned by this function. It is an error to // call this if has_frame() is false. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextNode:: +INLINE LVecBase4 TextNode:: get_frame_as_set() const { - nassertr(has_frame(), LVecBase4f(0.0, 0.0, 0.0, 0.0)); - return LVecBase4f(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]); + nassertr(has_frame(), LVecBase4(0.0, 0.0, 0.0, 0.0)); + return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]); } //////////////////////////////////////////////////////////////////// @@ -373,15 +373,15 @@ get_frame_as_set() const { // dimensions of the text itself, as if the frame were // set with a margin of 0, 0, 0, 0. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextNode:: +INLINE LVecBase4 TextNode:: get_frame_actual() const { if (!has_frame()) { check_measure(); - return LVecBase4f(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); + return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); } else if (is_frame_as_margin()) { check_measure(); - return LVecBase4f(_text_ul[0] - _frame_ul[0], + return LVecBase4(_text_ul[0] - _frame_ul[0], _text_lr[0] + _frame_lr[0], _text_lr[1] - _frame_lr[1], _text_ul[1] + _frame_ul[1]); @@ -397,7 +397,7 @@ get_frame_actual() const { // used to draw the frame. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_frame_line_width(float frame_width) { +set_frame_line_width(PN_stdfloat frame_width) { _frame_width = frame_width; invalidate_no_measure(); } @@ -408,7 +408,7 @@ set_frame_line_width(float frame_width) { // Description: Returns the thickness of the lines that will be // used to draw the frame. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_frame_line_width() const { return _frame_width; } @@ -452,7 +452,7 @@ get_frame_corners() const { // positive. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_card_as_margin(float left, float right, float bottom, float top) { +set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= (F_has_card | F_card_as_margin); _card_ul.set(left, top); _card_lr.set(right, bottom); @@ -470,7 +470,7 @@ set_card_as_margin(float left, float right, float bottom, float top) { // coordinates should generally be positive. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_card_actual(float left, float right, float bottom, float top) { +set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= F_has_card; _flags &= ~F_card_as_margin; _card_ul.set(left, top); @@ -554,10 +554,10 @@ is_card_as_margin() const { // values returned by this function. It is an error to // call this if has_card() is false. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextNode:: +INLINE LVecBase4 TextNode:: get_card_as_set() const { - nassertr(has_card(), LVecBase4f(0.0, 0.0, 0.0, 0.0)); - return LVecBase4f(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]); + nassertr(has_card(), LVecBase4(0.0, 0.0, 0.0, 0.0)); + return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]); } //////////////////////////////////////////////////////////////////// @@ -574,15 +574,15 @@ get_card_as_set() const { // dimensions of the text itself, as if the card were // set with a margin of 0, 0, 0, 0. //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextNode:: +INLINE LVecBase4 TextNode:: get_card_actual() const { if (!has_card()) { check_measure(); - return LVecBase4f(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); + return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); } else if (is_card_as_margin()) { check_measure(); - return LVecBase4f(_text_ul[0] - _card_ul[0], + return LVecBase4(_text_ul[0] - _card_ul[0], _text_lr[0] + _card_lr[0], _text_lr[1] - _card_lr[1], _text_ul[1] + _card_ul[1]); @@ -600,13 +600,13 @@ get_card_actual() const { // rest of the world. Also see get_upper_left_3d() and // get_lower_right_3d(). //////////////////////////////////////////////////////////////////// -INLINE LVecBase4f TextNode:: +INLINE LVecBase4 TextNode:: get_card_transformed() const { - LVecBase4f card = get_card_actual(); - LPoint3f ul = LPoint3f(card[0], 0.0, card[3]) * _transform; - LPoint3f lr = LPoint3f(card[1], 0.0, card[2]) * _transform; + LVecBase4 card = get_card_actual(); + LPoint3 ul = LPoint3(card[0], 0.0, card[3]) * _transform; + LPoint3 lr = LPoint3(card[1], 0.0, card[2]) * _transform; - return LVecBase4f(ul[0], lr[0], lr[2], ul[2]); + return LVecBase4(ul[0], lr[0], lr[2], ul[2]); } //////////////////////////////////////////////////////////////////// @@ -616,7 +616,7 @@ get_card_transformed() const { // entire text paragraph. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_transform(const LMatrix4f &transform) { +set_transform(const LMatrix4 &transform) { _transform = transform; invalidate_with_measure(); } @@ -626,7 +626,7 @@ set_transform(const LMatrix4f &transform) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE LMatrix4f TextNode:: +INLINE LMatrix4 TextNode:: get_transform() const { return _transform; } @@ -810,7 +810,7 @@ clear_small_caps() { // this will be a number less than one. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_small_caps_scale(float small_caps_scale) { +set_small_caps_scale(PN_stdfloat small_caps_scale) { TextProperties::set_small_caps_scale(small_caps_scale); invalidate_with_measure(); } @@ -832,7 +832,7 @@ clear_small_caps_scale() { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_slant(float slant) { +set_slant(PN_stdfloat slant) { TextProperties::set_slant(slant); invalidate_with_measure(); } @@ -878,7 +878,7 @@ clear_align() { // thought of as a left margin. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_indent(float indent) { +set_indent(PN_stdfloat indent) { TextProperties::set_indent(indent); invalidate_with_measure(); } @@ -902,7 +902,7 @@ clear_indent() { // as a right margin or margin width. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_wordwrap(float wordwrap) { +set_wordwrap(PN_stdfloat wordwrap) { TextProperties::set_wordwrap(wordwrap); invalidate_with_measure(); } @@ -925,7 +925,7 @@ clear_wordwrap() { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_text_color(const Colorf &text_color) { +set_text_color(const LColor &text_color) { TextProperties::set_text_color(text_color); invalidate_no_measure(); } @@ -936,8 +936,8 @@ set_text_color(const Colorf &text_color) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_text_color(float r, float g, float b, float a) { - set_text_color(Colorf(r, g, b, a)); +set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_text_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -958,8 +958,8 @@ clear_text_color() { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_shadow_color(float r, float g, float b, float a) { - set_shadow_color(Colorf(r, g, b, a)); +set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_shadow_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -968,7 +968,7 @@ set_shadow_color(float r, float g, float b, float a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_shadow_color(const Colorf &shadow_color) { +set_shadow_color(const LColor &shadow_color) { TextProperties::set_shadow_color(shadow_color); invalidate_no_measure(); } @@ -992,8 +992,8 @@ clear_shadow_color() { // offsetting it slightly behind the first. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_shadow(float xoffset, float yoffset) { - set_shadow(LVecBase2f(xoffset, yoffset)); +set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) { + set_shadow(LVecBase2(xoffset, yoffset)); } //////////////////////////////////////////////////////////////////// @@ -1004,7 +1004,7 @@ set_shadow(float xoffset, float yoffset) { // offsetting it slightly behind the first. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_shadow(const LVecBase2f &shadow_offset) { +set_shadow(const LVecBase2 &shadow_offset) { TextProperties::set_shadow(shadow_offset); invalidate_no_measure(); } @@ -1094,7 +1094,7 @@ clear_draw_order() { // horizontal position to the next tab stop. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_tab_width(float tab_width) { +set_tab_width(PN_stdfloat tab_width) { TextProperties::set_tab_width(tab_width); invalidate_with_measure(); } @@ -1119,7 +1119,7 @@ clear_tab_width() { // superscripting or subscripting. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_glyph_scale(float glyph_scale) { +set_glyph_scale(PN_stdfloat glyph_scale) { TextProperties::set_glyph_scale(glyph_scale); invalidate_with_measure(); } @@ -1144,7 +1144,7 @@ clear_glyph_scale() { // superscripting or subscripting. //////////////////////////////////////////////////////////////////// INLINE void TextNode:: -set_glyph_shift(float glyph_shift) { +set_glyph_shift(PN_stdfloat glyph_shift) { TextProperties::set_glyph_shift(glyph_shift); invalidate_with_measure(); } @@ -1247,7 +1247,7 @@ get_wordwrapped_text() const { // characters. The line should not include the newline // character. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: calc_width(const string &line) const { return calc_width(decode_text(line)); } @@ -1301,7 +1301,7 @@ get_wordwrapped_wtext() const { // coordinates, unmodified by the set_transform() // matrix. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_left() const { check_measure(); return _text_ul[0]; @@ -1314,7 +1314,7 @@ get_left() const { // coordinates, unmodified by the set_transform() // matrix. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_right() const { check_measure(); return _text_lr[0]; @@ -1327,7 +1327,7 @@ get_right() const { // 2-d coordinates, unmodified by the set_transform() // matrix. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_bottom() const { check_measure(); return _text_lr[1]; @@ -1340,7 +1340,7 @@ get_bottom() const { // coordinates, unmodified by the set_transform() // matrix. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_top() const { check_measure(); return _text_ul[1]; @@ -1352,7 +1352,7 @@ get_top() const { // Description: Returns the net height of the text in local 2-d // coordinates. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_height() const { check_measure(); return _text_ul[1] - _text_lr[1]; @@ -1364,7 +1364,7 @@ get_height() const { // Description: Returns the net width of the text in local 2-d // coordinates. //////////////////////////////////////////////////////////////////// -INLINE float TextNode:: +INLINE PN_stdfloat TextNode:: get_width() const { check_measure(); return _text_lr[0] - _text_ul[0]; @@ -1377,7 +1377,7 @@ get_width() const { // after it has been transformed into 3-d space by // applying the set_transform() matrix. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f TextNode:: +INLINE LPoint3 TextNode:: get_upper_left_3d() const { check_measure(); return _ul3d; @@ -1390,7 +1390,7 @@ get_upper_left_3d() const { // after it has been transformed into 3-d space by // applying the set_transform() matrix. //////////////////////////////////////////////////////////////////// -INLINE LPoint3f TextNode:: +INLINE LPoint3 TextNode:: get_lower_right_3d() const { check_measure(); return _lr3d; diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index b1507109af..c42e2a8b03 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -88,7 +88,7 @@ TextNode(const string &name) : PandaNode(name) { _card_ul.set(0.0f, 0.0f); _card_lr.set(0.0f, 0.0f); - _transform = LMatrix4f::ident_mat(); + _transform = LMatrix4::ident_mat(); _coordinate_system = CS_default; _ul3d.set(0.0f, 0.0f, 0.0f); @@ -120,7 +120,7 @@ TextNode(const string &name, const TextProperties ©) : _card_ul.set(0.0f, 0.0f); _card_lr.set(0.0f, 0.0f); - _transform = LMatrix4f::ident_mat(); + _transform = LMatrix4::ident_mat(); _coordinate_system = CS_default; _ul3d.set(0.0f, 0.0f, 0.0f); @@ -187,7 +187,7 @@ TextNode:: // or 0.0 if the character is not known. This may be a // wide character (greater than 255). //////////////////////////////////////////////////////////////////// -float TextNode:: +PN_stdfloat TextNode:: calc_width(wchar_t character) const { TextFont *font = get_font(); if (font == (TextFont *)NULL) { @@ -287,9 +287,9 @@ is_whitespace(wchar_t character) const { // character or any embedded control characters like \1 // or \3. //////////////////////////////////////////////////////////////////// -float TextNode:: +PN_stdfloat TextNode:: calc_width(const wstring &line) const { - float width = 0.0f; + PN_stdfloat width = 0.0f; wstring::const_iterator si; for (si = line.begin(); si != line.end(); ++si) { @@ -383,8 +383,8 @@ generate() { // Compute the overall text transform matrix. We build the text in // a Z-up coordinate system and then convert it to whatever the user // asked for. - LMatrix4f mat = - LMatrix4f::convert_mat(CS_zup_right, _coordinate_system) * + LMatrix4 mat = + LMatrix4::convert_mat(CS_zup_right, _coordinate_system) * _transform; CPT(TransformState) transform = TransformState::make_mat(mat); @@ -420,8 +420,8 @@ generate() { // Save the bounding-box information about the text in a form // friendly to the user. - const LVector2f &ul = assembler.get_ul(); - const LVector2f &lr = assembler.get_lr(); + const LVector2 &ul = assembler.get_ul(); + const LVector2 &lr = assembler.get_lr(); _ul3d.set(ul[0], 0.0f, ul[1]); _lr3d.set(lr[0], 0.0f, lr[1]); @@ -558,7 +558,7 @@ void TextNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { - const LMatrix4f &mat = attribs._transform->get_mat(); + const LMatrix4 &mat = attribs._transform->get_mat(); _transform *= mat; if ((_flags & F_needs_measure) == 0) { @@ -573,7 +573,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if (attribs._color != (const RenderAttrib *)NULL) { const ColorAttrib *ca = DCAST(ColorAttrib, attribs._color); if (ca->get_color_type() == ColorAttrib::T_flat) { - const Colorf &c = ca->get_color(); + const LColor &c = ca->get_color(); set_text_color(c); set_frame_color(c); set_card_color(c); @@ -584,27 +584,27 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { if (attribs._color_scale != (const RenderAttrib *)NULL) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attribs._color_scale); - const LVecBase4f &s = csa->get_scale(); - if (s != LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)) { - LVecBase4f tc = get_text_color(); + const LVecBase4 &s = csa->get_scale(); + if (s != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { + LVecBase4 tc = get_text_color(); tc[0] *= s[0]; tc[1] *= s[1]; tc[2] *= s[2]; tc[3] *= s[3]; set_text_color(tc); - LVecBase4f sc = get_shadow_color(); + LVecBase4 sc = get_shadow_color(); sc[0] *= s[0]; sc[1] *= s[1]; sc[2] *= s[2]; sc[3] *= s[3]; set_shadow_color(sc); - LVecBase4f fc = get_frame_color(); + LVecBase4 fc = get_frame_color(); fc[0] *= s[0]; fc[1] *= s[1]; fc[2] *= s[2]; fc[3] *= s[3]; set_frame_color(fc); - LVecBase4f cc = get_card_color(); + LVecBase4 cc = get_card_color(); cc[0] *= s[0]; cc[1] *= s[1]; cc[2] *= s[2]; @@ -640,7 +640,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // already set. //////////////////////////////////////////////////////////////////// CPT(TransformState) TextNode:: -calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, bool &found_any, +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { CPT(TransformState) next_transform = PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, @@ -732,7 +732,7 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // measured it. check_measure(); - LPoint3f vertices[8]; + LPoint3 vertices[8]; vertices[0].set(_ul3d[0], _ul3d[1], _ul3d[2]); vertices[1].set(_ul3d[0], _ul3d[1], _lr3d[2]); vertices[2].set(_ul3d[0], _lr3d[1], _ul3d[2]); @@ -806,11 +806,11 @@ PT(PandaNode) TextNode:: make_frame() { PT(GeomNode) frame_node = new GeomNode("frame"); - LVector4f dimensions = get_frame_actual(); - float left = dimensions[0]; - float right = dimensions[1]; - float bottom = dimensions[2]; - float top = dimensions[3]; + LVector4 dimensions = get_frame_actual(); + PN_stdfloat left = dimensions[0]; + PN_stdfloat right = dimensions[1]; + PN_stdfloat bottom = dimensions[2]; + PN_stdfloat top = dimensions[3]; CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _frame_width); CPT(RenderState) state = RenderState::make(thick); @@ -819,10 +819,10 @@ make_frame() { ("text", GeomVertexFormat::get_v3(), get_usage_hint()); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3f(left, 0.0f, top); - vertex.add_data3f(left, 0.0f, bottom); - vertex.add_data3f(right, 0.0f, bottom); - vertex.add_data3f(right, 0.0f, top); + vertex.add_data3(left, 0.0f, top); + vertex.add_data3(left, 0.0f, bottom); + vertex.add_data3(right, 0.0f, bottom); + vertex.add_data3(right, 0.0f, top); PT(GeomLinestrips) frame = new GeomLinestrips(get_usage_hint()); frame->add_consecutive_vertices(0, 4); @@ -853,26 +853,26 @@ PT(PandaNode) TextNode:: make_card() { PT(GeomNode) card_node = new GeomNode("card"); - LVector4f dimensions = get_card_actual(); - float left = dimensions[0]; - float right = dimensions[1]; - float bottom = dimensions[2]; - float top = dimensions[3]; + LVector4 dimensions = get_card_actual(); + PN_stdfloat left = dimensions[0]; + PN_stdfloat right = dimensions[1]; + PN_stdfloat bottom = dimensions[2]; + PN_stdfloat top = dimensions[3]; PT(GeomVertexData) vdata = new GeomVertexData ("text", GeomVertexFormat::get_v3t2(), get_usage_hint()); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - vertex.add_data3f(left, 0.0f, top); - vertex.add_data3f(left, 0.0f, bottom); - vertex.add_data3f(right, 0.0f, top); - vertex.add_data3f(right, 0.0f, bottom); + vertex.add_data3(left, 0.0f, top); + vertex.add_data3(left, 0.0f, bottom); + vertex.add_data3(right, 0.0f, top); + vertex.add_data3(right, 0.0f, bottom); - texcoord.add_data2f(0.0f, 1.0f); - texcoord.add_data2f(0.0f, 0.0f); - texcoord.add_data2f(1.0f, 1.0f); - texcoord.add_data2f(1.0f, 0.0f); + texcoord.add_data2(0.0f, 1.0f); + texcoord.add_data2(0.0f, 0.0f); + texcoord.add_data2(1.0f, 1.0f); + texcoord.add_data2(1.0f, 0.0f); PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); card->add_consecutive_vertices(0, 4); @@ -897,11 +897,11 @@ PT(PandaNode) TextNode:: make_card_with_border() { PT(GeomNode) card_node = new GeomNode("card"); - LVector4f dimensions = get_card_actual(); - float left = dimensions[0]; - float right = dimensions[1]; - float bottom = dimensions[2]; - float top = dimensions[3]; + LVector4 dimensions = get_card_actual(); + PN_stdfloat left = dimensions[0]; + PN_stdfloat right = dimensions[1]; + PN_stdfloat bottom = dimensions[2]; + PN_stdfloat top = dimensions[3]; // we now create three tri-strips instead of one // with vertices arranged as follows: @@ -918,50 +918,50 @@ make_card_with_border() { GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); // verts 1,2,3,4 - vertex.add_data3f(left, 0.02f, top); - vertex.add_data3f(left, 0.02f, top - _card_border_size); - vertex.add_data3f(left + _card_border_size, 0.02f, top); - vertex.add_data3f(left + _card_border_size, 0.02f, + vertex.add_data3(left, 0.02, top); + vertex.add_data3(left, 0.02, top - _card_border_size); + vertex.add_data3(left + _card_border_size, 0.02, top); + vertex.add_data3(left + _card_border_size, 0.02, top - _card_border_size); // verts 5,6,7,8 - vertex.add_data3f(right - _card_border_size, 0.02f, top); - vertex.add_data3f(right - _card_border_size, 0.02f, + vertex.add_data3(right - _card_border_size, 0.02, top); + vertex.add_data3(right - _card_border_size, 0.02, top - _card_border_size); - vertex.add_data3f(right, 0.02f, top); - vertex.add_data3f(right, 0.02f, top - _card_border_size); + vertex.add_data3(right, 0.02, top); + vertex.add_data3(right, 0.02, top - _card_border_size); // verts 9,10,11,12 - vertex.add_data3f(left, 0.02f, bottom + _card_border_size); - vertex.add_data3f(left, 0.02f, bottom); - vertex.add_data3f(left + _card_border_size, 0.02f, + vertex.add_data3(left, 0.02, bottom + _card_border_size); + vertex.add_data3(left, 0.02, bottom); + vertex.add_data3(left + _card_border_size, 0.02, bottom + _card_border_size); - vertex.add_data3f(left + _card_border_size, 0.02f, bottom); + vertex.add_data3(left + _card_border_size, 0.02, bottom); // verts 13,14,15,16 - vertex.add_data3f(right - _card_border_size, 0.02f, + vertex.add_data3(right - _card_border_size, 0.02, bottom + _card_border_size); - vertex.add_data3f(right - _card_border_size, 0.02f, bottom); - vertex.add_data3f(right, 0.02f, bottom + _card_border_size); - vertex.add_data3f(right, 0.02f, bottom); + vertex.add_data3(right - _card_border_size, 0.02, bottom); + vertex.add_data3(right, 0.02, bottom + _card_border_size); + vertex.add_data3(right, 0.02, bottom); - texcoord.add_data2f(0.0f, 1.0f); //1 - texcoord.add_data2f(0.0f, 1.0f - _card_border_uv_portion); //2 - texcoord.add_data2f(0.0f + _card_border_uv_portion, 1.0f); //3 - texcoord.add_data2f(0.0f + _card_border_uv_portion, + texcoord.add_data2(0.0f, 1.0f); //1 + texcoord.add_data2(0.0f, 1.0f - _card_border_uv_portion); //2 + texcoord.add_data2(0.0f + _card_border_uv_portion, 1.0f); //3 + texcoord.add_data2(0.0f + _card_border_uv_portion, 1.0f - _card_border_uv_portion); //4 - texcoord.add_data2f(1.0f -_card_border_uv_portion, 1.0f); //5 - texcoord.add_data2f(1.0f -_card_border_uv_portion, + texcoord.add_data2(1.0f -_card_border_uv_portion, 1.0f); //5 + texcoord.add_data2(1.0f -_card_border_uv_portion, 1.0f - _card_border_uv_portion); //6 - texcoord.add_data2f(1.0f, 1.0f); //7 - texcoord.add_data2f(1.0f, 1.0f - _card_border_uv_portion); //8 + texcoord.add_data2(1.0f, 1.0f); //7 + texcoord.add_data2(1.0f, 1.0f - _card_border_uv_portion); //8 - texcoord.add_data2f(0.0f, _card_border_uv_portion); //9 - texcoord.add_data2f(0.0f, 0.0f); //10 - texcoord.add_data2f(_card_border_uv_portion, _card_border_uv_portion); //11 - texcoord.add_data2f(_card_border_uv_portion, 0.0f); //12 + texcoord.add_data2(0.0f, _card_border_uv_portion); //9 + texcoord.add_data2(0.0f, 0.0f); //10 + texcoord.add_data2(_card_border_uv_portion, _card_border_uv_portion); //11 + texcoord.add_data2(_card_border_uv_portion, 0.0f); //12 - texcoord.add_data2f(1.0f - _card_border_uv_portion, _card_border_uv_portion);//13 - texcoord.add_data2f(1.0f - _card_border_uv_portion, 0.0f);//14 - texcoord.add_data2f(1.0f, _card_border_uv_portion);//15 - texcoord.add_data2f(1.0f, 0.0f);//16 + texcoord.add_data2(1.0f - _card_border_uv_portion, _card_border_uv_portion);//13 + texcoord.add_data2(1.0f - _card_border_uv_portion, 0.0f);//14 + texcoord.add_data2(1.0f, _card_border_uv_portion);//15 + texcoord.add_data2(1.0f, 0.0f);//16 PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 9d879740ad..38e21b3ef9 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -68,7 +68,7 @@ PUBLISHED: FF_dynamic_merge = 0x0008, }; - INLINE float get_line_height() const; + INLINE PN_stdfloat get_line_height() const; INLINE void set_max_rows(int max_rows); INLINE void clear_max_rows(); @@ -76,55 +76,55 @@ PUBLISHED: INLINE int get_max_rows() const; INLINE bool has_overflow() const; - INLINE void set_frame_color(float r, float g, float b, float a); - INLINE void set_frame_color(const Colorf &frame_color); - INLINE Colorf get_frame_color() const; + INLINE void set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_frame_color(const LColor &frame_color); + INLINE LColor get_frame_color() const; - INLINE void set_card_border(float size, float uv_portion); + INLINE void set_card_border(PN_stdfloat size, PN_stdfloat uv_portion); INLINE void clear_card_border(); - INLINE float get_card_border_size() const; - INLINE float get_card_border_uv_portion() const; + INLINE PN_stdfloat get_card_border_size() const; + INLINE PN_stdfloat get_card_border_uv_portion() const; INLINE bool has_card_border() const; - INLINE void set_card_color(float r, float g, float b, float a); - INLINE void set_card_color(const Colorf &card_color); - INLINE Colorf get_card_color() const; + INLINE void set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_card_color(const LColor &card_color); + INLINE LColor get_card_color() const; INLINE void set_card_texture(Texture *card_texture); INLINE void clear_card_texture(); INLINE bool has_card_texture() const; INLINE Texture *get_card_texture() const; - INLINE void set_frame_as_margin(float left, float right, - float bottom, float top); - INLINE void set_frame_actual(float left, float right, - float bottom, float top); + INLINE void set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_frame_actual(PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top); INLINE void clear_frame(); INLINE bool has_frame() const; INLINE bool is_frame_as_margin() const; - INLINE LVecBase4f get_frame_as_set() const; - INLINE LVecBase4f get_frame_actual() const; + INLINE LVecBase4 get_frame_as_set() const; + INLINE LVecBase4 get_frame_actual() const; - INLINE void set_frame_line_width(float line_width); - INLINE float get_frame_line_width() const; + INLINE void set_frame_line_width(PN_stdfloat line_width); + INLINE PN_stdfloat get_frame_line_width() const; INLINE void set_frame_corners(bool corners); INLINE bool get_frame_corners() const; - INLINE void set_card_as_margin(float left, float right, - float bottom, float top); - INLINE void set_card_actual(float left, float right, - float bottom, float top); + INLINE void set_card_as_margin(PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_card_actual(PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top); INLINE void set_card_decal(bool card_decal); INLINE void clear_card(); INLINE bool has_card() const; INLINE bool get_card_decal() const; INLINE bool is_card_as_margin() const; - INLINE LVecBase4f get_card_as_set() const; - INLINE LVecBase4f get_card_actual() const; - INLINE LVecBase4f get_card_transformed() const; + INLINE LVecBase4 get_card_as_set() const; + INLINE LVecBase4 get_card_actual() const; + INLINE LVecBase4 get_card_transformed() const; - INLINE void set_transform(const LMatrix4f &transform); - INLINE LMatrix4f get_transform() const; + INLINE void set_transform(const LMatrix4 &transform); + INLINE LMatrix4 get_transform() const; INLINE void set_coordinate_system(CoordinateSystem cs); INLINE CoordinateSystem get_coordinate_system() const; @@ -145,31 +145,31 @@ PUBLISHED: INLINE void set_small_caps(bool small_caps); INLINE void clear_small_caps(); - INLINE void set_small_caps_scale(float small_caps_scale); + INLINE void set_small_caps_scale(PN_stdfloat small_caps_scale); INLINE void clear_small_caps_scale(); - INLINE void set_slant(float slant); + INLINE void set_slant(PN_stdfloat slant); INLINE void clear_slant(); INLINE void set_align(Alignment align_type); INLINE void clear_align(); - INLINE void set_indent(float indent); + INLINE void set_indent(PN_stdfloat indent); INLINE void clear_indent(); - INLINE void set_wordwrap(float wordwrap); + INLINE void set_wordwrap(PN_stdfloat wordwrap); INLINE void clear_wordwrap(); - INLINE void set_text_color(float r, float g, float b, float a); - INLINE void set_text_color(const Colorf &text_color); + INLINE void set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_text_color(const LColor &text_color); INLINE void clear_text_color(); - INLINE void set_shadow_color(float r, float g, float b, float a); - INLINE void set_shadow_color(const Colorf &shadow_color); + INLINE void set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_shadow_color(const LColor &shadow_color); INLINE void clear_shadow_color(); - INLINE void set_shadow(float xoffset, float yoffset); - INLINE void set_shadow(const LVecBase2f &shadow_offset); + INLINE void set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset); + INLINE void set_shadow(const LVecBase2 &shadow_offset); INLINE void clear_shadow(); INLINE void set_bin(const string &bin); @@ -178,13 +178,13 @@ PUBLISHED: INLINE int set_draw_order(int draw_order); INLINE void clear_draw_order(); - INLINE void set_tab_width(float tab_width); + INLINE void set_tab_width(PN_stdfloat tab_width); INLINE void clear_tab_width(); - INLINE void set_glyph_scale(float glyph_scale); + INLINE void set_glyph_scale(PN_stdfloat glyph_scale); INLINE void clear_glyph_scale(); - INLINE void set_glyph_shift(float glyph_shift); + INLINE void set_glyph_shift(PN_stdfloat glyph_shift); INLINE void clear_glyph_shift(); // These methods are inherited from TextEncoder, but we override @@ -202,8 +202,8 @@ PUBLISHED: // These methods calculate the width of a single character or a line // of text in the current font. - float calc_width(wchar_t character) const; - INLINE float calc_width(const string &line) const; + PN_stdfloat calc_width(wchar_t character) const; + INLINE PN_stdfloat calc_width(const string &line) const; bool has_exact_character(wchar_t character) const; bool has_character(wchar_t character) const; @@ -214,22 +214,22 @@ PUBLISHED: INLINE void append_wtext(const wstring &text); INLINE wstring get_wordwrapped_wtext() const; - float calc_width(const wstring &line) const; + PN_stdfloat calc_width(const wstring &line) const; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; // The following functions return information about the text that // was last built (and is currently visible). - INLINE float get_left() const; - INLINE float get_right() const; - INLINE float get_bottom() const; - INLINE float get_top() const; - INLINE float get_height() const; - INLINE float get_width() const; + INLINE PN_stdfloat get_left() const; + INLINE PN_stdfloat get_right() const; + INLINE PN_stdfloat get_bottom() const; + INLINE PN_stdfloat get_top() const; + INLINE PN_stdfloat get_height() const; + INLINE PN_stdfloat get_width() const; - INLINE LPoint3f get_upper_left_3d() const; - INLINE LPoint3f get_lower_right_3d() const; + INLINE LPoint3 get_upper_left_3d() const; + INLINE LPoint3 get_lower_right_3d() const; INLINE int get_num_rows() const; @@ -246,7 +246,7 @@ public: int attrib_types, GeomTransformer &transformer); virtual CPT(TransformState) - calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point, + calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const; @@ -281,8 +281,8 @@ private: PT(PandaNode) _internal_geom; PT(Texture) _card_texture; - Colorf _frame_color; - Colorf _card_color; + LColor _frame_color; + LColor _card_color; enum Flags { F_has_frame = 0x0001, @@ -304,20 +304,20 @@ private: GeomEnums::UsageHint _usage_hint; int _flatten_flags; bool _dynamic_merge; - float _frame_width; - float _card_border_size; - float _card_border_uv_portion; + PN_stdfloat _frame_width; + PN_stdfloat _card_border_size; + PN_stdfloat _card_border_uv_portion; - LVector2f _frame_ul, _frame_lr; - LVector2f _card_ul, _card_lr; + LVector2 _frame_ul, _frame_lr; + LVector2 _card_ul, _card_lr; - LMatrix4f _transform; + LMatrix4 _transform; CoordinateSystem _coordinate_system; - LPoint3f _ul3d, _lr3d; + LPoint3 _ul3d, _lr3d; // Returned from TextAssembler: - LVector2f _text_ul, _text_lr; + LVector2 _text_ul, _text_lr; int _num_rows; wstring _wordwrapped_wtext; diff --git a/panda/src/text/textProperties.I b/panda/src/text/textProperties.I index 179482e4db..05c3521b05 100644 --- a/panda/src/text/textProperties.I +++ b/panda/src/text/textProperties.I @@ -176,7 +176,7 @@ get_small_caps() const { // this will be a number less than one. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_small_caps_scale(float small_caps_scale) { +set_small_caps_scale(PN_stdfloat small_caps_scale) { _small_caps_scale = small_caps_scale; } @@ -209,7 +209,7 @@ has_small_caps_scale() const { // flag is in effect. See set_small_caps() and // set_small_caps_scale(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_small_caps_scale() const { return _small_caps_scale; } @@ -221,7 +221,7 @@ get_small_caps_scale() const { // right. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_slant(float slant) { +set_slant(PN_stdfloat slant) { _slant = slant; _specified |= F_has_slant; } @@ -253,7 +253,7 @@ has_slant() const { // Description: Returns the factor by which the text is specified to // slant to the right. //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_slant() const { return _slant; } @@ -312,7 +312,7 @@ get_underscore() const { // set_underscore(). //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_underscore_height(float underscore_height) { +set_underscore_height(PN_stdfloat underscore_height) { _underscore_height = underscore_height; _specified |= F_has_underscore_height; } @@ -344,7 +344,7 @@ has_underscore_height() const { // Description: Returns the vertical height of the underscore; see // set_underscore_height(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_underscore_height() const { return has_underscore_height() ? _underscore_height : text_default_underscore_height; } @@ -400,7 +400,7 @@ get_align() const { // thought of as a left margin. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_indent(float indent) { +set_indent(PN_stdfloat indent) { _indent_width = indent; _specified |= F_has_indent; } @@ -432,7 +432,7 @@ has_indent() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_indent() const { return _indent_width; } @@ -445,7 +445,7 @@ get_indent() const { // as a right margin or margin width. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_wordwrap(float wordwrap) { +set_wordwrap(PN_stdfloat wordwrap) { _wordwrap_width = wordwrap; _specified |= F_has_wordwrap; } @@ -477,7 +477,7 @@ has_wordwrap() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_wordwrap() const { return _wordwrap_width; } @@ -537,8 +537,8 @@ get_preserve_trailing_whitespace() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_text_color(float r, float g, float b, float a) { - set_text_color(Colorf(r, g, b, a)); +set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_text_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -547,7 +547,7 @@ set_text_color(float r, float g, float b, float a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_text_color(const Colorf &text_color) { +set_text_color(const LColor &text_color) { _text_color = text_color; _specified |= F_has_text_color; } @@ -579,7 +579,7 @@ has_text_color() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE Colorf TextProperties:: +INLINE LColor TextProperties:: get_text_color() const { return _text_color; } @@ -590,8 +590,8 @@ get_text_color() const { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_shadow_color(float r, float g, float b, float a) { - set_shadow_color(Colorf(r, g, b, a)); +set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { + set_shadow_color(LColor(r, g, b, a)); } //////////////////////////////////////////////////////////////////// @@ -600,7 +600,7 @@ set_shadow_color(float r, float g, float b, float a) { // Description: //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_shadow_color(const Colorf &shadow_color) { +set_shadow_color(const LColor &shadow_color) { _shadow_color = shadow_color; _specified |= F_has_shadow_color; } @@ -631,7 +631,7 @@ has_shadow_color() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE Colorf TextProperties:: +INLINE LColor TextProperties:: get_shadow_color() const { return _shadow_color; } @@ -644,8 +644,8 @@ get_shadow_color() const { // offsetting it slightly behind the first. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_shadow(float xoffset, float yoffset) { - set_shadow(LVecBase2f(xoffset, yoffset)); +set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) { + set_shadow(LVecBase2(xoffset, yoffset)); } //////////////////////////////////////////////////////////////////// @@ -656,7 +656,7 @@ set_shadow(float xoffset, float yoffset) { // offsetting it slightly behind the first. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_shadow(const LVecBase2f &shadow_offset) { +set_shadow(const LVecBase2 &shadow_offset) { _shadow_offset = shadow_offset; _specified |= F_has_shadow; } @@ -690,7 +690,7 @@ has_shadow() const { // set_shadow(). It is an error to call this if // has_shadow() is false. //////////////////////////////////////////////////////////////////// -INLINE LVector2f TextProperties:: +INLINE LVector2 TextProperties:: get_shadow() const { return _shadow_offset; } @@ -810,7 +810,7 @@ get_draw_order() const { // horizontal position to the next tab stop. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_tab_width(float tab_width) { +set_tab_width(PN_stdfloat tab_width) { _tab_width = tab_width; _specified |= F_has_tab_width; } @@ -841,7 +841,7 @@ has_tab_width() const { // Access: Published // Description: Returns the width set via set_tab_width(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_tab_width() const { return _tab_width; } @@ -864,7 +864,7 @@ get_tab_width() const { // and is not cumulative. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_glyph_scale(float glyph_scale) { +set_glyph_scale(PN_stdfloat glyph_scale) { _glyph_scale = glyph_scale; _specified |= F_has_glyph_scale; } @@ -896,7 +896,7 @@ has_glyph_scale() const { // Description: Returns the scale factor of each letter as specified // by set_glyph_scale(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_glyph_scale() const { return _glyph_scale; } @@ -910,7 +910,7 @@ get_glyph_scale() const { // superscripting or subscripting. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_glyph_shift(float glyph_shift) { +set_glyph_shift(PN_stdfloat glyph_shift) { _glyph_shift = glyph_shift; _specified |= F_has_glyph_shift; } @@ -942,7 +942,7 @@ has_glyph_shift() const { // Description: Returns the vertical shift of each letter as // specified by set_glyph_shift(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_glyph_shift() const { return _glyph_shift; } @@ -959,7 +959,7 @@ get_glyph_shift() const { // which is cumulative. //////////////////////////////////////////////////////////////////// INLINE void TextProperties:: -set_text_scale(float text_scale) { +set_text_scale(PN_stdfloat text_scale) { _text_scale = text_scale; _specified |= F_has_text_scale; } @@ -991,7 +991,7 @@ has_text_scale() const { // Description: Returns the scale factor of the text as specified // by set_text_scale(). //////////////////////////////////////////////////////////////////// -INLINE float TextProperties:: +INLINE PN_stdfloat TextProperties:: get_text_scale() const { return _text_scale; } diff --git a/panda/src/text/textProperties.h b/panda/src/text/textProperties.h index 3ecf7d76bd..68710bbbba 100644 --- a/panda/src/text/textProperties.h +++ b/panda/src/text/textProperties.h @@ -77,63 +77,63 @@ PUBLISHED: INLINE bool has_small_caps() const; INLINE bool get_small_caps() const; - INLINE void set_small_caps_scale(float small_caps_scale); + INLINE void set_small_caps_scale(PN_stdfloat small_caps_scale); INLINE void clear_small_caps_scale(); INLINE bool has_small_caps_scale() const; - INLINE float get_small_caps_scale() const; + INLINE PN_stdfloat get_small_caps_scale() const; - INLINE void set_slant(float slant); + INLINE void set_slant(PN_stdfloat slant); INLINE void clear_slant(); INLINE bool has_slant() const; - INLINE float get_slant() const; + INLINE PN_stdfloat get_slant() const; INLINE void set_underscore(bool underscore); INLINE void clear_underscore(); INLINE bool has_underscore() const; INLINE bool get_underscore() const; - INLINE void set_underscore_height(float underscore_height); + INLINE void set_underscore_height(PN_stdfloat underscore_height); INLINE void clear_underscore_height(); INLINE bool has_underscore_height() const; - INLINE float get_underscore_height() const; + INLINE PN_stdfloat get_underscore_height() const; INLINE void set_align(Alignment align_type); INLINE void clear_align(); INLINE bool has_align() const; INLINE Alignment get_align() const; - INLINE void set_indent(float indent); + INLINE void set_indent(PN_stdfloat indent); INLINE void clear_indent(); INLINE bool has_indent() const; - INLINE float get_indent() const; + INLINE PN_stdfloat get_indent() const; - INLINE void set_wordwrap(float wordwrap); + INLINE void set_wordwrap(PN_stdfloat wordwrap); INLINE void clear_wordwrap(); INLINE bool has_wordwrap() const; - INLINE float get_wordwrap() const; + INLINE PN_stdfloat get_wordwrap() const; INLINE void set_preserve_trailing_whitespace(bool preserve_trailing_whitespace); INLINE void clear_preserve_trailing_whitespace(); INLINE bool has_preserve_trailing_whitespace() const; INLINE bool get_preserve_trailing_whitespace() const; - INLINE void set_text_color(float r, float g, float b, float a); - INLINE void set_text_color(const Colorf &text_color); + INLINE void set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_text_color(const LColor &text_color); INLINE void clear_text_color(); INLINE bool has_text_color() const; - INLINE Colorf get_text_color() const; + INLINE LColor get_text_color() const; - INLINE void set_shadow_color(float r, float g, float b, float a); - INLINE void set_shadow_color(const Colorf &shadow_color); + INLINE void set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a); + INLINE void set_shadow_color(const LColor &shadow_color); INLINE void clear_shadow_color(); INLINE bool has_shadow_color() const; - INLINE Colorf get_shadow_color() const; + INLINE LColor get_shadow_color() const; - INLINE void set_shadow(float xoffset, float yoffset); - INLINE void set_shadow(const LVecBase2f &shadow_offset); + INLINE void set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset); + INLINE void set_shadow(const LVecBase2 &shadow_offset); INLINE void clear_shadow(); INLINE bool has_shadow() const; - INLINE LVector2f get_shadow() const; + INLINE LVector2 get_shadow() const; INLINE void set_bin(const string &bin); INLINE void clear_bin(); @@ -145,25 +145,25 @@ PUBLISHED: INLINE bool has_draw_order() const; INLINE int get_draw_order() const; - INLINE void set_tab_width(float tab_width); + INLINE void set_tab_width(PN_stdfloat tab_width); INLINE void clear_tab_width(); INLINE bool has_tab_width() const; - INLINE float get_tab_width() const; + INLINE PN_stdfloat get_tab_width() const; - INLINE void set_glyph_scale(float glyph_scale); + INLINE void set_glyph_scale(PN_stdfloat glyph_scale); INLINE void clear_glyph_scale(); INLINE bool has_glyph_scale() const; - INLINE float get_glyph_scale() const; + INLINE PN_stdfloat get_glyph_scale() const; - INLINE void set_glyph_shift(float glyph_shift); + INLINE void set_glyph_shift(PN_stdfloat glyph_shift); INLINE void clear_glyph_shift(); INLINE bool has_glyph_shift() const; - INLINE float get_glyph_shift() const; + INLINE PN_stdfloat get_glyph_shift() const; - INLINE void set_text_scale(float text_scale); + INLINE void set_text_scale(PN_stdfloat text_scale); INLINE void clear_text_scale(); INLINE bool has_text_scale() const; - INLINE float get_text_scale() const; + INLINE PN_stdfloat get_text_scale() const; void add_properties(const TextProperties &other); @@ -198,23 +198,23 @@ private: PT(TextFont) _font; bool _small_caps; - float _small_caps_scale; - float _slant; + PN_stdfloat _small_caps_scale; + PN_stdfloat _slant; bool _underscore; - float _underscore_height; + PN_stdfloat _underscore_height; Alignment _align; - float _indent_width; - float _wordwrap_width; + PN_stdfloat _indent_width; + PN_stdfloat _wordwrap_width; bool _preserve_trailing_whitespace; - Colorf _text_color; - Colorf _shadow_color; - LVector2f _shadow_offset; + LColor _text_color; + LColor _shadow_color; + LVector2 _shadow_offset; string _bin; int _draw_order; - float _tab_width; - float _glyph_scale; - float _glyph_shift; - float _text_scale; + PN_stdfloat _tab_width; + PN_stdfloat _glyph_scale; + PN_stdfloat _glyph_shift; + PN_stdfloat _text_scale; static PT(TextFont) _default_font; static bool _loaded_default_font; diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index c4ac21a3fd..1ca6b0ad3d 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -144,14 +144,14 @@ set_graphic(const string &name, const TextGraphic &graphic) { //////////////////////////////////////////////////////////////////// void TextPropertiesManager:: set_graphic(const string &name, const NodePath &model) { - LPoint3f min_point, max_point; + LPoint3 min_point, max_point; model.calc_tight_bounds(min_point, max_point); TextGraphic graphic(model, - min_point.dot(LVector3f::right()), - max_point.dot(LVector3f::right()), - min_point.dot(LVector3f::up()), - max_point.dot(LVector3f::up())); + min_point.dot(LVector3::right()), + max_point.dot(LVector3::right()), + min_point.dot(LVector3::up()), + max_point.dot(LVector3::up())); _graphics[name] = graphic; } diff --git a/panda/src/tform/driveInterface.I b/panda/src/tform/driveInterface.I index d23d39a1e3..9155b596b4 100644 --- a/panda/src/tform/driveInterface.I +++ b/panda/src/tform/driveInterface.I @@ -21,7 +21,7 @@ // (e.g. feet) per second. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_forward_speed(float speed) { +set_forward_speed(PN_stdfloat speed) { _forward_speed = speed; } @@ -32,7 +32,7 @@ set_forward_speed(float speed) { // mouse is at the very top of the window. This is in // units (e.g. feet) per second. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_forward_speed() const { return _forward_speed; } @@ -45,7 +45,7 @@ get_forward_speed() const { // units (e.g. feet) per second. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_reverse_speed(float speed) { +set_reverse_speed(PN_stdfloat speed) { _reverse_speed = speed; } @@ -56,7 +56,7 @@ set_reverse_speed(float speed) { // mouse is at the very bottom of the window. This is // in units (e.g. feet) per second. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_reverse_speed() const { return _reverse_speed; } @@ -69,7 +69,7 @@ get_reverse_speed() const { // the window. This is in degrees per second. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_rotate_speed(float speed) { +set_rotate_speed(PN_stdfloat speed) { _rotate_speed = speed; } @@ -80,7 +80,7 @@ set_rotate_speed(float speed) { // left or right, when the mouse is at the very edge of // the window. This is in degrees per second. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_rotate_speed() const { return _rotate_speed; } @@ -96,7 +96,7 @@ get_rotate_speed() const { // large as half the screen. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_vertical_dead_zone(float speed) { +set_vertical_dead_zone(PN_stdfloat speed) { _vertical_dead_zone = speed; } @@ -110,7 +110,7 @@ set_vertical_dead_zone(float speed) { // the window height, so 0.5 will set a dead zone as // large as half the screen. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_vertical_dead_zone() const { return _vertical_dead_zone; } @@ -126,7 +126,7 @@ get_vertical_dead_zone() const { // large as half the screen. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_horizontal_dead_zone(float speed) { +set_horizontal_dead_zone(PN_stdfloat speed) { _horizontal_dead_zone = speed; } @@ -140,7 +140,7 @@ set_horizontal_dead_zone(float speed) { // the window width, so 0.5 will set a dead zone as // large as half the screen. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_horizontal_dead_zone() const { return _horizontal_dead_zone; } @@ -153,7 +153,7 @@ get_horizontal_dead_zone() const { // time it registers full forward or backward motion. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_vertical_ramp_up_time(float ramp_up_time) { +set_vertical_ramp_up_time(PN_stdfloat ramp_up_time) { _vertical_ramp_up_time = ramp_up_time; } @@ -165,7 +165,7 @@ set_vertical_ramp_up_time(float ramp_up_time) { // and the time it registers full forward or backward // motion. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_vertical_ramp_up_time() const { return _vertical_ramp_up_time; } @@ -178,7 +178,7 @@ get_vertical_ramp_up_time() const { // time it registers no motion. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_vertical_ramp_down_time(float ramp_down_time) { +set_vertical_ramp_down_time(PN_stdfloat ramp_down_time) { _vertical_ramp_down_time = ramp_down_time; } @@ -189,7 +189,7 @@ set_vertical_ramp_down_time(float ramp_down_time) { // between the time an up or down arrow key is released // and the time it registers no motion. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_vertical_ramp_down_time() const { return _vertical_ramp_down_time; } @@ -202,7 +202,7 @@ get_vertical_ramp_down_time() const { // time it registers full rotation. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_horizontal_ramp_up_time(float ramp_up_time) { +set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time) { _horizontal_ramp_up_time = ramp_up_time; } @@ -213,7 +213,7 @@ set_horizontal_ramp_up_time(float ramp_up_time) { // between the time a left or right arrow key is pressed // and the time it registers full rotation. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_horizontal_ramp_up_time() const { return _horizontal_ramp_up_time; } @@ -226,7 +226,7 @@ get_horizontal_ramp_up_time() const { // time it registers no motion. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_horizontal_ramp_down_time(float ramp_down_time) { +set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time) { _horizontal_ramp_down_time = ramp_down_time; } @@ -237,7 +237,7 @@ set_horizontal_ramp_down_time(float ramp_down_time) { // between the time a left or right arrow key is released // and the time it registers no motion. //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_horizontal_ramp_down_time() const { return _horizontal_ramp_down_time; } @@ -247,7 +247,7 @@ get_horizontal_ramp_down_time() const { // Access: Published // Description: Returns the speed of the previous update in units/sec //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_speed() const { return _speed; } @@ -257,7 +257,7 @@ get_speed() const { // Access: Published // Description: Returns the rot_speed of the previous update in units/sec //////////////////////////////////////////////////////////////////// -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_rot_speed() const { return _rot_speed; } @@ -267,22 +267,22 @@ get_rot_speed() const { // Access: Published // Description: Returns the driver's position. //////////////////////////////////////////////////////////////////// -INLINE const LPoint3f &DriveInterface:: +INLINE const LPoint3 &DriveInterface:: get_pos() const { return _xyz; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_x() const { return _xyz[0]; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_y() const { return _xyz[1]; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_z() const { return _xyz[2]; } @@ -294,27 +294,27 @@ get_z() const { // Description: Directly sets the driver's position. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_pos(const LVecBase3f &vec) { +set_pos(const LVecBase3 &vec) { _xyz = vec; } INLINE void DriveInterface:: -set_pos(float x, float y, float z) { +set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _xyz.set(x, y, z); } INLINE void DriveInterface:: -set_x(float x) { +set_x(PN_stdfloat x) { _xyz[0] = x; } INLINE void DriveInterface:: -set_y(float y) { +set_y(PN_stdfloat y) { _xyz[1] = y; } INLINE void DriveInterface:: -set_z(float z) { +set_z(PN_stdfloat z) { _xyz[2] = z; } @@ -324,22 +324,22 @@ set_z(float z) { // Access: Published // Description: Returns the driver's orientation. //////////////////////////////////////////////////////////////////// -INLINE const LVecBase3f &DriveInterface:: +INLINE const LVecBase3 &DriveInterface:: get_hpr() const { return _hpr; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_h() const { return _hpr[0]; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_p() const { return _hpr[1]; } -INLINE float DriveInterface:: +INLINE PN_stdfloat DriveInterface:: get_r() const { return _hpr[2]; } @@ -351,29 +351,29 @@ get_r() const { // Description: Directly sets the driver's orientation. //////////////////////////////////////////////////////////////////// INLINE void DriveInterface:: -set_hpr(const LVecBase3f &hpr) { +set_hpr(const LVecBase3 &hpr) { set_hpr(hpr[0], hpr[1], hpr[2]); } INLINE void DriveInterface:: -set_hpr(float h, float p, float r) { +set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_h(h); set_p(p); set_r(r); } INLINE void DriveInterface:: -set_h(float h) { +set_h(PN_stdfloat h) { _hpr[0] = _hpr_quantize * floor(h / _hpr_quantize + 0.5f); } INLINE void DriveInterface:: -set_p(float p) { +set_p(PN_stdfloat p) { _hpr[1] = _hpr_quantize * floor(p / _hpr_quantize + 0.5f); } INLINE void DriveInterface:: -set_r(float r) { +set_r(PN_stdfloat r) { _hpr[2] = _hpr_quantize * floor(r / _hpr_quantize + 0.5f); } diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index e8a637b45a..278bccde59 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -27,7 +27,7 @@ #include "dataGraphTraverser.h" TypeHandle DriveInterface::_type_handle; -const float DriveInterface::_hpr_quantize = 0.001; +const PN_stdfloat DriveInterface::_hpr_quantize = 0.001; DriveInterface::KeyHeld:: KeyHeld() { @@ -37,8 +37,8 @@ KeyHeld() { _effect_at_change = 0.0f; } -float DriveInterface::KeyHeld:: -get_effect(float ramp_up_time, float ramp_down_time) { +PN_stdfloat DriveInterface::KeyHeld:: +get_effect(PN_stdfloat ramp_up_time, PN_stdfloat ramp_down_time) { double elapsed = ClockObject::get_global_clock()->get_frame_time() - _changed_time; if (_down) { // We are currently holding down the key. That means we base our @@ -47,8 +47,8 @@ get_effect(float ramp_up_time, float ramp_down_time) { _effect = 1.0f; } else { - float change = elapsed / ramp_up_time; - _effect = min(_effect_at_change + change, 1.0f); + PN_stdfloat change = elapsed / ramp_up_time; + _effect = min(_effect_at_change + change, (PN_stdfloat)1.0); } } else { // We are *not* currently holding down the key. That means we @@ -57,8 +57,8 @@ get_effect(float ramp_up_time, float ramp_down_time) { _effect = 0.0f; } else { - float change = elapsed / ramp_down_time; - _effect = max(_effect_at_change - change, 0.0f); + PN_stdfloat change = elapsed / ramp_down_time; + _effect = max(_effect_at_change - change, (PN_stdfloat)0.0); } } return _effect; @@ -109,7 +109,7 @@ DriveInterface(const string &name) : _velocity_output = define_output("velocity", EventStoreVec3::get_class_type()); _transform = TransformState::make_identity(); - _velocity = new EventStoreVec3(LVector3f::zero()); + _velocity = new EventStoreVec3(LVector3::zero()); _forward_speed = drive_forward_speed; _reverse_speed = drive_reverse_speed; @@ -172,7 +172,7 @@ reset() { // will be removed soon. //////////////////////////////////////////////////////////////////// void DriveInterface:: -set_force_roll(float) { +set_force_roll(PN_stdfloat) { } //////////////////////////////////////////////////////////////////// @@ -181,8 +181,8 @@ set_force_roll(float) { // Description: Stores the indicated transform in the DriveInterface. //////////////////////////////////////////////////////////////////// void DriveInterface:: -set_mat(const LMatrix4f &mat) { - LVecBase3f scale, shear; +set_mat(const LMatrix4 &mat) { + LVecBase3 scale, shear; decompose_matrix(mat, scale, shear, _hpr, _xyz); } @@ -191,11 +191,11 @@ set_mat(const LMatrix4f &mat) { // Access: Published // Description: Returns the current transform. //////////////////////////////////////////////////////////////////// -const LMatrix4f &DriveInterface:: +const LMatrix4 &DriveInterface:: get_mat() { compose_matrix(_mat, - LVecBase3f(1.0f, 1.0f, 1.0f), - LVecBase3f(0.0f, 0.0f, 0.0f), + LVecBase3(1.0f, 1.0f, 1.0f), + LVecBase3(0.0f, 0.0f, 0.0f), _hpr, _xyz); return _mat; } @@ -249,13 +249,13 @@ apply(double x, double y, bool any_button) { // First, how fast are we moving? This is based on the mouse's // vertical position. - float dead_zone_top = _vertical_center + _vertical_dead_zone; - float dead_zone_bottom = _vertical_center - _vertical_dead_zone; + PN_stdfloat dead_zone_top = _vertical_center + _vertical_dead_zone; + PN_stdfloat dead_zone_bottom = _vertical_center - _vertical_dead_zone; if (y >= dead_zone_top) { // Motion is forward. Compute the throttle value: the ratio of // the mouse pointer within the range of vertical movement. - float throttle = + PN_stdfloat throttle = // double 1.0, not 1.0f, is required here to satisfy min() (min(y, 1.0) - dead_zone_top) / (1.0f - dead_zone_top); @@ -263,7 +263,7 @@ apply(double x, double y, bool any_button) { } else if (y <= dead_zone_bottom) { // Motion is backward. - float throttle = + PN_stdfloat throttle = (max(y, -1.0) - dead_zone_bottom) / (-1.0f - dead_zone_bottom); _speed = -throttle * _reverse_speed; @@ -271,21 +271,21 @@ apply(double x, double y, bool any_button) { // Now, what's our rotational velocity? This is based on the // mouse's horizontal position. - float dead_zone_right = _horizontal_center + _horizontal_dead_zone; - float dead_zone_left = _horizontal_center - _horizontal_dead_zone; + PN_stdfloat dead_zone_right = _horizontal_center + _horizontal_dead_zone; + PN_stdfloat dead_zone_left = _horizontal_center - _horizontal_dead_zone; if (x >= dead_zone_right) { // Rotation is to the right. Compute the throttle value: the // ratio of the mouse pointer within the range of horizontal // movement. - float throttle = + PN_stdfloat throttle = (min(x, 1.0) - dead_zone_right) / (1.0f - dead_zone_right); _rot_speed = throttle * _rotate_speed; } else if (x <= dead_zone_left) { // Rotation is to the left. - float throttle = + PN_stdfloat throttle = (max(x, -1.0) - dead_zone_left) / (-1.0f - dead_zone_left); _rot_speed = -throttle * _rotate_speed; @@ -296,7 +296,7 @@ apply(double x, double y, bool any_button) { // computation based on the arrow keys. // Which vertical arrow key changed state more recently? - float throttle; + PN_stdfloat throttle; if (_up_arrow < _down_arrow) { throttle = _up_arrow.get_effect(_vertical_ramp_up_time, @@ -334,8 +334,8 @@ apply(double x, double y, bool any_button) { } // Now how far did we move based on the amount of time elapsed? - float distance = ClockObject::get_global_clock()->get_dt() * _speed; - float rotation = ClockObject::get_global_clock()->get_dt() * _rot_speed; + PN_stdfloat distance = ClockObject::get_global_clock()->get_dt() * _speed; + PN_stdfloat rotation = ClockObject::get_global_clock()->get_dt() * _rot_speed; if (_stop_this_frame) { distance = 0.0f; rotation = 0.0f; @@ -346,12 +346,12 @@ apply(double x, double y, bool any_button) { // rot_mat is the rotation matrix corresponding to our previous // heading. - LMatrix3f rot_mat; - rot_mat.set_rotate_mat_normaxis(_hpr[0], LVector3f::up()); + LMatrix3 rot_mat; + rot_mat.set_rotate_mat_normaxis(_hpr[0], LVector3::up()); // Take a step in the direction of our previous heading. - _vel = LVector3f::forward() * distance; - LVector3f step = (_vel * rot_mat); + _vel = LVector3::forward() * distance; + LVector3 step = (_vel * rot_mat); // To prevent upward drift due to numerical errors, force the // vertical component of our step to zero (it should be pretty near @@ -404,7 +404,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (required_buttons_match && input.has_data(_xy_input)) { const EventStoreVec2 *xy; DCAST_INTO_V(xy, input.get_data(_xy_input).get_ptr()); - const LVecBase2f &p = xy->get_value(); + const LVecBase2 &p = xy->get_value(); x = p[0]; y = p[1]; diff --git a/panda/src/tform/driveInterface.h b/panda/src/tform/driveInterface.h index a2fadd6f32..b70d753d86 100644 --- a/panda/src/tform/driveInterface.h +++ b/panda/src/tform/driveInterface.h @@ -36,56 +36,56 @@ PUBLISHED: DriveInterface(const string &name = ""); ~DriveInterface(); - INLINE void set_forward_speed(float speed); - INLINE float get_forward_speed() const; - INLINE void set_reverse_speed(float speed); - INLINE float get_reverse_speed() const; - INLINE void set_rotate_speed(float speed); - INLINE float get_rotate_speed() const; - INLINE void set_vertical_dead_zone(float zone); - INLINE float get_vertical_dead_zone() const; - INLINE void set_horizontal_dead_zone(float zone); - INLINE float get_horizontal_dead_zone() const; + INLINE void set_forward_speed(PN_stdfloat speed); + INLINE PN_stdfloat get_forward_speed() const; + INLINE void set_reverse_speed(PN_stdfloat speed); + INLINE PN_stdfloat get_reverse_speed() const; + INLINE void set_rotate_speed(PN_stdfloat speed); + INLINE PN_stdfloat get_rotate_speed() const; + INLINE void set_vertical_dead_zone(PN_stdfloat zone); + INLINE PN_stdfloat get_vertical_dead_zone() const; + INLINE void set_horizontal_dead_zone(PN_stdfloat zone); + INLINE PN_stdfloat get_horizontal_dead_zone() const; - INLINE void set_vertical_ramp_up_time(float ramp_up_time); - INLINE float get_vertical_ramp_up_time() const; - INLINE void set_vertical_ramp_down_time(float ramp_down_time); - INLINE float get_vertical_ramp_down_time() const; - INLINE void set_horizontal_ramp_up_time(float ramp_up_time); - INLINE float get_horizontal_ramp_up_time() const; - INLINE void set_horizontal_ramp_down_time(float ramp_down_time); - INLINE float get_horizontal_ramp_down_time() const; + INLINE void set_vertical_ramp_up_time(PN_stdfloat ramp_up_time); + INLINE PN_stdfloat get_vertical_ramp_up_time() const; + INLINE void set_vertical_ramp_down_time(PN_stdfloat ramp_down_time); + INLINE PN_stdfloat get_vertical_ramp_down_time() const; + INLINE void set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time); + INLINE PN_stdfloat get_horizontal_ramp_up_time() const; + INLINE void set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time); + INLINE PN_stdfloat get_horizontal_ramp_down_time() const; - INLINE float get_speed() const; - INLINE float get_rot_speed() const; + INLINE PN_stdfloat get_speed() const; + INLINE PN_stdfloat get_rot_speed() const; void reset(); /// **** Translation **** - INLINE const LPoint3f &get_pos() const; - INLINE float get_x() const; - INLINE float get_y() const; - INLINE float get_z() const; - INLINE void set_pos(const LVecBase3f &vec); - INLINE void set_pos(float x, float y, float z); - INLINE void set_x(float x); - INLINE void set_y(float y); - INLINE void set_z(float z); + INLINE const LPoint3 &get_pos() const; + INLINE PN_stdfloat get_x() const; + INLINE PN_stdfloat get_y() const; + INLINE PN_stdfloat get_z() const; + INLINE void set_pos(const LVecBase3 &vec); + INLINE void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + INLINE void set_x(PN_stdfloat x); + INLINE void set_y(PN_stdfloat y); + INLINE void set_z(PN_stdfloat z); /// **** Rotation **** - INLINE const LVecBase3f &get_hpr() const; - INLINE float get_h() const; - INLINE float get_p() const; - INLINE float get_r() const; - INLINE void set_hpr(const LVecBase3f &hpr); - INLINE void set_hpr(float h, float p, float r); - INLINE void set_h(float h); - INLINE void set_p(float p); - INLINE void set_r(float r); + INLINE const LVecBase3 &get_hpr() const; + INLINE PN_stdfloat get_h() const; + INLINE PN_stdfloat get_p() const; + INLINE PN_stdfloat get_r() const; + INLINE void set_hpr(const LVecBase3 &hpr); + INLINE void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + INLINE void set_h(PN_stdfloat h); + INLINE void set_p(PN_stdfloat p); + INLINE void set_r(PN_stdfloat r); - void set_force_roll(float force_roll); + void set_force_roll(PN_stdfloat force_roll); INLINE void set_ignore_mouse(bool ignore_mouse); INLINE bool get_ignore_mouse() const; @@ -96,56 +96,56 @@ PUBLISHED: INLINE void set_stop_this_frame(bool stop_this_frame); INLINE bool get_stop_this_frame() const; - void set_mat(const LMatrix4f &mat); - const LMatrix4f &get_mat(); + void set_mat(const LMatrix4 &mat); + const LMatrix4 &get_mat(); void force_dgraph(); private: void apply(double x, double y, bool any_button); - float _forward_speed; // units / sec, mouse all the way up - float _reverse_speed; // units / sec, mouse all the way down - float _rotate_speed; // degrees / sec, mouse all the way over - float _vertical_dead_zone; // fraction of window size - float _horizontal_dead_zone; // fraction of window size - float _vertical_center; // window units, 0 = center, -1 = bottom, 1 = top - float _horizontal_center; // window units, 0 = center, -1 = left, 1 = right + PN_stdfloat _forward_speed; // units / sec, mouse all the way up + PN_stdfloat _reverse_speed; // units / sec, mouse all the way down + PN_stdfloat _rotate_speed; // degrees / sec, mouse all the way over + PN_stdfloat _vertical_dead_zone; // fraction of window size + PN_stdfloat _horizontal_dead_zone; // fraction of window size + PN_stdfloat _vertical_center; // window units, 0 = center, -1 = bottom, 1 = top + PN_stdfloat _horizontal_center; // window units, 0 = center, -1 = left, 1 = right // The time it takes to ramp up to full speed from a stop (or return // to a stop from full speed) when using the keyboard. - float _vertical_ramp_up_time; - float _vertical_ramp_down_time; - float _horizontal_ramp_up_time; - float _horizontal_ramp_down_time; + PN_stdfloat _vertical_ramp_up_time; + PN_stdfloat _vertical_ramp_down_time; + PN_stdfloat _horizontal_ramp_up_time; + PN_stdfloat _horizontal_ramp_down_time; - float _speed; // instantaneous units / sec - float _rot_speed; // instantaneous rotational units / sec + PN_stdfloat _speed; // instantaneous units / sec + PN_stdfloat _rot_speed; // instantaneous rotational units / sec - LPoint3f _xyz; - LVecBase3f _hpr; - LVector3f _vel; + LPoint3 _xyz; + LVecBase3 _hpr; + LVector3 _vel; bool _ignore_mouse; bool _force_mouse; bool _stop_this_frame; // This is only used to return a temporary value in get_mat(). - LMatrix4f _mat; + LMatrix4 _mat; // Remember which arrow keys are being held down and which aren't, // and at what point they last changed state. class KeyHeld { public: KeyHeld(); - float get_effect(float ramp_up_time, float ramp_down_time); + PN_stdfloat get_effect(PN_stdfloat ramp_up_time, PN_stdfloat ramp_down_time); void set_key(bool down); void clear(); bool operator < (const KeyHeld &other) const; - float _effect; + PN_stdfloat _effect; bool _down; double _changed_time; - float _effect_at_change; + PN_stdfloat _effect_at_change; }; KeyHeld _up_arrow, _down_arrow; KeyHeld _left_arrow, _right_arrow; @@ -174,7 +174,7 @@ private: // small meaningless perturbations of hpr that may get introduced // due to numerical inaccuracy as we compute relative orientations // in the show. - static const float _hpr_quantize; + static const PN_stdfloat _hpr_quantize; public: static TypeHandle get_class_type() { diff --git a/panda/src/tform/mouseSubregion.I b/panda/src/tform/mouseSubregion.I index 1ac2fb1a90..9989217f8e 100644 --- a/panda/src/tform/mouseSubregion.I +++ b/panda/src/tform/mouseSubregion.I @@ -20,7 +20,7 @@ // rectangle within the window. This number will be in // the range [0..1]. //////////////////////////////////////////////////////////////////// -float MouseSubregion:: +PN_stdfloat MouseSubregion:: get_left() const { return _l; } @@ -32,7 +32,7 @@ get_left() const { // rectangle within the window. This number will be in // the range [0..1]. //////////////////////////////////////////////////////////////////// -float MouseSubregion:: +PN_stdfloat MouseSubregion:: get_right() const { return _r; } @@ -44,7 +44,7 @@ get_right() const { // the rectangle within the window. This number will be // in the range [0..1]. //////////////////////////////////////////////////////////////////// -float MouseSubregion:: +PN_stdfloat MouseSubregion:: get_bottom() const { return _b; } @@ -56,7 +56,7 @@ get_bottom() const { // rectangle within the window. This number will be in // the range [0..1]. //////////////////////////////////////////////////////////////////// -float MouseSubregion:: +PN_stdfloat MouseSubregion:: get_top() const { return _t; } @@ -72,7 +72,7 @@ get_top() const { // whole window. //////////////////////////////////////////////////////////////////// void MouseSubregion:: -set_dimensions(float l, float r, float b, float t) { +set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { _l = l; _r = r; _b = b; @@ -81,8 +81,8 @@ set_dimensions(float l, float r, float b, float t) { _minx = l * 2.0f - 1.0f; _miny = b * 2.0f - 1.0f; - float maxx = r * 2.0f - 1.0f; - float maxy = t * 2.0f - 1.0f; + PN_stdfloat maxx = r * 2.0f - 1.0f; + PN_stdfloat maxy = t * 2.0f - 1.0f; _scalex = 2.0f / (maxx - _minx); _scaley = 2.0f / (maxy - _miny); diff --git a/panda/src/tform/mouseSubregion.cxx b/panda/src/tform/mouseSubregion.cxx index 98163787b5..e7ea085db3 100644 --- a/panda/src/tform/mouseSubregion.cxx +++ b/panda/src/tform/mouseSubregion.cxx @@ -36,9 +36,9 @@ MouseSubregion(const string &name) : _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); - _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _pixel_size = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _pixel_size = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); _button_events = new ButtonEventList; } @@ -72,10 +72,10 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (input.has_data(_xy_input)) { const EventStoreVec2 *xy; DCAST_INTO_V(xy, input.get_data(_xy_input).get_ptr()); - const LVecBase2f &p = xy->get_value(); + const LVecBase2 &p = xy->get_value(); // Scale the old value into the new range. - LVecBase2f n((p[0] - _minx) * _scalex - 1.0f, (p[1] - _miny) * _scaley - 1.0f); + LVecBase2 n((p[0] - _minx) * _scalex - 1.0f, (p[1] - _miny) * _scaley - 1.0f); // If the mouse is indeed within the display region, pass it down. if (n[0] >= -1.0f && n[0] <= 1.0f && @@ -88,12 +88,12 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (input.has_data(_pixel_size_input)) { const EventStoreVec2 *pixel_size; DCAST_INTO_V(pixel_size, input.get_data(_pixel_size_input).get_ptr()); - const LVecBase2f &s = pixel_size->get_value(); + const LVecBase2 &s = pixel_size->get_value(); - float xf = (1.0f + n[0]) * 0.5f * s[0]; - float yf = (1.0f - n[1]) * 0.5f * s[1]; + PN_stdfloat xf = (1.0f + n[0]) * 0.5f * s[0]; + PN_stdfloat yf = (1.0f - n[1]) * 0.5f * s[1]; - _pixel_xy->set_value(LPoint2f(xf, yf)); + _pixel_xy->set_value(LPoint2(xf, yf)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); } @@ -131,9 +131,9 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (input.has_data(_pixel_size_input)) { const EventStoreVec2 *pixel_size; DCAST_INTO_V(pixel_size, input.get_data(_pixel_size_input).get_ptr()); - const LVecBase2f &s = pixel_size->get_value(); + const LVecBase2 &s = pixel_size->get_value(); - LVecBase2f n(s[0] * (_r - _l), s[1] * (_t - _b)); + LVecBase2 n(s[0] * (_r - _l), s[1] * (_t - _b)); _pixel_size->set_value(n); output.set_data(_pixel_size_output, EventParameter(_pixel_size)); } diff --git a/panda/src/tform/mouseSubregion.h b/panda/src/tform/mouseSubregion.h index b53c959cb6..cad1da671d 100644 --- a/panda/src/tform/mouseSubregion.h +++ b/panda/src/tform/mouseSubregion.h @@ -39,11 +39,11 @@ PUBLISHED: MouseSubregion(const string &name); ~MouseSubregion(); - INLINE float get_left() const; - INLINE float get_right() const; - INLINE float get_bottom() const; - INLINE float get_top() const; - INLINE void set_dimensions(float l, float r, float b, float t); + INLINE PN_stdfloat get_left() const; + INLINE PN_stdfloat get_right() const; + INLINE PN_stdfloat get_bottom() const; + INLINE PN_stdfloat get_top() const; + INLINE void set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t); protected: // Inherited from DataNode @@ -52,13 +52,13 @@ protected: DataNodeTransmit &output); private: - float _l; - float _r; - float _b; - float _t; + PN_stdfloat _l; + PN_stdfloat _r; + PN_stdfloat _b; + PN_stdfloat _t; - float _minx, _miny; - float _scalex, _scaley; + PN_stdfloat _minx, _miny; + PN_stdfloat _scalex, _scaley; private: // inputs diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 0d82f4ca79..548fb5259a 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -44,10 +44,10 @@ is_mouse_open() const { // true. If so, this returns the current position of // the mouse within the window. //////////////////////////////////////////////////////////////////// -INLINE const LPoint2f &MouseWatcher:: +INLINE const LPoint2 &MouseWatcher:: get_mouse() const { #ifndef NDEBUG - static LPoint2f bogus_mouse(0.0f, 0.0f); + static LPoint2 bogus_mouse(0.0f, 0.0f); nassertr(_has_mouse, bogus_mouse); #endif return _mouse; @@ -60,7 +60,7 @@ get_mouse() const { // true. If so, this returns the current X position of // the mouse within the window. //////////////////////////////////////////////////////////////////// -INLINE float MouseWatcher:: +INLINE PN_stdfloat MouseWatcher:: get_mouse_x() const { nassertr(_has_mouse, 0.0f); return _mouse[0]; @@ -73,7 +73,7 @@ get_mouse_x() const { // true. If so, this returns the current Y position of // the mouse within the window. //////////////////////////////////////////////////////////////////// -INLINE float MouseWatcher:: +INLINE PN_stdfloat MouseWatcher:: get_mouse_y() const { nassertr(_has_mouse, 0.0f); return _mouse[1]; @@ -86,8 +86,8 @@ get_mouse_y() const { // flavor of this method for a more verbose explanation. //////////////////////////////////////////////////////////////////// INLINE void MouseWatcher:: -set_frame(float left, float right, float bottom, float top) { - set_frame(LVecBase4f(left, right, bottom, top)); +set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_frame(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -107,7 +107,7 @@ set_frame(float left, float right, float bottom, float top) { // cover the lower half of the screen. //////////////////////////////////////////////////////////////////// INLINE void MouseWatcher:: -set_frame(const LVecBase4f &frame) { +set_frame(const LVecBase4 &frame) { _frame = frame; } @@ -117,7 +117,7 @@ set_frame(const LVecBase4f &frame) { // Description: Returns the frame of the MouseWatcher. See // set_frame(). //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &MouseWatcher:: +INLINE const LVecBase4 &MouseWatcher:: get_frame() const { return _frame; } @@ -140,7 +140,7 @@ is_over_region() const { // region, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool MouseWatcher:: -is_over_region(float x, float y) const { +is_over_region(PN_stdfloat x, PN_stdfloat y) const { return get_over_region(x, y) != (MouseWatcherRegion *)NULL; } @@ -151,7 +151,7 @@ is_over_region(float x, float y) const { // region, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool MouseWatcher:: -is_over_region(const LPoint2f &pos) const { +is_over_region(const LPoint2 &pos) const { return get_over_region(pos) != (MouseWatcherRegion *)NULL; } @@ -173,8 +173,8 @@ get_over_region() const { // over, or NULL if it is over no region. //////////////////////////////////////////////////////////////////// INLINE MouseWatcherRegion *MouseWatcher:: -get_over_region(float x, float y) const { - return get_over_region(LPoint2f(x, y)); +get_over_region(PN_stdfloat x, PN_stdfloat y) const { + return get_over_region(LPoint2(x, y)); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index ee2604446a..66e6c22ab9 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -58,9 +58,9 @@ MouseWatcher(const string &name) : _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); - _pixel_xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _xy = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); - _pixel_size = new EventStoreVec2(LPoint2f(0.0f, 0.0f)); + _pixel_xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); + _pixel_size = new EventStoreVec2(LPoint2(0.0f, 0.0f)); _button_events = new ButtonEventList; _has_mouse = false; @@ -140,7 +140,7 @@ remove_region(MouseWatcherRegion *region) { // preferred. //////////////////////////////////////////////////////////////////// MouseWatcherRegion *MouseWatcher:: -get_over_region(const LPoint2f &pos) const { +get_over_region(const LPoint2 &pos) const { LightMutexHolder holder(_lock); Regions regions; @@ -489,7 +489,7 @@ update_trail_node() { for (int i=0; i<(int)_trail_log->get_num_events(); i++) { double x = (_trail_log->get_xpos(i) * xscale) - 1.0; double y = (_trail_log->get_ypos(i) * yscale) - 1.0; - vertex.add_data3f(LVecBase3f(x,0.0,-y)); + vertex.add_data3(LVecBase3(x,0.0,-y)); lines->add_vertex(i); } lines->close_primitive(); @@ -586,12 +586,12 @@ write(ostream &out, int indent_level) const { // pointer. Assumes the lock is held. //////////////////////////////////////////////////////////////////// void MouseWatcher:: -get_over_regions(MouseWatcher::Regions ®ions, const LPoint2f &pos) const { +get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { nassertv(_lock.debug_is_locked()); // Scale the mouse coordinates into the frame. - float mx = (pos[0] + 1.0f) * 0.5f * (_frame[1] - _frame[0]) + _frame[0]; - float my = (pos[1] + 1.0f) * 0.5f * (_frame[3] - _frame[2]) + _frame[2]; + PN_stdfloat mx = (pos[0] + 1.0f) * 0.5f * (_frame[1] - _frame[0]) + _frame[0]; + PN_stdfloat my = (pos[1] + 1.0f) * 0.5f * (_frame[3] - _frame[2]) + _frame[2]; // pos[0] = 2.0f * (mx - _frame[0]) / (_frame[1] - _frame[0]) - 1.0f; // pos[1] = 2.0f * (my - _frame[2]) / (_frame[3] - _frame[2]) - 1.0f; @@ -602,7 +602,7 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2f &pos) const { Regions::const_iterator ri; for (ri = _regions.begin(); ri != _regions.end(); ++ri) { MouseWatcherRegion *region = (*ri); - const LVecBase4f &frame = region->get_frame(); + const LVecBase4 &frame = region->get_frame(); if (region->get_active() && mx >= frame[0] && mx <= frame[1] && @@ -618,7 +618,7 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2f &pos) const { MouseWatcherGroup *group = (*gi); for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { MouseWatcherRegion *region = (*ri); - const LVecBase4f &frame = region->get_frame(); + const LVecBase4 &frame = region->get_frame(); if (region->get_active() && mx >= frame[0] && mx <= frame[1] && @@ -1338,12 +1338,12 @@ set_no_mouse() { // position. //////////////////////////////////////////////////////////////////// void MouseWatcher:: -set_mouse(const LVecBase2f &xy, const LVecBase2f &pixel_xy) { +set_mouse(const LVecBase2 &xy, const LVecBase2 &pixel_xy) { nassertv(_lock.debug_is_locked()); if (!_geometry.is_null()) { // Transform the mouse pointer. - _geometry->set_transform(TransformState::make_pos(LVecBase3f(xy[0], 0, xy[1]))); + _geometry->set_transform(TransformState::make_pos(LVecBase3(xy[0], 0, xy[1]))); if (!_has_mouse) { // Show the mouse pointer. _geometry->set_overall_hidden(false); @@ -1416,11 +1416,11 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DCAST_INTO_V(xy, input.get_data(_xy_input).get_ptr()); DCAST_INTO_V(pixel_xy, input.get_data(_pixel_xy_input).get_ptr()); - LVecBase2f f = xy->get_value(); - LVecBase2f p = pixel_xy->get_value(); + LVecBase2 f = xy->get_value(); + LVecBase2 p = pixel_xy->get_value(); // Asad: determine if mouse moved from last position - const LVecBase2f &last_f = _xy->get_value(); + const LVecBase2 &last_f = _xy->get_value(); if (f != last_f) { activity = true; move(); @@ -1667,7 +1667,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, //////////////////////////////////////////////////////////////////// bool MouseWatcher:: constrain_display_region(DisplayRegion *display_region, - LVecBase2f &f, LVecBase2f &p, + LVecBase2 &f, LVecBase2 &p, Thread *current_thread) { // If it's a stereo DisplayRegion, we should actually call this // method twice, once for each eye, in case we have side-by-side @@ -1680,12 +1680,12 @@ constrain_display_region(DisplayRegion *display_region, } DisplayRegionPipelineReader dr_reader(display_region, current_thread); - float left, right, bottom, top; + PN_stdfloat left, right, bottom, top; dr_reader.get_dimensions(left, right, bottom, top); // Need to translate this into DisplayRegion [0, 1] space - float x = (f[0] + 1.0f) / 2.0f; - float y = (f[1] + 1.0f) / 2.0f; + PN_stdfloat x = (f[0] + 1.0f) / 2.0f; + PN_stdfloat y = (f[1] + 1.0f) / 2.0f; if (x < left || x >= right || y < bottom || y >= top) { @@ -1696,12 +1696,12 @@ constrain_display_region(DisplayRegion *display_region, // The mouse is within the display region; rescale it. // Scale in DR space - float xp = (x - left) / (right - left); + PN_stdfloat xp = (x - left) / (right - left); // Translate back into [-1, 1] space - float xpp = (xp * 2.0f) - 1.0f; + PN_stdfloat xpp = (xp * 2.0f) - 1.0f; - float yp = (y - bottom) / (top - bottom); - float ypp = (yp * 2.0f) - 1.0f; + PN_stdfloat yp = (y - bottom) / (top - bottom); + PN_stdfloat ypp = (yp * 2.0f) - 1.0f; int xo, yo, w, h; dr_reader.get_region_pixels_i(xo, yo, w, h); diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index 0bbe28b3cc..e3e39700bc 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -74,21 +74,21 @@ PUBLISHED: INLINE bool has_mouse() const; INLINE bool is_mouse_open() const; - INLINE const LPoint2f &get_mouse() const; - INLINE float get_mouse_x() const; - INLINE float get_mouse_y() const; + INLINE const LPoint2 &get_mouse() const; + INLINE PN_stdfloat get_mouse_x() const; + INLINE PN_stdfloat get_mouse_y() const; - INLINE void set_frame(float left, float right, float bottom, float top); - INLINE void set_frame(const LVecBase4f &frame); - INLINE const LVecBase4f &get_frame() const; + INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_frame(const LVecBase4 &frame); + INLINE const LVecBase4 &get_frame() const; INLINE bool is_over_region() const; - INLINE bool is_over_region(float x, float y) const; - INLINE bool is_over_region(const LPoint2f &pos) const; + INLINE bool is_over_region(PN_stdfloat x, PN_stdfloat y) const; + INLINE bool is_over_region(const LPoint2 &pos) const; INLINE MouseWatcherRegion *get_over_region() const; - INLINE MouseWatcherRegion *get_over_region(float x, float y) const; - MouseWatcherRegion *get_over_region(const LPoint2f &pos) const; + INLINE MouseWatcherRegion *get_over_region(PN_stdfloat x, PN_stdfloat y) const; + MouseWatcherRegion *get_over_region(const LPoint2 &pos) const; INLINE bool is_button_down(ButtonHandle button) const; @@ -158,7 +158,7 @@ public: virtual void write(ostream &out, int indent_level = 0) const; protected: - void get_over_regions(Regions ®ions, const LPoint2f &pos) const; + void get_over_regions(Regions ®ions, const LPoint2 &pos) const; static MouseWatcherRegion *get_preferred_region(const Regions ®ions); void set_current_regions(Regions ®ions); @@ -200,7 +200,7 @@ protected: void exit_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m); void set_no_mouse(); - void set_mouse(const LVecBase2f &xy, const LVecBase2f &pixel_xy); + void set_mouse(const LVecBase2 &xy, const LVecBase2 &pixel_xy); private: void consider_keyboard_suppress(const MouseWatcherRegion *region); @@ -208,7 +208,7 @@ private: void update_trail_node(); static bool constrain_display_region(DisplayRegion *display_region, - LVecBase2f &f, LVecBase2f &p, + LVecBase2 &f, LVecBase2 &p, Thread *current_thread); private: @@ -220,11 +220,11 @@ private: bool _has_mouse; int _internal_suppress; int _external_suppress; - LPoint2f _mouse; - LPoint2f _mouse_pixel; + LPoint2 _mouse; + LPoint2 _mouse_pixel; BitArray _current_buttons_down; - LVecBase4f _frame; + LVecBase4 _frame; PT(PointerEventList) _trail_log; int _num_trail_recent; diff --git a/panda/src/tform/mouseWatcherGroup.cxx b/panda/src/tform/mouseWatcherGroup.cxx index 17e2668616..414820b24d 100644 --- a/panda/src/tform/mouseWatcherGroup.cxx +++ b/panda/src/tform/mouseWatcherGroup.cxx @@ -31,7 +31,7 @@ MouseWatcherGroup() : _sorted = true; #ifndef NDEBUG _show_regions = false; - _color.set(0.4f, 0.6f, 1.0f, 1.0f); + _color.set(0.4, 0.6f, 1.0f, 1.0f); #endif // NDEBUG } @@ -262,7 +262,7 @@ show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { // show_regions(). //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: -set_color(const Colorf &color) { +set_color(const LColor &color) { LightMutexHolder holder(_lock); _color = color; @@ -428,13 +428,13 @@ make_viz_region(MouseWatcherRegion *region) { LineSegs ls("show_regions"); ls.set_color(_color); - const LVecBase4f &f = region->get_frame(); + const LVecBase4 &f = region->get_frame(); - ls.move_to(LVector3f::rfu(f[0], 0.0f, f[2])); - ls.draw_to(LVector3f::rfu(f[1], 0.0f, f[2])); - ls.draw_to(LVector3f::rfu(f[1], 0.0f, f[3])); - ls.draw_to(LVector3f::rfu(f[0], 0.0f, f[3])); - ls.draw_to(LVector3f::rfu(f[0], 0.0f, f[2])); + ls.move_to(LVector3::rfu(f[0], 0.0f, f[2])); + ls.draw_to(LVector3::rfu(f[1], 0.0f, f[2])); + ls.draw_to(LVector3::rfu(f[1], 0.0f, f[3])); + ls.draw_to(LVector3::rfu(f[0], 0.0f, f[3])); + ls.draw_to(LVector3::rfu(f[0], 0.0f, f[2])); PT(PandaNode) node = ls.create(); _show_regions_root.attach_new_node(node); diff --git a/panda/src/tform/mouseWatcherGroup.h b/panda/src/tform/mouseWatcherGroup.h index df7abcc6c8..30b4f4d419 100644 --- a/panda/src/tform/mouseWatcherGroup.h +++ b/panda/src/tform/mouseWatcherGroup.h @@ -54,7 +54,7 @@ PUBLISHED: #ifndef NDEBUG void show_regions(const NodePath &render2d, const string &bin_name, int draw_order); - void set_color(const Colorf &color); + void set_color(const LColor &color); void hide_regions(); void update_regions(); @@ -90,7 +90,7 @@ private: bool _show_regions; NodePath _show_regions_root; - Colorf _color; + LColor _color; #endif // NDEBUG public: diff --git a/panda/src/tform/mouseWatcherParameter.I b/panda/src/tform/mouseWatcherParameter.I index fda8135a67..b6775af2ba 100644 --- a/panda/src/tform/mouseWatcherParameter.I +++ b/panda/src/tform/mouseWatcherParameter.I @@ -137,7 +137,7 @@ set_modifier_buttons(const ModifierButtons &mods) { // the event was generated. //////////////////////////////////////////////////////////////////// INLINE void MouseWatcherParameter:: -set_mouse(const LPoint2f &mouse) { +set_mouse(const LPoint2 &mouse) { _mouse = mouse; _flags |= F_has_mouse; } @@ -325,7 +325,7 @@ has_mouse() const { // generated, in the normalized range (-1 .. 1). It is // valid to call this only if has_mouse() returned true. //////////////////////////////////////////////////////////////////// -INLINE const LPoint2f &MouseWatcherParameter:: +INLINE const LPoint2 &MouseWatcherParameter:: get_mouse() const { nassertr(has_mouse(), _mouse); return _mouse; diff --git a/panda/src/tform/mouseWatcherParameter.h b/panda/src/tform/mouseWatcherParameter.h index b3eea96513..70b9b0574c 100644 --- a/panda/src/tform/mouseWatcherParameter.h +++ b/panda/src/tform/mouseWatcherParameter.h @@ -43,7 +43,7 @@ public: size_t higlight_end, size_t cursor_pos); INLINE void set_modifier_buttons(const ModifierButtons &mods); - INLINE void set_mouse(const LPoint2f &mouse); + INLINE void set_mouse(const LPoint2 &mouse); INLINE void set_outside(bool flag); PUBLISHED: @@ -69,7 +69,7 @@ PUBLISHED: INLINE const ModifierButtons &get_modifier_buttons() const; INLINE bool has_mouse() const; - INLINE const LPoint2f &get_mouse() const; + INLINE const LPoint2 &get_mouse() const; INLINE bool is_outside() const; @@ -83,7 +83,7 @@ public: size_t _highlight_end; size_t _cursor_pos; ModifierButtons _mods; - LPoint2f _mouse; + LPoint2 _mouse; enum Flags { F_has_button = 0x001, diff --git a/panda/src/tform/mouseWatcherRegion.I b/panda/src/tform/mouseWatcherRegion.I index 09a0b8ee64..20a75458e5 100644 --- a/panda/src/tform/mouseWatcherRegion.I +++ b/panda/src/tform/mouseWatcherRegion.I @@ -19,8 +19,8 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE MouseWatcherRegion:: -MouseWatcherRegion(const string &name, float left, float right, - float bottom, float top) : +MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top) : Namable(name), _frame(left, right, bottom, top) { @@ -34,7 +34,7 @@ MouseWatcherRegion(const string &name, float left, float right, // Description: //////////////////////////////////////////////////////////////////// INLINE MouseWatcherRegion:: -MouseWatcherRegion(const string &name, const LVecBase4f &frame) : +MouseWatcherRegion(const string &name, const LVecBase4 &frame) : Namable(name), _frame(frame) { @@ -48,8 +48,8 @@ MouseWatcherRegion(const string &name, const LVecBase4f &frame) : // Description: //////////////////////////////////////////////////////////////////// INLINE void MouseWatcherRegion:: -set_frame(float left, float right, float bottom, float top) { - set_frame(LVecBase4f(left, right, bottom, top)); +set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + set_frame(LVecBase4(left, right, bottom, top)); } //////////////////////////////////////////////////////////////////// @@ -58,7 +58,7 @@ set_frame(float left, float right, float bottom, float top) { // Description: //////////////////////////////////////////////////////////////////// INLINE void MouseWatcherRegion:: -set_frame(const LVecBase4f &frame) { +set_frame(const LVecBase4 &frame) { _frame = frame; _area = (_frame[1] - _frame[0]) * (_frame[3] - _frame[2]); } @@ -68,7 +68,7 @@ set_frame(const LVecBase4f &frame) { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE const LVecBase4f &MouseWatcherRegion:: +INLINE const LVecBase4 &MouseWatcherRegion:: get_frame() const { return _frame; } @@ -78,7 +78,7 @@ get_frame() const { // Access: Published // Description: Returns the area of the rectangular region. //////////////////////////////////////////////////////////////////// -INLINE float MouseWatcherRegion:: +INLINE PN_stdfloat MouseWatcherRegion:: get_area() const { return _area; } diff --git a/panda/src/tform/mouseWatcherRegion.h b/panda/src/tform/mouseWatcherRegion.h index 09d12bf1b0..907ec6e939 100644 --- a/panda/src/tform/mouseWatcherRegion.h +++ b/panda/src/tform/mouseWatcherRegion.h @@ -32,14 +32,14 @@ class MouseWatcherParameter; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_TFORM MouseWatcherRegion : public TypedWritableReferenceCount, public Namable { PUBLISHED: - INLINE MouseWatcherRegion(const string &name, float left, float right, - float bottom, float top); - INLINE MouseWatcherRegion(const string &name, const LVecBase4f &frame); + INLINE MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, + PN_stdfloat bottom, PN_stdfloat top); + INLINE MouseWatcherRegion(const string &name, const LVecBase4 &frame); - INLINE void set_frame(float left, float right, float bottom, float top); - INLINE void set_frame(const LVecBase4f &frame); - INLINE const LVecBase4f &get_frame() const; - INLINE float get_area() const; + INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); + INLINE void set_frame(const LVecBase4 &frame); + INLINE const LVecBase4 &get_frame() const; + INLINE PN_stdfloat get_area() const; INLINE void set_sort(int sort); INLINE int get_sort() const; @@ -77,8 +77,8 @@ public: virtual void move(const MouseWatcherParameter ¶m); private: - LVecBase4f _frame; - float _area; + LVecBase4 _frame; + PN_stdfloat _area; int _sort; enum Flags { diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index ace49e91ad..bece8d91d1 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -45,16 +45,16 @@ Trackball(const string &name) : _transform = TransformState::make_identity(); - _rotscale = 0.3f; - _fwdscale = 0.3f; + _rotscale = 0.3; + _fwdscale = 0.3; _last_button = 0; _lastx = _lasty = 0.5f; - _rotation = LMatrix4f::ident_mat(); + _rotation = LMatrix4::ident_mat(); _translation.set(0.0f, 0.0f, 0.0f); - _mat = LMatrix4f::ident_mat(); - _orig = LMatrix4f::ident_mat(); + _mat = LMatrix4::ident_mat(); + _orig = LMatrix4::ident_mat(); _invert = true; _cs = get_default_coordinate_system(); @@ -88,10 +88,10 @@ Trackball:: //////////////////////////////////////////////////////////////////// void Trackball:: reset() { - _rotation = LMatrix4f::ident_mat(); + _rotation = LMatrix4::ident_mat(); _translation.set(0.0f, 0.0f, 0.0f); - _orig = LMatrix4f::ident_mat(); - _mat = LMatrix4f::ident_mat(); + _orig = LMatrix4::ident_mat(); + _mat = LMatrix4::ident_mat(); } //////////////////////////////////////////////////////////////////// @@ -100,7 +100,7 @@ reset() { // Description: Returns the scale factor applied to forward and // backward motion. See set_forward_scale(). //////////////////////////////////////////////////////////////////// -float Trackball:: +PN_stdfloat Trackball:: get_forward_scale() const { return _fwdscale; } @@ -114,7 +114,7 @@ get_forward_scale() const { // out. //////////////////////////////////////////////////////////////////// void Trackball:: -set_forward_scale(float fwdscale) { +set_forward_scale(PN_stdfloat fwdscale) { _fwdscale = fwdscale; } @@ -124,22 +124,22 @@ set_forward_scale(float fwdscale) { // Access: Published // Description: Return the offset from the center of rotation. //////////////////////////////////////////////////////////////////// -const LPoint3f &Trackball:: +const LPoint3 &Trackball:: get_pos() const { return _translation; } -float Trackball:: +PN_stdfloat Trackball:: get_x() const { return _translation[0]; } -float Trackball:: +PN_stdfloat Trackball:: get_y() const { return _translation[1]; } -float Trackball:: +PN_stdfloat Trackball:: get_z() const { return _translation[2]; } @@ -151,31 +151,31 @@ get_z() const { // Description: Directly set the offset from the rotational origin. //////////////////////////////////////////////////////////////////// void Trackball:: -set_pos(const LVecBase3f &vec) { +set_pos(const LVecBase3 &vec) { _translation = vec; recompute(); } void Trackball:: -set_pos(float x, float y, float z) { +set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _translation.set(x, y, z); recompute(); } void Trackball:: -set_x(float x) { +set_x(PN_stdfloat x) { _translation[0] = x; recompute(); } void Trackball:: -set_y(float y) { +set_y(PN_stdfloat y) { _translation[1] = y; recompute(); } void Trackball:: -set_z(float z) { +set_z(PN_stdfloat z) { _translation[2] = z; recompute(); } @@ -186,30 +186,30 @@ set_z(float z) { // Access: Published // Description: Return the trackball's orientation. //////////////////////////////////////////////////////////////////// -LVecBase3f Trackball:: +LVecBase3 Trackball:: get_hpr() const { - LVecBase3f scale, shear, hpr, translate; + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); return hpr; } -float Trackball:: +PN_stdfloat Trackball:: get_h() const { - LVecBase3f scale, shear, hpr, translate; + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); return hpr[0]; } -float Trackball:: +PN_stdfloat Trackball:: get_p() const { - LVecBase3f scale, shear, hpr, translate; + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); return hpr[1]; } -float Trackball:: +PN_stdfloat Trackball:: get_r() const { - LVecBase3f scale, shear, hpr, translate; + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); return hpr[2]; } @@ -221,16 +221,16 @@ get_r() const { // Description: Directly set the mover's orientation. //////////////////////////////////////////////////////////////////// void Trackball:: -set_hpr(const LVecBase3f &hpr) { - LVecBase3f scale, shear, old_hpr, translate; +set_hpr(const LVecBase3 &hpr) { + LVecBase3 scale, shear, old_hpr, translate; decompose_matrix(_rotation, scale, shear, old_hpr, translate); compose_matrix(_rotation, scale, shear, hpr, translate); recompute(); } void Trackball:: -set_hpr(float h, float p, float r) { - LVecBase3f scale, shear, hpr, translate; +set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); hpr.set(h, p, r); compose_matrix(_rotation, scale, shear, hpr, translate); @@ -238,8 +238,8 @@ set_hpr(float h, float p, float r) { } void Trackball:: -set_h(float h) { - LVecBase3f scale, shear, hpr, translate; +set_h(PN_stdfloat h) { + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); hpr[0] = h; compose_matrix(_rotation, scale, shear, hpr, translate); @@ -247,8 +247,8 @@ set_h(float h) { } void Trackball:: -set_p(float p) { - LVecBase3f scale, shear, hpr, translate; +set_p(PN_stdfloat p) { + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); hpr[1] = p; compose_matrix(_rotation, scale, shear, hpr, translate); @@ -256,8 +256,8 @@ set_p(float p) { } void Trackball:: -set_r(float r) { - LVecBase3f scale, shear, hpr, translate; +set_r(PN_stdfloat r) { + LVecBase3 scale, shear, hpr, translate; decompose_matrix(_rotation, scale, shear, hpr, translate); hpr[2] = r; compose_matrix(_rotation, scale, shear, hpr, translate); @@ -286,8 +286,8 @@ reset_origin_here() { // Description: Moves the center of rotation by the given amount. //////////////////////////////////////////////////////////////////// void Trackball:: -move_origin(float x, float y, float z) { - _rotation = LMatrix4f::translate_mat(LVecBase3f(x, y, z)) * _rotation; +move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { + _rotation = LMatrix4::translate_mat(LVecBase3(x, y, z)) * _rotation; } //////////////////////////////////////////////////////////////////// @@ -295,7 +295,7 @@ move_origin(float x, float y, float z) { // Access: Published // Description: Returns the current center of rotation. //////////////////////////////////////////////////////////////////// -LPoint3f Trackball:: +LPoint3 Trackball:: get_origin() const { return _rotation.get_row3(3); } @@ -306,9 +306,9 @@ get_origin() const { // Description: Directly sets the center of rotation. //////////////////////////////////////////////////////////////////// void Trackball:: -set_origin(const LVecBase3f &origin) { - _rotation.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); - _rotation = LMatrix4f::translate_mat(-origin) * _rotation; +set_origin(const LVecBase3 &origin) { + _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); + _rotation = LMatrix4::translate_mat(-origin) * _rotation; } @@ -396,7 +396,7 @@ get_coordinate_system() const { // the rel_to node. //////////////////////////////////////////////////////////////////// void Trackball:: -set_mat(const LMatrix4f &mat) { +set_mat(const LMatrix4 &mat) { _orig = mat; if (_invert) { _mat = invert(_orig); @@ -414,7 +414,7 @@ set_mat(const LMatrix4f &mat) { // Description: Returns the matrix represented by the trackball // rotation. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Trackball:: +const LMatrix4 &Trackball:: get_mat() const { return _orig; } @@ -426,7 +426,7 @@ get_mat() const { // the scene graph. This is the same as get_mat(), // unless invert is in effect. //////////////////////////////////////////////////////////////////// -const LMatrix4f &Trackball:: +const LMatrix4 &Trackball:: get_trans_mat() const { return _mat; } @@ -450,16 +450,16 @@ apply(double x, double y, int button) { // Button 1: translate in plane parallel to screen. _translation += - x * _fwdscale * LVector3f::right(_cs) + - y * _fwdscale * LVector3f::down(_cs); + x * _fwdscale * LVector3::right(_cs) + + y * _fwdscale * LVector3::down(_cs); } else if (button == (B2_MASK | B3_MASK)) { // Buttons 2 + 3: rotate about the vector perpendicular to the // screen. _rotation *= - LMatrix4f::rotate_mat_normaxis((x - y) * _rotscale, - LVector3f::forward(_cs), _cs); + LMatrix4::rotate_mat_normaxis((x - y) * _rotscale, + LVector3::forward(_cs), _cs); } else if ((button == B2_MASK) || (button == (B1_MASK | B3_MASK))) { // Button 2, or buttons 1 + 3: rotate about the right and up @@ -467,14 +467,14 @@ apply(double x, double y, int button) { // support two-button mice.) _rotation *= - LMatrix4f::rotate_mat_normaxis(x * _rotscale, LVector3f::up(_cs), _cs) * - LMatrix4f::rotate_mat_normaxis(y * _rotscale, LVector3f::right(_cs), _cs); + LMatrix4::rotate_mat_normaxis(x * _rotscale, LVector3::up(_cs), _cs) * + LMatrix4::rotate_mat_normaxis(y * _rotscale, LVector3::right(_cs), _cs); } else if ((button == B3_MASK) || (button == (B1_MASK | B2_MASK))) { // Button 3, or buttons 1 + 2: dolly in and out along the forward // vector. (We alternately define this as buttons 1 + 2, to // support two-button mice.) - _translation -= y * _fwdscale * LVector3f::forward(_cs); + _translation -= y * _fwdscale * LVector3::forward(_cs); } if (button) { @@ -491,7 +491,7 @@ apply(double x, double y, int button) { //////////////////////////////////////////////////////////////////// void Trackball:: reextract() { - LMatrix4f m = _orig; + LMatrix4 m = _orig; if (!_rel_to.is_empty()) { NodePath root; m = _orig * root.get_transform(_rel_to)->get_mat(); @@ -499,7 +499,7 @@ reextract() { m.get_row3(_translation,3); _rotation = m; - _rotation.set_row(3, LVecBase3f(0.0f, 0.0f, 0.0f)); + _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); } //////////////////////////////////////////////////////////////////// @@ -510,7 +510,7 @@ reextract() { //////////////////////////////////////////////////////////////////// void Trackball:: recompute() { - _orig = _rotation * LMatrix4f::translate_mat(_translation); + _orig = _rotation * LMatrix4::translate_mat(_translation); if (!_rel_to.is_empty()) { NodePath root; @@ -549,9 +549,9 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (required_buttons_match && input.has_data(_pixel_xy_input)) { const EventStoreVec2 *pixel_xy; DCAST_INTO_V(pixel_xy, input.get_data(_pixel_xy_input).get_ptr()); - const LVecBase2f &p = pixel_xy->get_value(); - float this_x = p[0]; - float this_y = p[1]; + const LVecBase2 &p = pixel_xy->get_value(); + PN_stdfloat this_x = p[0]; + PN_stdfloat this_y = p[1]; int this_button = 0; if (is_down(MouseButton::one())) { @@ -578,8 +578,8 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, this_button |= B3_MASK; } - float x = this_x - _lastx; - float y = this_y - _lasty; + PN_stdfloat x = this_x - _lastx; + PN_stdfloat y = this_y - _lasty; if (this_button == _last_button) { apply(x, y, this_button); diff --git a/panda/src/tform/trackball.h b/panda/src/tform/trackball.h index 74c9b9efa0..4bc9607b71 100644 --- a/panda/src/tform/trackball.h +++ b/panda/src/tform/trackball.h @@ -44,40 +44,40 @@ PUBLISHED: void reset(); - float get_forward_scale() const; - void set_forward_scale(float fwdscale); + PN_stdfloat get_forward_scale() const; + void set_forward_scale(PN_stdfloat fwdscale); /// **** Translation **** - const LPoint3f &get_pos() const; - float get_x() const; - float get_y() const; - float get_z() const; - void set_pos(const LVecBase3f &vec); - void set_pos(float x, float y, float z); - void set_x(float x); - void set_y(float y); - void set_z(float z); + const LPoint3 &get_pos() const; + PN_stdfloat get_x() const; + PN_stdfloat get_y() const; + PN_stdfloat get_z() const; + void set_pos(const LVecBase3 &vec); + void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); + void set_x(PN_stdfloat x); + void set_y(PN_stdfloat y); + void set_z(PN_stdfloat z); /// **** Rotation **** - LVecBase3f get_hpr() const; - float get_h() const; - float get_p() const; - float get_r() const; - void set_hpr(const LVecBase3f &hpr); - void set_hpr(float h, float p, float r); - void set_h(float h); - void set_p(float p); - void set_r(float r); + LVecBase3 get_hpr() const; + PN_stdfloat get_h() const; + PN_stdfloat get_p() const; + PN_stdfloat get_r() const; + void set_hpr(const LVecBase3 &hpr); + void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); + void set_h(PN_stdfloat h); + void set_p(PN_stdfloat p); + void set_r(PN_stdfloat r); /// **** Origin of Rotation **** void reset_origin_here(); - void move_origin(float x, float y, float z); + void move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); - LPoint3f get_origin() const; - void set_origin(const LVecBase3f &origin); + LPoint3 get_origin() const; + void set_origin(const LVecBase3 &origin); /// **** Misc **** @@ -90,9 +90,9 @@ PUBLISHED: void set_coordinate_system(CoordinateSystem cs); CoordinateSystem get_coordinate_system() const; - void set_mat(const LMatrix4f &mat); - const LMatrix4f &get_mat() const; - const LMatrix4f &get_trans_mat() const; + void set_mat(const LMatrix4 &mat); + const LMatrix4 &get_mat() const; + const LMatrix4 &get_trans_mat() const; private: @@ -102,14 +102,14 @@ private: void recompute(); int _last_button; - float _lastx, _lasty; + PN_stdfloat _lastx, _lasty; - float _rotscale; - float _fwdscale; + PN_stdfloat _rotscale; + PN_stdfloat _fwdscale; - LMatrix4f _rotation; - LPoint3f _translation; - LMatrix4f _mat, _orig; + LMatrix4 _rotation; + LPoint3 _translation; + LMatrix4 _mat, _orig; bool _invert; NodePath _rel_to; CoordinateSystem _cs; diff --git a/panda/src/tinydisplay/clip.cxx b/panda/src/tinydisplay/clip.cxx index b9a7f6f5c6..2b497bc305 100644 --- a/panda/src/tinydisplay/clip.cxx +++ b/panda/src/tinydisplay/clip.cxx @@ -13,7 +13,7 @@ void gl_transform_to_viewport(GLContext *c,GLVertex *v) { - float winv; + PN_stdfloat winv; /* coordinates */ winv = 1.0f / v->pc.v[3]; @@ -74,7 +74,7 @@ void gl_draw_point(GLContext *c,GLVertex *p0) /* line */ -static inline void interpolate(GLVertex *q,GLVertex *p0,GLVertex *p1,float t) +static inline void interpolate(GLVertex *q,GLVertex *p0,GLVertex *p1,PN_stdfloat t) { q->pc.v[0]=p0->pc.v[0]+(p1->pc.v[0]-p0->pc.v[0])*t; q->pc.v[1]=p0->pc.v[1]+(p1->pc.v[1]-p0->pc.v[1])*t; @@ -93,9 +93,9 @@ static inline void interpolate(GLVertex *q,GLVertex *p0,GLVertex *p1,float t) /* Line Clipping algorithm from 'Computer Graphics', Principles and Practice */ -static inline int ClipLine1(float denom,float num,float *tmin,float *tmax) +static inline int ClipLine1(PN_stdfloat denom,PN_stdfloat num,PN_stdfloat *tmin,PN_stdfloat *tmax) { - float t; + PN_stdfloat t; if (denom>0) { t=num/denom; @@ -111,8 +111,8 @@ static inline int ClipLine1(float denom,float num,float *tmin,float *tmax) void gl_draw_line(GLContext *c,GLVertex *p1,GLVertex *p2) { - float dx,dy,dz,dw,x1,y1,z1,w1; - float tmin,tmax; + PN_stdfloat dx,dy,dz,dw,x1,y1,z1,w1; + PN_stdfloat tmin,tmax; GLVertex q1,q2; int cc1,cc2; @@ -171,10 +171,10 @@ void gl_draw_line(GLContext *c,GLVertex *p1,GLVertex *p2) */ #define clip_func(name, sign, dir, dir1, dir2) \ -static float name(V4 *c, V4 *a, V4 *b) \ +static PN_stdfloat name(V4 *c, V4 *a, V4 *b) \ {\ - float t,den;\ - float d[4];\ + PN_stdfloat t,den;\ + PN_stdfloat d[4];\ d[0] = (b->v[0] - a->v[0]);\ d[1] = (b->v[1] - a->v[1]);\ d[2] = (b->v[2] - a->v[2]);\ @@ -203,14 +203,14 @@ clip_func(clip_zmin, -, 2, 0, 1) clip_func(clip_zmax, +, 2, 0, 1) -float (*clip_proc[6])(V4 *,V4 *,V4 *)= { +PN_stdfloat (*clip_proc[6])(V4 *,V4 *,V4 *)= { clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax }; static inline void updateTmp(GLContext *c, - GLVertex *q,GLVertex *p0,GLVertex *p1,float t) + GLVertex *q,GLVertex *p0,GLVertex *p1,PN_stdfloat t) { if (c->smooth_shade_model) { q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t; @@ -242,7 +242,7 @@ void gl_draw_triangle(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2) { int co,c_and,cc[3],front; - float norm; + PN_stdfloat norm; cc[0]=p0->clip_code; cc[1]=p1->clip_code; @@ -253,8 +253,8 @@ void gl_draw_triangle(GLContext *c, /* we handle the non clipped case here to go faster */ if (co==0) { - norm=(float)(p1->zp.x-p0->zp.x)*(float)(p2->zp.y-p0->zp.y)- - (float)(p2->zp.x-p0->zp.x)*(float)(p1->zp.y-p0->zp.y); + norm=(PN_stdfloat)(p1->zp.x-p0->zp.x)*(PN_stdfloat)(p2->zp.y-p0->zp.y)- + (PN_stdfloat)(p2->zp.x-p0->zp.x)*(PN_stdfloat)(p1->zp.y-p0->zp.y); if (norm == 0) return; @@ -291,7 +291,7 @@ static void gl_draw_triangle_clip(GLContext *c, { int co,c_and,co1,cc[3],edge_flag_tmp,clip_mask; GLVertex tmp1,tmp2,*q[3]; - float tt; + PN_stdfloat tt; cc[0]=p0->clip_code; cc[1]=p1->clip_code; diff --git a/panda/src/tinydisplay/image_util.cxx b/panda/src/tinydisplay/image_util.cxx index 1b4da77072..fd19ffc256 100644 --- a/panda/src/tinydisplay/image_util.cxx +++ b/panda/src/tinydisplay/image_util.cxx @@ -73,14 +73,14 @@ void gl_resizeImage(unsigned char *dest,int xsize_dest,int ysize_dest, unsigned char *src,int xsize_src,int ysize_src) { unsigned char *pix,*pix_src; - float x1,y1,x1inc,y1inc; + PN_stdfloat x1,y1,x1inc,y1inc; int xi,yi,j,xf,yf,x,y; pix=dest; pix_src=src; - x1inc=(float) (xsize_src - 1) / (float) (xsize_dest - 1); - y1inc=(float) (ysize_src - 1) / (float) (ysize_dest - 1); + x1inc=(PN_stdfloat) (xsize_src - 1) / (PN_stdfloat) (xsize_dest - 1); + y1inc=(PN_stdfloat) (ysize_src - 1) / (PN_stdfloat) (ysize_dest - 1); y1=0; for(y=0;yfirst_light=NULL; - c->ambient_light_model=gl_V4_New(0.2f, 0.2f, 0.2f, 1.0f); + c->ambient_light_model=gl_V4_New(0.2, 0.2, 0.2, 1.0f); c->local_light_model=0; c->lighting_enabled=0; c->light_model_two_side = 0; @@ -30,7 +30,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) for(i=0;i<2;i++) { GLMaterial *m=&c->materials[i]; m->emission=gl_V4_New(0.0f, 0.0f, 0.0f, 1.0f); - m->ambient=gl_V4_New(0.2f, 0.2f, 0.2f, 1.0f); + m->ambient=gl_V4_New(0.2, 0.2, 0.2, 1.0f); m->diffuse=gl_V4_New(0.8f, 0.8f, 0.8f, 1.0f); m->specular=gl_V4_New(0.0f, 0.0f, 0.0f, 1.0f); m->shininess=0; diff --git a/panda/src/tinydisplay/specbuf.cxx b/panda/src/tinydisplay/specbuf.cxx index 2297ced9aa..d0c153714e 100644 --- a/panda/src/tinydisplay/specbuf.cxx +++ b/panda/src/tinydisplay/specbuf.cxx @@ -2,10 +2,10 @@ #include #include -static void calc_buf(GLSpecBuf *buf, const float shininess) +static void calc_buf(GLSpecBuf *buf, const PN_stdfloat shininess) { int i; - float val, inc; + PN_stdfloat val, inc; val = 0.0f; inc = 1.0f/SPECULAR_BUFFER_SIZE; for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++) { @@ -16,7 +16,7 @@ static void calc_buf(GLSpecBuf *buf, const float shininess) GLSpecBuf * specbuf_get_buffer(GLContext *c, const int shininess_i, - const float shininess) + const PN_stdfloat shininess) { GLSpecBuf *found, *oldest; found = oldest = c->specbuf_first; diff --git a/panda/src/tinydisplay/td_light.cxx b/panda/src/tinydisplay/td_light.cxx index b769617ced..a7b03a3bc5 100644 --- a/panda/src/tinydisplay/td_light.cxx +++ b/panda/src/tinydisplay/td_light.cxx @@ -1,7 +1,7 @@ #include "zgl.h" #include -static inline float clampf(float a,float min,float max) +static inline PN_stdfloat clampf(PN_stdfloat a,PN_stdfloat min,PN_stdfloat max) { if (amax) return max; @@ -11,11 +11,11 @@ static inline float clampf(float a,float min,float max) /* non optimized lighting model */ void gl_shade_vertex(GLContext *c,GLVertex *v) { - float R,G,B,A; + PN_stdfloat R,G,B,A; GLMaterial *m; GLLight *l; V3 n,s,d; - float dist,tmp,att,dot,dot_spot,dot_spec; + PN_stdfloat dist,tmp,att,dot,dot_spot,dot_spec; int twoside = c->light_model_two_side; m=&c->materials[0]; @@ -30,7 +30,7 @@ void gl_shade_vertex(GLContext *c,GLVertex *v) A=clampf(m->diffuse.v[3],0,1); for(l=c->first_light;l!=NULL;l=l->next) { - float lR,lB,lG; + PN_stdfloat lR,lB,lG; /* ambient */ lR=l->ambient.v[0] * m->ambient.v[0]; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index bf6576bbb9..42e9c28f3b 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -232,7 +232,7 @@ clear(DrawableRegion *clearable) { bool clear_color = false; int r, g, b, a; if (clearable->get_clear_color_active()) { - Colorf v = clearable->get_clear_color(); + LColor v = clearable->get_clear_color(); r = (int)(v[0] * 0xffff); g = (int)(v[1] * 0xffff); b = (int)(v[2] * 0xffff); @@ -269,7 +269,7 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { int xmin, ymin, xsize, ysize; dr->get_region_pixels_i(xmin, ymin, xsize, ysize); - float pixel_factor = _current_display_region->get_pixel_factor(); + PN_stdfloat pixel_factor = _current_display_region->get_pixel_factor(); if (pixel_factor != 1.0) { // Render into an aux buffer, and zoom it up into the main // frame buffer later. @@ -332,14 +332,14 @@ calc_projection_mat(const Lens *lens) { // matrix, and store the conversion to our coordinate system of // choice in the modelview matrix. - LMatrix4f result = - LMatrix4f::convert_mat(CS_yup_right, _current_lens->get_coordinate_system()) * + LMatrix4 result = + LMatrix4::convert_mat(CS_yup_right, _current_lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the // projection matrix. - result *= LMatrix4f::scale_mat(1.0f, -1.0f, 1.0f); + result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); @@ -439,7 +439,7 @@ end_scene() { // up to the appropriate size. int xmin, ymin, xsize, ysize; _current_display_region->get_region_pixels_i(xmin, ymin, xsize, ysize); - float pixel_factor = _current_display_region->get_pixel_factor(); + PN_stdfloat pixel_factor = _current_display_region->get_pixel_factor(); int fb_xsize = int(xsize * pixel_factor); int fb_ysize = int(ysize * pixel_factor); @@ -569,7 +569,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, /* test to accelerate computation */ _c->matrix_model_projection_no_w_transform = 0; - float *m = &_c->matrix_model_projection.m[0][0]; + PN_stdfloat *m = &_c->matrix_model_projection.m[0][0]; if (m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0) { _c->matrix_model_projection_no_w_transform = 1; } @@ -690,8 +690,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } if (!needs_color) { - const Colorf &d = _scene_graph_color; - const Colorf &s = _current_color_scale; + const LColor &d = _scene_graph_color; + const LColor &s = _current_color_scale; _c->current_color.v[0] = d[0] * s[0]; _c->current_color.v[1] = d[1] * s[1]; _c->current_color.v[2] = d[2] * s[2]; @@ -735,7 +735,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, for (i = 0; i < num_used_vertices; ++i) { GLVertex *v = &_vertices[i]; - const LVecBase4f &d = rvertex.get_data4f(); + const LVecBase4 &d = rvertex.get_data4(); v->coord.v[0] = d[0]; v->coord.v[1] = d[1]; @@ -744,13 +744,13 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Texture coordinates. for (int si = 0; si < max_stage_index; ++si) { - TexCoordf d; + LTexCoord d; (*texgen_func[si])(v->tex_coord[si], tcdata[si]); } if (needs_color) { - const Colorf &d = rcolor.get_data4f(); - const Colorf &s = _current_color_scale; + const LColor &d = rcolor.get_data4(); + const LColor &s = _current_color_scale; _c->current_color.v[0] = d[0] * s[0]; _c->current_color.v[1] = d[1] * s[1]; _c->current_color.v[2] = d[2] * s[2]; @@ -771,7 +771,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, v->color = _c->current_color; if (lighting_enabled) { - const LVecBase3f &d = rnormal.get_data3f(); + const LVecBase3 &d = rnormal.get_data3(); _c->current_normal.v[0] = d[0]; _c->current_normal.v[1] = d[1]; _c->current_normal.v[2] = d[2]; @@ -838,7 +838,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, int op_a = get_color_blend_op(target_color_blend->get_operand_a()); int op_b = get_color_blend_op(target_color_blend->get_operand_b()); _c->zb->store_pix_func = store_pixel_funcs[op_a][op_b][color_channels]; - Colorf c = target_color_blend->get_color(); + LColor c = target_color_blend->get_color(); _c->zb->blend_r = (int)(c[0] * ZB_POINT_RED_MAX); _c->zb->blend_g = (int)(c[1] * ZB_POINT_GREEN_MAX); _c->zb->blend_b = (int)(c[2] * ZB_POINT_BLUE_MAX); @@ -1368,7 +1368,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr, if (!setup_gltex(gltex, tex->get_x_size(), tex->get_y_size(), 1)) { return false; } - Colorf border_color = tex->get_border_color(); + LColor border_color = tex->get_border_color(); gltex->border_color.v[0] = border_color[0]; gltex->border_color.v[1] = border_color[1]; gltex->border_color.v[2] = border_color[2]; @@ -1765,7 +1765,7 @@ void TinyGraphicsStateGuardian:: do_issue_light() { // Initialize the current ambient light total and newly enabled // light list - Colorf cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); + LColor cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); int num_enabled = 0; int num_on_lights = 0; @@ -1809,7 +1809,7 @@ do_issue_light() { // property. GLLight *gl_light = _c->first_light; nassertv(gl_light != NULL); - const Colorf &diffuse = light_obj->get_color(); + const LColor &diffuse = light_obj->get_color(); gl_light->diffuse.v[0] = diffuse[0]; gl_light->diffuse.v[1] = diffuse[1]; gl_light->diffuse.v[2] = diffuse[2]; @@ -1844,7 +1844,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // It's a brand new light. Define it. memset(gl_light, 0, sizeof(GLLight)); - const Colorf &specular = light_obj->get_specular_color(); + const LColor &specular = light_obj->get_specular_color(); gl_light->specular.v[0] = specular[0]; gl_light->specular.v[1] = specular[1]; gl_light->specular.v[2] = specular[2]; @@ -1858,7 +1858,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); CPT(TransformState) net_transform = render_transform->compose(transform); - LPoint3f pos = light_obj->get_point() * net_transform->get_mat(); + LPoint3 pos = light_obj->get_point() * net_transform->get_mat(); gl_light->position.v[0] = pos[0]; gl_light->position.v[1] = pos[1]; gl_light->position.v[2] = pos[2]; @@ -1870,7 +1870,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { // Cutoff == 180 means uniform point light source gl_light->spot_cutoff = 180.0f; - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); gl_light->attenuation[0] = att[0]; gl_light->attenuation[1] = att[1]; gl_light->attenuation[2] = att[2]; @@ -1899,7 +1899,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // It's a brand new light. Define it. memset(gl_light, 0, sizeof(GLLight)); - const Colorf &specular = light_obj->get_specular_color(); + const LColor &specular = light_obj->get_specular_color(); gl_light->specular.v[0] = specular[0]; gl_light->specular.v[1] = specular[1]; gl_light->specular.v[2] = specular[2]; @@ -1913,7 +1913,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); CPT(TransformState) net_transform = render_transform->compose(transform); - LVector3f dir = light_obj->get_direction() * net_transform->get_mat(); + LVector3 dir = light_obj->get_direction() * net_transform->get_mat(); dir.normalize(); gl_light->position.v[0] = -dir[0]; gl_light->position.v[1] = -dir[1]; @@ -1961,7 +1961,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // It's a brand new light. Define it. memset(gl_light, 0, sizeof(GLLight)); - const Colorf &specular = light_obj->get_specular_color(); + const LColor &specular = light_obj->get_specular_color(); gl_light->specular.v[0] = specular[0]; gl_light->specular.v[1] = specular[1]; gl_light->specular.v[2] = specular[2]; @@ -1978,9 +1978,9 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); CPT(TransformState) net_transform = render_transform->compose(transform); - const LMatrix4f &light_mat = net_transform->get_mat(); - LPoint3f pos = lens->get_nodal_point() * light_mat; - LVector3f dir = lens->get_view_vector() * light_mat; + const LMatrix4 &light_mat = net_transform->get_mat(); + LPoint3 pos = lens->get_nodal_point() * light_mat; + LVector3 dir = lens->get_view_vector() * light_mat; dir.normalize(); gl_light->position.v[0] = pos[0]; @@ -2000,7 +2000,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { gl_light->spot_exponent = light_obj->get_exponent(); gl_light->spot_cutoff = lens->get_hfov() * 0.5f; - const LVecBase3f &att = light_obj->get_attenuation(); + const LVecBase3 &att = light_obj->get_attenuation(); gl_light->attenuation[0] = att[0]; gl_light->attenuation[1] = att[1]; gl_light->attenuation[2] = att[2]; @@ -2385,7 +2385,7 @@ do_issue_texture() { void TinyGraphicsStateGuardian:: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); - const LVecBase4f &frame = target_scissor->get_frame(); + const LVecBase4 &frame = target_scissor->get_frame(); set_scissor(frame[0], frame[1], frame[2], frame[3]); } @@ -2396,23 +2396,23 @@ do_issue_scissor() { // relative to the current viewport. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -set_scissor(float left, float right, float bottom, float top) { +set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _c->scissor.left = left; _c->scissor.right = right; _c->scissor.bottom = bottom; _c->scissor.top = top; gl_eval_viewport(_c); - float xsize = right - left; - float ysize = top - bottom; - float xcenter = (left + right) - 1.0f; - float ycenter = (bottom + top) - 1.0f; + PN_stdfloat xsize = right - left; + PN_stdfloat ysize = top - bottom; + PN_stdfloat xcenter = (left + right) - 1.0f; + PN_stdfloat ycenter = (bottom + top) - 1.0f; if (xsize == 0.0f || ysize == 0.0f) { // If the scissor region is zero, nothing will be drawn anyway, so // don't worry about it. _scissor_mat = TransformState::make_identity(); } else { - _scissor_mat = TransformState::make_scale(LVecBase3f(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3f(-xcenter, -ycenter, 0.0f))); + _scissor_mat = TransformState::make_scale(LVecBase3(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3(-xcenter, -ycenter, 0.0f))); } } @@ -2485,7 +2485,7 @@ upload_texture(TinyTextureContext *gtc, bool force) { if (!setup_gltex(gltex, tex->get_x_size(), tex->get_y_size(), num_levels)) { return false; } - Colorf border_color = tex->get_border_color(); + LColor border_color = tex->get_border_color(); gltex->border_color.v[0] = border_color[0]; gltex->border_color.v[1] = border_color[1]; gltex->border_color.v[2] = border_color[2]; @@ -2595,7 +2595,7 @@ upload_simple_texture(TinyTextureContext *gtc) { if (!setup_gltex(gltex, width, height, 1)) { return false; } - Colorf border_color = tex->get_border_color(); + LColor border_color = tex->get_border_color(); gltex->border_color.v[0] = border_color[0]; gltex->border_color.v[1] = border_color[1]; gltex->border_color.v[2] = border_color[2]; @@ -2992,13 +2992,13 @@ copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *g //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: setup_material(GLMaterial *gl_material, const Material *material) { - const Colorf &specular = material->get_specular(); + const LColor &specular = material->get_specular(); gl_material->specular.v[0] = specular[0]; gl_material->specular.v[1] = specular[1]; gl_material->specular.v[2] = specular[2]; gl_material->specular.v[3] = specular[3]; - const Colorf &emission = material->get_emission(); + const LColor &emission = material->get_emission(); gl_material->emission.v[0] = emission[0]; gl_material->emission.v[1] = emission[1]; gl_material->emission.v[2] = emission[2]; @@ -3010,7 +3010,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { _color_material_flags = CMF_ambient | CMF_diffuse; if (material->has_ambient()) { - const Colorf &ambient = material->get_ambient(); + const LColor &ambient = material->get_ambient(); gl_material->ambient.v[0] = ambient[0]; gl_material->ambient.v[1] = ambient[1]; gl_material->ambient.v[2] = ambient[2]; @@ -3020,7 +3020,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { } if (material->has_diffuse()) { - const Colorf &diffuse = material->get_diffuse(); + const LColor &diffuse = material->get_diffuse(); gl_material->diffuse.v[0] = diffuse[0]; gl_material->diffuse.v[1] = diffuse[1]; gl_material->diffuse.v[2] = diffuse[2]; @@ -3059,7 +3059,7 @@ do_auto_rescale_normal() { //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: load_matrix(M4 *matrix, const TransformState *transform) { - const LMatrix4f &pm = transform->get_mat(); + const LMatrix4 &pm = transform->get_mat(); for (int i = 0; i < 4; ++i) { matrix->m[0][i] = pm.get_cell(i, 0); matrix->m[1][i] = pm.get_cell(i, 1); @@ -3202,7 +3202,7 @@ texgen_null(V2 &result, TinyGraphicsStateGuardian::TexCoordData &) { void TinyGraphicsStateGuardian:: texgen_simple(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // No need to transform, so just extract as two-component. - const LVecBase2f &d = tcdata._r1.get_data2f(); + const LVecBase2 &d = tcdata._r1.get_data2(); result.v[0] = d[0]; result.v[1] = d[1]; } @@ -3216,7 +3216,7 @@ texgen_simple(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { void TinyGraphicsStateGuardian:: texgen_texmat(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // Transform texcoords as a four-component vector for most generality. - LVecBase4f d = tcdata._r1.get_data4f() * tcdata._mat; + LVecBase4 d = tcdata._r1.get_data4() * tcdata._mat; result.v[0] = d[0] / d[3]; result.v[1] = d[1] / d[3]; } @@ -3230,18 +3230,18 @@ texgen_texmat(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { void TinyGraphicsStateGuardian:: texgen_sphere_map(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // Get the normal and point in eye coordinates. - LVector3f n = tcdata._mat.xform_vec(tcdata._r1.get_data3f()); - LVector3f u = tcdata._mat.xform_point(tcdata._r2.get_data3f()); + LVector3 n = tcdata._mat.xform_vec(tcdata._r1.get_data3()); + LVector3 u = tcdata._mat.xform_point(tcdata._r2.get_data3()); // Normalize the vectors. n.normalize(); u.normalize(); // Compute the reflection vector. - LVector3f r = u - n * dot(n, u) * 2.0f; + LVector3 r = u - n * dot(n, u) * 2.0f; // compute the denominator, m. - float m = 2.0f * csqrt(r[0] * r[0] + r[1] * r[1] + (r[2] + 1.0f) * (r[2] + 1.0f)); + PN_stdfloat m = 2.0f * csqrt(r[0] * r[0] + r[1] * r[1] + (r[2] + 1.0f) * (r[2] + 1.0f)); // Now we can compute the s and t coordinates. result.v[0] = r[0] / m + 0.5f; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h index df1f3b465e..876fe7b0e4 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h @@ -112,7 +112,7 @@ private: void do_issue_texture(); void do_issue_scissor(); - void set_scissor(float left, float right, float bottom, float top); + void set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); bool apply_texture(TextureContext *tc); bool upload_texture(TinyTextureContext *gtc, bool force); @@ -141,7 +141,7 @@ private: public: GeomVertexReader _r1; GeomVertexReader _r2; - LMatrix4f _mat; + LMatrix4 _mat; }; typedef void GenTexcoordFunc(V2 &result, TexCoordData &tcdata); diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index 8cac3555a9..fc9c45338c 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -304,8 +304,8 @@ void TinyOsxGraphicsWindow::DoResize(void) { CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}}; GetWindowPortBounds (_osx_window, &rectPort); - viewRect.size.width = (float) (rectPort.right - rectPort.left); - viewRect.size.height = (float) (rectPort.bottom - rectPort.top); + viewRect.size.width = (PN_stdfloat) (rectPort.right - rectPort.left); + viewRect.size.height = (PN_stdfloat) (rectPort.bottom - rectPort.top); // tell panda WindowProperties properties; properties.set_size((int)viewRect.size.width,(int)viewRect.size.height); diff --git a/panda/src/tinydisplay/vertex.cxx b/panda/src/tinydisplay/vertex.cxx index d078757000..5410f963bd 100644 --- a/panda/src/tinydisplay/vertex.cxx +++ b/panda/src/tinydisplay/vertex.cxx @@ -5,11 +5,11 @@ void gl_eval_viewport(GLContext * c) { GLViewport *v = &c->viewport; GLScissor *s = &c->scissor; - float xsize = v->xsize * (s->right - s->left); - float xmin = v->xmin + v->xsize * s->left; - float ysize = v->ysize * (s->top - s->bottom); - float ymin = v->ymin + v->ysize * (1.0f - s->top); - float zsize = (float)(1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS)); + PN_stdfloat xsize = v->xsize * (s->right - s->left); + PN_stdfloat xmin = v->xmin + v->xsize * s->left; + PN_stdfloat ysize = v->ysize * (s->top - s->bottom); + PN_stdfloat ymin = v->ymin + v->ysize * (1.0f - s->top); + PN_stdfloat zsize = (PN_stdfloat)(1 << (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS)); v->trans.v[0] = ((xsize - 0.5f) / 2.0f) + xmin; v->trans.v[1] = ((ysize - 0.5f) / 2.0f) + ymin; @@ -24,7 +24,7 @@ void gl_eval_viewport(GLContext * c) { /* TODO : handle all cases */ void gl_vertex_transform(GLContext * c, GLVertex * v) { - float *m; + PN_stdfloat *m; V4 *n; if (c->lighting_enabled) { diff --git a/panda/src/tinydisplay/zbuffer.h b/panda/src/tinydisplay/zbuffer.h index 2d13a735d1..909779dc07 100644 --- a/panda/src/tinydisplay/zbuffer.h +++ b/panda/src/tinydisplay/zbuffer.h @@ -157,13 +157,13 @@ struct ZBufferPoint { int s,t; /* coordinates for the mapping */ int r,g,b,a; /* color indexes */ - float sz,tz; /* temporary coordinates for mapping */ + PN_stdfloat sz,tz; /* temporary coordinates for mapping */ int sa, ta; /* mapping coordinates for optional second texture stage */ - float sza,tza; + PN_stdfloat sza,tza; int sb, tb; /* mapping coordinates for optional third texture stage */ - float szb,tzb; + PN_stdfloat szb,tzb; }; /* zbuffer.c */ diff --git a/panda/src/tinydisplay/zgl.h b/panda/src/tinydisplay/zgl.h index 8d74e9fe32..b346831780 100644 --- a/panda/src/tinydisplay/zgl.h +++ b/panda/src/tinydisplay/zgl.h @@ -39,7 +39,7 @@ typedef struct GLSpecBuf { int shininess_i; int last_used; - float buf[SPECULAR_BUFFER_SIZE+1]; + PN_stdfloat buf[SPECULAR_BUFFER_SIZE+1]; struct GLSpecBuf *next; } GLSpecBuf; @@ -49,11 +49,11 @@ typedef struct GLLight { V4 specular; V4 position; V3 spot_direction; - float spot_exponent; - float spot_cutoff; - float attenuation[3]; + PN_stdfloat spot_exponent; + PN_stdfloat spot_cutoff; + PN_stdfloat attenuation[3]; /* precomputed values */ - float cos_spot_cutoff; + PN_stdfloat cos_spot_cutoff; V3 norm_spot_direction; V3 norm_position; struct GLLight *next; @@ -64,7 +64,7 @@ typedef struct GLMaterial { V4 ambient; V4 diffuse; V4 specular; - float shininess; + PN_stdfloat shininess; /* computed values */ int shininess_i; @@ -80,12 +80,12 @@ typedef struct GLViewport { } GLViewport; typedef struct GLScissor { - float left, right, bottom, top; + PN_stdfloat left, right, bottom, top; } GLScissor; typedef union { int op; - float f; + PN_stdfloat f; int i; unsigned int ui; void *p; @@ -173,7 +173,7 @@ typedef struct GLContext { int cull_face_enabled; int cull_clockwise; int normalize_enabled; - float normal_scale; + PN_stdfloat normal_scale; gl_draw_triangle_func draw_triangle_front,draw_triangle_back; ZB_fillTriangleFunc zb_fill_tri; @@ -235,16 +235,16 @@ void gl_fatal_error(const char *format, ...); /* specular buffer "api" */ GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, - const float shininess); + const PN_stdfloat shininess); /* this clip epsilon is needed to avoid some rounding errors after several clipping stages */ #define CLIP_EPSILON (1E-5f) -static inline int gl_clipcode(float x,float y,float z,float w1) +static inline int gl_clipcode(PN_stdfloat x,PN_stdfloat y,PN_stdfloat z,PN_stdfloat w1) { - float w; + PN_stdfloat w; w = w1 * (1.0f + CLIP_EPSILON); return (x<-w) | diff --git a/panda/src/tinydisplay/zmath.cxx b/panda/src/tinydisplay/zmath.cxx index 0a4b667086..fba1751c3b 100644 --- a/panda/src/tinydisplay/zmath.cxx +++ b/panda/src/tinydisplay/zmath.cxx @@ -32,7 +32,7 @@ int gl_M4_IsId(M4 *a) void gl_M4_Mul(M4 *c,M4 *a,M4 *b) { int i,j,k; - float s; + PN_stdfloat s; for(i=0;i<4;i++) for(j=0;j<4;j++) { s=0.0; @@ -45,10 +45,10 @@ void gl_M4_Mul(M4 *c,M4 *a,M4 *b) void gl_M4_MulLeft(M4 *c,M4 *b) { int i,j,k; - float s; + PN_stdfloat s; M4 a; - /*memcpy(&a, c, 16*sizeof(float)); + /*memcpy(&a, c, 16*sizeof(PN_stdfloat)); */ a=*c; @@ -121,7 +121,7 @@ void gl_M4_Transpose(M4 *a,M4 *b) void gl_M4_InvOrtho(M4 *a,M4 b) { int i,j; - float s; + PN_stdfloat s; for(i=0;i<3;i++) for(j=0;j<3;j++) a->m[i][j]=b.m[j][i]; a->m[3][0]=0.0; a->m[3][1]=0.0; a->m[3][2]=0.0; a->m[3][3]=1.0; @@ -135,10 +135,10 @@ void gl_M4_InvOrtho(M4 *a,M4 b) /* Inversion of a general nxn matrix. Note : m is destroyed */ -int Matrix_Inv(float *r,float *m,int n) +int Matrix_Inv(PN_stdfloat *r,PN_stdfloat *m,int n) { int i,j,k,l; - float max,tmp,t; + PN_stdfloat max,tmp,t; /* identitée dans r */ for(i=0;im[0][0],&tmp.m[0][0],4); } -void gl_M4_Rotate(M4 *a,float t,int u) +void gl_M4_Rotate(M4 *a,PN_stdfloat t,int u) { - float s,c; + PN_stdfloat s,c; int v,w; if ((v=u+1)>2) v=0; if ((w=v+1)>2) w=0; @@ -220,7 +220,7 @@ void gl_M4_Rotate(M4 *a,float t,int u) /* inverse of a 3x3 matrix */ void gl_M3_Inv(M3 *a,M3 *m) { - float det; + PN_stdfloat det; det = m->m[0][0]*m->m[1][1]*m->m[2][2]-m->m[0][0]*m->m[1][2]*m->m[2][1]- m->m[1][0]*m->m[0][1]*m->m[2][2]+m->m[1][0]*m->m[0][2]*m->m[2][1]+ @@ -244,7 +244,7 @@ void gl_M3_Inv(M3 *a,M3 *m) int gl_V3_Norm(V3 *a) { - float n; + PN_stdfloat n; n=sqrt(a->v[0]*a->v[0]+a->v[1]*a->v[1]+a->v[2]*a->v[2]); if (n==0) return 1; a->v[0]/=n; @@ -253,7 +253,7 @@ int gl_V3_Norm(V3 *a) return 0; } -V3 gl_V3_New(float x,float y,float z) +V3 gl_V3_New(PN_stdfloat x,PN_stdfloat y,PN_stdfloat z) { V3 a; a.v[0]=x; @@ -262,7 +262,7 @@ V3 gl_V3_New(float x,float y,float z) return a; } -V4 gl_V4_New(float x,float y,float z,float w) +V4 gl_V4_New(PN_stdfloat x,PN_stdfloat y,PN_stdfloat z,PN_stdfloat w) { V4 a; a.v[0]=x; diff --git a/panda/src/tinydisplay/zmath.h b/panda/src/tinydisplay/zmath.h index da34a17bb4..5296a8ad06 100644 --- a/panda/src/tinydisplay/zmath.h +++ b/panda/src/tinydisplay/zmath.h @@ -4,27 +4,27 @@ /* Matrix & Vertex */ typedef struct { - float m[4][4]; + PN_stdfloat m[4][4]; } M4; typedef struct { - float m[3][3]; + PN_stdfloat m[3][3]; } M3; typedef struct { - float m[3][4]; + PN_stdfloat m[3][4]; } M34; typedef struct { - float v[2]; + PN_stdfloat v[2]; } V2; typedef struct { - float v[3]; + PN_stdfloat v[3]; } V3; typedef struct { - float v[4]; + PN_stdfloat v[4]; } V4; void gl_M4_Id(M4 *a); @@ -40,12 +40,12 @@ void gl_M4_Inv(M4 *a,M4 *b); void gl_M4_Mul(M4 *c,M4 *a,M4 *b); void gl_M4_MulLeft(M4 *c,M4 *a); void gl_M4_Transpose(M4 *a,M4 *b); -void gl_M4_Rotate(M4 *c,float t,int u); +void gl_M4_Rotate(M4 *c,PN_stdfloat t,int u); int gl_V3_Norm(V3 *a); -V3 gl_V3_New(float x,float y,float z); -V4 gl_V4_New(float x,float y,float z,float w); +V3 gl_V3_New(PN_stdfloat x,PN_stdfloat y,PN_stdfloat z); +V4 gl_V4_New(PN_stdfloat x,PN_stdfloat y,PN_stdfloat z,PN_stdfloat w); -int gl_Matrix_Inv(float *r,float *m,int n); +int gl_Matrix_Inv(PN_stdfloat *r,PN_stdfloat *m,int n); #endif diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index b1662beb06..2c3e5c1d1f 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -4,7 +4,7 @@ { ZBufferPoint *t,*pr1,*pr2,*l1,*l2; - float fdx1, fdx2, fdy1, fdy2, fz, d1, d2; + PN_stdfloat fdx1, fdx2, fdy1, fdy2, fz, d1, d2; ZPOINT *pz1; PIXEL *pp1; int part, update_left, update_right; @@ -30,16 +30,16 @@ int t1 = 0, dtdx = 0, dtdy = 0, dtdl_min = 0, dtdl_max = 0; #endif #ifdef INTERP_STZ - float sz1 = 0, dszdx = 0, dszdy = 0, dszdl_min = 0, dszdl_max = 0; - float tz1 = 0, dtzdx = 0, dtzdy = 0, dtzdl_min = 0, dtzdl_max = 0; + PN_stdfloat sz1 = 0, dszdx = 0, dszdy = 0, dszdl_min = 0, dszdl_max = 0; + PN_stdfloat tz1 = 0, dtzdx = 0, dtzdy = 0, dtzdl_min = 0, dtzdl_max = 0; #endif #ifdef INTERP_STZA - float sza1 = 0, dszadx = 0, dszady = 0, dszadl_min = 0, dszadl_max = 0; - float tza1 = 0, dtzadx = 0, dtzady = 0, dtzadl_min = 0, dtzadl_max = 0; + PN_stdfloat sza1 = 0, dszadx = 0, dszady = 0, dszadl_min = 0, dszadl_max = 0; + PN_stdfloat tza1 = 0, dtzadx = 0, dtzady = 0, dtzadl_min = 0, dtzadl_max = 0; #endif #ifdef INTERP_STZB - float szb1 = 0, dszbdx = 0, dszbdy = 0, dszbdl_min = 0, dszbdl_max = 0; - float tzb1 = 0, dtzbdx = 0, dtzbdy = 0, dtzbdl_min = 0, dtzbdl_max = 0; + PN_stdfloat szb1 = 0, dszbdx = 0, dszbdy = 0, dszbdl_min = 0, dszbdl_max = 0; + PN_stdfloat tzb1 = 0, dtzbdx = 0, dtzbdy = 0, dtzbdl_min = 0, dtzbdl_max = 0; #endif #if defined(INTERP_MIPMAP) && (defined(INTERP_ST) || defined(INTERP_STZ)) unsigned int mipmap_dx = 0, mipmap_level = 0; @@ -74,11 +74,11 @@ /* we compute dXdx and dXdy for all interpolated values */ - fdx1 = (float) (p1->x - p0->x); - fdy1 = (float) (p1->y - p0->y); + fdx1 = (PN_stdfloat) (p1->x - p0->x); + fdy1 = (PN_stdfloat) (p1->y - p0->y); - fdx2 = (float) (p2->x - p0->x); - fdy2 = (float) (p2->y - p0->y); + fdx2 = (PN_stdfloat) (p2->x - p0->x); + fdy2 = (PN_stdfloat) (p2->y - p0->y); fz = fdx1 * fdy2 - fdx2 * fdy1; if (fz == 0) @@ -91,43 +91,43 @@ fdy2 *= fz; #ifdef INTERP_Z - d1 = (float) (p1->z - p0->z); - d2 = (float) (p2->z - p0->z); + d1 = (PN_stdfloat) (p1->z - p0->z); + d2 = (PN_stdfloat) (p2->z - p0->z); dzdx = (int) (fdy2 * d1 - fdy1 * d2); dzdy = (int) (fdx1 * d2 - fdx2 * d1); #endif #ifdef INTERP_RGB - d1 = (float) (p1->r - p0->r); - d2 = (float) (p2->r - p0->r); + d1 = (PN_stdfloat) (p1->r - p0->r); + d2 = (PN_stdfloat) (p2->r - p0->r); drdx = (int) (fdy2 * d1 - fdy1 * d2); drdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = (float) (p1->g - p0->g); - d2 = (float) (p2->g - p0->g); + d1 = (PN_stdfloat) (p1->g - p0->g); + d2 = (PN_stdfloat) (p2->g - p0->g); dgdx = (int) (fdy2 * d1 - fdy1 * d2); dgdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = (float) (p1->b - p0->b); - d2 = (float) (p2->b - p0->b); + d1 = (PN_stdfloat) (p1->b - p0->b); + d2 = (PN_stdfloat) (p2->b - p0->b); dbdx = (int) (fdy2 * d1 - fdy1 * d2); dbdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = (float) (p1->a - p0->a); - d2 = (float) (p2->a - p0->a); + d1 = (PN_stdfloat) (p1->a - p0->a); + d2 = (PN_stdfloat) (p2->a - p0->a); dadx = (int) (fdy2 * d1 - fdy1 * d2); dady = (int) (fdx1 * d2 - fdx2 * d1); #endif #ifdef INTERP_ST - d1 = (float) (p1->s - p0->s); - d2 = (float) (p2->s - p0->s); + d1 = (PN_stdfloat) (p1->s - p0->s); + d2 = (PN_stdfloat) (p2->s - p0->s); dsdx = (int) (fdy2 * d1 - fdy1 * d2); dsdy = (int) (fdx1 * d2 - fdx2 * d1); - d1 = (float) (p1->t - p0->t); - d2 = (float) (p2->t - p0->t); + d1 = (PN_stdfloat) (p1->t - p0->t); + d2 = (PN_stdfloat) (p2->t - p0->t); dtdx = (int) (fdy2 * d1 - fdy1 * d2); dtdy = (int) (fdx1 * d2 - fdx2 * d1); @@ -136,16 +136,16 @@ #ifdef INTERP_STZ { - float zz; - zz=(float) p0->z; - p0->sz= (float) p0->s * zz; - p0->tz= (float) p0->t * zz; - zz=(float) p1->z; - p1->sz= (float) p1->s * zz; - p1->tz= (float) p1->t * zz; - zz=(float) p2->z; - p2->sz= (float) p2->s * zz; - p2->tz= (float) p2->t * zz; + PN_stdfloat zz; + zz=(PN_stdfloat) p0->z; + p0->sz= (PN_stdfloat) p0->s * zz; + p0->tz= (PN_stdfloat) p0->t * zz; + zz=(PN_stdfloat) p1->z; + p1->sz= (PN_stdfloat) p1->s * zz; + p1->tz= (PN_stdfloat) p1->t * zz; + zz=(PN_stdfloat) p2->z; + p2->sz= (PN_stdfloat) p2->s * zz; + p2->tz= (PN_stdfloat) p2->t * zz; d1 = p1->sz - p0->sz; d2 = p2->sz - p0->sz; @@ -161,16 +161,16 @@ #ifdef INTERP_STZA { - float zz; - zz=(float) p0->z; - p0->sza= (float) p0->sa * zz; - p0->tza= (float) p0->ta * zz; - zz=(float) p1->z; - p1->sza= (float) p1->sa * zz; - p1->tza= (float) p1->ta * zz; - zz=(float) p2->z; - p2->sza= (float) p2->sa * zz; - p2->tza= (float) p2->ta * zz; + PN_stdfloat zz; + zz=(PN_stdfloat) p0->z; + p0->sza= (PN_stdfloat) p0->sa * zz; + p0->tza= (PN_stdfloat) p0->ta * zz; + zz=(PN_stdfloat) p1->z; + p1->sza= (PN_stdfloat) p1->sa * zz; + p1->tza= (PN_stdfloat) p1->ta * zz; + zz=(PN_stdfloat) p2->z; + p2->sza= (PN_stdfloat) p2->sa * zz; + p2->tza= (PN_stdfloat) p2->ta * zz; d1 = p1->sza - p0->sza; d2 = p2->sza - p0->sza; @@ -186,16 +186,16 @@ #ifdef INTERP_STZB { - float zz; - zz=(float) p0->z; - p0->szb= (float) p0->sb * zz; - p0->tzb= (float) p0->tb * zz; - zz=(float) p1->z; - p1->szb= (float) p1->sb * zz; - p1->tzb= (float) p1->tb * zz; - zz=(float) p2->z; - p2->szb= (float) p2->sb * zz; - p2->tzb= (float) p2->tb * zz; + PN_stdfloat zz; + zz=(PN_stdfloat) p0->z; + p0->szb= (PN_stdfloat) p0->sb * zz; + p0->tzb= (PN_stdfloat) p0->tb * zz; + zz=(PN_stdfloat) p1->z; + p1->szb= (PN_stdfloat) p1->sb * zz; + p1->tzb= (PN_stdfloat) p1->tb * zz; + zz=(PN_stdfloat) p2->z; + p2->szb= (PN_stdfloat) p2->sb * zz; + p2->tzb= (PN_stdfloat) p2->tb * zz; d1 = p1->szb - p0->szb; d2 = p2->szb - p0->szb; @@ -357,13 +357,13 @@ register unsigned int s,t; #endif #ifdef INTERP_STZ - float sz,tz; + PN_stdfloat sz,tz; #endif #ifdef INTERP_STZA - float sza,tza; + PN_stdfloat sza,tza; #endif #ifdef INTERP_STZB - float szb,tzb; + PN_stdfloat szb,tzb; #endif n=(x2 >> 16) - x1; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index b1df8d7aa7..eade11cceb 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -288,7 +288,7 @@ FNAME(white_perspective) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { ZTextureDef *texture_def; - float fdzdx,fndzdx,ndszdx,ndtzdx; + PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; #define INTERP_Z #define INTERP_STZ @@ -302,7 +302,7 @@ FNAME(white_perspective) (ZBuffer *zb, #define DRAW_INIT() \ { \ texture_def = &zb->current_textures[0]; \ - fdzdx=(float)dzdx; \ + fdzdx=(PN_stdfloat)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ ndtzdx=NB_INTERP * dtzdx; \ @@ -330,9 +330,9 @@ FNAME(white_perspective) (ZBuffer *zb, register PIXEL *pp; \ register int s,t,z,zz; \ register int n,dsdx,dtdx; \ - float sz,tz,fz,zinv; \ + PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ - fz=(float)z1; \ + fz=(PN_stdfloat)z1; \ zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ @@ -341,7 +341,7 @@ FNAME(white_perspective) (ZBuffer *zb, tz=tz1; \ while (n>=(NB_INTERP-1)) { \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -367,7 +367,7 @@ FNAME(white_perspective) (ZBuffer *zb, tz+=ndtzdx; \ } \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -398,7 +398,7 @@ FNAME(flat_perspective) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { ZTextureDef *texture_def; - float fdzdx,fndzdx,ndszdx,ndtzdx; + PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; int or0, og0, ob0, oa0; #define INTERP_Z @@ -416,7 +416,7 @@ FNAME(flat_perspective) (ZBuffer *zb, return; \ } \ texture_def = &zb->current_textures[0]; \ - fdzdx=(float)dzdx; \ + fdzdx=(PN_stdfloat)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ ndtzdx=NB_INTERP * dtzdx; \ @@ -457,9 +457,9 @@ FNAME(flat_perspective) (ZBuffer *zb, register int s,t,z,zz; \ register int n,dsdx,dtdx; \ register int or1,og1,ob1,oa1; \ - float sz,tz,fz,zinv; \ + PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ - fz=(float)z1; \ + fz=(PN_stdfloat)z1; \ zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ @@ -472,7 +472,7 @@ FNAME(flat_perspective) (ZBuffer *zb, oa1 = a1; \ while (n>=(NB_INTERP-1)) { \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -498,7 +498,7 @@ FNAME(flat_perspective) (ZBuffer *zb, tz+=ndtzdx; \ } \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -529,7 +529,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { ZTextureDef *texture_def; - float fdzdx,fndzdx,ndszdx,ndtzdx; + PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; #define INTERP_Z #define INTERP_STZ @@ -556,7 +556,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, #define DRAW_INIT() \ { \ texture_def = &zb->current_textures[0]; \ - fdzdx=(float)dzdx; \ + fdzdx=(PN_stdfloat)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ ndtzdx=NB_INTERP * dtzdx; \ @@ -597,9 +597,9 @@ FNAME(smooth_perspective) (ZBuffer *zb, register int s,t,z,zz; \ register int n,dsdx,dtdx; \ register int or1,og1,ob1,oa1; \ - float sz,tz,fz,zinv; \ + PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ - fz=(float)z1; \ + fz=(PN_stdfloat)z1; \ zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ @@ -612,7 +612,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, oa1 = a1; \ while (n>=(NB_INTERP-1)) { \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -638,7 +638,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, tz+=ndtzdx; \ } \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -669,7 +669,7 @@ static void FNAME(smooth_multitex2) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - float fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx; + PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx; #define INTERP_Z #define INTERP_STZ @@ -682,7 +682,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, #define DRAW_INIT() \ { \ - fdzdx=(float)dzdx; \ + fdzdx=(PN_stdfloat)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ ndtzdx=NB_INTERP * dtzdx; \ @@ -728,9 +728,9 @@ FNAME(smooth_multitex2) (ZBuffer *zb, register int s,t,sa,ta,z,zz; \ register int n,dsdx,dtdx,dsadx,dtadx; \ register int or1,og1,ob1,oa1; \ - float sz,tz,sza,tza,fz,zinv; \ + PN_stdfloat sz,tz,sza,tza,fz,zinv; \ n=(x2>>16)-x1; \ - fz=(float)z1; \ + fz=(PN_stdfloat)z1; \ zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ @@ -745,7 +745,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, oa1 = a1; \ while (n>=(NB_INTERP-1)) { \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -755,7 +755,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \ } \ { \ - float ssa,tta; \ + PN_stdfloat ssa,tta; \ ssa=(sza * zinv); \ tta=(tza * zinv); \ sa=(int) ssa; \ @@ -783,7 +783,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, tza+=ndtzadx; \ } \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -793,7 +793,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \ } \ { \ - float ssa,tta; \ + PN_stdfloat ssa,tta; \ ssa=(sza * zinv); \ tta=(tza * zinv); \ sa=(int) ssa; \ @@ -824,7 +824,7 @@ static void FNAME(smooth_multitex3) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - float fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx,ndszbdx,ndtzbdx; + PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx,ndszbdx,ndtzbdx; #define INTERP_Z #define INTERP_STZ @@ -838,7 +838,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, #define DRAW_INIT() \ { \ - fdzdx=(float)dzdx; \ + fdzdx=(PN_stdfloat)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ ndtzdx=NB_INTERP * dtzdx; \ @@ -889,9 +889,9 @@ FNAME(smooth_multitex3) (ZBuffer *zb, register int s,t,sa,ta,sb,tb,z,zz; \ register int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \ register int or1,og1,ob1,oa1; \ - float sz,tz,sza,tza,szb,tzb,fz,zinv; \ + PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \ n=(x2>>16)-x1; \ - fz=(float)z1; \ + fz=(PN_stdfloat)z1; \ zinv=1.0f / fz; \ pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \ pz=pz1+x1; \ @@ -908,7 +908,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, oa1 = a1; \ while (n>=(NB_INTERP-1)) { \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -918,7 +918,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \ } \ { \ - float ssa,tta; \ + PN_stdfloat ssa,tta; \ ssa=(sza * zinv); \ tta=(tza * zinv); \ sa=(int) ssa; \ @@ -928,7 +928,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \ } \ { \ - float ssb,ttb; \ + PN_stdfloat ssb,ttb; \ ssb=(szb * zinv); \ ttb=(tzb * zinv); \ sb=(int) ssb; \ @@ -958,7 +958,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, tzb+=ndtzbdx; \ } \ { \ - float ss,tt; \ + PN_stdfloat ss,tt; \ ss=(sz * zinv); \ tt=(tz * zinv); \ s=(int) ss; \ @@ -968,7 +968,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \ } \ { \ - float ssa,tta; \ + PN_stdfloat ssa,tta; \ ssa=(sza * zinv); \ tta=(tza * zinv); \ sa=(int) ssa; \ @@ -978,7 +978,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \ } \ { \ - float ssb,ttb; \ + PN_stdfloat ssb,ttb; \ ssb=(szb * zinv); \ ttb=(tzb * zinv); \ sb=(int) ssb; \ diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 448d0f6722..8cb346e65d 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -411,7 +411,7 @@ analyze(Texture *tex, bool do_flip_texture) { arGetTransMat(inf, center, _marker_size, _prev_conv); _have_prev_conv = true; } - LMatrix4f mat; + LMatrix4 mat; for (int i=0; i<4; i++) { mat(i,0) = _prev_conv[0][i]; mat(i,1) = _prev_conv[2][i]; @@ -419,7 +419,7 @@ analyze(Texture *tex, bool do_flip_texture) { mat(i,3) = 0.0; } mat(3,3) = 1.0; - LVecBase3f scale, shear, hpr, pos; + LVecBase3 scale, shear, hpr, pos; decompose_matrix(mat, scale, shear, hpr, pos); if (np.get_parent().is_empty()) { diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 5d434ed9c1..aa62b5d3db 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -63,7 +63,7 @@ // NOTE: there is a problem with dxtrans.h missing from newer Microsoft DirectX SDKs (including March 2009) // See "dxtrans.h missing in Microsoft DirectX SDK" at -// http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/ed097d2c-3d68-4f48-8448-277eaaf68252/ for example. +// http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/ed097d2c-3d68-448-8448-277eaaf68252/ for example. // This header file is referenced only by qedit.h and not needed. // Solution: add this pragma and these defines before the qedit.h inclusion: #pragma include_alias( "dxtrans.h", "qedit.h" ) diff --git a/panda/src/vrpn/vrpnClient.I b/panda/src/vrpn/vrpnClient.I index a6032fc183..7bc568b82e 100644 --- a/panda/src/vrpn/vrpnClient.I +++ b/panda/src/vrpn/vrpnClient.I @@ -87,8 +87,8 @@ VrpnClient(const string &server) : INLINE void VrpnClient:: tracker_position(const string &tracker, const vrpn_TRACKERCB info) { double ptime = convert_to_secs(info.msg_time); - LPoint3f pos(info.pos[0], info.pos[1], info.pos[2]); - LVector4f pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]); + LPoint3 pos(info.pos[0], info.pos[1], info.pos[2]); + LVector4 pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]); push_tracker_position(tracker, info.sensor, ptime, pos, pquat); } @@ -103,10 +103,10 @@ tracker_position(const string &tracker, const vrpn_TRACKERCB info) { INLINE void VrpnClient:: tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { double vtime = convert_to_secs(info.msg_time); - LPoint3f vel(info.vel[0], info.vel[1], info.vel[2]); - LVector4f vquat(info.vel_quat[0], info.vel_quat[1], + LPoint3 vel(info.vel[0], info.vel[1], info.vel[2]); + LVector4 vquat(info.vel_quat[0], info.vel_quat[1], info.vel_quat[2], info.vel_quat[3]); - float dt = info.vel_quat_dt; + PN_stdfloat dt = info.vel_quat_dt; push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt); } @@ -120,10 +120,10 @@ tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { INLINE void VrpnClient:: tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) { double atime = convert_to_secs(info.msg_time); - LPoint3f acc(info.acc[0], info.acc[1], info.acc[2]); - LVector4f aquat(info.acc_quat[0], info.acc_quat[1], + LPoint3 acc(info.acc[0], info.acc[1], info.acc[2]); + LVector4 aquat(info.acc_quat[0], info.acc_quat[1], info.acc_quat[2], info.acc_quat[3]); - float dt = info.acc_quat_dt; + PN_stdfloat dt = info.acc_quat_dt; push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt); } diff --git a/panda/src/vrpn/vrpnTracker.cxx b/panda/src/vrpn/vrpnTracker.cxx index 801d6f790d..c99e95b513 100644 --- a/panda/src/vrpn/vrpnTracker.cxx +++ b/panda/src/vrpn/vrpnTracker.cxx @@ -125,8 +125,8 @@ vrpn_position_callback(void *userdata, const vrpn_TRACKERCB info) { device->get_data_type() == VrpnTrackerDevice::DT_position) { device->acquire(); device->_data.set_time(VrpnClient::convert_to_secs(info.msg_time)); - device->_data.set_pos(LPoint3f(info.pos[0], info.pos[1], info.pos[2])); - device->_data.set_orient(LOrientationf(info.quat[3], info.quat[0], info.quat[1], info.quat[2])); + device->_data.set_pos(LPoint3(info.pos[0], info.pos[1], info.pos[2])); + device->_data.set_orient(LOrientation(info.quat[3], info.quat[0], info.quat[1], info.quat[2])); device->unlock(); } } @@ -154,8 +154,8 @@ vrpn_velocity_callback(void *userdata, const vrpn_TRACKERVELCB info) { device->get_data_type() == VrpnTrackerDevice::DT_velocity) { device->acquire(); device->_data.set_time(VrpnClient::convert_to_secs(info.msg_time)); - device->_data.set_pos(LPoint3f(info.vel[0], info.vel[1], info.vel[2])); - device->_data.set_orient(LOrientationf(info.vel_quat[3], info.vel_quat[0], + device->_data.set_pos(LPoint3(info.vel[0], info.vel[1], info.vel[2])); + device->_data.set_orient(LOrientation(info.vel_quat[3], info.vel_quat[0], info.vel_quat[1], info.vel_quat[2])); device->_data.set_dt(info.vel_quat_dt); device->unlock(); @@ -185,8 +185,8 @@ vrpn_acceleration_callback(void *userdata, const vrpn_TRACKERACCCB info) { device->get_data_type() == VrpnTrackerDevice::DT_acceleration) { device->acquire(); device->_data.set_time(VrpnClient::convert_to_secs(info.msg_time)); - device->_data.set_pos(LPoint3f(info.acc[0], info.acc[1], info.acc[2])); - device->_data.set_orient(LOrientationf(info.acc_quat[3], info.acc_quat[0], + device->_data.set_pos(LPoint3(info.acc[0], info.acc[1], info.acc[2])); + device->_data.set_orient(LOrientation(info.acc_quat[3], info.acc_quat[0], info.acc_quat[1], info.acc_quat[2])); device->_data.set_dt(info.acc_quat_dt); device->unlock(); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index b15c467420..0dc48bd8fe 100755 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -365,7 +365,7 @@ choose_pixel_format(const FrameBufferProperties &properties, static const int max_attrib_list = 64; int iattrib_list[max_attrib_list]; - float fattrib_list[max_attrib_list]; + PN_stdfloat fattrib_list[max_attrib_list]; int ni = 0; int nf = 0; @@ -779,7 +779,7 @@ register_twindow_class() { static bool _gamma_table_initialized = false; static unsigned short _orignial_gamma_table [256 * 3]; -void _create_gamma_table (float gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; double gamma_correction; @@ -862,7 +862,7 @@ get_gamma_table(void) { // for atexit. //////////////////////////////////////////////////////////////////// bool wglGraphicsStateGuardian:: -static_set_gamma(bool restore, float gamma) { +static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; HDC hdc = GetDC(NULL); @@ -894,7 +894,7 @@ static_set_gamma(bool restore, float gamma) { // on success. //////////////////////////////////////////////////////////////////// bool wglGraphicsStateGuardian:: -set_gamma(float gamma) { +set_gamma(PN_stdfloat gamma) { bool set; set = static_set_gamma(false, gamma); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.h b/panda/src/wgldisplay/wglGraphicsStateGuardian.h index fdd5587e4d..4c6d0a79a2 100755 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.h +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.h @@ -49,8 +49,8 @@ public: INLINE HDC get_twindow_dc(); static bool get_gamma_table(void); - static bool static_set_gamma(bool restore, float gamma); - bool set_gamma(float gamma); + static bool static_set_gamma(bool restore, PN_stdfloat gamma); + bool set_gamma(PN_stdfloat gamma); void restore_gamma(); static void atexit_function(void); diff --git a/panda/src/wgldisplay/wglext.h b/panda/src/wgldisplay/wglext.h index 22ad1053c2..e5c61dd792 100644 --- a/panda/src/wgldisplay/wglext.h +++ b/panda/src/wgldisplay/wglext.h @@ -592,15 +592,15 @@ typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 #ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); +extern BOOL WINAPI wglGetFrameUsageI3D (PN_stdfloat *); extern BOOL WINAPI wglBeginFrameTrackingI3D (void); extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); +extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, PN_stdfloat *); #endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (PN_stdfloat *pUsage); typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, PN_stdfloat *pLastMissedUsage); #endif diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index a1c7b13b41..2dcd3f36e8 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -231,7 +231,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur aiString path; aiTextureMapping mapping; unsigned int uvindex; - float blend; + PN_stdfloat blend; aiTextureOp op; aiTextureMapMode mapmode; @@ -310,7 +310,7 @@ load_material(size_t index) { aiColor3D col; bool have; int ival; - float fval; + PN_stdfloat fval; // XXX a lot of this is untested. @@ -318,23 +318,23 @@ load_material(size_t index) { PT(Material) pmat = new Material; have = false; if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_DIFFUSE, col)) { - pmat->set_diffuse(Colorf(col.r, col.g, col.b, 1)); + pmat->set_diffuse(LColor(col.r, col.g, col.b, 1)); have = true; } if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_SPECULAR, col)) { if (AI_SUCCESS == mat.Get(AI_MATKEY_SHININESS_STRENGTH, fval)) { - pmat->set_specular(Colorf(col.r * fval, col.g * fval, col.b * fval, 1)); + pmat->set_specular(LColor(col.r * fval, col.g * fval, col.b * fval, 1)); } else { - pmat->set_specular(Colorf(col.r, col.g, col.b, 1)); + pmat->set_specular(LColor(col.r, col.g, col.b, 1)); } have = true; } if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_AMBIENT, col)) { - pmat->set_specular(Colorf(col.r, col.g, col.b, 1)); + pmat->set_specular(LColor(col.r, col.g, col.b, 1)); have = true; } if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_EMISSIVE, col)) { - pmat->set_emission(Colorf(col.r, col.g, col.b, 1)); + pmat->set_emission(LColor(col.r, col.g, col.b, 1)); have = true; } if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_TRANSPARENT, col)) { @@ -389,21 +389,21 @@ load_mesh(size_t index) { // Create the vertex format. PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat; - aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_float32, Geom::C_point); + aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point); if (mesh.HasNormals()) { - aformat->add_column(InternalName::get_normal(), 3, Geom::NT_float32, Geom::C_vector); + aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_vector); } if (mesh.HasVertexColors(0)) { - aformat->add_column(InternalName::get_color(), 4, Geom::NT_float32, Geom::C_color); + aformat->add_column(InternalName::get_color(), 4, Geom::NT_stdfloat, Geom::C_color); } unsigned int num_uvs = mesh.GetNumUVChannels(); if (num_uvs > 0) { // UV sets are named texcoord, texcoord.1, texcoord.2... - aformat->add_column(InternalName::get_texcoord(), 3, Geom::NT_float32, Geom::C_texcoord); + aformat->add_column(InternalName::get_texcoord(), 3, Geom::NT_stdfloat, Geom::C_texcoord); for (unsigned int u = 1; u < num_uvs; ++u) { ostringstream out; out << u; - aformat->add_column(InternalName::get_texcoord_name(out.str()), 3, Geom::NT_float32, Geom::C_texcoord); + aformat->add_column(InternalName::get_texcoord_name(out.str()), 3, Geom::NT_stdfloat, Geom::C_texcoord); } } //TODO: if there is only one UV set, hackily iterate over the texture stages and clear the texcoord name things @@ -420,7 +420,7 @@ load_mesh(size_t index) { GeomVertexWriter vertex (vdata, InternalName::get_vertex()); for (size_t i = 0; i < mesh.mNumVertices; ++i) { const aiVector3D &vec = mesh.mVertices[i]; - vertex.add_data3f(vec.x, vec.y, vec.z); + vertex.add_data3(vec.x, vec.y, vec.z); } // Now the normals, if any. @@ -428,7 +428,7 @@ load_mesh(size_t index) { GeomVertexWriter normal (vdata, InternalName::get_normal()); for (size_t i = 0; i < mesh.mNumVertices; ++i) { const aiVector3D &vec = mesh.mNormals[i]; - normal.add_data3f(vec.x, vec.y, vec.z); + normal.add_data3(vec.x, vec.y, vec.z); } } @@ -437,7 +437,7 @@ load_mesh(size_t index) { GeomVertexWriter color (vdata, InternalName::get_color()); for (size_t i = 0; i < mesh.mNumVertices; ++i) { const aiColor4D &col = mesh.mColors[0][i]; - color.add_data4f(col.r, col.g, col.b, col.a); + color.add_data4(col.r, col.g, col.b, col.a); } } @@ -447,7 +447,7 @@ load_mesh(size_t index) { GeomVertexWriter texcoord0 (vdata, InternalName::get_texcoord()); for (size_t i = 0; i < mesh.mNumVertices; ++i) { const aiVector3D &vec = mesh.mTextureCoords[0][i]; - texcoord0.add_data3f(vec.x, vec.y, vec.z); + texcoord0.add_data3(vec.x, vec.y, vec.z); } for (unsigned int u = 1; u < num_uvs; ++u) { ostringstream out; @@ -455,7 +455,7 @@ load_mesh(size_t index) { GeomVertexWriter texcoord (vdata, InternalName::get_texcoord_name(out.str())); for (size_t i = 0; i < mesh.mNumVertices; ++i) { const aiVector3D &vec = mesh.mTextureCoords[u][i]; - texcoord.add_data3f(vec.x, vec.y, vec.z); + texcoord.add_data3(vec.x, vec.y, vec.z); } } } @@ -525,7 +525,7 @@ load_node(const aiNode &node, PandaNode *parent) { // Load in the transformation matrix. const aiMatrix4x4 &t = node.mTransformation; if (!t.IsIdentity()) { - LMatrix4f mat(t.a1, t.b1, t.c1, t.d1, + LMatrix4 mat(t.a1, t.b1, t.c1, t.d1, t.a2, t.b2, t.c2, t.d2, t.a3, t.b3, t.c3, t.d3, t.a4, t.b4, t.c4, t.d4); @@ -578,13 +578,13 @@ load_light(const aiLight &light) { lnode = DCAST(LightNode, dlight); col = light.mColorSpecular; - dlight->set_specular_color(Colorf(col.r, col.g, col.b, 1)); + dlight->set_specular_color(LColor(col.r, col.g, col.b, 1)); vec = light.mPosition; - dlight->set_point(LPoint3f(vec.x, vec.y, vec.z)); + dlight->set_point(LPoint3(vec.x, vec.y, vec.z)); vec = light.mDirection; - dlight->set_direction(LVector3f(vec.x, vec.y, vec.z)); + dlight->set_direction(LVector3(vec.x, vec.y, vec.z)); break; } case aiLightSource_POINT: { @@ -592,12 +592,12 @@ load_light(const aiLight &light) { lnode = DCAST(LightNode, plight); col = light.mColorSpecular; - plight->set_specular_color(Colorf(col.r, col.g, col.b, 1)); + plight->set_specular_color(LColor(col.r, col.g, col.b, 1)); vec = light.mPosition; - plight->set_point(LPoint3f(vec.x, vec.y, vec.z)); + plight->set_point(LPoint3(vec.x, vec.y, vec.z)); - plight->set_attenuation(LVecBase3f(light.mAttenuationConstant, + plight->set_attenuation(LVecBase3(light.mAttenuationConstant, light.mAttenuationLinear, light.mAttenuationQuadratic)); break; } @@ -607,9 +607,9 @@ load_light(const aiLight &light) { lnode = DCAST(LightNode, plight); col = light.mColorSpecular; - plight->set_specular_color(Colorf(col.r, col.g, col.b, 1)); + plight->set_specular_color(LColor(col.r, col.g, col.b, 1)); - plight->set_attenuation(LVecBase3f(light.mAttenuationConstant, + plight->set_attenuation(LVecBase3(light.mAttenuationConstant, light.mAttenuationLinear, light.mAttenuationQuadratic)); @@ -618,10 +618,10 @@ load_light(const aiLight &light) { // This *should* be about right. vec = light.mDirection; - LPoint3f pos (light.mPosition.x, light.mPosition.y, light.mPosition.z); - LQuaternionf quat; - ::look_at(quat, LPoint3f(vec.x, vec.y, vec.z), LVector3f::up()); - plight->set_transform(TransformState::make_pos_quat_scale(pos, quat, LVecBase3f(1, 1, 1))); + LPoint3 pos (light.mPosition.x, light.mPosition.y, light.mPosition.z); + LQuaternion quat; + ::look_at(quat, LPoint3(vec.x, vec.y, vec.z), LVector3::up()); + plight->set_transform(TransformState::make_pos_quat_scale(pos, quat, LVecBase3(1, 1, 1))); break; } default: @@ -630,8 +630,8 @@ load_light(const aiLight &light) { } // If there's an ambient color, add it as ambient light. - LVecBase4f ambient (col.r, col.g, col.b, 0); - if (ambient != LVecBase4f::zero()) { + LVecBase4 ambient (col.r, col.g, col.b, 0); + if (ambient != LVecBase4::zero()) { PT(AmbientLight) alight = new AmbientLight(name); col = light.mColorAmbient; alight->set_color(ambient); @@ -640,5 +640,5 @@ load_light(const aiLight &light) { _root->add_child(lnode); col = light.mColorDiffuse; - lnode->set_color(Colorf(col.r, col.g, col.b, 1)); + lnode->set_color(LColor(col.r, col.g, col.b, 1)); } diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx index c4c03c8472..731724c9df 100644 --- a/pandatool/src/bam/bamToEgg.cxx +++ b/pandatool/src/bam/bamToEgg.cxx @@ -239,9 +239,9 @@ convert_lod_node(LODNode *node, const WorkingNodePath &node_path, } // Now set up the switching properties appropriately. - float in = node->get_in(i); - float out = node->get_out(i); - LPoint3f center = node->get_center(); + PN_stdfloat in = node->get_in(i); + PN_stdfloat out = node->get_out(i); + LPoint3 center = node->get_center(); EggSwitchConditionDistance dist(in, out, LCAST(double, center)); next_group->set_lod(dist); egg_group->add_child(next_group.p()); @@ -339,7 +339,7 @@ EggGroupNode * BamToEgg::convert_animGroup_node(AnimGroup *animGroup, double fps for (int i = 0; i < num_matrix_components; i++) { string componentName(1, matrix_component_letters[i]); char table_id = matrix_component_letters[i]; - CPTA_float table = xmfTable->get_table(table_id); + CPTA_stdfloat table = xmfTable->get_table(table_id); if (xmfTable->has_table(table_id)) { for (unsigned int j = 0; j < table.size(); j++) { @@ -398,7 +398,7 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac if (bundleNode->is_of_type(CharacterJoint::get_class_type())) { CharacterJoint *character_joint = DCAST(CharacterJoint, bundleNode); - LMatrix4f transformf; + LMatrix4 transformf; character_joint->get_net_transform(transformf); LMatrix4d transformd(LCAST(double, transformf)); EggGroup *joint = new EggGroup(bundleNode->get_name()); @@ -409,8 +409,8 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac if (jointMap!=NULL) { CharacterJointMap::iterator mi = jointMap->find(character_joint); if (mi != jointMap->end()) { - pvector > &joint_vertices = (*mi).second; - pvector >::const_iterator vi; + pvector > &joint_vertices = (*mi).second; + pvector >::const_iterator vi; for (vi = joint_vertices.begin(); vi != joint_vertices.end(); ++vi) { joint->set_vertex_membership((*vi).first, (*vi).second); } @@ -487,8 +487,8 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, NodePath np = node_path.get_node_path(); CPT(TransformState) net_transform = np.get_net_transform(); - LMatrix4f net_mat = net_transform->get_mat(); - LMatrix4f inv = LCAST(float, egg_parent->get_vertex_frame_inv()); + LMatrix4 net_mat = net_transform->get_mat(); + LMatrix4 inv = LCAST(PN_stdfloat, egg_parent->get_vertex_frame_inv()); net_mat = net_mat * inv; int num_solids = node->get_num_solids(); @@ -564,8 +564,8 @@ convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, NodePath np = node_path.get_node_path(); CPT(RenderState) net_state = np.get_net_state(); CPT(TransformState) net_transform = np.get_net_transform(); - LMatrix4f net_mat = net_transform->get_mat(); - LMatrix4f inv = LCAST(float, egg_parent->get_vertex_frame_inv()); + LMatrix4 net_mat = net_transform->get_mat(); + LMatrix4 inv = LCAST(PN_stdfloat, egg_parent->get_vertex_frame_inv()); net_mat = net_mat * inv; // Now get out all the various kinds of geometry. @@ -600,12 +600,12 @@ void BamToEgg:: convert_triangles(const GeomVertexData *vertex_data, const GeomTriangles *primitive, const RenderState *net_state, - const LMatrix4f &net_mat, EggGroupNode *egg_parent, + const LMatrix4 &net_mat, EggGroupNode *egg_parent, CharacterJointMap *jointMap) { GeomVertexReader reader(vertex_data); // Check for a color scale. - LVecBase4f color_scale(1.0f, 1.0f, 1.0f, 1.0f); + LVecBase4 color_scale(1.0f, 1.0f, 1.0f, 1.0f); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, net_state->get_attrib(ColorScaleAttrib::get_class_type())); if (csa != (const ColorScaleAttrib *)NULL) { color_scale = csa->get_scale(); @@ -614,7 +614,7 @@ convert_triangles(const GeomVertexData *vertex_data, // Check for a color override. bool has_color_override = false; bool has_color_off = false; - Colorf color_override; + LColor color_override; const ColorAttrib *ca = DCAST(ColorAttrib, net_state->get_attrib(ColorAttrib::get_class_type())); if (ca != (const ColorAttrib *)NULL) { if (ca->get_color_type() == ColorAttrib::T_flat) { @@ -735,8 +735,8 @@ convert_triangles(const GeomVertexData *vertex_data, } - Normalf normal; - Colorf color; + LNormal normal; + LColor color; CPT(TransformBlendTable) transformBlendTable = vertex_data->get_transform_blend_table(); int nprims = primitive->get_num_primitives(); @@ -758,24 +758,24 @@ convert_triangles(const GeomVertexData *vertex_data, reader.set_row(primitive->get_vertex(i * 3 + j)); reader.set_column(InternalName::get_vertex()); - Vertexf vertex = reader.get_data3f(); + LVertex vertex = reader.get_data3(); egg_vert.set_pos(LCAST(double, vertex * net_mat)); if (vertex_data->has_column(InternalName::get_normal())) { reader.set_column(InternalName::get_normal()); - Normalf normal = reader.get_data3f(); + LNormal normal = reader.get_data3(); egg_vert.set_normal(LCAST(double, normal * net_mat)); } if (has_color_override) { egg_vert.set_color(color_override); } else if (!has_color_off) { - Colorf color(1.0f, 1.0f, 1.0f, 1.0f); + LColor color(1.0f, 1.0f, 1.0f, 1.0f); if (vertex_data->has_column(InternalName::get_color())) { reader.set_column(InternalName::get_color()); - color = reader.get_data4f(); + color = reader.get_data4(); } - egg_vert.set_color(Colorf(color[0] * color_scale[0], + egg_vert.set_color(LColor(color[0] * color_scale[0], color[1] * color_scale[1], color[2] * color_scale[2], color[3] * color_scale[3])); @@ -783,7 +783,7 @@ convert_triangles(const GeomVertexData *vertex_data, if (vertex_data->has_column(InternalName::get_texcoord())) { reader.set_column(InternalName::get_texcoord()); - TexCoordf uv = reader.get_data2f(); + LTexCoord uv = reader.get_data2(); egg_vert.set_uv(LCAST(double, uv)); } @@ -796,7 +796,7 @@ convert_triangles(const GeomVertexData *vertex_data, const TransformBlend &blend = transformBlendTable->get_blend(idx); int num_weights = blend.get_num_transforms(); for (int k = 0; k < num_weights; ++k) { - float weight = blend.get_weight(k); + PN_stdfloat weight = blend.get_weight(k); if (weight!=0) { const VertexTransform *vertex_transform = blend.get_transform(k); if (vertex_transform->is_of_type(JointVertexTransform::get_class_type())) { @@ -804,10 +804,10 @@ convert_triangles(const GeomVertexData *vertex_data, CharacterJointMap::iterator mi = jointMap->find(joint_vertex_transform->get_joint()); if (mi == jointMap->end()) { - mi = jointMap->insert(CharacterJointMap::value_type(joint_vertex_transform->get_joint(), pvector >())).first; + mi = jointMap->insert(CharacterJointMap::value_type(joint_vertex_transform->get_joint(), pvector >())).first; } - pvector > &joint_vertices = (*mi).second; - joint_vertices.push_back(pair(new_egg_vert, weight)); + pvector > &joint_vertices = (*mi).second; + joint_vertices.push_back(pair(new_egg_vert, weight)); } } } @@ -903,22 +903,22 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage if (transform->has_components()) { // If the transform can be represented componentwise, we prefer // storing it that way in the egg file. - const LVecBase3f &scale = transform->get_scale(); - const LQuaternionf &quat = transform->get_quat(); - const LVecBase3f &pos = transform->get_pos(); - if (!scale.almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f))) { + const LVecBase3 &scale = transform->get_scale(); + const LQuaternion &quat = transform->get_quat(); + const LVecBase3 &pos = transform->get_pos(); + if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { egg_group->add_scale3d(LCAST(double, scale)); } if (!quat.is_identity()) { egg_group->add_rotate3d(LCAST(double, quat)); } - if (!pos.almost_equal(LVecBase3f::zero())) { + if (!pos.almost_equal(LVecBase3::zero())) { egg_group->add_translate3d(LCAST(double, pos)); } } else if (transform->has_mat()) { // Otherwise, we store the raw matrix. - const LMatrix4f &mat = transform->get_mat(); + const LMatrix4 &mat = transform->get_mat(); egg_group->set_transform3d(LCAST(double, mat)); } any_applied = true; diff --git a/pandatool/src/bam/bamToEgg.h b/pandatool/src/bam/bamToEgg.h index 0efb0251e2..97b31f1d4d 100644 --- a/pandatool/src/bam/bamToEgg.h +++ b/pandatool/src/bam/bamToEgg.h @@ -45,7 +45,7 @@ class Texture; class CharacterJoint; class EggVertex; -typedef pmap > > CharacterJointMap; +typedef pmap > > CharacterJointMap; //////////////////////////////////////////////////////////////////// // Class : BamToEgg @@ -81,7 +81,7 @@ private: void convert_triangles(const GeomVertexData *vertex_data, const GeomTriangles *primitive, const RenderState *net_state, - const LMatrix4f &net_mat, EggGroupNode *egg_parent, + const LMatrix4 &net_mat, EggGroupNode *egg_parent, CharacterJointMap *jointMap); void recurse_nodes(const WorkingNodePath &node_path, EggGroupNode *egg_parent, diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index eb6ea0c585..fcd10e602f 100755 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -93,7 +93,7 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { // Set the material parameters egg_material->set_amb(TO_COLOR(effect_common->GetAmbientColor())); ////We already process transparency using blend modes - //LVecBase4f diffuse = TO_COLOR(effect_common->GetDiffuseColor()); + //LVecBase4 diffuse = TO_COLOR(effect_common->GetDiffuseColor()); //diffuse.set_w(diffuse.get_w() * (1.0f - effect_common->GetOpacity())); //egg_material->set_diff(diffuse); egg_material->set_diff(TO_COLOR(effect_common->GetDiffuseColor())); @@ -374,18 +374,18 @@ convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type) // Description: Converts collada blend attribs to Panda's equivalents. //////////////////////////////////////////////////////////////////// PT(DaeMaterials::DaeBlendSettings) DaeMaterials:: -convert_blend(FCDEffectStandard::TransparencyMode mode, Colorf transparent, double transparency) { +convert_blend(FCDEffectStandard::TransparencyMode mode, LColor transparent, double transparency) { // Create the DaeBlendSettings and fill it with some defaults. PT(DaeBlendSettings) blend = new DaeBlendSettings(); blend->_enabled = true; - blend->_color = Colorf::zero(); + blend->_color = LColor::zero(); blend->_operand_a = EggGroup::BO_unspecified; blend->_operand_b = EggGroup::BO_unspecified; // First fill in the color value. if (mode == FCDEffectStandard::A_ONE) {// || mode == FCDEffectStandard::A_ZERO) { double value = transparent[3] * transparency; - blend->_color = Colorf(value, value, value, value); + blend->_color = LColor(value, value, value, value); } else if (mode == FCDEffectStandard::RGB_ZERO) {//|| mode == FCDEffectStandard::RGB_ONE) { blend->_color = transparent * transparency; blend->_color[3] = luminance(blend->_color); diff --git a/pandatool/src/daeegg/daeMaterials.h b/pandatool/src/daeegg/daeMaterials.h index 3fbb7255ee..4b1950889a 100755 --- a/pandatool/src/daeegg/daeMaterials.h +++ b/pandatool/src/daeegg/daeMaterials.h @@ -56,7 +56,7 @@ private: // Holds stuff for color blend attribs. struct DaeBlendSettings : public ReferenceCount { bool _enabled; - Colorf _color; + LColor _color; EggGroup::BlendOperand _operand_a; EggGroup::BlendOperand _operand_b; }; @@ -79,7 +79,7 @@ private: void process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified); void process_extra(const string semantic, const FCDExtra* extra); - static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, Colorf transparent, double transparency); + static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, LColor transparent, double transparency); pmap _materials; diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index 249e7f6aa0..f0e6de067b 100755 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -406,7 +406,7 @@ void DAEToEggConverter::process_mesh(PT(EggGroup) parent, const FCDGeometryMesh* // Loop through the indices and add the vertices. for (size_t ix = 0; ix < pinput->GetIndexCount(); ++ix) { PT_EggVertex vertex = mesh_pool->make_new_vertex(); - const float* data = &vsource->GetData()[indices[ix]*3]; + const PN_stdfloat* data = &vsource->GetData()[indices[ix]*3]; vertex->set_pos(LPoint3d(data[0], data[1], data[2])); // Process the normal if (nsource != NULL && ninput != NULL) { @@ -429,10 +429,10 @@ void DAEToEggConverter::process_mesh(PT(EggGroup) parent, const FCDGeometryMesh* assert(csource->GetStride() == 3 || csource->GetStride() == 4); if (csource->GetStride() == 3) { data = &csource->GetData()[cindices[ix]*3]; - vertex->set_color(Colorf(data[0], data[1], data[2], 1.0f)); + vertex->set_color(LColor(data[0], data[1], data[2], 1.0f)); } else { data = &csource->GetData()[cindices[ix]*4]; - vertex->set_color(Colorf(data[0], data[1], data[2], data[3])); + vertex->set_color(LColor(data[0], data[1], data[2], data[3])); } } // Possibly add a UV object @@ -529,7 +529,7 @@ void DAEToEggConverter::process_spline(PT(EggGroup) parent, const FCDSpline* spl //TODO: what value is this? nurbs_curve->setup(0, ((const FCDNURBSSpline*) spline)->GetKnotCount()); for (size_t kn = 0; kn < ((const FCDNURBSSpline*) spline)->GetKnotCount(); ++kn) { - const float* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn); + const PN_stdfloat* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn); assert(knot != NULL); nurbs_curve->set_knot(kn, *knot); } @@ -573,18 +573,18 @@ void DAEToEggConverter::process_controller(PT(EggGroup) parent, const FCDControl } if (controller->IsSkin()) { // Load in the vertex influences first - pmap > > influences; + pmap > > influences; if (vertex_pool) { for (size_t in = 0; in < controller->GetSkinController()->GetInfluenceCount(); ++in) { assert(vertex_pool->has_vertex(in)); for (size_t pa = 0; pa < controller->GetSkinController()->GetVertexInfluence(in)->GetPairCount(); ++pa) { const FCDJointWeightPair* jwpair = controller->GetSkinController()->GetVertexInfluence(in)->GetPair(pa); - influences[jwpair->jointIndex].push_back(pair (vertex_pool->get_vertex(in), jwpair->weight)); + influences[jwpair->jointIndex].push_back(pair (vertex_pool->get_vertex(in), jwpair->weight)); } } } // Loop through the joints in the vertex influences - for (pmap > >::iterator it = influences.begin(); it != influences.end(); ++it) { + for (pmap > >::iterator it = influences.begin(); it != influences.end(); ++it) { if (it->first == -1) { daeegg_cat.warning() << "Ignoring vertex influence with negative joint index\n"; //FIXME: Why are there joints with index -1 @@ -593,7 +593,7 @@ void DAEToEggConverter::process_controller(PT(EggGroup) parent, const FCDControl //TODO: what if the joints have just not been defined yet? if (_joints.count(joint_id) > 0) { if (_joints[joint_id]) { - for (pvector >::iterator vi = it->second.begin(); vi != it->second.end(); ++vi) { + for (pvector >::iterator vi = it->second.begin(); vi != it->second.end(); ++vi) { _joints[joint_id]->ref_vertex(vi->first, vi->second); } } else { diff --git a/pandatool/src/daeegg/fcollada_utils.h b/pandatool/src/daeegg/fcollada_utils.h index aef07be3e2..10145f615b 100644 --- a/pandatool/src/daeegg/fcollada_utils.h +++ b/pandatool/src/daeegg/fcollada_utils.h @@ -28,8 +28,8 @@ inline LVecBase3d TO_VEC3(FMVector3 v) { inline LVecBase4d TO_VEC4(FMVector4 v) { return LVecBase4d(v.x, v.y, v.z, v.w); } -inline Colorf TO_COLOR(FMVector4 v) { - return Colorf(v.x, v.y, v.z, v.w); +inline LColor TO_COLOR(FMVector4 v) { + return LColor(v.x, v.y, v.z, v.w); } #define FROM_VEC3(v) (FMVector3(v[0], v[1], v[2])) #define FROM_VEC4(v) (FMVector4(v[0], v[1], v[2], v[3])) diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index 9742f426f7..cb119a5d28 100755 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -24,7 +24,7 @@ // Useful conversion stuff #define TO_VEC3(v) (LVecBase3d(v[0], v[1], v[2])) #define TO_VEC4(v) (LVecBase4d(v[0], v[1], v[2], v[3])) -#define TO_COLOR(v) (Colorf(v[0], v[1], v[2], v[3])) +#define TO_COLOR(v) (LColor(v[0], v[1], v[2], v[3])) #define FROM_VEC3(v) (FMVector3(v[0], v[1], v[2])) #define FROM_VEC4(v) (FMVector4(v[0], v[1], v[2], v[3])) #define FROM_MAT4(v) (FMMatrix44(v.get_data())) diff --git a/pandatool/src/dxfegg/dxfToEggLayer.cxx b/pandatool/src/dxfegg/dxfToEggLayer.cxx index 8fdedc16cc..bf0c52e8ea 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.cxx +++ b/pandatool/src/dxfegg/dxfToEggLayer.cxx @@ -51,7 +51,7 @@ add_polygon(const DXFToEggConverter *entity) { _group->add_child(poly); const DXFFile::Color &color = entity->get_color(); - poly->set_color(Colorf(color.r, color.g, color.b, 1.0)); + poly->set_color(LColor(color.r, color.g, color.b, 1.0)); // A polyline's vertices are stored in the attached vector by // dxf.cxx. They were defined in the DXF file using a series of @@ -84,7 +84,7 @@ add_line(const DXFToEggConverter *entity) { _group->add_child(line); const DXFFile::Color &color = entity->get_color(); - line->set_color(Colorf(color.r, color.g, color.b, 1.0)); + line->set_color(LColor(color.r, color.g, color.b, 1.0)); DXFVertices::const_iterator vi; for (vi = entity->_verts.begin(); diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.cxx b/pandatool/src/dxfprogs/eggToDXFLayer.cxx index 20b7a2cd68..7046312eb5 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.cxx +++ b/pandatool/src/dxfprogs/eggToDXFLayer.cxx @@ -69,7 +69,7 @@ operator = (const EggToDXFLayer ©) { // the layer color. //////////////////////////////////////////////////////////////////// void EggToDXFLayer:: -add_color(const Colorf &color) { +add_color(const LColor &color) { int autocad_color = get_autocad_color(color); ColorCounts::iterator cci; @@ -226,8 +226,8 @@ write_entities(ostream &out) { // matches the indicated EggColor. //////////////////////////////////////////////////////////////////// int EggToDXFLayer:: -get_autocad_color(const Colorf &color) { - typedef pmap ColorMap; +get_autocad_color(const LColor &color) { + typedef pmap ColorMap; static ColorMap _map; ColorMap::iterator cmi; diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.h b/pandatool/src/dxfprogs/eggToDXFLayer.h index 310257f50a..a479ca27b9 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.h +++ b/pandatool/src/dxfprogs/eggToDXFLayer.h @@ -35,7 +35,7 @@ public: EggToDXFLayer(const EggToDXFLayer ©); void operator = (const EggToDXFLayer ©); - void add_color(const Colorf &color); + void add_color(const LColor &color); void choose_overall_color(); void write_layer(ostream &out); @@ -44,7 +44,7 @@ public: void write_entities(ostream &out); private: - int get_autocad_color(const Colorf &color); + int get_autocad_color(const LColor &color); typedef pmap ColorCounts; ColorCounts _color_counts; diff --git a/pandatool/src/egg-mkfont/eggMakeFont.h b/pandatool/src/egg-mkfont/eggMakeFont.h index 04246dca77..e5d456200e 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.h +++ b/pandatool/src/egg-mkfont/eggMakeFont.h @@ -63,7 +63,7 @@ private: private: - Colorf _fg, _bg, _interior; + LColor _fg, _bg, _interior; bool _got_interior; RangeDescription _range; vector_string _extra_filenames; diff --git a/pandatool/src/egg-qtess/isoPlacer.cxx b/pandatool/src/egg-qtess/isoPlacer.cxx index b79f7dad0c..7c22d3bafd 100644 --- a/pandatool/src/egg-qtess/isoPlacer.cxx +++ b/pandatool/src/egg-qtess/isoPlacer.cxx @@ -47,8 +47,8 @@ get_scores(int subdiv, int across, double ratio, for (a = 0; a <= across; a++) { double v = (double)a / (double)across; - LVecBase3f p1, p2, p3, pnext; - LVecBase3f v1, v2; + LVecBase3 p1, p2, p3, pnext; + LVecBase3 v1, v2; if (s) { surf->eval_point(0.0, v, p3); } else { diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index 477addb6d1..97bcbc16cf 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -308,7 +308,7 @@ record_vertex_extras() { dxi != egg_vertex->_dxyzs.end(); ++dxi) { const string &morph_name = (*dxi).get_name(); - LVector3f delta = LCAST(float, (*dxi).get_offset()); + LVector3 delta = LCAST(PN_stdfloat, (*dxi).get_offset()); int d = get_dxyz_index(morph_name); _nurbs->set_extended_vertices(ui, vi, d, delta.get_data(), 3); } @@ -319,7 +319,7 @@ record_vertex_extras() { dri != egg_vertex->_drgbas.end(); ++dri) { const string &morph_name = (*dri).get_name(); - const LVector4f &delta = (*dri).get_offset(); + const LVector4 &delta = (*dri).get_offset(); int d = get_drgba_index(morph_name); _nurbs->set_extended_vertices(ui, vi, d, delta.get_data(), 4); } @@ -541,15 +541,15 @@ PT(EggVertex) QtessSurface:: evaluate_vertex(double u, double v) const { PT(EggVertex) egg_vertex = new EggVertex; - Vertexf point; - Normalf normal; + LVertex point; + LNormal normal; _nurbs_result->eval_point(u, v, point); _nurbs_result->eval_normal(u, v, normal); // If the normal is too short, don't consider it--it's probably // inaccurate due to numerical limitations. We'll recompute it // later based on the polygon normals. - float length = normal.length(); + PN_stdfloat length = normal.length(); if (length > 0.0001f) { normal /= length; egg_vertex->set_normal(LCAST(double, normal)); @@ -560,7 +560,7 @@ evaluate_vertex(double u, double v) const { // The color is stored, by convention, in slots 0-4 of the surface. if (_has_vertex_color) { - Colorf rgba; + LColor rgba; _nurbs_result->eval_extended_points(u, v, 0, &rgba[0], 4); egg_vertex->set_color(rgba); } @@ -583,9 +583,9 @@ evaluate_vertex(double u, double v) const { const string &morph_name = (*mti).first; int d = (*mti).second; - LVector3f delta; + LVector3 delta; _nurbs_result->eval_extended_points(u, v, d, &delta[0], 3); - if (!delta.almost_equal(LVector3f::zero())) { + if (!delta.almost_equal(LVector3::zero())) { egg_vertex->_dxyzs.insert(EggMorphVertex(morph_name, LCAST(double, delta))); } } @@ -594,9 +594,9 @@ evaluate_vertex(double u, double v) const { const string &morph_name = (*mti).first; int d = (*mti).second; - LVector4f delta; + LVector4 delta; _nurbs_result->eval_extended_points(u, v, d, &delta[0], 4); - if (!delta.almost_equal(LVector4f::zero())) { + if (!delta.almost_equal(LVector4::zero())) { egg_vertex->_drgbas.insert(EggMorphColor(morph_name, delta)); } } diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 3c9e8b570c..79966d8148 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -198,8 +198,8 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { // First, build up a big array of the new transforms this joint // would receive in all frames of all models, were it reparented to // the indicated joint. - vector_float i, j, k, a, b, c, x, y, z; - pvector hprs; + vector_stdfloat i, j, k, a, b, c, x, y, z; + pvector hprs; int num_rows = 0; int num_models = get_num_models(); @@ -243,7 +243,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { a.push_back(shear[0]); b.push_back(shear[1]); c.push_back(shear[2]); - hprs.push_back(LCAST(float, hpr)); + hprs.push_back(LCAST(PN_stdfloat, hpr)); x.push_back(translate[0]); y.push_back(translate[1]); z.push_back(translate[2]); diff --git a/pandatool/src/eggprogs/eggTextureCards.h b/pandatool/src/eggprogs/eggTextureCards.h index 81ea1929ac..2858f8d11c 100644 --- a/pandatool/src/eggprogs/eggTextureCards.h +++ b/pandatool/src/eggprogs/eggTextureCards.h @@ -56,7 +56,7 @@ public: LVecBase2d _pixel_scale; bool _got_pixel_scale; vector_string _suffixes; - Colorf _polygon_color; + LColor _polygon_color; vector_string _texture_names; EggTexture::WrapMode _wrap_mode; EggTexture::WrapMode _wrap_u; diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index eb74012bb5..b28d44546f 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -242,7 +242,7 @@ write_vertex_pool(EggVertexPool *vpool) { if (vert == (EggVertex *)NULL || !vert->has_color()) { out << " color(), /* " << i << " */\n"; } else { - Colorf c = vert->get_color(); + LColor c = vert->get_color(); out << " color(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << "), /* " << i << " */\n"; } @@ -361,7 +361,7 @@ write_bin(EggBin *bin) { if (!prim->has_color()) { out << " color(), /* " << prim_index << " */\n"; } else { - Colorf c = prim->get_color(); + LColor c = prim->get_color(); out << " color(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << "), /* " << prim_index << " */\n"; } diff --git a/pandatool/src/flt/fltEyepoint.cxx b/pandatool/src/flt/fltEyepoint.cxx index 825a693876..c63d1312a7 100644 --- a/pandatool/src/flt/fltEyepoint.cxx +++ b/pandatool/src/flt/fltEyepoint.cxx @@ -25,12 +25,12 @@ FltEyepoint:: FltEyepoint() { _rotation_center.set(0.0, 0.0, 0.0); _hpr.set(0.0, 0.0, 0.0); - _rotation = LMatrix4f::ident_mat(); + _rotation = LMatrix4::ident_mat(); _fov = 60.0; _scale = 1.0; _near_clip = 0.1; _far_clip = 10000.0; - _fly_through = LMatrix4f::ident_mat(); + _fly_through = LMatrix4::ident_mat(); _eyepoint.set(0.0, 0.0, 0.0); _fly_through_yaw = 0.0; _fly_through_pitch = 0.0; diff --git a/pandatool/src/flt/fltEyepoint.h b/pandatool/src/flt/fltEyepoint.h index 06d3da3b74..44f950371d 100644 --- a/pandatool/src/flt/fltEyepoint.h +++ b/pandatool/src/flt/fltEyepoint.h @@ -36,17 +36,17 @@ public: public: LPoint3d _rotation_center; - LVecBase3f _hpr; - LMatrix4f _rotation; - float _fov; - float _scale; - float _near_clip; - float _far_clip; - LMatrix4f _fly_through; - LPoint3f _eyepoint; - float _fly_through_yaw; - float _fly_through_pitch; - LVector3f _eyepoint_direction; + LVecBase3 _hpr; + LMatrix4 _rotation; + PN_stdfloat _fov; + PN_stdfloat _scale; + PN_stdfloat _near_clip; + PN_stdfloat _far_clip; + LMatrix4 _fly_through; + LPoint3 _eyepoint; + PN_stdfloat _fly_through_yaw; + PN_stdfloat _fly_through_pitch; + LVector3 _eyepoint_direction; bool _no_fly_through; bool _ortho_mode; bool _is_valid; diff --git a/pandatool/src/flt/fltGeometry.cxx b/pandatool/src/flt/fltGeometry.cxx index 02ccd1720d..ffe7f93d2c 100644 --- a/pandatool/src/flt/fltGeometry.cxx +++ b/pandatool/src/flt/fltGeometry.cxx @@ -61,9 +61,9 @@ FltGeometry(FltHeader *header) : FltBeadID(header) { // If has_color() is false, the result is white, but // still reflects the transparency correctly. //////////////////////////////////////////////////////////////////// -Colorf FltGeometry:: +LColor FltGeometry:: get_color() const { - Colorf color; + LColor color; if (!has_color() || (_texwhite && has_texture())) { // Force this one white. @@ -77,14 +77,14 @@ get_color() const { material->_diffuse[2], material->_alpha); } else { - RGBColorf rgb = + LRGBColor rgb = _header->get_rgb(_color_index, (_flags & F_packed_color) != 0, _packed_color); color.set(rgb[0], rgb[1], rgb[2], 1.0); } // Modify the whole thing by our transparency. - float alpha = 1.0 - (_transparency / 65535.0); + PN_stdfloat alpha = 1.0 - (_transparency / 65535.0); color[3] *= alpha; return color; @@ -97,8 +97,8 @@ get_color() const { // color convention. //////////////////////////////////////////////////////////////////// void FltGeometry:: -set_color(const Colorf &color) { - set_rgb(RGBColorf(color[0], color[1], color[2])); +set_color(const LColor &color) { + set_rgb(LRGBColor(color[0], color[1], color[2])); _transparency = (int)floor((1.0 - color[3]) * 65535.0); } @@ -108,11 +108,11 @@ set_color(const Colorf &color) { // Description: Returns the primary color of the face, as a // three-component value ignoring transparency. //////////////////////////////////////////////////////////////////// -RGBColorf FltGeometry:: +LRGBColor FltGeometry:: get_rgb() const { if (!has_color() || (_texwhite && has_texture())) { // Force this one white. - return RGBColorf(1.0, 1.0, 1.0); + return LRGBColor(1.0, 1.0, 1.0); } if (has_material()) { @@ -132,7 +132,7 @@ get_rgb() const { // color convention; does not affect transparency. //////////////////////////////////////////////////////////////////// void FltGeometry:: -set_rgb(const RGBColorf &rgb) { +set_rgb(const LRGBColor &rgb) { _packed_color.set_rgb(rgb); _flags = ((_flags & ~F_no_color) | F_packed_color); @@ -159,9 +159,9 @@ has_alt_color() const { // color of the face, as a four-component value // (including alpha as the transparency channel). //////////////////////////////////////////////////////////////////// -Colorf FltGeometry:: +LColor FltGeometry:: get_alt_color() const { - nassertr(has_alt_color(), Colorf(0.0, 0.0, 0.0, 0.0)); + nassertr(has_alt_color(), LColor(0.0, 0.0, 0.0, 0.0)); return _header->get_color(_alt_color_index, (_flags & F_packed_color) != 0, _alt_packed_color, _transparency); @@ -174,9 +174,9 @@ get_alt_color() const { // color of the face, as a three-component value // ignoring transparency. //////////////////////////////////////////////////////////////////// -RGBColorf FltGeometry:: +LRGBColor FltGeometry:: get_alt_rgb() const { - nassertr(has_alt_color(), RGBColorf(0.0, 0.0, 0.0)); + nassertr(has_alt_color(), LRGBColor(0.0, 0.0, 0.0)); return _header->get_rgb(_alt_color_index, (_flags & F_packed_color) != 0, _alt_packed_color); diff --git a/pandatool/src/flt/fltGeometry.h b/pandatool/src/flt/fltGeometry.h index b571b6e653..97007d8f44 100644 --- a/pandatool/src/flt/fltGeometry.h +++ b/pandatool/src/flt/fltGeometry.h @@ -105,14 +105,14 @@ public: INLINE void set_material(FltMaterial *material); INLINE bool has_color() const; - Colorf get_color() const; - void set_color(const Colorf &color); - RGBColorf get_rgb() const; - void set_rgb(const RGBColorf &rgb); + LColor get_color() const; + void set_color(const LColor &color); + LRGBColor get_rgb() const; + void set_rgb(const LRGBColor &rgb); bool has_alt_color() const; - Colorf get_alt_color() const; - RGBColorf get_alt_rgb() const; + LColor get_alt_color() const; + LRGBColor get_alt_rgb() const; protected: diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index 89366eb28b..9816ce6f7b 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -655,18 +655,18 @@ get_num_colors() const { // given color index. Each component will be in the // range [0, 1]. //////////////////////////////////////////////////////////////////// -Colorf FltHeader:: +LColor FltHeader:: get_color(int color_index) const { nassertr(color_index >= 0 && color_index < get_num_colors(), - Colorf(0.0, 0.0, 0.0, 0.0)); + LColor(0.0, 0.0, 0.0, 0.0)); int num_color_shades = get_num_color_shades(); int index = (color_index / num_color_shades); int level = (color_index % num_color_shades); nassertr(index >= 0 && index < (int)_colors.size(), - Colorf(0.0, 0.0, 0.0, 0.0)); + LColor(0.0, 0.0, 0.0, 0.0)); - Colorf color = _colors[index].get_color(); + LColor color = _colors[index].get_color(); return color * ((double)level / (double)(num_color_shades - 1)); } @@ -677,18 +677,18 @@ get_color(int color_index) const { // the given color index, ignoring the alpha component. // Each component will be in the range [0, 1]. //////////////////////////////////////////////////////////////////// -RGBColorf FltHeader:: +LRGBColor FltHeader:: get_rgb(int color_index) const { nassertr(color_index >= 0 && color_index < get_num_colors(), - RGBColorf(0.0, 0.0, 0.0)); + LRGBColor(0.0, 0.0, 0.0)); int num_color_shades = get_num_color_shades(); int index = (color_index / num_color_shades); int level = (color_index % num_color_shades); nassertr(index >= 0 && index < (int)_colors.size(), - RGBColorf(0.0, 0.0, 0.0)); + LRGBColor(0.0, 0.0, 0.0)); - RGBColorf color = _colors[index].get_rgb(); + LRGBColor color = _colors[index].get_rgb(); return color * ((double)level / (double)(num_color_shades - 1)); } @@ -727,7 +727,7 @@ get_color_name(int color_index) const { // including alpha. //////////////////////////////////////////////////////////////////// int FltHeader:: -get_closest_color(Colorf color) const { +get_closest_color(LColor color) const { // Since the colortable stores the brightest colors, with // num_color_shades scaled versions of each color implicitly // available, we really only care about the relative brightnesses of @@ -762,13 +762,13 @@ get_closest_color(Colorf color) const { } // Now search for the best match. - float best_dist = 5.0; // Greater than 4. + PN_stdfloat best_dist = 5.0; // Greater than 4. int best_i = -1; int num_color_entries = get_num_color_entries(); for (int i = 0; i < num_color_entries; i++) { - Colorf consider = _colors[i].get_color(); - float dist2 = dot(consider - color, consider - color); + LColor consider = _colors[i].get_color(); + PN_stdfloat dist2 = dot(consider - color, consider - color); nassertr(dist2 < 5.0, 0); if (dist2 < best_dist) { @@ -792,7 +792,7 @@ get_closest_color(Colorf color) const { // ignoring alpha. //////////////////////////////////////////////////////////////////// int FltHeader:: -get_closest_rgb(RGBColorf color) const { +get_closest_rgb(LRGBColor color) const { // Since the colortable stores the brightest colors, with // num_color_shades scaled versions of each color implicitly // available, we really only care about the relative brightnesses of @@ -823,13 +823,13 @@ get_closest_rgb(RGBColorf color) const { } // Now search for the best match. - float best_dist = 5.0; // Greater than 4. + PN_stdfloat best_dist = 5.0; // Greater than 4. int best_i = -1; int num_color_entries = get_num_color_entries(); for (int i = 0; i < num_color_entries; i++) { - RGBColorf consider = _colors[i].get_rgb(); - float dist2 = dot(consider - color, consider - color); + LRGBColor consider = _colors[i].get_rgb(); + PN_stdfloat dist2 = dot(consider - color, consider - color); nassertr(dist2 < 5.0, 0); if (dist2 < best_dist) { @@ -874,12 +874,12 @@ get_num_color_shades() const { // Function: FltHeader::get_color // Access: Public // Description: Decodes a MultiGen color, as stored on a face or -// vertex, into an actual four-component Colorf. +// vertex, into an actual four-component LColor. // Normally you need not call this directly; there are // color accessors defined on faces and vertices that do // this. //////////////////////////////////////////////////////////////////// -Colorf FltHeader:: +LColor FltHeader:: get_color(int color_index, bool use_packed_color, const FltPackedColor &packed_color, int transparency) { @@ -887,7 +887,7 @@ get_color(int color_index, bool use_packed_color, return get_color(color_index); } - Colorf color; + LColor color; color[0] = packed_color._r / 255.0; color[1] = packed_color._g / 255.0; color[2] = packed_color._b / 255.0; @@ -901,19 +901,19 @@ get_color(int color_index, bool use_packed_color, // Function: FltHeader::get_color // Access: Public // Description: Decodes a MultiGen color, as stored on a face or -// vertex, into an actual three-component RGBColorf. +// vertex, into an actual three-component LRGBColor. // Normally you need not call this directly; there are // color accessors defined on faces and vertices that do // this. //////////////////////////////////////////////////////////////////// -RGBColorf FltHeader:: +LRGBColor FltHeader:: get_rgb(int color_index, bool use_packed_color, const FltPackedColor &packed_color) { if (!use_packed_color) { return get_rgb(color_index); } - RGBColorf color; + LRGBColor color; color[0] = packed_color._r / 255.0; color[1] = packed_color._g / 255.0; color[2] = packed_color._b / 255.0; diff --git a/pandatool/src/flt/fltHeader.h b/pandatool/src/flt/fltHeader.h index 64a99f8e8f..1b25eb04fe 100644 --- a/pandatool/src/flt/fltHeader.h +++ b/pandatool/src/flt/fltHeader.h @@ -182,23 +182,23 @@ public: // Accessors into the color palette. This is read-only; why would // you want to mess with building a new color palette? int get_num_colors() const; - Colorf get_color(int color_index) const; - RGBColorf get_rgb(int color_index) const; + LColor get_color(int color_index) const; + LRGBColor get_rgb(int color_index) const; bool has_color_name(int color_index) const; string get_color_name(int color_index) const; - int get_closest_color(Colorf color) const; - int get_closest_rgb(RGBColorf color) const; + int get_closest_color(LColor color) const; + int get_closest_rgb(LRGBColor color) const; int get_num_color_entries() const; int get_num_color_shades() const; // These functions are mainly used behind-the-scenes to decode the // strange forest of color options defined for faces and vertices. - Colorf get_color(int color_index, bool use_packed_color, + LColor get_color(int color_index, bool use_packed_color, const FltPackedColor &packed_color, int transparency); - RGBColorf get_rgb(int color_index, bool use_packed_color, + LRGBColor get_rgb(int color_index, bool use_packed_color, const FltPackedColor &packed_color); // Accessors into the material palette. diff --git a/pandatool/src/flt/fltLightSourceDefinition.h b/pandatool/src/flt/fltLightSourceDefinition.h index 159d88434e..bd90057aa1 100644 --- a/pandatool/src/flt/fltLightSourceDefinition.h +++ b/pandatool/src/flt/fltLightSourceDefinition.h @@ -40,21 +40,21 @@ public: int _light_index; string _light_name; - Colorf _ambient; - Colorf _diffuse; - Colorf _specular; + LColor _ambient; + LColor _diffuse; + LColor _specular; LightType _light_type; - float _exponential_dropoff; - float _cutoff_angle; // in degrees + PN_stdfloat _exponential_dropoff; + PN_stdfloat _cutoff_angle; // in degrees // yaw and pitch only for modeling lights, which are positioned at // the eyepoint. - float _yaw; - float _pitch; + PN_stdfloat _yaw; + PN_stdfloat _pitch; - float _constant_coefficient; - float _linear_coefficient; - float _quadratic_coefficient; + PN_stdfloat _constant_coefficient; + PN_stdfloat _linear_coefficient; + PN_stdfloat _quadratic_coefficient; bool _modeling_light; protected: diff --git a/pandatool/src/flt/fltLocalVertexPool.cxx b/pandatool/src/flt/fltLocalVertexPool.cxx index 1dcd061077..5b0951e027 100644 --- a/pandatool/src/flt/fltLocalVertexPool.cxx +++ b/pandatool/src/flt/fltLocalVertexPool.cxx @@ -193,7 +193,7 @@ build_record(FltRecordWriter &writer) const { if ((vertex->_flags & (FltVertex::F_no_color | FltVertex::F_packed_color)) != 0) { // This particular vertex does not have a color index. // Make it white. - datagram.add_be_int32(_header->get_closest_rgb(RGBColorf(1.0, 1.0, 1.0))); + datagram.add_be_int32(_header->get_closest_rgb(LRGBColor(1.0, 1.0, 1.0))); } else { datagram.add_be_int32(vertex->_color_index); } @@ -209,7 +209,7 @@ build_record(FltRecordWriter &writer) const { color.set_color(vertex->get_color()); } else { // An uncolored vertex. Make it white. - color.set_color(Colorf(1.0, 1.0, 1.0, 1.0)); + color.set_color(LColor(1.0, 1.0, 1.0, 1.0)); } if (!color.build_record(writer)) { diff --git a/pandatool/src/flt/fltMaterial.h b/pandatool/src/flt/fltMaterial.h index 9e5f8f9ccc..7c70446022 100644 --- a/pandatool/src/flt/fltMaterial.h +++ b/pandatool/src/flt/fltMaterial.h @@ -38,12 +38,12 @@ public: int _material_index; string _material_name; unsigned int _flags; - RGBColorf _ambient; - RGBColorf _diffuse; - RGBColorf _specular; - RGBColorf _emissive; - float _shininess; - float _alpha; + LRGBColor _ambient; + LRGBColor _diffuse; + LRGBColor _specular; + LRGBColor _emissive; + PN_stdfloat _shininess; + PN_stdfloat _alpha; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltPackedColor.I b/pandatool/src/flt/fltPackedColor.I index 6548c79249..8eaefee12a 100644 --- a/pandatool/src/flt/fltPackedColor.I +++ b/pandatool/src/flt/fltPackedColor.I @@ -35,34 +35,34 @@ FltPackedColor() { //////////////////////////////////////////////////////////////////// // Function: FltPackedColor::get_color // Access: Public -// Description: Returns the four-component color as a Colorf, where +// Description: Returns the four-component color as a LColor, where // each component is in the range [0, 1]. //////////////////////////////////////////////////////////////////// -INLINE Colorf FltPackedColor:: +INLINE LColor FltPackedColor:: get_color() const { - return Colorf(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0); + return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0); } //////////////////////////////////////////////////////////////////// // Function: FltPackedColor::get_rgb // Access: Public -// Description: Returns the three-component color as an RGBColorf +// Description: Returns the three-component color as an LRGBColor // (ignoring the alpha component), where each component // is in the range [0, 1]. //////////////////////////////////////////////////////////////////// -INLINE RGBColorf FltPackedColor:: +INLINE LRGBColor FltPackedColor:: get_rgb() const { - return RGBColorf(_r / 255.0, _g / 255.0, _b / 255.0); + return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0); } //////////////////////////////////////////////////////////////////// // Function: FltPackedColor::set_color // Access: Public // Description: Sets the color according to the indicated -// four-component Colorf value (including alpha). +// four-component LColor value (including alpha). //////////////////////////////////////////////////////////////////// INLINE void FltPackedColor:: -set_color(const Colorf &color) { +set_color(const LColor &color) { _r = (int)floor(color[0] * 255.0); _g = (int)floor(color[1] * 255.0); _b = (int)floor(color[2] * 255.0); @@ -73,11 +73,11 @@ set_color(const Colorf &color) { // Function: FltPackedColor::set_rgb // Access: Public // Description: Sets the color according to the indicated -// three-component RGBColorf value, and set the alpha to +// three-component LRGBColor value, and set the alpha to // 1.0. //////////////////////////////////////////////////////////////////// INLINE void FltPackedColor:: -set_rgb(const RGBColorf &color) { +set_rgb(const LRGBColor &color) { _r = (int)floor(color[0] * 255.0); _g = (int)floor(color[1] * 255.0); _b = (int)floor(color[2] * 255.0); diff --git a/pandatool/src/flt/fltPackedColor.h b/pandatool/src/flt/fltPackedColor.h index 1d3e4d1cbc..55a4b5c629 100644 --- a/pandatool/src/flt/fltPackedColor.h +++ b/pandatool/src/flt/fltPackedColor.h @@ -32,10 +32,10 @@ class FltPackedColor { public: INLINE FltPackedColor(); - INLINE Colorf get_color() const; - INLINE RGBColorf get_rgb() const; - INLINE void set_color(const Colorf &color); - INLINE void set_rgb(const RGBColorf &rgb); + INLINE LColor get_color() const; + INLINE LRGBColor get_rgb() const; + INLINE void set_color(const LColor &color); + INLINE void set_rgb(const LRGBColor &rgb); void output(ostream &out) const; bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltTexture.h b/pandatool/src/flt/fltTexture.h index e2860a5aa0..2322bd7496 100644 --- a/pandatool/src/flt/fltTexture.h +++ b/pandatool/src/flt/fltTexture.h @@ -147,8 +147,8 @@ public: }; struct LODScale { - float _lod; - float _scale; + PN_stdfloat _lod; + PN_stdfloat _scale; }; struct GeospecificControlPoint { @@ -192,10 +192,10 @@ public: InternalFormat _internal_format; ExternalFormat _external_format; bool _use_mipmap_kernel; - float _mipmap_kernel[8]; + PN_stdfloat _mipmap_kernel[8]; bool _use_lod_scale; LODScale _lod_scale[8]; - float _clamp; + PN_stdfloat _clamp; Magnification _mag_filter_alpha; Magnification _mag_filter_color; double _lambert_conic_central_meridian; @@ -208,10 +208,10 @@ public: int _detail_n; int _detail_scramble; bool _use_tile; - float _tile_lower_left_u; - float _tile_lower_left_v; - float _tile_upper_right_u; - float _tile_upper_right_v; + PN_stdfloat _tile_lower_left_u; + PN_stdfloat _tile_lower_left_v; + PN_stdfloat _tile_upper_right_u; + PN_stdfloat _tile_upper_right_v; ProjectionType _projection; EarthModel _earth_model; int _utm_zone; diff --git a/pandatool/src/flt/fltTrackplane.h b/pandatool/src/flt/fltTrackplane.h index 9a186d9a99..7fed3f931e 100644 --- a/pandatool/src/flt/fltTrackplane.h +++ b/pandatool/src/flt/fltTrackplane.h @@ -40,7 +40,7 @@ public: LVector3d _plane; bool _grid_state; bool _grid_under; - float _grid_angle; + PN_stdfloat _grid_angle; double _grid_spacing_x; double _grid_spacing_y; bool _snap_to_grid; diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx b/pandatool/src/flt/fltTransformRotateAboutEdge.cxx index 99ebd68dcd..e53c800729 100644 --- a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx +++ b/pandatool/src/flt/fltTransformRotateAboutEdge.cxx @@ -37,7 +37,7 @@ FltTransformRotateAboutEdge(FltHeader *header) : FltTransformRecord(header) { // counterclockwise about the axis as seen from point a. //////////////////////////////////////////////////////////////////// void FltTransformRotateAboutEdge:: -set(const LPoint3d &point_a, const LPoint3d &point_b, float angle) { +set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle) { _point_a = point_a; _point_b = point_b; _angle = angle; @@ -71,7 +71,7 @@ get_point_b() const { // Description: Returns the angle of rotation, in degrees // counterclockwise about the axis as seen from point a. //////////////////////////////////////////////////////////////////// -float FltTransformRotateAboutEdge:: +PN_stdfloat FltTransformRotateAboutEdge:: get_angle() const { return _angle; } diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.h b/pandatool/src/flt/fltTransformRotateAboutEdge.h index f7ae4378ae..adeae7ea89 100644 --- a/pandatool/src/flt/fltTransformRotateAboutEdge.h +++ b/pandatool/src/flt/fltTransformRotateAboutEdge.h @@ -28,18 +28,18 @@ class FltTransformRotateAboutEdge : public FltTransformRecord { public: FltTransformRotateAboutEdge(FltHeader *header); - void set(const LPoint3d &point_a, const LPoint3d &point_b, float angle); + void set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle); const LPoint3d &get_point_a() const; const LPoint3d &get_point_b() const; - float get_angle() const; + PN_stdfloat get_angle() const; private: void recompute_matrix(); LPoint3d _point_a; LPoint3d _point_b; - float _angle; + PN_stdfloat _angle; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx b/pandatool/src/flt/fltTransformRotateAboutPoint.cxx index cceeb60445..c04ebe5924 100644 --- a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx +++ b/pandatool/src/flt/fltTransformRotateAboutPoint.cxx @@ -37,7 +37,7 @@ FltTransformRotateAboutPoint(FltHeader *header) : FltTransformRecord(header) { // counterclockwise about the axis as seen from point a. //////////////////////////////////////////////////////////////////// void FltTransformRotateAboutPoint:: -set(const LPoint3d ¢er, const LVector3f &axis, float angle) { +set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle) { _center = center; _axis = axis; _angle = angle; @@ -60,7 +60,7 @@ get_center() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -const LVector3f &FltTransformRotateAboutPoint:: +const LVector3 &FltTransformRotateAboutPoint:: get_axis() const { return _axis; } @@ -71,7 +71,7 @@ get_axis() const { // Description: Returns the angle of rotation, in degrees // counterclockwise about the axis. //////////////////////////////////////////////////////////////////// -float FltTransformRotateAboutPoint:: +PN_stdfloat FltTransformRotateAboutPoint:: get_angle() const { return _angle; } @@ -83,7 +83,7 @@ get_angle() const { //////////////////////////////////////////////////////////////////// void FltTransformRotateAboutPoint:: recompute_matrix() { - if (_axis == LVector3f::zero()) { + if (_axis == LVector3::zero()) { // Degenerate case. _matrix = LMatrix4d::ident_mat(); } else { diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.h b/pandatool/src/flt/fltTransformRotateAboutPoint.h index cc14d3063a..f61015d896 100644 --- a/pandatool/src/flt/fltTransformRotateAboutPoint.h +++ b/pandatool/src/flt/fltTransformRotateAboutPoint.h @@ -28,18 +28,18 @@ class FltTransformRotateAboutPoint : public FltTransformRecord { public: FltTransformRotateAboutPoint(FltHeader *header); - void set(const LPoint3d ¢er, const LVector3f &axis, float angle); + void set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle); const LPoint3d &get_center() const; - const LVector3f &get_axis() const; - float get_angle() const; + const LVector3 &get_axis() const; + PN_stdfloat get_angle() const; private: void recompute_matrix(); LPoint3d _center; - LVector3f _axis; - float _angle; + LVector3 _axis; + PN_stdfloat _angle; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltTransformRotateScale.cxx b/pandatool/src/flt/fltTransformRotateScale.cxx index bdece25a17..f7b5c0daba 100644 --- a/pandatool/src/flt/fltTransformRotateScale.cxx +++ b/pandatool/src/flt/fltTransformRotateScale.cxx @@ -107,7 +107,7 @@ get_to_point() const { // Access: Public // Description: Returns the overall scale factor. //////////////////////////////////////////////////////////////////// -float FltTransformRotateScale:: +PN_stdfloat FltTransformRotateScale:: get_overall_scale() const { return _overall_scale; } @@ -118,7 +118,7 @@ get_overall_scale() const { // Description: Returns the scale factor in the direction of the // axis. //////////////////////////////////////////////////////////////////// -float FltTransformRotateScale:: +PN_stdfloat FltTransformRotateScale:: get_axis_scale() const { return _axis_scale; } @@ -128,7 +128,7 @@ get_axis_scale() const { // Access: Public // Description: Returns the angle of rotation in degrees. //////////////////////////////////////////////////////////////////// -float FltTransformRotateScale:: +PN_stdfloat FltTransformRotateScale:: get_angle() const { return _angle; } diff --git a/pandatool/src/flt/fltTransformRotateScale.h b/pandatool/src/flt/fltTransformRotateScale.h index b881ec6a21..d6a30a9c28 100644 --- a/pandatool/src/flt/fltTransformRotateScale.h +++ b/pandatool/src/flt/fltTransformRotateScale.h @@ -34,9 +34,9 @@ public: const LPoint3d &get_center() const; const LPoint3d &get_reference_point() const; const LPoint3d &get_to_point() const; - float get_overall_scale() const; - float get_axis_scale() const; - float get_angle() const; + PN_stdfloat get_overall_scale() const; + PN_stdfloat get_axis_scale() const; + PN_stdfloat get_angle() const; private: void recompute_matrix(); @@ -44,9 +44,9 @@ private: LPoint3d _center; LPoint3d _reference_point; LPoint3d _to_point; - float _overall_scale; - float _axis_scale; - float _angle; + PN_stdfloat _overall_scale; + PN_stdfloat _axis_scale; + PN_stdfloat _angle; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltTransformScale.cxx b/pandatool/src/flt/fltTransformScale.cxx index dd4f6572b5..a96ddf5f87 100644 --- a/pandatool/src/flt/fltTransformScale.cxx +++ b/pandatool/src/flt/fltTransformScale.cxx @@ -35,7 +35,7 @@ FltTransformScale(FltHeader *header) : FltTransformRecord(header) { // Description: Defines the scale. //////////////////////////////////////////////////////////////////// void FltTransformScale:: -set(const LPoint3d ¢er, const LVecBase3f &scale) { +set(const LPoint3d ¢er, const LVecBase3 &scale) { _center = center; _scale = scale; @@ -74,7 +74,7 @@ get_center() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -const LVecBase3f &FltTransformScale:: +const LVecBase3 &FltTransformScale:: get_scale() const { return _scale; } diff --git a/pandatool/src/flt/fltTransformScale.h b/pandatool/src/flt/fltTransformScale.h index e4d5bf4ed6..492fb93d12 100644 --- a/pandatool/src/flt/fltTransformScale.h +++ b/pandatool/src/flt/fltTransformScale.h @@ -28,17 +28,17 @@ class FltTransformScale : public FltTransformRecord { public: FltTransformScale(FltHeader *header); - void set(const LPoint3d ¢er, const LVecBase3f &scale); + void set(const LPoint3d ¢er, const LVecBase3 &scale); bool has_center() const; const LPoint3d &get_center() const; - const LVecBase3f &get_scale() const; + const LVecBase3 &get_scale() const; private: void recompute_matrix(); LPoint3d _center; - LVecBase3f _scale; + LVecBase3 _scale; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltVectorRecord.cxx b/pandatool/src/flt/fltVectorRecord.cxx index 724080ee1d..5fc7c8671b 100644 --- a/pandatool/src/flt/fltVectorRecord.cxx +++ b/pandatool/src/flt/fltVectorRecord.cxx @@ -33,7 +33,7 @@ FltVectorRecord(FltHeader *header) : FltRecord(header) { // Access: Public // Description: Returns the vector value. //////////////////////////////////////////////////////////////////// -const LVector3f &FltVectorRecord:: +const LVector3 &FltVectorRecord:: get_vector() const { return _vector; } diff --git a/pandatool/src/flt/fltVectorRecord.h b/pandatool/src/flt/fltVectorRecord.h index 481c3ab691..04c10efd76 100644 --- a/pandatool/src/flt/fltVectorRecord.h +++ b/pandatool/src/flt/fltVectorRecord.h @@ -32,10 +32,10 @@ class FltVectorRecord : public FltRecord { public: FltVectorRecord(FltHeader *header); - const LVector3f &get_vector() const; + const LVector3 &get_vector() const; protected: - LVector3f _vector; + LVector3 _vector; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltVertex.I b/pandatool/src/flt/fltVertex.I index 4e07c154fc..35440e3d6a 100644 --- a/pandatool/src/flt/fltVertex.I +++ b/pandatool/src/flt/fltVertex.I @@ -34,6 +34,6 @@ has_color() const { // color convention. The alpha component is ignored. //////////////////////////////////////////////////////////////////// INLINE void FltVertex:: -set_color(const Colorf &color) { - set_rgb(RGBColorf(color[0], color[1], color[2])); +set_color(const LColor &color) { + set_rgb(LRGBColor(color[0], color[1], color[2])); } diff --git a/pandatool/src/flt/fltVertex.cxx b/pandatool/src/flt/fltVertex.cxx index 229ffbdfbe..fe3aa7c759 100644 --- a/pandatool/src/flt/fltVertex.cxx +++ b/pandatool/src/flt/fltVertex.cxx @@ -119,9 +119,9 @@ get_record_length() const { // be 1.0, as MultiGen does not store transparency // per-vertex. //////////////////////////////////////////////////////////////////// -Colorf FltVertex:: +LColor FltVertex:: get_color() const { - nassertr(has_color(), Colorf(0.0, 0.0, 0.0, 0.0)); + nassertr(has_color(), LColor(0.0, 0.0, 0.0, 0.0)); return _header->get_color(_color_index, (_flags & F_packed_color) != 0, _packed_color, 0); @@ -133,9 +133,9 @@ get_color() const { // Description: If has_color() indicates true, returns the // color of the vertex, as a three-component value. //////////////////////////////////////////////////////////////////// -RGBColorf FltVertex:: +LRGBColor FltVertex:: get_rgb() const { - nassertr(has_color(), RGBColorf(0.0, 0.0, 0.0)); + nassertr(has_color(), LRGBColor(0.0, 0.0, 0.0)); return _header->get_rgb(_color_index, (_flags & F_packed_color) != 0, _packed_color); @@ -148,7 +148,7 @@ get_rgb() const { // color convention. //////////////////////////////////////////////////////////////////// void FltVertex:: -set_rgb(const RGBColorf &rgb) { +set_rgb(const LRGBColor &rgb) { _packed_color.set_rgb(rgb); _flags = ((_flags & ~F_no_color) | F_packed_color); } diff --git a/pandatool/src/flt/fltVertex.h b/pandatool/src/flt/fltVertex.h index f864f38205..8b71c202bb 100644 --- a/pandatool/src/flt/fltVertex.h +++ b/pandatool/src/flt/fltVertex.h @@ -49,8 +49,8 @@ public: int _color_name_index; unsigned int _flags; LPoint3d _pos; - LPoint3f _normal; - LPoint2f _uv; + LPoint3 _normal; + LPoint2 _uv; FltPackedColor _packed_color; int _color_index; @@ -59,10 +59,10 @@ public: public: INLINE bool has_color() const; - Colorf get_color() const; - INLINE void set_color(const Colorf &color); - RGBColorf get_rgb() const; - void set_rgb(const RGBColorf &rgb); + LColor get_color() const; + INLINE void set_color(const LColor &color); + LRGBColor get_rgb() const; + void set_rgb(const LRGBColor &rgb); protected: diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index 1c3fdae4ba..6f21965331 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -493,12 +493,12 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, break; } - Colorf face_color = flt_geom->get_color(); + LColor face_color = flt_geom->get_color(); if (state._flt_object != (FltObject *)NULL) { // If we have a FltObject above us, it might also specify a // transparency. This combines with our existing transparency. - float alpha = 1.0 - (state._flt_object->_transparency / 65535.0); + PN_stdfloat alpha = 1.0 - (state._flt_object->_transparency / 65535.0); face_color[3] *= alpha; } @@ -525,7 +525,7 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, for (vi = vertices.begin(); vi != vertices.end(); ++vi) { EggVertex *vertex = (*vi); if (vertex->has_color()) { - Colorf vertex_color = vertex->get_color(); + LColor vertex_color = vertex->get_color(); vertex_color[3] = face_color[3]; vertex->set_color(vertex_color); } else { diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index b3195a05bf..6748c67dfe 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -191,7 +191,7 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) { } else if (step->is_exact_type(FltTransformScale::get_class_type())) { const FltTransformScale *scale; DCAST_INTO_V(scale, step); - if (!scale->get_scale().almost_equal(LVecBase3f(1.0f, 1.0f, 1.0f))) { + if (!scale->get_scale().almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { if (scale->has_center() && !scale->get_center().almost_equal(LVector3d::zero())) { egg_group->add_translate3d(-scale->get_center()); diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 25c2106ff0..f47d8b221f 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -48,10 +48,10 @@ EggToFlt() : { set_binary_output(true); set_program_description - ("egg2flt converts files from egg format to MultiGen .flt " + ("egg2lt converts files from egg format to MultiGen .flt " "format. It attempts to be as robust as possible, and matches " "the capabilities of flt2egg. Generally, converting a model " - "from egg2flt and then back via flt2egg will result in essentially " + "from egg2lt and then back via flt2egg will result in essentially " "the same egg file, within the limitations of what can be " "represented in flt."); @@ -394,7 +394,7 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { { FltTransformScale *scale = new FltTransformScale(_flt_header); LVector2d v2 = egg_transform->get_component_vec2(i); - scale->set(LPoint3d::zero(), LVector3f(v2[0], v2[1], 1.0f)); + scale->set(LPoint3d::zero(), LVector3(v2[0], v2[1], 1.0f)); flt_node->add_transform_step(scale); } break; @@ -402,7 +402,7 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { case EggTransform::CT_scale3d: { FltTransformScale *scale = new FltTransformScale(_flt_header); - scale->set(LPoint3d::zero(), LCAST(float, egg_transform->get_component_vec3(i))); + scale->set(LPoint3d::zero(), LCAST(PN_stdfloat, egg_transform->get_component_vec3(i))); flt_node->add_transform_step(scale); } break; @@ -410,8 +410,8 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { case EggTransform::CT_uniform_scale: { FltTransformScale *scale = new FltTransformScale(_flt_header); - float factor = (float)egg_transform->get_component_number(i); - scale->set(LPoint3d::zero(), LVecBase3f(factor, factor, factor)); + PN_stdfloat factor = (PN_stdfloat)egg_transform->get_component_number(i); + scale->set(LPoint3d::zero(), LVecBase3(factor, factor, factor)); flt_node->add_transform_step(scale); } break; @@ -506,17 +506,17 @@ get_flt_vertex(EggVertex *egg_vertex, EggNode *context) { flt_vertex->set_color(egg_vertex->get_color()); } if (egg_vertex->has_normal()) { - flt_vertex->_normal = LCAST(float, egg_vertex->get_normal()); + flt_vertex->_normal = LCAST(PN_stdfloat, egg_vertex->get_normal()); flt_vertex->_has_normal = true; } if (egg_vertex->has_uv()) { - flt_vertex->_uv = LCAST(float, egg_vertex->get_uv()); + flt_vertex->_uv = LCAST(PN_stdfloat, egg_vertex->get_uv()); flt_vertex->_has_uv = true; } if (frame != (const LMatrix4d *)NULL) { flt_vertex->_pos = flt_vertex->_pos * (*frame); - flt_vertex->_normal = flt_vertex->_normal * LCAST(float, (*frame)); + flt_vertex->_normal = flt_vertex->_normal * LCAST(PN_stdfloat, (*frame)); } _flt_header->add_vertex(flt_vertex); diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 80f3c732d7..32e883c7fe 100755 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -208,7 +208,7 @@ set_time_units(int unit_mask) { // speed for the graph to the indicated value. //////////////////////////////////////////////////////////////////// void GtkStatsGraph:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { } //////////////////////////////////////////////////////////////////// @@ -280,7 +280,7 @@ get_collector_gc(int collector_index) { } // Ask the monitor what color this guy should be. - RGBColorf rgb = _monitor->get_collector_color(collector_index); + LRGBColor rgb = _monitor->get_collector_color(collector_index); GdkColor c; c.red = (int)(rgb[0] * 65535.0f); diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.h b/pandatool/src/gtk-stats/gtkStatsGraph.h index 8157ceecca..d7fddb4a59 100755 --- a/pandatool/src/gtk-stats/gtkStatsGraph.h +++ b/pandatool/src/gtk-stats/gtkStatsGraph.h @@ -50,7 +50,7 @@ public: virtual void changed_graph_size(int graph_xsize, int graph_ysize); virtual void set_time_units(int unit_mask); - virtual void set_scroll_speed(float scroll_speed); + virtual void set_scroll_speed(PN_stdfloat scroll_speed); void set_pause(bool pause); void user_guide_bars_changed(); @@ -102,7 +102,7 @@ protected: DragMode _drag_mode; DragMode _potential_drag_mode; int _drag_start_x, _drag_start_y; - float _drag_scale_start; + PN_stdfloat _drag_scale_start; int _drag_guide_bar; bool _pause; diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.cxx b/pandatool/src/gtk-stats/gtkStatsLabel.cxx index 0c1d442d80..1a154c0f8b 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabel.cxx @@ -60,13 +60,13 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, _layout = gtk_widget_create_pango_layout(_widget, _text.c_str()); // Set the fg and bg colors on the label. - RGBColorf rgb = _monitor->get_collector_color(_collector_index); + LRGBColor rgb = _monitor->get_collector_color(_collector_index); _bg_color.red = (int)(rgb[0] * 65535.0f); _bg_color.green = (int)(rgb[1] * 65535.0f); _bg_color.blue = (int)(rgb[2] * 65535.0f); // Should our foreground be black or white? - float bright = + PN_stdfloat bright = rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114; diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index ec11f5a9c3..33000cb236 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -243,7 +243,7 @@ idle() { // Update the frame rate label from the main thread (thread 0). const PStatThreadData *thread_data = get_client_data()->get_thread_data(0); - float frame_rate = thread_data->get_frame_rate(); + PN_stdfloat frame_rate = thread_data->get_frame_rate(); if (frame_rate != 0.0f) { char buffer[128]; sprintf(buffer, "%0.1f ms / %0.1f Hz", 1000.0f / frame_rate, frame_rate); @@ -364,7 +364,7 @@ set_time_units(int unit_mask) { // speeds for all graphs to the indicated value. //////////////////////////////////////////////////////////////////// void GtkStatsMonitor:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { _scroll_speed = scroll_speed; // First, change all of the open graphs appropriately. diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.h b/pandatool/src/gtk-stats/gtkStatsMonitor.h index dc2aaa92a8..d7d884b3dc 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.h +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.h @@ -72,7 +72,7 @@ public: const MenuDef *add_menu(const MenuDef &menu_def); void set_time_units(int unit_mask); - void set_scroll_speed(float scroll_speed); + void set_scroll_speed(PN_stdfloat scroll_speed); void set_pause(bool pause); private: @@ -104,7 +104,7 @@ private: GtkWidget *_frame_rate_label; string _window_title; int _time_units; - float _scroll_speed; + PN_stdfloat _scroll_speed; bool _pause; static GtkItemFactoryEntry menu_entries[]; diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx index 109a72f38f..ac55d6f6da 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx @@ -150,7 +150,7 @@ clicked_label(int collector_index) { // horizontal axis represents. This may force a redraw. //////////////////////////////////////////////////////////////////// void GtkStatsPianoRoll:: -set_horizontal_scale(float time_width) { +set_horizontal_scale(PN_stdfloat time_width) { PStatPianoRoll::set_horizontal_scale(time_width); gtk_widget_queue_draw(_graph_window); @@ -258,8 +258,8 @@ consider_drag_start(int graph_x, int graph_y) { if (graph_x >= 0 && graph_x < get_xsize()) { // See if the mouse is over a user-defined guide bar. int x = graph_x; - float from_height = pixel_to_height(x - 2); - float to_height = pixel_to_height(x + 2); + PN_stdfloat from_height = pixel_to_height(x - 2); + PN_stdfloat to_height = pixel_to_height(x + 2); _drag_guide_bar = find_user_guide_bar(from_height, to_height); if (_drag_guide_bar >= 0) { return DM_guide_bar; @@ -365,7 +365,7 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { } if (_drag_mode == DM_scale) { - float ratio = (float)graph_x / (float)get_xsize(); + PN_stdfloat ratio = (PN_stdfloat)graph_x / (PN_stdfloat)get_xsize(); if (ratio > 0.0f) { set_horizontal_scale(_drag_scale_start / ratio); } @@ -506,8 +506,8 @@ draw_guide_label(const PStatGraph::GuideBar &bar) { pango_layout_get_pixel_size(layout, &width, &height); if (bar._style != GBS_user) { - float from_height = pixel_to_height(x - width); - float to_height = pixel_to_height(x + width); + PN_stdfloat from_height = pixel_to_height(x - width); + PN_stdfloat to_height = pixel_to_height(x + width); if (find_user_guide_bar(from_height, to_height) >= 0) { // Omit the label: there's a user-defined guide bar in the same space. g_object_unref(layout); diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h index ea789168dd..3160c51bf2 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h @@ -42,7 +42,7 @@ public: virtual void set_time_units(int unit_mask); virtual void clicked_label(int collector_index); - void set_horizontal_scale(float time_width); + void set_horizontal_scale(PN_stdfloat time_width); protected: void clear_region(); diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index 2f101a6fbd..e8a98dbd4c 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -188,7 +188,7 @@ set_time_units(int unit_mask) { // speed for the graph to the indicated value. //////////////////////////////////////////////////////////////////// void GtkStatsStripChart:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { // The speed factor indicates chart widths per minute. if (scroll_speed != 0.0f) { set_horizontal_scale(60.0f / scroll_speed); @@ -235,7 +235,7 @@ clicked_label(int collector_index) { // represents. This may force a redraw. //////////////////////////////////////////////////////////////////// void GtkStatsStripChart:: -set_vertical_scale(float value_height) { +set_vertical_scale(PN_stdfloat value_height) { PStatStripChart::set_vertical_scale(value_height); gtk_widget_queue_draw(_graph_window); @@ -309,7 +309,7 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0, w + 1, get_ysize()); - float overall_time = 0.0; + PN_stdfloat overall_time = 0.0; int y = get_ysize(); FrameData::const_iterator fi; @@ -406,8 +406,8 @@ consider_drag_start(int graph_x, int graph_y) { if (graph_y >= 0 && graph_y < get_ysize()) { // See if the mouse is over a user-defined guide bar. int y = graph_y; - float from_height = pixel_to_height(y + 2); - float to_height = pixel_to_height(y - 2); + PN_stdfloat from_height = pixel_to_height(y + 2); + PN_stdfloat to_height = pixel_to_height(y - 2); _drag_guide_bar = find_user_guide_bar(from_height, to_height); if (_drag_guide_bar >= 0) { return DM_guide_bar; @@ -541,7 +541,7 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { } if (_drag_mode == DM_scale) { - float ratio = 1.0f - ((float)graph_y / (float)get_ysize()); + PN_stdfloat ratio = 1.0f - ((PN_stdfloat)graph_y / (PN_stdfloat)get_ysize()); if (ratio > 0.0f) { set_vertical_scale(_drag_scale_start / ratio); } @@ -654,8 +654,8 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { pango_layout_get_pixel_size(layout, &width, &height); if (bar._style != GBS_user) { - float from_height = pixel_to_height(y + height); - float to_height = pixel_to_height(y - height); + PN_stdfloat from_height = pixel_to_height(y + height); + PN_stdfloat to_height = pixel_to_height(y - height); if (find_user_guide_bar(from_height, to_height) >= 0) { // Omit the label: there's a user-defined guide bar in the same space. g_object_unref(layout); diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.h b/pandatool/src/gtk-stats/gtkStatsStripChart.h index d4d5b7a7c8..6a481f2399 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.h +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.h @@ -41,9 +41,9 @@ public: virtual void changed_graph_size(int graph_xsize, int graph_ysize); virtual void set_time_units(int unit_mask); - virtual void set_scroll_speed(float scroll_speed); + virtual void set_scroll_speed(PN_stdfloat scroll_speed); virtual void clicked_label(int collector_index); - void set_vertical_scale(float value_height); + void set_vertical_scale(PN_stdfloat value_height); protected: virtual void update_labels(); diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index 40d5b77bdc..321f139124 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -102,7 +102,7 @@ run() { if (_image.has_alpha() && _color_scale[3] != 1.0f) { for (int yi = 0; yi < _image.get_y_size(); ++yi) { for (int xi = 0; xi < _image.get_x_size(); ++xi) { - float a = _image.get_alpha(xi, yi); + PN_stdfloat a = _image.get_alpha(xi, yi); _image.set_alpha(xi, yi, a * _color_scale[3]); } } diff --git a/pandatool/src/imageprogs/imageTrans.h b/pandatool/src/imageprogs/imageTrans.h index 6a6698343c..a1c106a39b 100644 --- a/pandatool/src/imageprogs/imageTrans.h +++ b/pandatool/src/imageprogs/imageTrans.h @@ -48,7 +48,7 @@ private: }; Channels _channels; - Colorf _color_scale; + LColor _color_scale; bool _has_color_scale; }; diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index b7632c4616..fb8965a53d 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -186,7 +186,7 @@ get_be_uint32() { // Description: Extracts a 32-bit big-endian single-precision // floating-point number. //////////////////////////////////////////////////////////////////// -float IffInputFile:: +PN_stdfloat IffInputFile:: get_be_float32() { Datagram dg; if (!read_bytes(dg, 4)) { diff --git a/pandatool/src/lwo/iffInputFile.h b/pandatool/src/lwo/iffInputFile.h index 640165af16..8c30e33710 100644 --- a/pandatool/src/lwo/iffInputFile.h +++ b/pandatool/src/lwo/iffInputFile.h @@ -53,7 +53,7 @@ public: PN_int32 get_be_int32(); PN_uint16 get_be_uint16(); PN_uint32 get_be_uint32(); - float get_be_float32(); + PN_stdfloat get_be_float32(); string get_string(); diff --git a/pandatool/src/lwo/lwoBoundingBox.h b/pandatool/src/lwo/lwoBoundingBox.h index ed70f3f93b..87a1363a54 100644 --- a/pandatool/src/lwo/lwoBoundingBox.h +++ b/pandatool/src/lwo/lwoBoundingBox.h @@ -28,8 +28,8 @@ //////////////////////////////////////////////////////////////////// class LwoBoundingBox : public LwoChunk { public: - LVecBase3f _min; - LVecBase3f _max; + LVecBase3 _min; + LVecBase3 _max; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx index cf3d697072..52197a4e2b 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx @@ -45,10 +45,10 @@ has_value(int polygon_index, int vertex_index) const { // Function: LwoDiscontinuousVertexMap::get_value // Access: Public // Description: Returns the mapping value associated with the given -// index, or an empty PTA_float if there is no mapping +// index, or an empty PTA_stdfloat if there is no mapping // value associated. //////////////////////////////////////////////////////////////////// -PTA_float LwoDiscontinuousVertexMap:: +PTA_stdfloat LwoDiscontinuousVertexMap:: get_value(int polygon_index, int vertex_index) const { VMad::const_iterator di; di = _vmad.find(polygon_index); @@ -61,7 +61,7 @@ get_value(int polygon_index, int vertex_index) const { } } - return PTA_float(); + return PTA_stdfloat(); } //////////////////////////////////////////////////////////////////// @@ -86,7 +86,7 @@ read_iff(IffInputFile *in, size_t stop_at) { int vertex_index = lin->get_vx(); int polygon_index = lin->get_vx(); - PTA_float value; + PTA_stdfloat value; for (int i = 0; i < _dimension; i++) { value.push_back(lin->get_be_float32()); } @@ -97,7 +97,7 @@ read_iff(IffInputFile *in, size_t stop_at) { if (!ir.second) { // This polygon/vertex pair was repeated in the vmad. Is it // simply redundant, or is it contradictory? - PTA_float orig_value = (*ir.first).second; + PTA_stdfloat orig_value = (*ir.first).second; if (value.v() != orig_value.v()) { nout << "Multiple UV values for vertex " << vertex_index @@ -105,7 +105,7 @@ read_iff(IffInputFile *in, size_t stop_at) { << " specified by discontinuous vertex map.\n" << "Original value = "; - PTA_float::const_iterator vi; + PTA_stdfloat::const_iterator vi; for (vi = orig_value.begin(); vi != orig_value.end(); ++vi) { nout << (*vi) << " "; } diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h index 009e8d7da7..eb047d2300 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h @@ -19,7 +19,7 @@ #include "lwoChunk.h" -#include "pta_float.h" +#include "pta_stdfloat.h" #include "pmap.h" //////////////////////////////////////////////////////////////////// @@ -31,7 +31,7 @@ class LwoDiscontinuousVertexMap : public LwoChunk { public: bool has_value(int polygon_index, int vertex_index) const; - PTA_float get_value(int polygon_index, int vertex_index) const; + PTA_stdfloat get_value(int polygon_index, int vertex_index) const; IffId _map_type; int _dimension; @@ -42,7 +42,7 @@ public: virtual void write(ostream &out, int indent_level = 0) const; private: - typedef pmap VMap; + typedef pmap VMap; typedef pmap VMad; VMad _vmad; diff --git a/pandatool/src/lwo/lwoInputFile.cxx b/pandatool/src/lwo/lwoInputFile.cxx index ec4bcb6013..e1de1ec4db 100644 --- a/pandatool/src/lwo/lwoInputFile.cxx +++ b/pandatool/src/lwo/lwoInputFile.cxx @@ -71,9 +71,9 @@ get_vx() { // Access: Public // Description: Reads a three-component vector of floats. //////////////////////////////////////////////////////////////////// -LVecBase3f LwoInputFile:: +LVecBase3 LwoInputFile:: get_vec3() { - LVecBase3f result; + LVecBase3 result; result[0] = get_be_float32(); result[1] = get_be_float32(); result[2] = get_be_float32(); diff --git a/pandatool/src/lwo/lwoInputFile.h b/pandatool/src/lwo/lwoInputFile.h index 7db7d1296b..3394e8f5b9 100644 --- a/pandatool/src/lwo/lwoInputFile.h +++ b/pandatool/src/lwo/lwoInputFile.h @@ -35,7 +35,7 @@ public: INLINE void set_lwo_version(double version); int get_vx(); - LVecBase3f get_vec3(); + LVecBase3 get_vec3(); Filename get_filename(); protected: diff --git a/pandatool/src/lwo/lwoLayer.h b/pandatool/src/lwo/lwoLayer.h index b2f1eb1e8f..8737268704 100644 --- a/pandatool/src/lwo/lwoLayer.h +++ b/pandatool/src/lwo/lwoLayer.h @@ -39,7 +39,7 @@ public: int _number; int _flags; - LPoint3f _pivot; + LPoint3 _pivot; string _name; int _parent; diff --git a/pandatool/src/lwo/lwoPoints.cxx b/pandatool/src/lwo/lwoPoints.cxx index 12ad367af5..f26cd8a4f6 100644 --- a/pandatool/src/lwo/lwoPoints.cxx +++ b/pandatool/src/lwo/lwoPoints.cxx @@ -35,9 +35,9 @@ get_num_points() const { // Access: Public // Description: Returns the nth point of this group. //////////////////////////////////////////////////////////////////// -const LPoint3f &LwoPoints:: +const LPoint3 &LwoPoints:: get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3f::zero()); + nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); return _points[n]; } @@ -56,7 +56,7 @@ read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); while (lin->get_bytes_read() < stop_at && !lin->is_eof()) { - LPoint3f point = lin->get_vec3(); + LPoint3 point = lin->get_vec3(); _points.push_back(point); } diff --git a/pandatool/src/lwo/lwoPoints.h b/pandatool/src/lwo/lwoPoints.h index a440abfe3d..56ab9d981a 100644 --- a/pandatool/src/lwo/lwoPoints.h +++ b/pandatool/src/lwo/lwoPoints.h @@ -29,14 +29,14 @@ class LwoPoints : public LwoChunk { public: int get_num_points() const; - const LPoint3f &get_point(int n) const; + const LPoint3 &get_point(int n) const; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); virtual void write(ostream &out, int indent_level = 0) const; private: - typedef pvector Points; + typedef pvector Points; Points _points; public: diff --git a/pandatool/src/lwo/lwoPolygons.h b/pandatool/src/lwo/lwoPolygons.h index 21aa37acac..8c1e4e1f36 100644 --- a/pandatool/src/lwo/lwoPolygons.h +++ b/pandatool/src/lwo/lwoPolygons.h @@ -34,7 +34,7 @@ public: enum PolygonFlags { PF_continuity_1 = 0x0400, PF_continuity_2 = 0x0800, - PF_numverts_mask = 0x03ff, + PF_numverts_mask = 0x03f, // This "flag" is stored artificially when reading 5.x LWOB files, // and indicates that the polygon is a decal of a preceding diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h index 3cee4575e4..dd2dbb4046 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h @@ -38,7 +38,7 @@ public: }; Type _type; - float _opacity; + PN_stdfloat _opacity; int _envelope; public: diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h index 6cc0f23cb9..54ff8b2952 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h @@ -29,7 +29,7 @@ //////////////////////////////////////////////////////////////////// class LwoSurfaceBlockRepeat : public LwoChunk { public: - float _cycles; + PN_stdfloat _cycles; int _envelope; public: diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.h b/pandatool/src/lwo/lwoSurfaceBlockTransform.h index a4476365fa..eb03e64beb 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.h +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.h @@ -31,7 +31,7 @@ //////////////////////////////////////////////////////////////////// class LwoSurfaceBlockTransform : public LwoChunk { public: - LVecBase3f _vec; + LVecBase3 _vec; int _envelope; public: diff --git a/pandatool/src/lwo/lwoSurfaceColor.h b/pandatool/src/lwo/lwoSurfaceColor.h index fb26e5ac03..0dc32e864f 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.h +++ b/pandatool/src/lwo/lwoSurfaceColor.h @@ -28,7 +28,7 @@ //////////////////////////////////////////////////////////////////// class LwoSurfaceColor : public LwoChunk { public: - RGBColorf _color; + LRGBColor _color; int _envelope; public: diff --git a/pandatool/src/lwo/lwoSurfaceParameter.h b/pandatool/src/lwo/lwoSurfaceParameter.h index 75f0dcca58..6fcc10ab84 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.h +++ b/pandatool/src/lwo/lwoSurfaceParameter.h @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////////////// class LwoSurfaceParameter : public LwoChunk { public: - float _value; + PN_stdfloat _value; int _envelope; public: diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h index 44488828d0..88e464e6b6 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h @@ -26,7 +26,7 @@ //////////////////////////////////////////////////////////////////// class LwoSurfaceSmoothingAngle : public LwoChunk { public: - float _angle; + PN_stdfloat _angle; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); diff --git a/pandatool/src/lwo/lwoVertexMap.cxx b/pandatool/src/lwo/lwoVertexMap.cxx index 157ed5d6ca..ea517bfb31 100644 --- a/pandatool/src/lwo/lwoVertexMap.cxx +++ b/pandatool/src/lwo/lwoVertexMap.cxx @@ -36,10 +36,10 @@ has_value(int index) const { // Function: LwoVertexMap::get_value // Access: Public // Description: Returns the mapping value associated with the given -// index, or an empty PTA_float if there is no mapping +// index, or an empty PTA_stdfloat if there is no mapping // value associated. //////////////////////////////////////////////////////////////////// -PTA_float LwoVertexMap:: +PTA_stdfloat LwoVertexMap:: get_value(int index) const { VMap::const_iterator vi; vi = _vmap.find(index); @@ -47,7 +47,7 @@ get_value(int index) const { return (*vi).second; } - return PTA_float(); + return PTA_stdfloat(); } //////////////////////////////////////////////////////////////////// @@ -71,7 +71,7 @@ read_iff(IffInputFile *in, size_t stop_at) { while (lin->get_bytes_read() < stop_at && !lin->is_eof()) { int index = lin->get_vx(); - PTA_float value; + PTA_stdfloat value; for (int i = 0; i < _dimension; i++) { value.push_back(lin->get_be_float32()); } diff --git a/pandatool/src/lwo/lwoVertexMap.h b/pandatool/src/lwo/lwoVertexMap.h index f6775bcb04..ef96bdc6da 100644 --- a/pandatool/src/lwo/lwoVertexMap.h +++ b/pandatool/src/lwo/lwoVertexMap.h @@ -19,7 +19,7 @@ #include "lwoChunk.h" -#include "pta_float.h" +#include "pta_stdfloat.h" //////////////////////////////////////////////////////////////////// // Class : LwoVertexMap @@ -30,7 +30,7 @@ class LwoVertexMap : public LwoChunk { public: bool has_value(int index) const; - PTA_float get_value(int index) const; + PTA_stdfloat get_value(int index) const; IffId _map_type; int _dimension; @@ -41,7 +41,7 @@ public: virtual void write(ostream &out, int indent_level = 0) const; private: - typedef pmap VMap; + typedef pmap VMap; VMap _vmap; public: diff --git a/pandatool/src/lwoegg/cLwoLayer.cxx b/pandatool/src/lwoegg/cLwoLayer.cxx index 7617258a7f..dda1916272 100644 --- a/pandatool/src/lwoegg/cLwoLayer.cxx +++ b/pandatool/src/lwoegg/cLwoLayer.cxx @@ -28,7 +28,7 @@ void CLwoLayer:: make_egg() { _egg_group = new EggGroup(_layer->_name); - if (_layer->_pivot != LPoint3f::zero()) { + if (_layer->_pivot != LPoint3::zero()) { // If we have a nonzero pivot point, that's a translation // transform. LPoint3d translate = LCAST(double, _layer->_pivot); diff --git a/pandatool/src/lwoegg/cLwoPoints.cxx b/pandatool/src/lwoegg/cLwoPoints.cxx index 85094cd151..0b8e6e1319 100644 --- a/pandatool/src/lwoegg/cLwoPoints.cxx +++ b/pandatool/src/lwoegg/cLwoPoints.cxx @@ -16,6 +16,7 @@ #include "lwoToEggConverter.h" #include "cLwoLayer.h" +#include "pta_stdfloat.h" #include "lwoVertexMap.h" #include "string_utils.h" @@ -58,7 +59,7 @@ add_vmap(const LwoVertexMap *lwo_vmap) { // If true, fills in uv with the value. //////////////////////////////////////////////////////////////////// bool CLwoPoints:: -get_uv(const string &uv_name, int n, LPoint2f &uv) const { +get_uv(const string &uv_name, int n, LPoint2 &uv) const { VMap::const_iterator ni = _txuv.find(uv_name); if (ni == _txuv.end()) { return false; @@ -75,7 +76,7 @@ get_uv(const string &uv_name, int n, LPoint2f &uv) const { return false; } - PTA_float value = vmap->get_value(n); + PTA_stdfloat value = vmap->get_value(n); uv.set(value[0], value[1]); return true; diff --git a/pandatool/src/lwoegg/cLwoPoints.h b/pandatool/src/lwoegg/cLwoPoints.h index 0a564a4d83..ec6298f634 100644 --- a/pandatool/src/lwoegg/cLwoPoints.h +++ b/pandatool/src/lwoegg/cLwoPoints.h @@ -39,7 +39,7 @@ public: CLwoLayer *layer); void add_vmap(const LwoVertexMap *lwo_vmap); - bool get_uv(const string &uv_name, int n, LPoint2f &uv) const; + bool get_uv(const string &uv_name, int n, LPoint2 &uv) const; void make_egg(); void connect_egg(); diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index 258e6a87e5..e659df7fb8 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -137,7 +137,7 @@ get_surface(int polygon_index) const { // is associated with the points themselves. //////////////////////////////////////////////////////////////////// bool CLwoPolygons:: -get_uv(const string &uv_name, int pi, int vi, LPoint2f &uv) const { +get_uv(const string &uv_name, int pi, int vi, LPoint2 &uv) const { VMad::const_iterator ni = _txuv.find(uv_name); if (ni == _txuv.end()) { return false; @@ -154,7 +154,7 @@ get_uv(const string &uv_name, int pi, int vi, LPoint2f &uv) const { return false; } - PTA_float value = vmad->get_value(pi, vi); + PTA_stdfloat value = vmad->get_value(pi, vi); uv.set(value[0], value[1]); return true; @@ -214,7 +214,7 @@ connect_egg() { //////////////////////////////////////////////////////////////////// void CLwoPolygons:: make_faces() { - float smooth_angle = -1.0; + PN_stdfloat smooth_angle = -1.0; int num_polygons = _polygons->get_num_polygons(); for (int pindex = 0; pindex < num_polygons; pindex++) { @@ -259,7 +259,7 @@ make_faces() { // Does the vertex used named UV's? if (surface != (CLwoSurface *)NULL && surface->has_named_uvs()) { string uv_name = surface->get_uv_name(); - LPoint2f uv; + LPoint2 uv; if (get_uv(uv_name, pindex, vindex, uv)) { // This UV is defined in a "discontinuous" map, that // associated a particular UV per each polygon. diff --git a/pandatool/src/lwoegg/cLwoPolygons.h b/pandatool/src/lwoegg/cLwoPolygons.h index 669d8fab07..fb36f9ed8a 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.h +++ b/pandatool/src/lwoegg/cLwoPolygons.h @@ -46,7 +46,7 @@ public: void add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad); CLwoSurface *get_surface(int polygon_index) const; - bool get_uv(const string &uv_name, int pi, int vi, LPoint2f &uv) const; + bool get_uv(const string &uv_name, int pi, int vi, LPoint2 &uv) const; void make_egg(); void connect_egg(); diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index 9b49d8d495..5559b56ad0 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -168,7 +168,7 @@ CLwoSurface:: //////////////////////////////////////////////////////////////////// void CLwoSurface:: apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, - float &smooth_angle) { + PN_stdfloat &smooth_angle) { if (!_surface->_source.empty()) { // This surface is derived from another surface; apply that one // first. @@ -323,7 +323,7 @@ check_material() { } if ((_flags & F_luminosity) != 0) { - Colorf luminosity(_color[0] * _luminosity, + LColor luminosity(_color[0] * _luminosity, _color[1] * _luminosity, _color[2] * _luminosity, 1.0); @@ -331,7 +331,7 @@ check_material() { } if ((_flags & F_specular) != 0) { - Colorf specular(_color[0] * _specular, + LColor specular(_color[0] * _specular, _color[1] * _specular, _color[2] * _specular, 1.0); diff --git a/pandatool/src/lwoegg/cLwoSurface.h b/pandatool/src/lwoegg/cLwoSurface.h index 8107bc8a57..313fb1cebf 100644 --- a/pandatool/src/lwoegg/cLwoSurface.h +++ b/pandatool/src/lwoegg/cLwoSurface.h @@ -48,7 +48,7 @@ public: void apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, - float &smooth_angle); + PN_stdfloat &smooth_angle); bool check_texture(); bool check_material(); @@ -70,19 +70,19 @@ public: }; int _flags; - RGBColorf _rgb; - float _diffuse; - float _luminosity; - float _specular; - float _reflection; - float _transparency; - float _gloss; - float _translucency; - float _smooth_angle; + LRGBColor _rgb; + PN_stdfloat _diffuse; + PN_stdfloat _luminosity; + PN_stdfloat _specular; + PN_stdfloat _reflection; + PN_stdfloat _transparency; + PN_stdfloat _gloss; + PN_stdfloat _translucency; + PN_stdfloat _smooth_angle; bool _backface; - Colorf _color; - Colorf _diffuse_color; + LColor _color; + LColor _diffuse_color; LwoToEggConverter *_converter; CPT(LwoSurface) _surface; diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.h b/pandatool/src/lwoegg/cLwoSurfaceBlock.h index ed936b2ebf..de2f6a2d46 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.h @@ -45,7 +45,7 @@ public: bool _enabled; LwoSurfaceBlockOpacity::Type _opacity_type; - float _opacity; + PN_stdfloat _opacity; LMatrix4d _transform; LMatrix4d _inv_transform; @@ -55,8 +55,8 @@ public: int _clip_index; LwoSurfaceBlockWrap::Mode _w_wrap; LwoSurfaceBlockWrap::Mode _h_wrap; - float _w_repeat; - float _h_repeat; + PN_stdfloat _w_repeat; + PN_stdfloat _h_repeat; string _uv_name; LwoToEggConverter *_converter; diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h index b2c12c54ab..a5cd0a7fcd 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h @@ -36,9 +36,9 @@ public: void get_transform(LMatrix4d &mat) const; - LPoint3f _center; - LVecBase3f _size; - LVecBase3f _rotation; + LPoint3 _center; + LVecBase3 _size; + LVecBase3 _rotation; string _reference_object; diff --git a/pandatool/src/maxegg/maxEgg.cxx b/pandatool/src/maxegg/maxEgg.cxx index f84d6dd7fc..326205dd51 100755 --- a/pandatool/src/maxegg/maxEgg.cxx +++ b/pandatool/src/maxegg/maxEgg.cxx @@ -657,7 +657,7 @@ void MaxEggPlugin::GetMat(TimeValue t, INode* inode, ViewExp* vpt, Matrix3& tm) { tm = inode->GetObjectTM(t); tm.NoScale(); - float scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(tm.GetTrans())/(float)360.0; + PN_stdfloat scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(tm.GetTrans())/(PN_stdfloat)360.0; tm.Scale(Point3(scaleFactor,scaleFactor,scaleFactor)); } @@ -671,7 +671,7 @@ void MaxEggPlugin::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box Matrix3 m = inode->GetObjectTM(t); Point3 pt; Point3 q[4]; - float scaleFactor = vpt->GetVPWorldWidth(m.GetTrans())/360.0f; + PN_stdfloat scaleFactor = vpt->GetVPWorldWidth(m.GetTrans())/360.0f; box = mesh.getBoundingBox(); box.Scale(scaleFactor); } diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index 2f9c297339..23545b982b 100755 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -143,7 +143,7 @@ class MaxEggPlugin : public HelperObject int DoOwnSelectHilite() { return 1; } // From GeomObject - int IntersectRay(TimeValue t, Ray& r, float& at) { return 0; } + int IntersectRay(TimeValue t, Ray& r, PN_stdfloat& at) { return 0; } void GetWorldBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box ); void GetLocalBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box ); void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel ); diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index c6148ab367..2486daebfc 100755 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -263,7 +263,7 @@ void MaxEggJoint::CreateMaxBone(void) Point3 fwd = endpos - pos; double len = fwd.Length(); - Point3 txv = fwd * ((float)(1.0/len)); + Point3 txv = fwd * ((PN_stdfloat)(1.0/len)); Point3 tyv = tzv ^ txv; Point3 row1 = Point3(txv % xv, txv % yv, txv % zv); Point3 row2 = Point3(tyv % xv, tyv % yv, tyv % zv); @@ -276,9 +276,9 @@ void MaxEggJoint::CreateMaxBone(void) IParamBlock2 *blk = _bone->pblock2; for (int i=0; iNumParams(); i++) { TSTR n = blk->GetLocalName(i); - if (strcmp(n, "Length")==0) blk->SetValue(i,0,(float)len); - else if (strcmp(n, "Width")==0) blk->SetValue(i,0,(float)_thickness); - else if (strcmp(n, "Height")==0) blk->SetValue(i,0,(float)_thickness); + if (strcmp(n, "Length")==0) blk->SetValue(i,0,(PN_stdfloat)len); + else if (strcmp(n, "Width")==0) blk->SetValue(i,0,(PN_stdfloat)_thickness); + else if (strcmp(n, "Height")==0) blk->SetValue(i,0,(PN_stdfloat)_thickness); } Point3 boneColor = GetUIColor(COLOR_BONES); _node->SetWireColor(RGB(int(boneColor.x*255.0f), int(boneColor.y*255.0f), int(boneColor.z*255.0f) )); @@ -340,7 +340,7 @@ struct MEV_Compare: public stl_hash_compare typedef phash_set VertTable; typedef phash_map TVertTable; -typedef phash_map CVertTable; +typedef phash_map CVertTable; class MaxEggMesh { @@ -365,7 +365,7 @@ public: int GetVert(EggVertex *vert, EggGroup *context); int GetTVert(TexCoordd uv); - int GetCVert(Colorf col); + int GetCVert(LColor col); int AddFace(int v0, int v1, int v2, int tv0, int tv1, int tv2, int cv0, int cv1, int cv2, int tex); EggGroup *GetControlJoint(void); }; @@ -418,7 +418,7 @@ int MaxEggMesh::GetTVert(TexCoordd uv) return idx; } -int MaxEggMesh::GetCVert(Colorf col) +int MaxEggMesh::GetCVert(LColor col) { if (_cvert_tab.count(col)) return _cvert_tab[col]; @@ -539,11 +539,11 @@ void MaxEggLoader::CreateSkinModifier(MaxEggMesh *M) for (vert=M->_vert_tab.begin(); vert != M->_vert_tab.end(); ++vert) { Tab maxJoints; - Tab maxWeights; + Tab maxWeights; maxJoints.ZeroCount(); maxWeights.ZeroCount(); for (int i=0; i_weights.size(); i++) { - float strength = (float)(vert->_weights[i].first); + PN_stdfloat strength = (PN_stdfloat)(vert->_weights[i].first); MaxEggJoint *joint = FindJoint(vert->_weights[i].second); maxWeights.Append(1,&strength); maxJoints.Append(1,&(joint->_node)); diff --git a/pandatool/src/maxegg/maxNodeTree.h b/pandatool/src/maxegg/maxNodeTree.h index 5b5c65c8a9..d7fd259c02 100755 --- a/pandatool/src/maxegg/maxNodeTree.h +++ b/pandatool/src/maxegg/maxNodeTree.h @@ -43,7 +43,7 @@ public: EggXfmSAnim *get_egg_anim(MaxNodeDesc *node_desc); MaxNodeDesc* _root; - float _fps; + PN_stdfloat _fps; // the flag for the setting up collision //bool _has_collision; //EggGroup::CollideFlags _cf_type; diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 8908f43ee3..3a31952583 100755 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -685,7 +685,7 @@ make_polyset(INode *max_node, Mesh *mesh, if(mesh->vcFace) // if has vcFace, has used vertex color { VertColor vertexColor = get_max_vertex_color(mesh, iFace, iVertex); - Colorf pVC(vertexColor.x, vertexColor.y, vertexColor.z, 1); + LColor pVC(vertexColor.x, vertexColor.y, vertexColor.z, 1); vert.set_color(pVC); } // Get the UVs for this vertex @@ -896,7 +896,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { IPhyBlendedRigidVertex *pTypeVertex = (IPhyBlendedRigidVertex *)pVertexExport; for (int ji = 0; ji < pTypeVertex->GetNumberNodes(); ++ji) { - float weight = pTypeVertex->GetWeight(ji); + PN_stdfloat weight = pTypeVertex->GetWeight(ji); if (weight > 0.0f) { INode *bone_node = pTypeVertex->GetNode(ji); MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); @@ -932,7 +932,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { int max_vi = vert->get_external_index(); for (int ji = 0; ji < skinMC->GetNumAssignedBones(max_vi); ++ji) { - float weight = skinMC->GetBoneWeight(max_vi, ji); + PN_stdfloat weight = skinMC->GetBoneWeight(max_vi, ji); if (weight > 0.0f) { INode *bone_node = skin->GetBone(skinMC->GetAssignedBone(max_vi, ji)); MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); @@ -967,7 +967,7 @@ get_panda_material(Mtl *mtl, MtlID matID) { } PandaMaterial &pandaMat = _material_map[mtl]; - pandaMat._color = Colorf(1,1,1,1); + pandaMat._color = LColor(1,1,1,1); pandaMat._any_diffuse = false; pandaMat._any_opacity = false; pandaMat._any_gloss = false; diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index fb89bad35c..42af2ab14c 100755 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -47,7 +47,7 @@ class MaxToEggConverter { private: struct PandaMaterial { std::vector _texture_list; - Colorf _color; + LColor _color; std::vector _map_channels; bool _any_diffuse; bool _any_opacity; diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index f9beb3ff00..3df8cef87b 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -142,14 +142,14 @@ get_color_def(size_t idx) const { // color, so if a texture is also applied (_has_texture // is true), this value is not used by Maya. //////////////////////////////////////////////////////////////////// -Colorf MayaShader:: +LColor MayaShader:: get_rgba(size_t idx) const { - Colorf rgba(1.0f, 1.0f, 1.0f, 1.0f); + LColor rgba(1.0f, 1.0f, 1.0f, 1.0f); if (_color.size() && _color[idx]->_has_flat_color) { - rgba[0] = (float)_color[idx]->_flat_color[0]; - rgba[1] = (float)_color[idx]->_flat_color[1]; - rgba[2] = (float)_color[idx]->_flat_color[2]; + rgba[0] = (PN_stdfloat)_color[idx]->_flat_color[0]; + rgba[1] = (PN_stdfloat)_color[idx]->_flat_color[1]; + rgba[2] = (PN_stdfloat)_color[idx]->_flat_color[2]; } if (_transparency._has_flat_color) { @@ -160,7 +160,7 @@ get_rgba(size_t idx) const { _transparency._flat_color[0] * lumin_red + _transparency._flat_color[1] * lumin_grn + _transparency._flat_color[2] * lumin_blu; - rgba[3] = 1.0f - (float)trans; + rgba[3] = 1.0f - (PN_stdfloat)trans; } return rgba; diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index 6d53c84e11..193c368a24 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -75,7 +75,7 @@ private: public: // relevant only to legacy mode. MayaShaderColorList _color; MayaShaderColorDef _transparency; - Colorf get_rgba(size_t idx=0) const; + LColor get_rgba(size_t idx=0) const; MayaShaderColorDef *get_color_def(size_t idx=0) const; }; diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 3ac3fcc871..c38a3cc767 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -267,8 +267,8 @@ get_panda_uvset_name() { //////////////////////////////////////////////////////////////////// void MayaShaderColorDef:: find_textures_legacy(MayaShader *shader, MObject color, bool _texture_copy, Filename _texture_out_dir, bool trans) { - RGBColorf color_gain; - if (get_vec3f_attribute(color, "colorGain", color_gain)) { + LRGBColor color_gain; + if (get_vec3_attribute(color, "colorGain", color_gain)) { color_gain[0] = color_gain[0] > 1.0 ? 1.0 : color_gain[0]; color_gain[0] = color_gain[0] < 0.0 ? 0.0 : color_gain[0]; _color_gain[0] *= color_gain[0]; @@ -279,7 +279,7 @@ find_textures_legacy(MayaShader *shader, MObject color, bool _texture_copy, File color_gain[2] = color_gain[2] < 0.0 ? 0.0 : color_gain[2]; _color_gain[2] *= color_gain[2]; } - float alpha_gain; + PN_stdfloat alpha_gain; if (get_maya_attribute(color, "alphaGain", alpha_gain)) { alpha_gain = alpha_gain > 1.0 ? 1.0 : alpha_gain; alpha_gain = alpha_gain < 0.0 ? 0.0 : alpha_gain; @@ -321,8 +321,8 @@ find_textures_legacy(MayaShader *shader, MObject color, bool _texture_copy, File } } - get_vec2f_attribute(color, "coverage", _coverage); - get_vec2f_attribute(color, "translateFrame", _translate_frame); + get_vec2_attribute(color, "coverage", _coverage); + get_vec2_attribute(color, "translateFrame", _translate_frame); get_angle_attribute(color, "rotateFrame", _rotate_frame); //get_bool_attribute(color, "alphaIsLuminance", _alpha_is_luminance); @@ -332,8 +332,8 @@ find_textures_legacy(MayaShader *shader, MObject color, bool _texture_copy, File get_bool_attribute(color, "wrapU", _wrap_u); get_bool_attribute(color, "wrapV", _wrap_v); - get_vec2f_attribute(color, "repeatUV", _repeat_uv); - get_vec2f_attribute(color, "offset", _offset); + get_vec2_attribute(color, "repeatUV", _repeat_uv); + get_vec2_attribute(color, "offset", _offset); get_angle_attribute(color, "rotateUV", _rotate_uv); if (!trans) { @@ -578,8 +578,8 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug } def->_texture_name = sourceFn.name().asChar(); - get_vec2f_attribute(source, "coverage", def->_coverage); - get_vec2f_attribute(source, "translateFrame", def->_translate_frame); + get_vec2_attribute(source, "coverage", def->_coverage); + get_vec2_attribute(source, "translateFrame", def->_translate_frame); get_angle_attribute(source, "rotateFrame", def->_rotate_frame); get_bool_attribute(source, "mirror", def->_mirror); @@ -587,13 +587,13 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug get_bool_attribute(source, "wrapU", def->_wrap_u); get_bool_attribute(source, "wrapV", def->_wrap_v); - get_vec2f_attribute(source, "repeatUV", def->_repeat_uv); - get_vec2f_attribute(source, "offset", def->_offset); + get_vec2_attribute(source, "repeatUV", def->_repeat_uv); + get_vec2_attribute(source, "offset", def->_offset); get_angle_attribute(source, "rotateUV", def->_rotate_uv); - RGBColorf color_gain; - float alpha_gain; - get_vec3f_attribute(source, "colorGain", color_gain); + LRGBColor color_gain; + PN_stdfloat alpha_gain; + get_vec3_attribute(source, "colorGain", color_gain); get_maya_attribute(source, "alphaGain", alpha_gain); def->_color_gain[0] = color_gain[0]; def->_color_gain[1] = color_gain[1]; diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index f295462a7e..b56c0899b4 100755 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -88,10 +88,10 @@ public: Filename _texture_filename; string _texture_name; - Colorf _color_gain; + LColor _color_gain; - LVector2f _coverage; - LVector2f _translate_frame; + LVector2 _coverage; + LVector2 _translate_frame; double _rotate_frame; bool _mirror; @@ -99,8 +99,8 @@ public: bool _wrap_u; bool _wrap_v; - LVector2f _repeat_uv; - LVector2f _offset; + LVector2 _repeat_uv; + LVector2 _offset; double _rotate_uv; bool _is_alpha; diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 7d1afb173f..661ed10a28 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -198,29 +198,29 @@ get_angle_attribute(MObject &node, const string &attribute_name, } //////////////////////////////////////////////////////////////////// -// Function: get_vec2f_attribute +// Function: get_vec2_attribute // Description: Extracts the named two-component vector from the // MObject. //////////////////////////////////////////////////////////////////// bool -get_vec2f_attribute(MObject &node, const string &attribute_name, - LVecBase2f &value) { +get_vec2_attribute(MObject &node, const string &attribute_name, + LVecBase2 &value) { MStatus status; - MObject vec2f_object; - if (!get_maya_attribute(node, attribute_name, vec2f_object)) { + MObject vec2_object; + if (!get_maya_attribute(node, attribute_name, vec2_object)) { maya_cat.warning() << "Attribute " << attribute_name - << " does not have a vec2f object value.\n"; + << " does not have a vec2 object value.\n"; describe_maya_attribute(node, attribute_name); return false; } - MFnNumericData data(vec2f_object, &status); + MFnNumericData data(vec2_object, &status); if (!status) { maya_cat.warning() << "Attribute " << attribute_name << " is of type " - << vec2f_object.apiTypeStr() << ", not a NumericData.\n"; + << vec2_object.apiTypeStr() << ", not a NumericData.\n"; return false; } @@ -228,36 +228,36 @@ get_vec2f_attribute(MObject &node, const string &attribute_name, if (!status) { maya_cat.warning() << "Unable to extract 2 floats from " << attribute_name - << ", of type " << vec2f_object.apiTypeStr() << "\n"; + << ", of type " << vec2_object.apiTypeStr() << "\n"; } return true; } //////////////////////////////////////////////////////////////////// -// Function: get_vec3f_attribute +// Function: get_vec3_attribute // Description: Extracts the named three-component vector from the // MObject. //////////////////////////////////////////////////////////////////// bool -get_vec3f_attribute(MObject &node, const string &attribute_name, - LVecBase3f &value) { +get_vec3_attribute(MObject &node, const string &attribute_name, + LVecBase3 &value) { MStatus status; - MObject vec3f_object; - if (!get_maya_attribute(node, attribute_name, vec3f_object)) { + MObject vec3_object; + if (!get_maya_attribute(node, attribute_name, vec3_object)) { maya_cat.warning() << "Attribute " << attribute_name - << " does not have a vec3f object value.\n"; + << " does not have a vec3 object value.\n"; describe_maya_attribute(node, attribute_name); return false; } - MFnNumericData data(vec3f_object, &status); + MFnNumericData data(vec3_object, &status); if (!status) { maya_cat.warning() << "Attribute " << attribute_name << " is of type " - << vec3f_object.apiTypeStr() << ", not a NumericData.\n"; + << vec3_object.apiTypeStr() << ", not a NumericData.\n"; return false; } @@ -265,7 +265,7 @@ get_vec3f_attribute(MObject &node, const string &attribute_name, if (!status) { maya_cat.warning() << "Unable to extract 3 floats from " << attribute_name - << ", of type " << vec3f_object.apiTypeStr() << "\n"; + << ", of type " << vec3_object.apiTypeStr() << "\n"; } return true; @@ -545,9 +545,9 @@ describe_compound_attribute(MObject &node) { for (size_t i = 0; i < comp_attr.numChildren(); i++) { MObject child = comp_attr.child(i, &status); if (child.apiType() == MFn::kAttribute3Float){ - RGBColorf color; + LRGBColor color; /* - if (get_vec3f_attribute(child, "color", color)) { + if (get_vec3_attribute(child, "color", color)) { maya_cat.info() << "color: " << color << endl; } */ @@ -557,7 +557,7 @@ describe_compound_attribute(MObject &node) { if (status) { switch(numeric.unitType()) { case MFnNumericData::kFloat : - float alpha; + PN_stdfloat alpha; status = numeric.getDefault(alpha); maya_cat.info() << "found a float :" << alpha << endl; break; diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index f8f1a01073..202b9bbcdc 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -62,12 +62,12 @@ get_angle_attribute(MObject &node, const string &attribute_name, double &value); bool -get_vec2f_attribute(MObject &node, const string &attribute_name, - LVecBase2f &value); +get_vec2_attribute(MObject &node, const string &attribute_name, + LVecBase2 &value); bool -get_vec3f_attribute(MObject &node, const string &attribute_name, - LVecBase3f &value); +get_vec3_attribute(MObject &node, const string &attribute_name, + LVecBase3 &value); bool get_vec2d_attribute(MObject &node, const string &attribute_name, diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index 0675d3d9da..765e83a8c5 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -51,7 +51,7 @@ MayaBlendDesc:: // affected vertices. //////////////////////////////////////////////////////////////////// void MayaBlendDesc:: -set_slider(float value) { +set_slider(PN_stdfloat value) { MStatus status = _deformer.setWeight(_weight_index, value); if (!status) { mayaegg_cat.warning() @@ -65,7 +65,7 @@ set_slider(float value) { // Description: Returns the current position of the Maya slider // associated with this blend shape. //////////////////////////////////////////////////////////////////// -float MayaBlendDesc:: +PN_stdfloat MayaBlendDesc:: get_slider() const { return _deformer.weight(_weight_index); } diff --git a/pandatool/src/mayaegg/mayaBlendDesc.h b/pandatool/src/mayaegg/mayaBlendDesc.h index b2db00ba1a..d2586d0eb6 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.h +++ b/pandatool/src/mayaegg/mayaBlendDesc.h @@ -45,8 +45,8 @@ public: MayaBlendDesc(MFnBlendShapeDeformer deformer, int weight_index); ~MayaBlendDesc(); - void set_slider(float value); - float get_slider() const; + void set_slider(PN_stdfloat value); + PN_stdfloat get_slider() const; private: void clear_egg(); diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index aed8b057e4..d6003c8a91 100755 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -152,7 +152,7 @@ MVector MakeMayaVector(const LVector3d &vec) return MVector(vec[0], vec[1], vec[2]); } -MColor MakeMayaColor(const Colorf &vec) +MColor MakeMayaColor(const LColor &vec) { return MColor(vec[0], vec[1], vec[2], vec[3]); } @@ -930,7 +930,7 @@ void MayaEggGeom::AddEggFlag(MString fieldName) { // //////////////////////////////////////////////////////////////////////////////////////////////////// typedef phash_map TVertTable; -typedef phash_map CVertTable; +typedef phash_map CVertTable; class MayaEggMesh : public MayaEggGeom { @@ -953,7 +953,7 @@ public: CVertTable _cvert_tab; int GetTVert(TexCoordd uv); - int GetCVert(Colorf col); + int GetCVert(LColor col); int AddFace(unsigned numVertices, MIntArray mvertIndices, MIntArray mtvertIndices, MayaEggTex *tex); void ConnectTextures(void); @@ -977,7 +977,7 @@ int MayaEggMesh::GetTVert(TexCoordd uv) return idx; } -int MayaEggMesh::GetCVert(Colorf col) +int MayaEggMesh::GetCVert(LColor col) { // if (_cvert_tab.count(col)) // return _cvert_tab[col]; @@ -1340,7 +1340,7 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) for (unsigned int i=0; i_weights.size(); i++) { double strength = vert->_weights[i].first / vert->_sumWeights; // [gjeon] nomalizing weights MayaEggJoint *joint = FindJoint(vert->_weights[i].second); - values[vert->_index * joints.size() + joint->_index] = (float)strength; + values[vert->_index * joints.size() + joint->_index] = (PN_stdfloat)strength; } } skinCluster.setWeights(M->_shape_dag_path, component.object(), influenceIndices, values, false, NULL); diff --git a/pandatool/src/mayaegg/mayaNodeTree.h b/pandatool/src/mayaegg/mayaNodeTree.h index cca169ccc5..30f5e3cbfe 100755 --- a/pandatool/src/mayaegg/mayaNodeTree.h +++ b/pandatool/src/mayaegg/mayaNodeTree.h @@ -75,7 +75,7 @@ public: public: string _subroot_parent_name; PT(MayaNodeDesc) _root; - float _fps; + PN_stdfloat _fps; private: MayaNodeDesc *r_build_node(const string &path); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 0b3d69f5f1..f4813f70d6 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -1550,7 +1550,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggVertex *vert = vpool->get_vertex(i); for (int ji = 0; ji < num_joints; ++ji) { - float weight = weights[maya_vi * num_joints + ji]; + PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; if (joint != (EggGroup *)NULL) { @@ -1901,7 +1901,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, ignore_vertex_color = default_color_def->_has_texture && !(egg_vertex_color || _always_show_vertex_color); } - Colorf poly_color(1.0f, 1.0f, 1.0f, 1.0f); + LColor poly_color(1.0f, 1.0f, 1.0f, 1.0f); if (!ignore_vertex_color) { // If we're respecting the vertex color, then remove the color // specification from the polygon (so we can apply it to the @@ -2104,7 +2104,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, nassertv(maya_vi >= 0 && maya_vi < num_verts); for (int ji = 0; ji < num_joints; ++ji) { - float weight = weights[maya_vi * num_joints + ji]; + PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; if (joint != (EggGroup *)NULL) { @@ -2799,7 +2799,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, dummy_tex->set_uv_name(dummy_uvset_name); } // Also apply an overall color to the primitive. - Colorf rgba = shader.get_rgba(); + LColor rgba = shader.get_rgba(); if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() << "ssa:rgba = " << rgba << endl; } @@ -3104,7 +3104,7 @@ string_transform_type(const string &arg) { // the legacy or modern vertex color functions. //////////////////////////////////////////////////////////////////// void MayaToEggConverter:: -set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color) { +set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { if (shader == (MayaShader *)NULL || shader->_legacy_mode) { set_vertex_color_legacy(vert, pi, vert_index, shader, color); } else { @@ -3121,7 +3121,7 @@ set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const Maya // in Maya. //////////////////////////////////////////////////////////////////// void MayaToEggConverter:: -set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color){ +set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color){ if (pi.hasColor()) { MColor c; MStatus status = pi.getColor(c, vert_index); @@ -3133,7 +3133,7 @@ set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con c /= 1.0; // The vertex color is a color scale that modifies the // polygon color, not an override that replaces it. - vert.set_color(Colorf(c.r * color[0], c.g * color[1], c.b * color[2], c.a * color[3])); + vert.set_color(LColor(c.r * color[0], c.g * color[1], c.b * color[2], c.a * color[3])); if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() << "maya_color = " << c.r << " " << c.g << " " << c.b << " " << c.a << endl; @@ -3155,13 +3155,13 @@ set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con // or shaders. //////////////////////////////////////////////////////////////////// void MayaToEggConverter:: -set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color) { +set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { // If there's an explicit vertex color, output it. if (pi.hasColor(vert_index)) { MColor c; MStatus status = pi.getColor(c, vert_index); if (status) { - vert.set_color(Colorf(c.r, c.g, c.b, c.a)); + vert.set_color(LColor(c.r, c.g, c.b, c.a)); return; } } @@ -3169,9 +3169,9 @@ set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con // If there's no explicit color, use flat color, or white on a textured model. if (shader->_color_maps.empty()) { const Colord &c = shader->_flat_color; - vert.set_color(Colorf((float)c[0], (float)c[1], (float)c[2], (float)c[3])); + vert.set_color(LColor((PN_stdfloat)c[0], (PN_stdfloat)c[1], (PN_stdfloat)c[2], (PN_stdfloat)c[3])); } else { //there's no explicit color anywhere, must be textured (or blank) - vert.set_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)); + vert.set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index 143dd6325c..f4db69de3a 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -160,11 +160,11 @@ private: bool mesh); void set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, bool mesh); - void set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color); + void set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color); - void set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color); + void set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color); - void set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const Colorf &color); + void set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color); int round(double value); diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index a2c4b7548a..79f794695d 100755 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -177,7 +177,7 @@ doIt(const MArgList &args) { loading_np.set_scale(0.125f); loading->set_text_color(1.0f, 1.0f, 1.0f, 1.0f); loading->set_shadow_color(0.0f, 0.0f, 0.0f, 1.0f); - loading->set_shadow(0.04f, 0.04f); + loading->set_shadow(0.04, 0.04); loading->set_align(TextNode::A_center); loading->set_text("Loading..."); diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 989be1ea30..4e54ce10b2 100755 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -240,7 +240,7 @@ process_v(vector_string &words) { << "Invalid number at line " << _line_number << "\n"; return false; } - vertex->set_color(Colorf(r, g, b, 1.0)); + vertex->set_color(LColor(r, g, b, 1.0)); } ++_vi; diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index da036f00f3..ce287baada 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -901,7 +901,7 @@ write_source_pathnames(ostream &out, int indent_level) const { if (_is_cutout) { indent(out, indent_level) - << "Cutout image (ratio " << (float)_mid_pixel_ratio << ")\n"; + << "Cutout image (ratio " << (PN_stdfloat)_mid_pixel_ratio << ")\n"; } // Now write out the group assignments. diff --git a/pandatool/src/palettizer/txaLine.h b/pandatool/src/palettizer/txaLine.h index 64aefa5c54..7699bbe5a2 100644 --- a/pandatool/src/palettizer/txaLine.h +++ b/pandatool/src/palettizer/txaLine.h @@ -60,7 +60,7 @@ private: }; SizeType _size_type; - float _scale; + PN_stdfloat _scale; int _x_size; int _y_size; int _num_channels; diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index de69ab1294..8ea2be0c66 100755 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -99,7 +99,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { }; for (int i = 0; i < bounds->get_num_points(); ++i) { - LPoint3f p = bounds->get_point(reorder_points[ri][i]); + LPoint3 p = bounds->get_point(reorder_points[ri][i]); out << p[0] << "," << p[1] << "," << p[2] << "\n"; } } diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index 0a63ad4dbb..7cef91d74b 100755 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -30,7 +30,7 @@ PfmTrans:: PfmTrans() { _got_transform = false; - _transform = LMatrix4f::ident_mat(); + _transform = LMatrix4::ident_mat(); add_transform_options(); @@ -255,16 +255,16 @@ handle_args(ProgramBase::Args &args) { // Function: PfmTrans::dispatch_scale // Access: Protected, Static // Description: Handles -TS, which specifies a scale transform. Var -// is an LMatrix4f. +// is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: dispatch_scale(const string &opt, const string &arg, void *var) { - LMatrix4f *transform = (LMatrix4f *)var; + LMatrix4 *transform = (LMatrix4 *)var; vector_string words; tokenize(arg, words, ","); - float sx, sy, sz; + PN_stdfloat sx, sy, sz; bool okflag = false; if (words.size() == 3) { @@ -285,7 +285,7 @@ dispatch_scale(const string &opt, const string &arg, void *var) { return false; } - *transform = (*transform) * LMatrix4f::scale_mat(sx, sy, sz); + *transform = (*transform) * LMatrix4::scale_mat(sx, sy, sz); return true; } @@ -294,7 +294,7 @@ dispatch_scale(const string &opt, const string &arg, void *var) { // Function: PfmTrans::dispatch_rotate_xyz // Access: Protected, Static // Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4f. +// the three cardinal axes. Var is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var) { @@ -306,16 +306,16 @@ dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, voi // Function: PfmTrans::ns_dispatch_rotate_xyz // Access: Protected // Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4f. +// the three cardinal axes. Var is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { - LMatrix4f *transform = (LMatrix4f *)var; + LMatrix4 *transform = (LMatrix4 *)var; vector_string words; tokenize(arg, words, ","); - LVecBase3f xyz; + LVecBase3 xyz; bool okflag = false; if (words.size() == 3) { @@ -331,10 +331,10 @@ ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { return false; } - LMatrix4f mat = - LMatrix4f::rotate_mat(xyz[0], LVector3f(1.0, 0.0, 0.0)) * - LMatrix4f::rotate_mat(xyz[1], LVector3f(0.0, 1.0, 0.0)) * - LMatrix4f::rotate_mat(xyz[2], LVector3f(0.0, 0.0, 1.0)); + LMatrix4 mat = + LMatrix4::rotate_mat(xyz[0], LVector3(1.0, 0.0, 0.0)) * + LMatrix4::rotate_mat(xyz[1], LVector3(0.0, 1.0, 0.0)) * + LMatrix4::rotate_mat(xyz[2], LVector3(0.0, 0.0, 1.0)); *transform = (*transform) * mat; @@ -345,7 +345,7 @@ ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { // Function: PfmTrans::dispatch_rotate_axis // Access: Protected, Static // Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4f. +// an arbitrary axis. Var is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var) { @@ -357,17 +357,17 @@ dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, vo // Function: PfmTrans::ns_dispatch_rotate_axis // Access: Protected // Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4f. +// an arbitrary axis. Var is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { - LMatrix4f *transform = (LMatrix4f *)var; + LMatrix4 *transform = (LMatrix4 *)var; vector_string words; tokenize(arg, words, ","); - float angle; - LVecBase3f axis; + PN_stdfloat angle; + LVecBase3 axis; bool okflag = false; if (words.size() == 4) { @@ -384,7 +384,7 @@ ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { return false; } - *transform = (*transform) * LMatrix4f::rotate_mat(angle, axis); + *transform = (*transform) * LMatrix4::rotate_mat(angle, axis); return true; } @@ -393,16 +393,16 @@ ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { // Function: PfmTrans::dispatch_translate // Access: Protected, Static // Description: Handles -TT, which specifies a translate transform. -// Var is an LMatrix4f. +// Var is an LMatrix4. //////////////////////////////////////////////////////////////////// bool PfmTrans:: dispatch_translate(const string &opt, const string &arg, void *var) { - LMatrix4f *transform = (LMatrix4f *)var; + LMatrix4 *transform = (LMatrix4 *)var; vector_string words; tokenize(arg, words, ","); - LVector3f trans; + LVector3 trans; bool okflag = false; if (words.size() == 3) { @@ -418,7 +418,7 @@ dispatch_translate(const string &opt, const string &arg, void *var) { return false; } - *transform = (*transform) * LMatrix4f::translate_mat(trans); + *transform = (*transform) * LMatrix4::translate_mat(trans); return true; } diff --git a/pandatool/src/pfmprogs/pfmTrans.h b/pandatool/src/pfmprogs/pfmTrans.h index f0777e1d88..a9f1e125da 100755 --- a/pandatool/src/pfmprogs/pfmTrans.h +++ b/pandatool/src/pfmprogs/pfmTrans.h @@ -68,7 +68,7 @@ private: Filename _vistex_filename; bool _got_transform; - LMatrix4f _transform; + LMatrix4 _transform; NodePath _mesh_root; }; diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 100a3508e5..01968b4d24 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -939,11 +939,11 @@ dispatch_double_quad(const string &opt, const string &arg, void *var) { // Access: Protected, Static // Description: Standard dispatch function for an option that takes a // color, as l or l,a or r,g,b or r,g,b,a. The data -// pointer is to an array of four floats, e.g. a Colorf. +// pointer is to an array of four floats, e.g. a LColor. //////////////////////////////////////////////////////////////////// bool ProgramBase:: dispatch_color(const string &opt, const string &arg, void *var) { - float *ip = (float *)var; + PN_stdfloat *ip = (PN_stdfloat *)var; vector_string words; tokenize(arg, words, ","); diff --git a/pandatool/src/pstatserver/pStatGraph.I b/pandatool/src/pstatserver/pStatGraph.I index 8c4a08cbee..a6d01ef867 100644 --- a/pandatool/src/pstatserver/pStatGraph.I +++ b/pandatool/src/pstatserver/pStatGraph.I @@ -62,9 +62,9 @@ get_label_name(int n) const { // Access: Public // Description: Returns the color associated with the nth label. //////////////////////////////////////////////////////////////////// -INLINE RGBColorf PStatGraph:: +INLINE LRGBColor PStatGraph:: get_label_color(int n) const { - nassertr(n >= 0 && n < (int)_labels.size(), RGBColorf(0.0, 0.0, 0.0)); + nassertr(n >= 0 && n < (int)_labels.size(), LRGBColor(0.0, 0.0, 0.0)); return _monitor->get_collector_color(_labels[n]); } @@ -76,7 +76,7 @@ get_label_color(int n) const { // placement of guide bars. //////////////////////////////////////////////////////////////////// INLINE void PStatGraph:: -set_target_frame_rate(float frame_rate) { +set_target_frame_rate(PN_stdfloat frame_rate) { if (_target_frame_rate != frame_rate) { _target_frame_rate = frame_rate; normal_guide_bars(); @@ -89,7 +89,7 @@ set_target_frame_rate(float frame_rate) { // Description: Returns the indicated target frame rate in Hz. See // set_target_frame_rate(). //////////////////////////////////////////////////////////////////// -INLINE float PStatGraph:: +INLINE PN_stdfloat PStatGraph:: get_target_frame_rate() const { return _target_frame_rate; } diff --git a/pandatool/src/pstatserver/pStatGraph.cxx b/pandatool/src/pstatserver/pStatGraph.cxx index 920ba9629b..9c118a9766 100644 --- a/pandatool/src/pstatserver/pStatGraph.cxx +++ b/pandatool/src/pstatserver/pStatGraph.cxx @@ -27,7 +27,7 @@ // Description: //////////////////////////////////////////////////////////////////// PStatGraph::GuideBar:: -GuideBar(float height, const string &label, PStatGraph::GuideBarStyle style) : +GuideBar(PN_stdfloat height, const string &label, PStatGraph::GuideBarStyle style) : _height(height), _label(label), _style(style) @@ -124,7 +124,7 @@ get_num_user_guide_bars() const { //////////////////////////////////////////////////////////////////// PStatGraph::GuideBar PStatGraph:: get_user_guide_bar(int n) const { - float height = _monitor->get_server()->get_user_guide_bar_height(n); + PN_stdfloat height = _monitor->get_server()->get_user_guide_bar_height(n); return make_guide_bar(height, GBS_user); } @@ -134,7 +134,7 @@ get_user_guide_bar(int n) const { // Description: Adjusts the height of the nth user-defined guide bar. //////////////////////////////////////////////////////////////////// void PStatGraph:: -move_user_guide_bar(int n, float height) { +move_user_guide_bar(int n, PN_stdfloat height) { _monitor->get_server()->move_user_guide_bar(n, height); } @@ -145,7 +145,7 @@ move_user_guide_bar(int n, float height) { // number. //////////////////////////////////////////////////////////////////// int PStatGraph:: -add_user_guide_bar(float height) { +add_user_guide_bar(PN_stdfloat height) { return _monitor->get_server()->add_user_guide_bar(height); } @@ -169,7 +169,7 @@ remove_user_guide_bar(int n) { // -1 if no user guide bars fall within the range. //////////////////////////////////////////////////////////////////// int PStatGraph:: -find_user_guide_bar(float from_height, float to_height) const { +find_user_guide_bar(PN_stdfloat from_height, PN_stdfloat to_height) const { return _monitor->get_server()->find_user_guide_bar(from_height, to_height); } @@ -181,15 +181,15 @@ find_user_guide_bar(float from_height, float to_height) const { // formatted for its range. //////////////////////////////////////////////////////////////////// string PStatGraph:: -format_number(float value) { +format_number(PN_stdfloat value) { char buffer[128]; if (value < 0.01) { - sprintf(buffer, "%0.4f", value); + sprintf(buffer, "%0.4", value); } else if (value < 0.1) { - sprintf(buffer, "%0.3f", value); + sprintf(buffer, "%0.3", value); } else if (value < 1.0) { - sprintf(buffer, "%0.2f", value); + sprintf(buffer, "%0.2", value); } else if (value < 10.0) { sprintf(buffer, "%0.1f", value); } else { @@ -207,7 +207,7 @@ format_number(float value) { // as indicated. //////////////////////////////////////////////////////////////////// string PStatGraph:: -format_number(float value, int guide_bar_units, const string &unit_name) { +format_number(PN_stdfloat value, int guide_bar_units, const string &unit_name) { string label; if ((guide_bar_units & GBU_named) != 0) { @@ -222,7 +222,7 @@ format_number(float value, int guide_bar_units, const string &unit_name) { } else { // Units are either milliseconds or hz, or both. if ((guide_bar_units & GBU_ms) != 0) { - float ms = value * 1000.0; + PN_stdfloat ms = value * 1000.0; label += format_number(ms); if ((guide_bar_units & GBU_show_units) != 0) { label += " ms"; @@ -230,7 +230,7 @@ format_number(float value, int guide_bar_units, const string &unit_name) { } if ((guide_bar_units & GBU_hz) != 0) { - float hz = 1.0 / value; + PN_stdfloat hz = 1.0 / value; if ((guide_bar_units & GBU_ms) != 0) { label += " ("; @@ -254,7 +254,7 @@ format_number(float value, int guide_bar_units, const string &unit_name) { // Description: Resets the list of guide bars. //////////////////////////////////////////////////////////////////// void PStatGraph:: -update_guide_bars(int num_bars, float scale) { +update_guide_bars(int num_bars, PN_stdfloat scale) { _guide_bars.clear(); // We'd like to draw about num_bars bars on the chart. But we also @@ -265,9 +265,9 @@ update_guide_bars(int num_bars, float scale) { // Choose a suitable harmonic of the target frame rate near the // bottom part of the chart. - float bottom = (float)num_bars / scale; + PN_stdfloat bottom = (PN_stdfloat)num_bars / scale; - float harmonic; + PN_stdfloat harmonic; if (_target_frame_rate < bottom) { // n * tfr harmonic = floor(bottom / _target_frame_rate + 0.5) * _target_frame_rate; @@ -292,14 +292,14 @@ update_guide_bars(int num_bars, float scale) { // level units. //////////////////////////////////////////////////////////////////// PStatGraph::GuideBar PStatGraph:: -make_guide_bar(float value, PStatGraph::GuideBarStyle style) const { +make_guide_bar(PN_stdfloat value, PStatGraph::GuideBarStyle style) const { string label = format_number(value, _guide_bar_units, _unit_name); if ((style == GBS_normal) && (_guide_bar_units & GBU_named) == 0) { // If it's a time unit, check to see if it matches our target // frame rate. - float hz = 1.0 / value; + PN_stdfloat hz = 1.0 / value; if (IS_THRESHOLD_EQUAL(hz, _target_frame_rate, 0.001)) { style = GBS_target; } diff --git a/pandatool/src/pstatserver/pStatGraph.h b/pandatool/src/pstatserver/pStatGraph.h index 53902d438e..e78a4d03ab 100644 --- a/pandatool/src/pstatserver/pStatGraph.h +++ b/pandatool/src/pstatserver/pStatGraph.h @@ -43,10 +43,10 @@ public: INLINE int get_num_labels() const; INLINE int get_label_collector(int n) const; INLINE string get_label_name(int n) const; - INLINE RGBColorf get_label_color(int n) const; + INLINE LRGBColor get_label_color(int n) const; - INLINE void set_target_frame_rate(float frame_rate); - INLINE float get_target_frame_rate() const; + INLINE void set_target_frame_rate(PN_stdfloat frame_rate); + INLINE PN_stdfloat get_target_frame_rate() const; INLINE int get_xsize() const; INLINE int get_ysize() const; @@ -59,10 +59,10 @@ public: class GuideBar { public: - GuideBar(float height, const string &label, GuideBarStyle style); + GuideBar(PN_stdfloat height, const string &label, GuideBarStyle style); GuideBar(const GuideBar ©); - float _height; + PN_stdfloat _height; string _label; GuideBarStyle _style; }; @@ -79,31 +79,31 @@ public: int get_num_user_guide_bars() const; GuideBar get_user_guide_bar(int n) const; - void move_user_guide_bar(int n, float height); - int add_user_guide_bar(float height); + void move_user_guide_bar(int n, PN_stdfloat height); + int add_user_guide_bar(PN_stdfloat height); void remove_user_guide_bar(int n); - int find_user_guide_bar(float from_height, float to_height) const; + int find_user_guide_bar(PN_stdfloat from_height, PN_stdfloat to_height) const; INLINE void set_guide_bar_units(int unit_mask); INLINE int get_guide_bar_units() const; INLINE void set_guide_bar_unit_name(const string &unit_name); INLINE const string &get_guide_bar_unit_name() const; - static string format_number(float value); - static string format_number(float value, int guide_bar_units, + static string format_number(PN_stdfloat value); + static string format_number(PN_stdfloat value, int guide_bar_units, const string &unit_name = string()); protected: virtual void normal_guide_bars()=0; - void update_guide_bars(int num_bars, float scale); - GuideBar make_guide_bar(float value, GuideBarStyle style = GBS_normal) const; + void update_guide_bars(int num_bars, PN_stdfloat scale); + GuideBar make_guide_bar(PN_stdfloat value, GuideBarStyle style = GBS_normal) const; bool _labels_changed; bool _guide_bars_changed; PT(PStatMonitor) _monitor; - float _target_frame_rate; + PN_stdfloat _target_frame_rate; int _xsize; int _ysize; diff --git a/pandatool/src/pstatserver/pStatMonitor.cxx b/pandatool/src/pstatserver/pStatMonitor.cxx index 0cf982ab53..886fea849a 100644 --- a/pandatool/src/pstatserver/pStatMonitor.cxx +++ b/pandatool/src/pstatserver/pStatMonitor.cxx @@ -119,7 +119,7 @@ close() { // spot and associated with this collector for the rest // of the session. //////////////////////////////////////////////////////////////////// -const RGBColorf &PStatMonitor:: +const LRGBColor &PStatMonitor:: get_collector_color(int collector_index) { Colors::iterator ci; ci = _colors.find(collector_index); @@ -133,10 +133,10 @@ get_collector_color(int collector_index) { const PStatCollectorDef &def = _client_data->get_collector_def(collector_index); - RGBColorf sc(def._suggested_color.r, + LRGBColor sc(def._suggested_color.r, def._suggested_color.g, def._suggested_color.b); - if (sc != RGBColorf::zero()) { + if (sc != LRGBColor::zero()) { ci = _colors.insert(Colors::value_type(collector_index, sc)).first; return (*ci).second; } @@ -153,10 +153,10 @@ get_collector_color(int collector_index) { } // We didn't have a color for the collector; make one up. - RGBColorf random_color; - random_color[0] = (float)rand() / (float)RAND_MAX; - random_color[1] = (float)rand() / (float)RAND_MAX; - random_color[2] = (float)rand() / (float)RAND_MAX; + LRGBColor random_color; + random_color[0] = (PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX; + random_color[1] = (PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX; + random_color[2] = (PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX; ci = _colors.insert(Colors::value_type(collector_index, random_color)).first; return (*ci).second; diff --git a/pandatool/src/pstatserver/pStatMonitor.h b/pandatool/src/pstatserver/pStatMonitor.h index d2be6df8b3..5f11c6d2d8 100644 --- a/pandatool/src/pstatserver/pStatMonitor.h +++ b/pandatool/src/pstatserver/pStatMonitor.h @@ -62,7 +62,7 @@ public: INLINE PStatServer *get_server(); INLINE const PStatClientData *get_client_data() const; INLINE string get_collector_name(int collector_index); - const RGBColorf &get_collector_color(int collector_index); + const LRGBColor &get_collector_color(int collector_index); INLINE bool is_client_known() const; INLINE string get_client_hostname() const; @@ -108,7 +108,7 @@ private: typedef pmap LevelViews; LevelViews _level_views; - typedef pmap Colors; + typedef pmap Colors; Colors _colors; }; diff --git a/pandatool/src/pstatserver/pStatPianoRoll.I b/pandatool/src/pstatserver/pStatPianoRoll.I index 9eecdf10f9..5a77823ee2 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.I +++ b/pandatool/src/pstatserver/pStatPianoRoll.I @@ -19,7 +19,7 @@ // horizontal axis represents. This may force a redraw. //////////////////////////////////////////////////////////////////// INLINE void PStatPianoRoll:: -set_horizontal_scale(float time_width) { +set_horizontal_scale(PN_stdfloat time_width) { if (_time_width != time_width) { _time_width = time_width; normal_guide_bars(); @@ -33,7 +33,7 @@ set_horizontal_scale(float time_width) { // Description: Returns the amount of total time the width of the // horizontal axis represents. //////////////////////////////////////////////////////////////////// -INLINE float PStatPianoRoll:: +INLINE PN_stdfloat PStatPianoRoll:: get_horizontal_scale() const { return _time_width; } @@ -44,8 +44,8 @@ get_horizontal_scale() const { // Description: Converts a timestamp to a horizontal pixel offset. //////////////////////////////////////////////////////////////////// INLINE int PStatPianoRoll:: -timestamp_to_pixel(float time) const { - return (int)((float)_xsize * (time - _start_time) / _time_width); +timestamp_to_pixel(PN_stdfloat time) const { + return (int)((PN_stdfloat)_xsize * (time - _start_time) / _time_width); } //////////////////////////////////////////////////////////////////// @@ -53,9 +53,9 @@ timestamp_to_pixel(float time) const { // Access: Public // Description: Converts a horizontal pixel offset to a timestamp. //////////////////////////////////////////////////////////////////// -INLINE float PStatPianoRoll:: +INLINE PN_stdfloat PStatPianoRoll:: pixel_to_timestamp(int x) const { - return _time_width * (float)x / (float)_xsize + _start_time; + return _time_width * (PN_stdfloat)x / (PN_stdfloat)_xsize + _start_time; } //////////////////////////////////////////////////////////////////// @@ -65,8 +65,8 @@ pixel_to_timestamp(int x) const { // to a horizontal pixel offset. //////////////////////////////////////////////////////////////////// INLINE int PStatPianoRoll:: -height_to_pixel(float value) const { - return (int)((float)_xsize * value / _time_width); +height_to_pixel(PN_stdfloat value) const { + return (int)((PN_stdfloat)_xsize * value / _time_width); } //////////////////////////////////////////////////////////////////// @@ -75,7 +75,7 @@ height_to_pixel(float value) const { // Description: Converts a horizontal pixel offset to a value (a // "height" in the strip chart). //////////////////////////////////////////////////////////////////// -INLINE float PStatPianoRoll:: +INLINE PN_stdfloat PStatPianoRoll:: pixel_to_height(int x) const { - return _time_width * (float)x / (float)_xsize; + return _time_width * (PN_stdfloat)x / (PN_stdfloat)_xsize; } diff --git a/pandatool/src/pstatserver/pStatPianoRoll.cxx b/pandatool/src/pstatserver/pStatPianoRoll.cxx index 4b011d3e88..a376928e99 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.cxx +++ b/pandatool/src/pstatserver/pStatPianoRoll.cxx @@ -51,7 +51,7 @@ clear() { // second data point turns it off (ends the bar). //////////////////////////////////////////////////////////////////// void PStatPianoRoll::BarBuilder:: -add_data_point(float time, bool is_start) { +add_data_point(PN_stdfloat time, bool is_start) { if (is_start) { // This is a "start" data point: start the bar. if (_color_bars.empty() || _color_bars.back()._end >= 0.0) { @@ -84,7 +84,7 @@ add_data_point(float time, bool is_start) { // by a corresponding end-bar data point. //////////////////////////////////////////////////////////////////// void PStatPianoRoll::BarBuilder:: -finish(float time) { +finish(PN_stdfloat time) { if (!_color_bars.empty() && _color_bars.back()._end < 0.0) { _color_bars.back()._end = time; } @@ -304,7 +304,7 @@ compute_page(const PStatFrameData &frame_data) { int num_events = frame_data.get_num_events(); for (int i = 0; i < num_events; i++) { int collector_index = frame_data.get_time_collector(i); - float time = frame_data.get_time(i); + PN_stdfloat time = frame_data.get_time(i); bool is_start = frame_data.is_start(i); _page_data[collector_index].add_data_point(time, is_start); } @@ -344,7 +344,7 @@ compute_page(const PStatFrameData &frame_data) { } // Finally, make sure all of the bars are closed. - float time = frame_data.get_end(); + PN_stdfloat time = frame_data.get_end(); PageData::iterator pi; for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) { (*pi).second.finish(time); diff --git a/pandatool/src/pstatserver/pStatPianoRoll.h b/pandatool/src/pstatserver/pStatPianoRoll.h index 76b740a20a..e245e75c3a 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.h +++ b/pandatool/src/pstatserver/pStatPianoRoll.h @@ -48,13 +48,13 @@ public: void update(); - INLINE void set_horizontal_scale(float time_width); - INLINE float get_horizontal_scale() const; + INLINE void set_horizontal_scale(PN_stdfloat time_width); + INLINE PN_stdfloat get_horizontal_scale() const; - INLINE int timestamp_to_pixel(float time) const; - INLINE float pixel_to_timestamp(int x) const; - INLINE int height_to_pixel(float value) const; - INLINE float pixel_to_height(int y) const; + INLINE int timestamp_to_pixel(PN_stdfloat time) const; + INLINE PN_stdfloat pixel_to_timestamp(int x) const; + INLINE int height_to_pixel(PN_stdfloat value) const; + INLINE PN_stdfloat pixel_to_height(int y) const; protected: void changed_size(int xsize, int ysize); @@ -75,13 +75,13 @@ protected: int _thread_index; private: - float _time_width; - float _start_time; + PN_stdfloat _time_width; + PN_stdfloat _start_time; class ColorBar { public: - float _start; - float _end; + PN_stdfloat _start; + PN_stdfloat _end; }; typedef pvector ColorBars; @@ -89,8 +89,8 @@ private: public: BarBuilder(); void clear(); - void add_data_point(float time, bool is_start); - void finish(float time); + void add_data_point(PN_stdfloat time, bool is_start); + void finish(PN_stdfloat time); bool _is_new; ColorBars _color_bars; diff --git a/pandatool/src/pstatserver/pStatServer.cxx b/pandatool/src/pstatserver/pStatServer.cxx index 431fed1fa2..cebea3d4e2 100644 --- a/pandatool/src/pstatserver/pStatServer.cxx +++ b/pandatool/src/pstatserver/pStatServer.cxx @@ -219,7 +219,7 @@ get_num_user_guide_bars() const { // Access: Public // Description: Returns the height of the nth user-defined guide bar. //////////////////////////////////////////////////////////////////// -float PStatServer:: +PN_stdfloat PStatServer:: get_user_guide_bar_height(int n) const { nassertr(n >= 0 && n < (int)_user_guide_bars.size(), 0.0f); return _user_guide_bars[n]; @@ -231,7 +231,7 @@ get_user_guide_bar_height(int n) const { // Description: Adjusts the height of the nth user-defined guide bar. //////////////////////////////////////////////////////////////////// void PStatServer:: -move_user_guide_bar(int n, float height) { +move_user_guide_bar(int n, PN_stdfloat height) { nassertv(n >= 0 && n < (int)_user_guide_bars.size()); _user_guide_bars[n] = height; user_guide_bars_changed(); @@ -244,7 +244,7 @@ move_user_guide_bar(int n, float height) { // number. //////////////////////////////////////////////////////////////////// int PStatServer:: -add_user_guide_bar(float height) { +add_user_guide_bar(PN_stdfloat height) { int n = (int)_user_guide_bars.size(); _user_guide_bars.push_back(height); user_guide_bars_changed(); @@ -274,12 +274,12 @@ remove_user_guide_bar(int n) { // -1 if no user guide bars fall within the range. //////////////////////////////////////////////////////////////////// int PStatServer:: -find_user_guide_bar(float from_height, float to_height) const { +find_user_guide_bar(PN_stdfloat from_height, PN_stdfloat to_height) const { GuideBars::const_iterator gbi; for (gbi = _user_guide_bars.begin(); gbi != _user_guide_bars.end(); ++gbi) { - float height = (*gbi); + PN_stdfloat height = (*gbi); if (height >= from_height && height <= to_height) { return (int)(gbi - _user_guide_bars.begin()); } diff --git a/pandatool/src/pstatserver/pStatServer.h b/pandatool/src/pstatserver/pStatServer.h index 8b027bc101..befec02eb5 100644 --- a/pandatool/src/pstatserver/pStatServer.h +++ b/pandatool/src/pstatserver/pStatServer.h @@ -18,7 +18,7 @@ #include "pandatoolbase.h" #include "pStatListener.h" #include "connectionManager.h" -#include "vector_float.h" +#include "vector_stdfloat.h" #include "pmap.h" #include "pdeque.h" @@ -56,11 +56,11 @@ public: void release_udp_port(int port); int get_num_user_guide_bars() const; - float get_user_guide_bar_height(int n) const; - void move_user_guide_bar(int n, float height); - int add_user_guide_bar(float height); + PN_stdfloat get_user_guide_bar_height(int n) const; + void move_user_guide_bar(int n, PN_stdfloat height); + int add_user_guide_bar(PN_stdfloat height); void remove_user_guide_bar(int n); - int find_user_guide_bar(float from_height, float to_height) const; + int find_user_guide_bar(PN_stdfloat from_height, PN_stdfloat to_height) const; virtual bool is_thread_safe(); @@ -83,7 +83,7 @@ private: Ports _available_udp_ports; int _next_udp_port; - typedef vector_float GuideBars; + typedef vector_stdfloat GuideBars; GuideBars _user_guide_bars; }; diff --git a/pandatool/src/pstatserver/pStatStripChart.I b/pandatool/src/pstatserver/pStatStripChart.I index 5143b6cdd9..968620be59 100644 --- a/pandatool/src/pstatserver/pStatStripChart.I +++ b/pandatool/src/pstatserver/pStatStripChart.I @@ -41,7 +41,7 @@ get_collector_index() const { // horizontal axis represents. This may force a redraw. //////////////////////////////////////////////////////////////////// INLINE void PStatStripChart:: -set_horizontal_scale(float time_width) { +set_horizontal_scale(PN_stdfloat time_width) { if (_time_width != time_width) { if (_scroll_mode) { _start_time += _time_width - time_width; @@ -58,7 +58,7 @@ set_horizontal_scale(float time_width) { // Description: Returns the amount of total time the width of the // horizontal axis represents. //////////////////////////////////////////////////////////////////// -INLINE float PStatStripChart:: +INLINE PN_stdfloat PStatStripChart:: get_horizontal_scale() const { return _time_width; } @@ -70,7 +70,7 @@ get_horizontal_scale() const { // represents. This may force a redraw. //////////////////////////////////////////////////////////////////// INLINE void PStatStripChart:: -set_vertical_scale(float value_height) { +set_vertical_scale(PN_stdfloat value_height) { if (_value_height != value_height) { _value_height = value_height; normal_guide_bars(); @@ -84,7 +84,7 @@ set_vertical_scale(float value_height) { // Description: Returns total value the height of the vertical axis // represents. //////////////////////////////////////////////////////////////////// -INLINE float PStatStripChart:: +INLINE PN_stdfloat PStatStripChart:: get_vertical_scale() const { return _value_height; } @@ -158,8 +158,8 @@ get_average_mode() const { // Description: Converts a timestamp to a horizontal pixel offset. //////////////////////////////////////////////////////////////////// INLINE int PStatStripChart:: -timestamp_to_pixel(float time) const { - return (int)((float)get_xsize() * (time - _start_time) / _time_width); +timestamp_to_pixel(PN_stdfloat time) const { + return (int)((PN_stdfloat)get_xsize() * (time - _start_time) / _time_width); } //////////////////////////////////////////////////////////////////// @@ -167,9 +167,9 @@ timestamp_to_pixel(float time) const { // Access: Public // Description: Converts a horizontal pixel offset to a timestamp. //////////////////////////////////////////////////////////////////// -INLINE float PStatStripChart:: +INLINE PN_stdfloat PStatStripChart:: pixel_to_timestamp(int x) const { - return _time_width * (float)x / (float)get_xsize() + _start_time; + return _time_width * (PN_stdfloat)x / (PN_stdfloat)get_xsize() + _start_time; } //////////////////////////////////////////////////////////////////// @@ -179,8 +179,8 @@ pixel_to_timestamp(int x) const { // to a vertical pixel offset. //////////////////////////////////////////////////////////////////// INLINE int PStatStripChart:: -height_to_pixel(float value) const { - return get_ysize() - (int)((float)get_ysize() * value / _value_height); +height_to_pixel(PN_stdfloat value) const { + return get_ysize() - (int)((PN_stdfloat)get_ysize() * value / _value_height); } //////////////////////////////////////////////////////////////////// @@ -189,9 +189,9 @@ height_to_pixel(float value) const { // Description: Converts a vertical pixel offset to a value (a // "height" in the strip chart). //////////////////////////////////////////////////////////////////// -INLINE float PStatStripChart:: +INLINE PN_stdfloat PStatStripChart:: pixel_to_height(int x) const { - return _value_height * (float)(get_ysize() - x) / (float)get_ysize(); + return _value_height * (PN_stdfloat)(get_ysize() - x) / (PN_stdfloat)get_ysize(); } //////////////////////////////////////////////////////////////////// diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 3e898358da..6cbdd58eb4 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -104,7 +104,7 @@ update() { _next_frame = latest; // Clean out the old data. - float oldest_time = + PN_stdfloat oldest_time = thread_data->get_frame(latest).get_start() - _time_width; Data::iterator di; @@ -185,16 +185,16 @@ void PStatStripChart:: set_auto_vertical_scale() { const PStatThreadData *thread_data = _view.get_thread_data(); - float max_value = 0.0; + PN_stdfloat max_value = 0.0; int frame_number = -1; for (int x = 0; x <= _xsize; x++) { - float time = pixel_to_timestamp(x); + PN_stdfloat time = pixel_to_timestamp(x); frame_number = thread_data->get_frame_number_at_time(time, frame_number); if (thread_data->has_frame(frame_number)) { - float net_value = get_net_value(frame_number); + PN_stdfloat net_value = get_net_value(frame_number); max_value = max(max_value, net_value); } } @@ -219,7 +219,7 @@ int PStatStripChart:: get_collector_under_pixel(int xpoint, int ypoint) { // First, we need to know what frame it was; to know that, we need // to determine the time corresponding to the x pixel. - float time = pixel_to_timestamp(xpoint); + PN_stdfloat time = pixel_to_timestamp(xpoint); // Now use that time to determine the frame. const PStatThreadData *thread_data = _view.get_thread_data(); @@ -227,13 +227,13 @@ get_collector_under_pixel(int xpoint, int ypoint) { // And now we can determine which collector within the frame, // based on the value height. if (_average_mode) { - float start_time = pixel_to_timestamp(xpoint); + PN_stdfloat start_time = pixel_to_timestamp(xpoint); int then_i = thread_data->get_frame_number_at_time(start_time - pstats_average_time); int now_i = thread_data->get_frame_number_at_time(start_time, then_i); FrameData fdata; compute_average_pixel_data(fdata, then_i, now_i, start_time); - float overall_value = 0.0; + PN_stdfloat overall_value = 0.0; int y = get_ysize(); FrameData::const_iterator fi; @@ -249,7 +249,7 @@ get_collector_under_pixel(int xpoint, int ypoint) { } else { int frame_number = thread_data->get_frame_number_at_time(time); const FrameData &fdata = get_frame_data(frame_number); - float overall_value = 0.0; + PN_stdfloat overall_value = 0.0; int y = get_ysize(); FrameData::const_iterator fi; @@ -323,7 +323,7 @@ is_title_unknown() const { //////////////////////////////////////////////////////////////////// void PStatStripChart:: accumulate_frame_data(FrameData &fdata, const FrameData &additional, - float weight) { + PN_stdfloat weight) { FrameData::iterator ai; FrameData::const_iterator bi; @@ -417,7 +417,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional, // in data. //////////////////////////////////////////////////////////////////// void PStatStripChart:: -scale_frame_data(FrameData &fdata, float factor) { +scale_frame_data(FrameData &fdata, PN_stdfloat factor) { FrameData::iterator fi; for (fi = fdata.begin(); fi != fdata.end(); ++fi) { (*fi)._net_value *= factor; @@ -491,7 +491,7 @@ get_frame_data(int frame_number) { //////////////////////////////////////////////////////////////////// void PStatStripChart:: compute_average_pixel_data(PStatStripChart::FrameData &result, - int &then_i, int &now_i, float now) { + int &then_i, int &now_i, PN_stdfloat now) { result.clear(); const PStatThreadData *thread_data = _view.get_thread_data(); @@ -500,7 +500,7 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, return; } - float then = now - pstats_average_time; + PN_stdfloat then = now - pstats_average_time; int latest_frame = thread_data->get_latest_frame_number(); while (then_i <= latest_frame && @@ -521,7 +521,7 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, // does fall within our "then to now" window. accumulate_frame_data(result, get_frame_data(then_i), thread_data->get_frame(then_i).get_end() - then); - float last = thread_data->get_frame(then_i).get_end(); + PN_stdfloat last = thread_data->get_frame(then_i).get_end(); // Then we get all of each of the middle frames. for (int frame_number = then_i + 1; @@ -546,12 +546,12 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, // Description: Returns the net value of the chart's collector for // the indicated frame number. //////////////////////////////////////////////////////////////////// -float PStatStripChart:: +PN_stdfloat PStatStripChart:: get_net_value(int frame_number) const { const FrameData &frame = ((PStatStripChart *)this)->get_frame_data(frame_number); - float net_value = 0.0; + PN_stdfloat net_value = 0.0; FrameData::const_iterator fi; for (fi = frame.begin(); fi != frame.end(); ++fi) { const ColorData &cd = (*fi); @@ -567,15 +567,15 @@ get_net_value(int frame_number) const { // Description: Computes the average value of the chart's collector // over the past pstats_average_time number of seconds. //////////////////////////////////////////////////////////////////// -float PStatStripChart:: +PN_stdfloat PStatStripChart:: get_average_net_value() const { const PStatThreadData *thread_data = _view.get_thread_data(); int now_i, then_i; if (!thread_data->get_elapsed_frames(then_i, now_i)) { return 0.0f; } - float now = _time_width + _start_time; - float then = now - pstats_average_time; + PN_stdfloat now = _time_width + _start_time; + PN_stdfloat then = now - pstats_average_time; int num_frames = now_i - then_i + 1; @@ -587,9 +587,9 @@ get_average_net_value() const { const PStatFrameData &now_frame_data = thread_data->get_frame(now_i); const PStatFrameData &then_frame_data = thread_data->get_frame(then_i); - float now = now_frame_data.get_end(); - float elapsed_time = (now - then_frame_data.get_start()); - return elapsed_time / (float)num_frames; + PN_stdfloat now = now_frame_data.get_end(); + PN_stdfloat elapsed_time = (now - then_frame_data.get_start()); + return elapsed_time / (PN_stdfloat)num_frames; } else { // On the other hand, if we're showing the time for some @@ -599,14 +599,14 @@ get_average_net_value() const { const PStatThreadData *thread_data = _view.get_thread_data(); - float net_value = 0.0f; - float net_time = 0.0f; + PN_stdfloat net_value = 0.0f; + PN_stdfloat net_time = 0.0f; // We start with just the portion of frame then_i that actually // does fall within our "then to now" window (usually some portion // of it will). if (thread_data->get_frame(then_i).get_end() > then) { - float this_time = (thread_data->get_frame(then_i).get_end() - then); + PN_stdfloat this_time = (thread_data->get_frame(then_i).get_end() - then); net_value += get_net_value(then_i) * this_time; net_time += this_time; } @@ -614,7 +614,7 @@ get_average_net_value() const { for (int frame_number = then_i + 1; frame_number <= now_i; frame_number++) { - float this_time = thread_data->get_frame(frame_number).get_net_time(); + PN_stdfloat this_time = thread_data->get_frame(frame_number).get_net_time(); net_value += get_net_value(frame_number) * this_time; net_time += this_time; } @@ -645,7 +645,7 @@ changed_size(int xsize, int ysize) { } else { // Redraw the stats that were there before. - float old_start_time = _start_time; + PN_stdfloat old_start_time = _start_time; // Back up a bit to draw the stuff to the right of the cursor. _start_time -= _time_width; @@ -892,7 +892,7 @@ draw_frames(int first_frame, int last_frame) { copy_region(slide_pixels, first_pixel, 0); first_pixel -= slide_pixels; last_pixel -= slide_pixels; - _start_time += (float)slide_pixels / (float)_xsize * _time_width; + _start_time += (PN_stdfloat)slide_pixels / (PN_stdfloat)_xsize * _time_width; draw_pixels(first_pixel, last_pixel); } else { @@ -919,7 +919,7 @@ draw_pixels(int first_pixel, int last_pixel) { if (_average_mode && !thread_data->is_empty()) { // In average mode, we have to calculate the average value for each pixel. - float start_time = pixel_to_timestamp(first_pixel); + PN_stdfloat start_time = pixel_to_timestamp(first_pixel); int then_i = thread_data->get_frame_number_at_time(start_time - pstats_average_time); int now_i = thread_data->get_frame_number_at_time(start_time, then_i); for (int x = first_pixel; x <= last_pixel; x++) { @@ -943,7 +943,7 @@ draw_pixels(int first_pixel, int last_pixel) { x++; } else { - float time = pixel_to_timestamp(x); + PN_stdfloat time = pixel_to_timestamp(x); frame_number = thread_data->get_frame_number_at_time(time, frame_number); int w = 1; int stop_pixel = last_pixel; diff --git a/pandatool/src/pstatserver/pStatStripChart.h b/pandatool/src/pstatserver/pStatStripChart.h index dbffca6524..aa58b2b7de 100644 --- a/pandatool/src/pstatserver/pStatStripChart.h +++ b/pandatool/src/pstatserver/pStatStripChart.h @@ -53,12 +53,12 @@ public: INLINE int get_collector_index() const; void set_collector_index(int collector_index); - INLINE void set_horizontal_scale(float time_width); - INLINE float get_horizontal_scale() const; - INLINE void set_vertical_scale(float value_height); + INLINE void set_horizontal_scale(PN_stdfloat time_width); + INLINE PN_stdfloat get_horizontal_scale() const; + INLINE void set_vertical_scale(PN_stdfloat value_height); void set_default_vertical_scale(); void set_auto_vertical_scale(); - INLINE float get_vertical_scale() const; + INLINE PN_stdfloat get_vertical_scale() const; INLINE void set_scroll_mode(bool scroll_mode); INLINE bool get_scroll_mode() const; @@ -67,10 +67,10 @@ public: INLINE bool get_average_mode() const; int get_collector_under_pixel(int xpoint, int ypoint); - INLINE int timestamp_to_pixel(float time) const; - INLINE float pixel_to_timestamp(int x) const; - INLINE int height_to_pixel(float value) const; - INLINE float pixel_to_height(int y) const; + INLINE int timestamp_to_pixel(PN_stdfloat time) const; + INLINE PN_stdfloat pixel_to_timestamp(int x) const; + INLINE int height_to_pixel(PN_stdfloat value) const; + INLINE PN_stdfloat pixel_to_height(int y) const; string get_title_text(); bool is_title_unknown() const; @@ -80,20 +80,20 @@ protected: public: unsigned short _collector_index; unsigned short _i; - float _net_value; + PN_stdfloat _net_value; }; typedef pvector FrameData; typedef pmap Data; static void accumulate_frame_data(FrameData &fdata, - const FrameData &additional, float weight); - static void scale_frame_data(FrameData &fdata, float factor); + const FrameData &additional, PN_stdfloat weight); + static void scale_frame_data(FrameData &fdata, PN_stdfloat factor); const FrameData &get_frame_data(int frame_number); void compute_average_pixel_data(PStatStripChart::FrameData &result, - int &then_i, int &now_i, float now); - float get_net_value(int frame_number) const; - float get_average_net_value() const; + int &then_i, int &now_i, PN_stdfloat now); + PN_stdfloat get_net_value(int frame_number) const; + PN_stdfloat get_average_net_value() const; void changed_size(int xsize, int ysize); void force_redraw(); @@ -137,9 +137,9 @@ private: int _level_index; - float _time_width; - float _start_time; - float _value_height; + PN_stdfloat _time_width; + PN_stdfloat _start_time; + PN_stdfloat _value_height; bool _title_unknown; typedef vector_int LabelUsage; diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index 968d3d4ec0..a7fc86bdcd 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -140,7 +140,7 @@ get_frame(int frame_number) const { // Description: Returns the timestamp (in seconds elapsed since // connection) of the latest available frame. //////////////////////////////////////////////////////////////////// -float PStatThreadData:: +PN_stdfloat PStatThreadData:: get_latest_time() const { nassertr(!_frames.empty(), 0.0); return _frames.back()->get_start(); @@ -152,7 +152,7 @@ get_latest_time() const { // Description: Returns the timestamp (in seconds elapsed since // connection) of the oldest available frame. //////////////////////////////////////////////////////////////////// -float PStatThreadData:: +PN_stdfloat PStatThreadData:: get_oldest_time() const { nassertr(!_frames.empty(), 0.0); return _frames.front()->get_start(); @@ -165,7 +165,7 @@ get_oldest_time() const { // latest frame not later than the indicated time. //////////////////////////////////////////////////////////////////// const PStatFrameData &PStatThreadData:: -get_frame_at_time(float time) const { +get_frame_at_time(PN_stdfloat time) const { return get_frame(get_frame_number_at_time(time)); } @@ -180,7 +180,7 @@ get_frame_at_time(float time) const { // which may speed the search for the frame. //////////////////////////////////////////////////////////////////// int PStatThreadData:: -get_frame_number_at_time(float time, int hint) const { +get_frame_number_at_time(PN_stdfloat time, int hint) const { hint -= _first_frame_number; if (hint >= 0 && hint < (int)_frames.size()) { if (_frames[hint] != (PStatFrameData *)NULL && @@ -253,7 +253,7 @@ get_elapsed_frames(int &then_i, int &now_i) const { // pstats_average_time seconds, by counting up the // number of frames elapsed in that time interval. //////////////////////////////////////////////////////////////////// -float PStatThreadData:: +PN_stdfloat PStatThreadData:: get_frame_rate() const { int then_i, now_i; if (!get_elapsed_frames(then_i, now_i)) { @@ -261,9 +261,9 @@ get_frame_rate() const { } int num_frames = now_i - then_i + 1; - float now = _frames[now_i - _first_frame_number]->get_end(); - float elapsed_time = (now - _frames[then_i - _first_frame_number]->get_start()); - return (float)num_frames / elapsed_time; + PN_stdfloat now = _frames[now_i - _first_frame_number]->get_end(); + PN_stdfloat elapsed_time = (now - _frames[then_i - _first_frame_number]->get_start()); + return (PN_stdfloat)num_frames / elapsed_time; } @@ -276,7 +276,7 @@ get_frame_rate() const { // frame that may be queried is. //////////////////////////////////////////////////////////////////// void PStatThreadData:: -set_history(float time) { +set_history(PN_stdfloat time) { _history = time; } @@ -288,7 +288,7 @@ set_history(float time) { // new frame is added. This affects how old the oldest // frame that may be queried is. //////////////////////////////////////////////////////////////////// -float PStatThreadData:: +PN_stdfloat PStatThreadData:: get_history() const { return _history; } @@ -309,11 +309,11 @@ void PStatThreadData:: record_new_frame(int frame_number, PStatFrameData *frame_data) { nassertv(frame_data != (PStatFrameData *)NULL); nassertv(!frame_data->is_empty()); - float time = frame_data->get_start(); + PN_stdfloat time = frame_data->get_start(); // First, remove all the old frames that fall outside of our // history window. - float oldest_allowable_time = time - _history; + PN_stdfloat oldest_allowable_time = time - _history; while (!_frames.empty() && (_frames.front() == (PStatFrameData *)NULL || _frames.front()->is_empty() || @@ -376,8 +376,8 @@ compute_elapsed_frames() { } else { nassertv(_frames[_now_i] != (PStatFrameData *)NULL); - float now = _frames[_now_i]->get_end(); - float then = now - pstats_average_time; + PN_stdfloat now = _frames[_now_i]->get_end(); + PN_stdfloat then = now - pstats_average_time; int old_i = _now_i; _then_i = _now_i; diff --git a/pandatool/src/pstatserver/pStatThreadData.h b/pandatool/src/pstatserver/pStatThreadData.h index 1c666eaf12..4eb505043c 100644 --- a/pandatool/src/pstatserver/pStatThreadData.h +++ b/pandatool/src/pstatserver/pStatThreadData.h @@ -49,19 +49,19 @@ public: bool has_frame(int frame_number) const; const PStatFrameData &get_frame(int frame_number) const; - float get_latest_time() const; - float get_oldest_time() const; - const PStatFrameData &get_frame_at_time(float time) const; - int get_frame_number_at_time(float time, int hint = -1) const; + PN_stdfloat get_latest_time() const; + PN_stdfloat get_oldest_time() const; + const PStatFrameData &get_frame_at_time(PN_stdfloat time) const; + int get_frame_number_at_time(PN_stdfloat time, int hint = -1) const; const PStatFrameData &get_latest_frame() const; bool get_elapsed_frames(int &then_i, int &now_i) const; - float get_frame_rate() const; + PN_stdfloat get_frame_rate() const; - void set_history(float time); - float get_history() const; + void set_history(PN_stdfloat time); + PN_stdfloat get_history() const; void record_new_frame(int frame_number, PStatFrameData *frame_data); @@ -72,7 +72,7 @@ private: typedef pdeque Frames; Frames _frames; int _first_frame_number; - float _history; + PN_stdfloat _history; bool _computed_elapsed_frames; bool _got_elapsed_frames; diff --git a/pandatool/src/pstatserver/pStatView.I b/pandatool/src/pstatserver/pStatView.I index 4bc7005ec1..fdf5e958f1 100644 --- a/pandatool/src/pstatserver/pStatView.I +++ b/pandatool/src/pstatserver/pStatView.I @@ -61,7 +61,7 @@ set_to_frame(int frame_number) { // set_to_frame. //////////////////////////////////////////////////////////////////// INLINE void PStatView:: -set_to_time(float time) { +set_to_time(PN_stdfloat time) { set_to_frame(_thread_data->get_frame_at_time(time)); } diff --git a/pandatool/src/pstatserver/pStatView.cxx b/pandatool/src/pstatserver/pStatView.cxx index a02a1c377e..9ac35c0d78 100644 --- a/pandatool/src/pstatserver/pStatView.cxx +++ b/pandatool/src/pstatserver/pStatView.cxx @@ -41,7 +41,7 @@ public: _pushed = false; _net_time = 0.0; } - void data_point(float time, bool is_start, Started &started) { + void data_point(PN_stdfloat time, bool is_start, Started &started) { _touched = true; // We only consider events that change the start/stop state. @@ -80,7 +80,7 @@ public: } } } - void push(float time) { + void push(PN_stdfloat time) { if (!_pushed) { _pushed = true; if (_is_started) { @@ -88,7 +88,7 @@ public: } } } - void pop(float time) { + void pop(PN_stdfloat time) { if (_pushed) { _pushed = false; if (_is_started) { @@ -97,14 +97,14 @@ public: } } - void push_all(float time, Started &started) { + void push_all(PN_stdfloat time, Started &started) { Started::iterator si; for (si = started.begin(); si != started.end(); ++si) { (*si)->push(time); } } - void pop_one(float time, Started &started) { + void pop_one(PN_stdfloat time, Started &started) { Started::reverse_iterator si; for (si = started.rbegin(); si != started.rend(); ++si) { if ((*si)->_pushed) { @@ -117,7 +117,7 @@ public: bool _touched; bool _is_started; bool _pushed; - float _net_time; + PN_stdfloat _net_time; }; @@ -246,9 +246,9 @@ all_collectors_known() const { // is the sum of all of the individual levels' // get_net_value() value. //////////////////////////////////////////////////////////////////// -float PStatView:: +PN_stdfloat PStatView:: get_net_value() const { - float net = 0.0; + PN_stdfloat net = 0.0; Levels::const_iterator li; for (li = _levels.begin(); li != _levels.end(); ++li) { net += (*li).second->_value_alone; @@ -437,14 +437,14 @@ update_level_data(const PStatFrameData &frame_data) { // This tracks the set of level values we got. - typedef pmap GotValues; + typedef pmap GotValues; GotValues net_values; int i; int num_levels = frame_data.get_num_levels(); for (i = 0; i < num_levels; i++) { int collector_index = frame_data.get_level_collector(i); - float value = frame_data.get_level(i); + PN_stdfloat value = frame_data.get_level(i); if (!_client_data->has_collector(collector_index)) { _all_collectors_known = false; @@ -465,7 +465,7 @@ update_level_data(const PStatFrameData &frame_data) { GotValues::iterator gi; for (gi = net_values.begin(); gi != net_values.end(); ++gi) { int collector_index = (*gi).first; - float value = (*gi).second; + PN_stdfloat value = (*gi).second; // Walk up to the top, but stop when we find a parent with actual // data. diff --git a/pandatool/src/pstatserver/pStatView.h b/pandatool/src/pstatserver/pStatView.h index 4ba76f3d14..986daa9ced 100644 --- a/pandatool/src/pstatserver/pStatView.h +++ b/pandatool/src/pstatserver/pStatView.h @@ -45,10 +45,10 @@ public: void set_to_frame(const PStatFrameData &frame_data); INLINE void set_to_frame(int frame_number); - INLINE void set_to_time(float time); + INLINE void set_to_time(PN_stdfloat time); bool all_collectors_known() const; - float get_net_value() const; + PN_stdfloat get_net_value() const; const PStatViewLevel *get_top_level(); diff --git a/pandatool/src/pstatserver/pStatViewLevel.I b/pandatool/src/pstatserver/pStatViewLevel.I index b66580bd5e..41cc39af3f 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.I +++ b/pandatool/src/pstatserver/pStatViewLevel.I @@ -31,7 +31,7 @@ get_collector() const { // for this Collector, not including any values // accounted for by its child Collectors. //////////////////////////////////////////////////////////////////// -INLINE float PStatViewLevel:: +INLINE PN_stdfloat PStatViewLevel:: get_value_alone() const { return _value_alone; } diff --git a/pandatool/src/pstatserver/pStatViewLevel.cxx b/pandatool/src/pstatserver/pStatViewLevel.cxx index 8aeb084a19..143aa7b09c 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.cxx +++ b/pandatool/src/pstatserver/pStatViewLevel.cxx @@ -27,9 +27,9 @@ // represented by this Collector, including all values // in its child Collectors. //////////////////////////////////////////////////////////////////// -float PStatViewLevel:: +PN_stdfloat PStatViewLevel:: get_net_value() const { - float net = _value_alone; + PN_stdfloat net = _value_alone; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { diff --git a/pandatool/src/pstatserver/pStatViewLevel.h b/pandatool/src/pstatserver/pStatViewLevel.h index 0100719007..921b9f7294 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.h +++ b/pandatool/src/pstatserver/pStatViewLevel.h @@ -33,8 +33,8 @@ class PStatClientData; class PStatViewLevel { public: INLINE int get_collector() const; - INLINE float get_value_alone() const; - float get_net_value() const; + INLINE PN_stdfloat get_value_alone() const; + PN_stdfloat get_net_value() const; void sort_children(const PStatClientData *client_data); @@ -43,7 +43,7 @@ public: private: int _collector; - float _value_alone; + PN_stdfloat _value_alone; PStatViewLevel *_parent; typedef pvector Children; diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 4ba3dcb013..82bd857b95 100755 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -516,9 +516,9 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b const char *name = get_name().c_str(); if ( skeletonPart != NULL ) { - float i,j,k; - float h,p,r; - float x,y,z; + PN_stdfloat i,j,k; + PN_stdfloat h,p,r; + PN_stdfloat x,y,z; int scale_joint = 0; softegg_cat.spam() << "\n\nanimating child " << name << endl; @@ -675,10 +675,10 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { softegg_cat.spam() << "numTexLoc = " << numTexLoc << endl; // allocate arrays of texture info - uScale = new float[numTri]; - vScale = new float[numTri]; - uOffset = new float[numTri]; - vOffset = new float[numTri]; + uScale = new PN_stdfloat[numTri]; + vScale = new PN_stdfloat[numTri]; + uOffset = new PN_stdfloat[numTri]; + vOffset = new PN_stdfloat[numTri]; texNameArray = new char *[numTri]; uRepeat = new int[numTri]; vRepeat = new int[numTri]; @@ -765,10 +765,10 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { softegg_cat.spam() << " global tex named: " << *texNameArray << endl; // allocate arrays of texture info - uScale = new float; - vScale = new float; - uOffset = new float; - vOffset = new float; + uScale = new PN_stdfloat; + vScale = new PN_stdfloat; + uOffset = new PN_stdfloat; + vOffset = new PN_stdfloat; SAA_texture2DGetUScale( scene, textures, uScale ); SAA_texture2DGetVScale( scene, textures, vScale ); @@ -871,10 +871,10 @@ load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) { // allocate the texture name array texNameArray = new char *[1]; // allocate arrays of texture info - uScale = new float; - vScale = new float; - uOffset = new float; - vOffset = new float; + uScale = new PN_stdfloat; + vScale = new PN_stdfloat; + uOffset = new PN_stdfloat; + vOffset = new PN_stdfloat; uRepeat = new int; vRepeat = new int; @@ -1077,7 +1077,7 @@ make_vertex_offsets(int numShapes) { // the shape weight info for this frame... //////////////////////////////////////////////////////////////////// void SoftNodeDesc:: -make_morph_table( float time ) { +make_morph_table( PN_stdfloat time ) { int numShapes; SAA_Elem *model = NULL; SAA_AnimInterpType type; @@ -1121,9 +1121,9 @@ make_morph_table( float time ) { // to populate the morph table. //////////////////////////////////////////////////////////////////// void SoftNodeDesc:: -make_linear_morph_table(int numShapes, float time) { +make_linear_morph_table(int numShapes, PN_stdfloat time) { int i; - float curveVal; + PN_stdfloat curveVal; char tableName[_MAX_PATH]; SAA_Elem fcurve; //SAnimTable *thisTable; @@ -1139,7 +1139,7 @@ make_linear_morph_table(int numShapes, float time) { softegg_cat.spam() << "at time " << time << ", fcurve for " << get_name() << " = " << curveVal << endl; - float nextVal = 0.0f; + PN_stdfloat nextVal = 0.0f; // populate morph table values for this frame for ( i = 1; i < numShapes; i++ ) { @@ -1193,8 +1193,8 @@ make_linear_morph_table(int numShapes, float time) { // appropriate routine. //////////////////////////////////////////////////////////////////// void SoftNodeDesc:: -make_weighted_morph_table(int numShapes, float time) { - float curveVal; +make_weighted_morph_table(int numShapes, PN_stdfloat time) { + PN_stdfloat curveVal; SI_Error result; char tableName[_MAX_PATH]; SAA_Elem *weightCurves; @@ -1246,13 +1246,13 @@ make_weighted_morph_table(int numShapes, float time) { // controlling sliders. //////////////////////////////////////////////////////////////////// void SoftNodeDesc:: -make_expression_morph_table(int numShapes, float time) +make_expression_morph_table(int numShapes, PN_stdfloat time) { //int j; int numExp; char *track; - //float expVal; - //float sliderVal; + //PN_stdfloat expVal; + //PN_stdfloat sliderVal; //char *tableName; //char *sliderName; //SAnimTable *thisTable; diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h index 6b35b6362e..3dac474305 100755 --- a/pandatool/src/softegg/softNodeDesc.h +++ b/pandatool/src/softegg/softNodeDesc.h @@ -96,7 +96,7 @@ public: char **texNameArray; int *uRepeat, *vRepeat; - float matrix[4][4]; + PN_stdfloat matrix[4][4]; const char *fullname; @@ -111,10 +111,10 @@ public: int numNurbTexGlb; int numNurbMats; - float *uScale; - float *vScale; - float *uOffset; - float *vOffset; + PN_stdfloat *uScale; + PN_stdfloat *vScale; + PN_stdfloat *uOffset; + PN_stdfloat *vOffset; SAA_Boolean valid; SAA_Boolean uv_swap; @@ -131,10 +131,10 @@ public: void load_poly_model(SAA_Scene *scene, SAA_ModelType type); void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type); - void make_morph_table(float time); - void make_linear_morph_table(int numShapes, float time); - void make_weighted_morph_table(int numShapes, float time); - void make_expression_morph_table(int numShapes, float time); + void make_morph_table(PN_stdfloat time); + void make_linear_morph_table(int numShapes, PN_stdfloat time); + void make_weighted_morph_table(int numShapes, PN_stdfloat time); + void make_expression_morph_table(int numShapes, PN_stdfloat time); void make_vertex_offsets(int numShapes); int find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert); diff --git a/pandatool/src/softegg/softNodeTree.h b/pandatool/src/softegg/softNodeTree.h index d70914d31a..83cda9d493 100755 --- a/pandatool/src/softegg/softNodeTree.h +++ b/pandatool/src/softegg/softNodeTree.h @@ -57,7 +57,7 @@ public: void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node); PT(SoftNodeDesc) _root; - float _fps; + PN_stdfloat _fps; int _use_prefix; char *_search_prefix; diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index bba48b81aa..d2e056b608 100755 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -677,7 +677,7 @@ open_api() { } // cout << "got past scene load" << endl; if ( SAA_updatelistGet( &scene ) == SI_SUCCESS ) { - float time; + PN_stdfloat time; softegg_cat.info() << "setting Scene to frame " << pose_frame << "...\n"; //SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); @@ -780,7 +780,7 @@ convert_char_chan() { int frame_inc, frame; double output_frame_rate = anim_rate; - float time; + PN_stdfloat time; EggTable *root_table_node = new EggTable(); get_egg_data()->add_child(root_table_node); @@ -1008,8 +1008,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { int numShapes; SAA_Boolean valid; SAA_Boolean visible; - float *uCoords = NULL; - float *vCoords = NULL; + PN_stdfloat *uCoords = NULL; + PN_stdfloat *vCoords = NULL; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -1094,8 +1094,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { // allocate arrays for u & v coords // I think there are one texture per triangle hence we need only 3 corrdinates - uCoords = new float[3]; - vCoords = new float[3]; + uCoords = new PN_stdfloat[3]; + vCoords = new PN_stdfloat[3]; // read the u & v coords into the arrays if ( uCoords != NULL && vCoords != NULL) { @@ -1116,8 +1116,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } else if (node_desc->numTexGlb) { // allocate arrays for u & v coords - uCoords = new float[node_desc->numTexGlb*3]; - vCoords = new float[node_desc->numTexGlb*3]; + uCoords = new PN_stdfloat[node_desc->numTexGlb*3]; + vCoords = new PN_stdfloat[node_desc->numTexGlb*3]; for ( i = 0; i < node_desc->numTexGlb*3; i++ ) { uCoords[i] = vCoords[i] = 0.0f; @@ -1167,7 +1167,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { // if texture present set the texture coordinates if (node_desc->textures) { - float u, v; + PN_stdfloat u, v; if (uCoords && vCoords) { u = uCoords[i]; @@ -1183,17 +1183,17 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { egg_poly->add_vertex(vpool->create_unique_vertex(vert)); // check to see if material is present - float r,g,b,a; + PN_stdfloat r,g,b,a; SAA_elementIsValid( &scene, &node_desc->materials[idx], &valid ); // material present - get the color if ( valid ) { SAA_materialGetDiffuse( &scene, &node_desc->materials[idx], &r, &g, &b ); SAA_materialGetTransparency( &scene, &node_desc->materials[idx], &a ); - egg_poly->set_color(Colorf(r, g, b, 1.0f - a)); + egg_poly->set_color(LColor(r, g, b, 1.0f - a)); softegg_cat.spam() << "color r = " << r << " g = " << g << " b = " << b << " a = " << 1.0f - a << "\n"; } else { // no material - default to white - egg_poly->set_color(Colorf(1.0, 1.0, 1.0, 1.0)); + egg_poly->set_color(LColor(1.0, 1.0, 1.0, 1.0)); softegg_cat.spam() << "default color\n"; } @@ -1246,8 +1246,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty int numShapes; SAA_Boolean valid; SAA_Boolean visible; - float *uCoords = NULL; - float *vCoords = NULL; + PN_stdfloat *uCoords = NULL; + PN_stdfloat *vCoords = NULL; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -1440,17 +1440,17 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty // check to see if material is present if (node_desc->numNurbMats) { - float r,g,b,a; + PN_stdfloat r,g,b,a; SAA_elementIsValid( &scene, &node_desc->materials[0], &valid ); // material present - get the color if ( valid ) { SAA_materialGetDiffuse( &scene, &node_desc->materials[0], &r, &g, &b ); SAA_materialGetTransparency( &scene, &node_desc->materials[0], &a ); - verts[k].set_color(Colorf(r, g, b, 1.0f - a)); + verts[k].set_color(LColor(r, g, b, 1.0f - a)); //softegg_cat.spam() << "color r = " << r << " g = " << g << " b = " << b << " a = " << a << "\n"; } else { // no material - default to white - verts[k].set_color(Colorf(1.0, 1.0, 1.0, 1.0)); + verts[k].set_color(LColor(1.0, 1.0, 1.0, 1.0)); softegg_cat.spam() << "default color\n"; } } @@ -1580,8 +1580,8 @@ FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { int i,j; int *vertMap = NULL; int vpoolSize = (int)vpool->size(); - float closestDist; - float thisDist; + PN_stdfloat closestDist; + PN_stdfloat thisDist; int closest; vertMap = new int[vpoolSize]; @@ -1733,10 +1733,10 @@ make_soft_skin() { } // loop through for each envelope for ( i = 0; i < numEnv; i++ ) { - float *weights = NULL; + PN_stdfloat *weights = NULL; int vertArrayOffset = 0; softegg_cat.spam() << "envelope[" << i << "]: "; - weights = new float[numEnvVertices[i]]; + weights = new PN_stdfloat[numEnvVertices[i]]; if ( weights ) { char *envName; int *vpoolMap = NULL; @@ -1816,7 +1816,7 @@ make_soft_skin() { // create array of global model coords SAA_DVector *globalModelVertices = NULL; globalModelVertices = new SAA_DVector[modelNumVert]; - float matrix[4][4]; + PN_stdfloat matrix[4][4]; // tranform local model vert coords to global diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index f01b4fa4ac..c99d15cdd4 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -109,17 +109,17 @@ get_polys() { //////////////////////////////////////////////////////////////////// // Function: IndexedFaceSet::get_vrml_colors // Access: Private -// Description: Builds up a vector of Colorf pointers corresponding +// Description: Builds up a vector of LColor pointers corresponding // to the VRML color node. //////////////////////////////////////////////////////////////////// void IndexedFaceSet:: get_vrml_colors(const VrmlNode *color_node, double transparency, - pvector &color_list) { + pvector &color_list) { const MFArray *color = color_node->get_value("color")._mf; MFArray::const_iterator ci; for (ci = color->begin(); ci != color->end(); ++ci) { const double *p = (*ci)._sfvec; - Colorf color(p[0], p[1], p[2], 1.0 - transparency); + LColor color(p[0], p[1], p[2], 1.0 - transparency); color_list.push_back(color); } } @@ -171,7 +171,7 @@ get_colors() { const VrmlNode *color = _geometry->get_value("color")._sfnode._p; if (color != NULL) { // Vertex or face colors. - pvector color_list; + pvector color_list; get_vrml_colors(color, _appearance._transparency, color_list); bool colorPerVertex = _geometry->get_value("colorPerVertex")._sfbool; diff --git a/pandatool/src/vrmlegg/indexedFaceSet.h b/pandatool/src/vrmlegg/indexedFaceSet.h index 87de3cc25a..c2ec5e52d2 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.h +++ b/pandatool/src/vrmlegg/indexedFaceSet.h @@ -42,7 +42,7 @@ private: void get_coord_values(); void get_polys(); void get_vrml_colors(const VrmlNode *color_node, double transparency, - pvector &color_list); + pvector &color_list); void get_vrml_normals(const VrmlNode *normal_node, pvector &normal_list); void get_vrml_uvs(const VrmlNode *texCoord_node, diff --git a/pandatool/src/vrmlegg/vrmlAppearance.h b/pandatool/src/vrmlegg/vrmlAppearance.h index d065cba577..2cb804174e 100644 --- a/pandatool/src/vrmlegg/vrmlAppearance.h +++ b/pandatool/src/vrmlegg/vrmlAppearance.h @@ -24,7 +24,7 @@ public: VRMLAppearance(const VrmlNode *vrmlAppearance); bool _has_material; - Colorf _color; + LColor _color; double _transparency; PT_EggTexture _tex; diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 4058c2366c..0e055b9a8c 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -146,7 +146,7 @@ set_time_units(int unit_mask) { // speed for the graph to the indicated value. //////////////////////////////////////////////////////////////////// void WinStatsGraph:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { } //////////////////////////////////////////////////////////////////// @@ -244,7 +244,7 @@ get_collector_brush(int collector_index) { } // Ask the monitor what color this guy should be. - RGBColorf rgb = _monitor->get_collector_color(collector_index); + LRGBColor rgb = _monitor->get_collector_color(collector_index); int r = (int)(rgb[0] * 255.0f); int g = (int)(rgb[1] * 255.0f); int b = (int)(rgb[2] * 255.0f); diff --git a/pandatool/src/win-stats/winStatsGraph.h b/pandatool/src/win-stats/winStatsGraph.h index fa8d53cd36..68706e3842 100644 --- a/pandatool/src/win-stats/winStatsGraph.h +++ b/pandatool/src/win-stats/winStatsGraph.h @@ -52,7 +52,7 @@ public: virtual void changed_graph_size(int graph_xsize, int graph_ysize); virtual void set_time_units(int unit_mask); - virtual void set_scroll_speed(float scroll_speed); + virtual void set_scroll_speed(PN_stdfloat scroll_speed); void set_pause(bool pause); void user_guide_bars_changed(); @@ -109,7 +109,7 @@ protected: DragMode _drag_mode; DragMode _potential_drag_mode; int _drag_start_x, _drag_start_y; - float _drag_scale_start; + PN_stdfloat _drag_scale_start; int _drag_guide_bar; bool _pause; diff --git a/pandatool/src/win-stats/winStatsLabel.cxx b/pandatool/src/win-stats/winStatsLabel.cxx index a32cfe7f73..2f3cdf9b28 100755 --- a/pandatool/src/win-stats/winStatsLabel.cxx +++ b/pandatool/src/win-stats/winStatsLabel.cxx @@ -44,7 +44,7 @@ WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph, _text = _monitor->get_client_data()->get_collector_name(_collector_index); } - RGBColorf rgb = _monitor->get_collector_color(_collector_index); + LRGBColor rgb = _monitor->get_collector_color(_collector_index); int r = (int)(rgb[0] * 255.0f); int g = (int)(rgb[1] * 255.0f); int b = (int)(rgb[2] * 255.0f); @@ -52,7 +52,7 @@ WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph, _bg_brush = CreateSolidBrush(RGB(r, g, b)); // Should our foreground be black or white? - float bright = + PN_stdfloat bright = rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114; diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index bef9619c7f..2706d94743 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -243,7 +243,7 @@ idle() { // Update the frame rate label from the main thread (thread 0). const PStatThreadData *thread_data = get_client_data()->get_thread_data(0); - float frame_rate = thread_data->get_frame_rate(); + PN_stdfloat frame_rate = thread_data->get_frame_rate(); if (frame_rate != 0.0f) { char buffer[128]; sprintf(buffer, "%0.1f ms / %0.1f Hz", 1000.0f / frame_rate, frame_rate); @@ -406,7 +406,7 @@ set_time_units(int unit_mask) { // speeds for all graphs to the indicated value. //////////////////////////////////////////////////////////////////// void WinStatsMonitor:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { _scroll_speed = scroll_speed; // First, change all of the open graphs appropriately. diff --git a/pandatool/src/win-stats/winStatsMonitor.h b/pandatool/src/win-stats/winStatsMonitor.h index d521842631..a43ae00e6b 100644 --- a/pandatool/src/win-stats/winStatsMonitor.h +++ b/pandatool/src/win-stats/winStatsMonitor.h @@ -72,7 +72,7 @@ public: int get_menu_id(const MenuDef &menu_def); void set_time_units(int unit_mask); - void set_scroll_speed(float scroll_speed); + void set_scroll_speed(PN_stdfloat scroll_speed); void set_pause(bool pause); private: @@ -106,7 +106,7 @@ private: HMENU _speed_menu; string _window_title; int _time_units; - float _scroll_speed; + PN_stdfloat _scroll_speed; bool _pause; static bool _window_class_registered; diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index 0e4d363ca3..c7ad2836ef 100755 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -134,7 +134,7 @@ clicked_label(int collector_index) { // horizontal axis represents. This may force a redraw. //////////////////////////////////////////////////////////////////// void WinStatsPianoRoll:: -set_horizontal_scale(float time_width) { +set_horizontal_scale(PN_stdfloat time_width) { PStatPianoRoll::set_horizontal_scale(time_width); RECT rect; @@ -287,7 +287,7 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_drag_mode == DM_scale) { PN_int16 x = LOWORD(lparam); - float ratio = (float)x / (float)get_xsize(); + PN_stdfloat ratio = (PN_stdfloat)x / (PN_stdfloat)get_xsize(); if (ratio > 0.0f) { set_horizontal_scale(_drag_scale_start / ratio); } @@ -412,8 +412,8 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { if (mouse_x >= _graph_left && mouse_x < _graph_left + get_xsize()) { // See if the mouse is over a user-defined guide bar. int x = mouse_x - _graph_left; - float from_height = pixel_to_height(x - 2); - float to_height = pixel_to_height(x + 2); + PN_stdfloat from_height = pixel_to_height(x - 2); + PN_stdfloat to_height = pixel_to_height(x + 2); _drag_guide_bar = find_user_guide_bar(from_height, to_height); if (_drag_guide_bar >= 0) { return DM_guide_bar; @@ -527,8 +527,8 @@ draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) { GetTextExtentPoint32(hdc, label.data(), label.length(), &size); if (bar._style != GBS_user) { - float from_height = pixel_to_height(x - size.cx); - float to_height = pixel_to_height(x + size.cx); + PN_stdfloat from_height = pixel_to_height(x - size.cx); + PN_stdfloat to_height = pixel_to_height(x + size.cx); if (find_user_guide_bar(from_height, to_height) >= 0) { // Omit the label: there's a user-defined guide bar in the same space. return; diff --git a/pandatool/src/win-stats/winStatsPianoRoll.h b/pandatool/src/win-stats/winStatsPianoRoll.h index 0d87db1271..d8eb78015a 100755 --- a/pandatool/src/win-stats/winStatsPianoRoll.h +++ b/pandatool/src/win-stats/winStatsPianoRoll.h @@ -42,7 +42,7 @@ public: virtual void set_time_units(int unit_mask); virtual void clicked_label(int collector_index); - void set_horizontal_scale(float time_width); + void set_horizontal_scale(PN_stdfloat time_width); protected: void clear_region(); diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 711e8aefcf..fa80352077 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -179,7 +179,7 @@ set_time_units(int unit_mask) { // speed for the graph to the indicated value. //////////////////////////////////////////////////////////////////// void WinStatsStripChart:: -set_scroll_speed(float scroll_speed) { +set_scroll_speed(PN_stdfloat scroll_speed) { // The speed factor indicates chart widths per minute. if (scroll_speed != 0.0f) { set_horizontal_scale(60.0f / scroll_speed); @@ -226,7 +226,7 @@ clicked_label(int collector_index) { // represents. This may force a redraw. //////////////////////////////////////////////////////////////////// void WinStatsStripChart:: -set_vertical_scale(float value_height) { +set_vertical_scale(PN_stdfloat value_height) { PStatStripChart::set_vertical_scale(value_height); RECT rect; @@ -301,7 +301,7 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { RECT rect = { x, 0, x + w, get_ysize() }; FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - float overall_time = 0.0; + PN_stdfloat overall_time = 0.0; int y = get_ysize(); FrameData::const_iterator fi; @@ -456,7 +456,7 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (_drag_mode == DM_scale) { PN_int16 y = HIWORD(lparam); - float ratio = 1.0f - ((float)y / (float)get_ysize()); + PN_stdfloat ratio = 1.0f - ((PN_stdfloat)y / (PN_stdfloat)get_ysize()); if (ratio > 0.0f) { set_vertical_scale(_drag_scale_start / ratio); } @@ -601,8 +601,8 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { if (mouse_y >= _graph_top && mouse_y < _graph_top + get_ysize()) { // See if the mouse is over a user-defined guide bar. int y = mouse_y - _graph_top; - float from_height = pixel_to_height(y + 2); - float to_height = pixel_to_height(y - 2); + PN_stdfloat from_height = pixel_to_height(y + 2); + PN_stdfloat to_height = pixel_to_height(y - 2); _drag_guide_bar = find_user_guide_bar(from_height, to_height); if (_drag_guide_bar >= 0) { return DM_guide_bar; @@ -725,8 +725,8 @@ draw_guide_label(HDC hdc, int x, const PStatGraph::GuideBar &bar, int last_y) { GetTextExtentPoint32(hdc, label.data(), label.length(), &size); if (bar._style != GBS_user) { - float from_height = pixel_to_height(y + size.cy); - float to_height = pixel_to_height(y - size.cy); + PN_stdfloat from_height = pixel_to_height(y + size.cy); + PN_stdfloat to_height = pixel_to_height(y - size.cy); if (find_user_guide_bar(from_height, to_height) >= 0) { // Omit the label: there's a user-defined guide bar in the same space. return last_y; diff --git a/pandatool/src/win-stats/winStatsStripChart.h b/pandatool/src/win-stats/winStatsStripChart.h index 4b2f0b7c4e..0af31a6761 100644 --- a/pandatool/src/win-stats/winStatsStripChart.h +++ b/pandatool/src/win-stats/winStatsStripChart.h @@ -41,9 +41,9 @@ public: virtual void changed_graph_size(int graph_xsize, int graph_ysize); virtual void set_time_units(int unit_mask); - virtual void set_scroll_speed(float scroll_speed); + virtual void set_scroll_speed(PN_stdfloat scroll_speed); virtual void clicked_label(int collector_index); - void set_vertical_scale(float value_height); + void set_vertical_scale(PN_stdfloat value_height); protected: virtual void update_labels(); diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index e71003fec6..9a0d0b8acd 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -146,7 +146,7 @@ add_MeshFace(XFile *x_file) { // Description: Appends a new IndexedColor instance. //////////////////////////////////////////////////////////////////// XFileDataObject &XFileDataObject:: -add_IndexedColor(XFile *x_file, int index, const Colorf &color) { +add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileTemplate *xtemplate = XFile::find_standard_template("IndexedColor"); nassertr(xtemplate != (XFileTemplate *)NULL, *this); XFileDataNodeTemplate *node = diff --git a/pandatool/src/xfile/xFileDataObject.h b/pandatool/src/xfile/xFileDataObject.h index 9617183815..8cecf61dc1 100644 --- a/pandatool/src/xfile/xFileDataObject.h +++ b/pandatool/src/xfile/xFileDataObject.h @@ -84,7 +84,7 @@ public: XFileDataObject &add_Vector(XFile *x_file, const LVecBase3d &vector); XFileDataObject &add_MeshFace(XFile *x_file); XFileDataObject &add_IndexedColor(XFile *x_file, int index, - const Colorf &color); + const LColor &color); XFileDataObject &add_Coords2d(XFile *x_file, const LVecBase2d &coords); public: diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index d8ed11ac49..f7e258da87 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -444,9 +444,9 @@ add_MeshMaterialList(const string &name) { // this node. //////////////////////////////////////////////////////////////////// XFileDataNode *XFileNode:: -add_Material(const string &name, const Colorf &face_color, - double power, const RGBColorf &specular_color, - const RGBColorf &emissive_color) { +add_Material(const string &name, const LColor &face_color, + double power, const LRGBColor &specular_color, + const LRGBColor &emissive_color) { XFileTemplate *xtemplate = XFile::find_standard_template("Material"); nassertr(xtemplate != (XFileTemplate *)NULL, NULL); XFileDataNodeTemplate *node = diff --git a/pandatool/src/xfile/xFileNode.h b/pandatool/src/xfile/xFileNode.h index 30d4e28ef1..202b8490c1 100644 --- a/pandatool/src/xfile/xFileNode.h +++ b/pandatool/src/xfile/xFileNode.h @@ -90,9 +90,9 @@ public: XFileDataNode *add_MeshVertexColors(const string &name); XFileDataNode *add_MeshTextureCoords(const string &name); XFileDataNode *add_MeshMaterialList(const string &name); - XFileDataNode *add_Material(const string &name, const Colorf &face_color, - double power, const RGBColorf &specular_color, - const RGBColorf &emissive_color); + XFileDataNode *add_Material(const string &name, const LColor &face_color, + double power, const LRGBColor &specular_color, + const LRGBColor &emissive_color); XFileDataNode *add_TextureFilename(const string &name, const Filename &filename); XFileDataNode *add_Frame(const string &name); diff --git a/pandatool/src/xfileegg/xFileMaterial.cxx b/pandatool/src/xfileegg/xFileMaterial.cxx index 74bfc016cb..938a24f76e 100644 --- a/pandatool/src/xfileegg/xFileMaterial.cxx +++ b/pandatool/src/xfileegg/xFileMaterial.cxx @@ -68,11 +68,11 @@ set_from_egg(EggPrimitive *egg_prim) { _face_color = egg_mat->get_diff(); } if (egg_mat->has_spec()) { - const Colorf &spec = egg_mat->get_spec(); + const LColor &spec = egg_mat->get_spec(); _specular_color.set(spec[0], spec[1], spec[2]); } if (egg_mat->has_emit()) { - const Colorf &emit = egg_mat->get_emit(); + const LColor &emit = egg_mat->get_emit(); _emissive_color.set(emit[0], emit[1], emit[2]); } if (egg_mat->has_shininess()) { @@ -106,18 +106,18 @@ apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter) { } // Are there any fancy lighting effects? - bool got_spec = (_specular_color != RGBColorf::zero()); - bool got_emit = (_emissive_color != RGBColorf::zero()); + bool got_spec = (_specular_color != LRGBColor::zero()); + bool got_emit = (_emissive_color != LRGBColor::zero()); if (got_spec || got_emit) { EggMaterial temp(""); temp.set_diff(_face_color); if (got_spec) { temp.set_shininess(_power); - temp.set_spec(Colorf(_specular_color[0], _specular_color[1], + temp.set_spec(LColor(_specular_color[0], _specular_color[1], _specular_color[2], 1.0)); } if (got_emit) { - temp.set_emit(Colorf(_emissive_color[0], _emissive_color[1], + temp.set_emit(LColor(_emissive_color[0], _emissive_color[1], _emissive_color[2], 1.0)); } EggMaterial *egg_mat = converter->create_unique_material(temp); @@ -202,10 +202,10 @@ make_x_material(XFileNode *x_meshMaterials, const string &suffix) { //////////////////////////////////////////////////////////////////// bool XFileMaterial:: fill_material(XFileDataNode *obj) { - _face_color = LCAST(float, (*obj)["faceColor"].vec4()); + _face_color = LCAST(PN_stdfloat, (*obj)["faceColor"].vec4()); _power = (*obj)["power"].d(); - _specular_color = LCAST(float, (*obj)["specularColor"].vec3()); - _emissive_color = LCAST(float, (*obj)["emissiveColor"].vec3()); + _specular_color = LCAST(PN_stdfloat, (*obj)["specularColor"].vec3()); + _emissive_color = LCAST(PN_stdfloat, (*obj)["emissiveColor"].vec3()); _has_material = true; // Walk through the children of the material. If there are any, diff --git a/pandatool/src/xfileegg/xFileMaterial.h b/pandatool/src/xfileegg/xFileMaterial.h index f93d2e23e0..5aef759355 100644 --- a/pandatool/src/xfileegg/xFileMaterial.h +++ b/pandatool/src/xfileegg/xFileMaterial.h @@ -47,10 +47,10 @@ public: bool fill_material(XFileDataNode *obj); private: - Colorf _face_color; + LColor _face_color; double _power; - RGBColorf _specular_color; - RGBColorf _emissive_color; + LRGBColor _specular_color; + LRGBColor _emissive_color; Filename _texture; bool _has_material; diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 4cbde70f86..484e4b8f32 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -582,7 +582,7 @@ make_x_colors(XFileNode *x_mesh, const string &suffix) { int i = 0; for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) { XFileVertex *vertex = (*vi); - const Colorf &color = vertex->_color; + const LColor &color = vertex->_color; x_colors.add_IndexedColor(x_mesh->get_x_file(), i, color); i++; } @@ -808,7 +808,7 @@ fill_colors(XFileDataNode *obj) { } XFileVertex *vertex = _vertices[vertex_index]; - vertex->_color = LCAST(float, vertexColors[i]["indexColor"].vec4()); + vertex->_color = LCAST(PN_stdfloat, vertexColors[i]["indexColor"].vec4()); vertex->_has_color = true; } diff --git a/pandatool/src/xfileegg/xFileMesh.h b/pandatool/src/xfileegg/xFileMesh.h index e4397fda64..7eff4bb906 100644 --- a/pandatool/src/xfileegg/xFileMesh.h +++ b/pandatool/src/xfileegg/xFileMesh.h @@ -96,7 +96,7 @@ private: Materials _materials; Faces _faces; - typedef pmap WeightMap; + typedef pmap WeightMap; class SkinWeightsData { public: diff --git a/pandatool/src/xfileegg/xFileVertex.h b/pandatool/src/xfileegg/xFileVertex.h index 8b58f7df20..24d5a6f7c3 100644 --- a/pandatool/src/xfileegg/xFileVertex.h +++ b/pandatool/src/xfileegg/xFileVertex.h @@ -34,7 +34,7 @@ public: Vertexd _point; TexCoordd _uv; - Colorf _color; + LColor _color; bool _has_color; bool _has_uv; }; diff --git a/pandatool/src/xfileegg/xFileVertexPool.h b/pandatool/src/xfileegg/xFileVertexPool.h index 936454e814..6281be33ca 100644 --- a/pandatool/src/xfileegg/xFileVertexPool.h +++ b/pandatool/src/xfileegg/xFileVertexPool.h @@ -30,24 +30,24 @@ public: int add_vertex(const XFileVertex &vertex); int get_num_vertices(); - const Vertexf *get_vertices(); - const Normalf *get_normals(); - const TexCoordf *get_uvs(); - const Colorf *get_colors(); + const LVertex *get_vertices(); + const LNormal *get_normals(); + const LTexCoord *get_uvs(); + const LColor *get_colors(); - void set_normal(const Normalf &normal); - void set_uv(const TexCoordf &uv); - void set_color(const Colorf &color); + void set_normal(const LNormal &normal); + void set_uv(const LTexCoord &uv); + void set_color(const LColor &color); bool operator < (const XFileVertexPool &other) const; private: - Vertexf _point; - Normalf _normal; - TexCoordf _uv; - Colorf _color; + LVertex _point; + LNormal _normal; + LTexCoord _uv; + LColor _color; }; #endif