rename dangerous PTA contructor to empty_array
This commit is contained in:
parent
fb66a4add7
commit
012486c12e
|
|
@ -671,7 +671,7 @@ build_geoms(InputIterator first, InputIterator last,
|
|||
}
|
||||
|
||||
if (want_lengths) {
|
||||
lengths = PTA_int(num_prims);
|
||||
lengths = PTA_int::empty_array(num_prims);
|
||||
j = 0;
|
||||
for (i = first; i != last; ++i) {
|
||||
if ((*i).is_valid()) {
|
||||
|
|
@ -682,10 +682,10 @@ build_geoms(InputIterator first, InputIterator last,
|
|||
}
|
||||
|
||||
// Now build up some arrays.
|
||||
PTA(VType) coords(0);
|
||||
PTA(NType) normals(0);
|
||||
PTA(TType) texcoords(0);
|
||||
PTA(CType) colors(0);
|
||||
PTA(VType) coords=PTA(VType)::empty_array(0);
|
||||
PTA(NType) normals=PTA(NType)::empty_array(0);
|
||||
PTA(TType) texcoords=PTA(TType)::empty_array(0);
|
||||
PTA(CType) colors=PTA(CType)::empty_array(0);
|
||||
|
||||
int total_verts = 0;
|
||||
int total_components = 0;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ fill_geom(Geom *geom, const PTA_BuilderV &v_array,
|
|||
// to a Vertexf, we can get away with casting this to a
|
||||
// PTA_Vertexf.
|
||||
|
||||
geom->set_coords((PTA_Vertexf &)v_array, G_PER_VERTEX);
|
||||
geom->set_coords((PTA_Vertexf &)v_array);
|
||||
|
||||
if (n_attr != G_OFF) {
|
||||
geom->set_normals((PTA_Normalf &)n_array, n_attr);
|
||||
|
|
@ -243,7 +243,7 @@ fill_geom(Geom *geom, const PTA_ushort &v_array,
|
|||
}
|
||||
}
|
||||
|
||||
geom->set_coords(v_data, G_PER_VERTEX, v_array);
|
||||
geom->set_coords(v_data, v_array);
|
||||
|
||||
if (n_attr != G_OFF) {
|
||||
geom->set_normals(n_data, n_attr, n_array);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
|
||||
#include "config_builder.cxx"
|
||||
#include "builderTypes.cxx"
|
||||
#include "builderMisc.cxx"
|
||||
#include "builder.cxx"
|
||||
#include "builderAttrib.cxx"
|
||||
#include "builderBucket.cxx"
|
||||
#include "builderBucketNode.cxx"
|
||||
#include "builderMisc.cxx"
|
||||
#include "builderTypes.cxx"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "config_builder.cxx"
|
||||
#include "builderNormalVisualizer.cxx"
|
||||
#include "builderPrim.cxx"
|
||||
#include "builderProperties.cxx"
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ void MesherTempl<PrimType>::
|
|||
finalize() {
|
||||
if (!_colors.empty()) {
|
||||
// Create an array in the bucket we might use to add to geoms.
|
||||
PTA_Colorf colors(_colors.size());
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(_colors.size());
|
||||
for (int i = 0; i < (int)_colors.size(); i++) {
|
||||
colors[i] = _colors[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ AnimChannelMatrixXfmTable::_table_ids[AnimChannelMatrixXfmTable::num_tables] =
|
|||
|
||||
const float
|
||||
AnimChannelMatrixXfmTable::_default_values[AnimChannelMatrixXfmTable::num_tables] =
|
||||
{ 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
||||
{ 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AnimChannelMatrixXfmTable::Constructor
|
||||
|
|
@ -107,9 +107,9 @@ get_value(int frame, LMatrix4f &mat) {
|
|||
void AnimChannelMatrixXfmTable::
|
||||
get_value_no_scale(int frame, LMatrix4f &mat) {
|
||||
float components[num_tables];
|
||||
components[0] = 1.0;
|
||||
components[1] = 1.0;
|
||||
components[2] = 1.0;
|
||||
components[0] = 1.0f;
|
||||
components[1] = 1.0f;
|
||||
components[2] = 1.0f;
|
||||
|
||||
for (int i = 3; i < num_tables; i++) {
|
||||
if (_tables[i].empty()) {
|
||||
|
|
@ -339,7 +339,7 @@ fillin(DatagramIterator& scan, BamReader* manager)
|
|||
int i;
|
||||
// First, read in the scales.
|
||||
for(i = 0; i < 3; i++) {
|
||||
PTA_float ind_table(0);
|
||||
PTA_float ind_table=PTA_float::empty_array(0);
|
||||
compressor.read_reals(scan, ind_table.v());
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
|
|
@ -347,9 +347,10 @@ fillin(DatagramIterator& scan, BamReader* manager)
|
|||
// Read in the HPR array and store it back in the joint angles.
|
||||
vector_LVecBase3f hprs;
|
||||
compressor.read_hprs(scan, hprs);
|
||||
PTA_float h_table(hprs.size());
|
||||
PTA_float p_table(hprs.size());
|
||||
PTA_float r_table(hprs.size());
|
||||
PTA_float h_table=PTA_float::empty_array(hprs.size());
|
||||
PTA_float p_table=PTA_float::empty_array(hprs.size());
|
||||
PTA_float r_table=PTA_float::empty_array(hprs.size());
|
||||
|
||||
for (i = 0; i < (int)hprs.size(); i++) {
|
||||
h_table[i] = hprs[i][0];
|
||||
p_table[i] = hprs[i][1];
|
||||
|
|
@ -361,7 +362,7 @@ fillin(DatagramIterator& scan, BamReader* manager)
|
|||
|
||||
// Now read in the translations.
|
||||
for (i = 6; i < 9; i++) {
|
||||
PTA_float ind_table(0);
|
||||
PTA_float ind_table=PTA_float::empty_array(0);
|
||||
compressor.read_reals(scan, ind_table.v());
|
||||
_tables[i] = ind_table;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ fillin(DatagramIterator& scan, BamReader* manager)
|
|||
|
||||
bool wrote_compressed = scan.get_bool();
|
||||
|
||||
PTA_float temp_table(0);
|
||||
PTA_float temp_table=PTA_float::empty_array(0);
|
||||
|
||||
if (!wrote_compressed) {
|
||||
// Regular floats.
|
||||
|
|
|
|||
|
|
@ -298,12 +298,12 @@ copy_geom(Geom *source, const Character *from) {
|
|||
|
||||
PT(Geom) dest = source;
|
||||
|
||||
source->get_coords(coords, bind, index);
|
||||
if (bind != G_OFF && coords == from->_cv._coords) {
|
||||
source->get_coords(coords, index);
|
||||
if ((coords != NULL) && (coords == (from->_cv._coords))) {
|
||||
if (dest == source) {
|
||||
dest = source->make_copy();
|
||||
}
|
||||
dest->set_coords(_cv._coords, bind, index);
|
||||
dest->set_coords(_cv._coords, index);
|
||||
}
|
||||
|
||||
source->get_normals(norms, bind, index);
|
||||
|
|
|
|||
|
|
@ -243,28 +243,28 @@ make_orig(Character *character) {
|
|||
if (character->_cv._coords.empty()) {
|
||||
_orig_coords.clear();
|
||||
} else {
|
||||
_orig_coords = PTA_Vertexf(0);
|
||||
_orig_coords = PTA_Vertexf::empty_array(0);
|
||||
_orig_coords.v() = character->_cv._coords.v();
|
||||
}
|
||||
|
||||
if (character->_cv._norms.empty()) {
|
||||
_orig_norms.clear();
|
||||
} else {
|
||||
_orig_norms = PTA_Normalf(0);
|
||||
_orig_norms = PTA_Normalf::empty_array(0);
|
||||
_orig_norms.v() = character->_cv._norms.v();
|
||||
}
|
||||
|
||||
if (character->_cv._colors.empty()) {
|
||||
_orig_colors.clear();
|
||||
} else {
|
||||
_orig_colors = PTA_Colorf(0);
|
||||
_orig_colors = PTA_Colorf::empty_array(0);
|
||||
_orig_colors.v() = character->_cv._colors.v();
|
||||
}
|
||||
|
||||
if (character->_cv._texcoords.empty()) {
|
||||
_orig_texcoords.clear();
|
||||
} else {
|
||||
_orig_texcoords = PTA_TexCoordf(0);
|
||||
_orig_texcoords = PTA_TexCoordf::empty_array(0);
|
||||
_orig_texcoords.v() = character->_cv._texcoords.v();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ DynamicVertices DynamicVertices::
|
|||
deep_copy(const DynamicVertices ©) {
|
||||
DynamicVertices dv;
|
||||
if (!copy._coords.empty()) {
|
||||
dv._coords = PTA_Vertexf(0);
|
||||
dv._coords = PTA_Vertexf::empty_array(0);
|
||||
dv._coords.v() = copy._coords.v();
|
||||
}
|
||||
if (!copy._norms.empty()) {
|
||||
dv._norms = PTA_Normalf(0);
|
||||
dv._norms = PTA_Normalf::empty_array(0);
|
||||
dv._norms.v() = copy._norms.v();
|
||||
}
|
||||
if (!copy._colors.empty()) {
|
||||
dv._colors = PTA_Colorf(0);
|
||||
dv._colors = PTA_Colorf::empty_array(0);
|
||||
dv._colors.v() = copy._colors.v();
|
||||
}
|
||||
if (!copy._texcoords.empty()) {
|
||||
dv._texcoords = PTA_TexCoordf(0);
|
||||
dv._texcoords = PTA_TexCoordf::empty_array(0);
|
||||
dv._texcoords.v() = copy._texcoords.v();
|
||||
}
|
||||
return dv;
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ recompute_viz(Node *parent) {
|
|||
verts.push_back(cp + p4 * plane_scale);
|
||||
|
||||
GeomQuad *quad = new GeomQuad;
|
||||
quad->set_coords(verts, G_PER_VERTEX);
|
||||
quad->set_coords(verts);
|
||||
quad->set_num_prims(1);
|
||||
|
||||
GeomNode *viz = new GeomNode("viz-plane");
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ recompute_viz(Node *parent) {
|
|||
lengths.push_back(_points.size());
|
||||
|
||||
GeomPolygon *polygon = new GeomPolygon;
|
||||
polygon->set_coords(verts, G_PER_VERTEX);
|
||||
polygon->set_coords(verts);
|
||||
polygon->set_num_prims(1);
|
||||
polygon->set_lengths(lengths);
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ recompute_viz(Node *parent) {
|
|||
colors.push_back(Colorf(1.0, 1.0, 1.0, 1.0) +
|
||||
((double)i / 100.0) * Colorf(0.0, 0.0, 0.0, -1.0));
|
||||
}
|
||||
ray->set_coords(verts, G_PER_VERTEX);
|
||||
ray->set_coords(verts);
|
||||
ray->set_colors(colors, G_PER_VERTEX);
|
||||
|
||||
PTA_int lengths;
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ recompute_viz(Node *parent) {
|
|||
PTA_Colorf colors;
|
||||
verts.push_back(_a);
|
||||
verts.push_back(_b);
|
||||
colors.push_back(Colorf(1.0, 1.0, 1.0, 1.0));
|
||||
segment->set_coords(verts, G_PER_VERTEX);
|
||||
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
segment->set_coords(verts);
|
||||
segment->set_colors(colors, G_OVERALL);
|
||||
|
||||
segment->set_num_prims(1);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ xform(const LMatrix4f &mat) {
|
|||
|
||||
// This is a little cheesy and fails miserably in the presence of a
|
||||
// non-proportionate scale.
|
||||
LVector3f radius_v = LVector3f(_radius, 0.0, 0.0) * mat;
|
||||
LVector3f radius_v = LVector3f(_radius, 0.0f, 0.0f) * mat;
|
||||
_radius = length(radius_v);
|
||||
|
||||
clear_viz_arcs();
|
||||
|
|
@ -125,7 +125,7 @@ test_intersection_from_sphere(CollisionHandler *record,
|
|||
|
||||
LPoint3f from_center = sphere->get_center() * entry.get_wrt_space();
|
||||
LVector3f from_radius_v =
|
||||
LVector3f(sphere->get_radius(), 0.0, 0.0) * entry.get_wrt_space();
|
||||
LVector3f(sphere->get_radius(), 0.0f, 0.0f) * entry.get_wrt_space();
|
||||
float from_radius = length(from_radius_v);
|
||||
|
||||
LPoint3f into_center = _center;
|
||||
|
|
@ -268,8 +268,8 @@ recompute_viz(Node *parent) {
|
|||
GeomSphere *sphere = new GeomSphere;
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(_center);
|
||||
verts.push_back(_center + LVector3f(_radius, 0.0, 0.0));
|
||||
sphere->set_coords(verts, G_PER_VERTEX);
|
||||
verts.push_back(_center + LVector3f(_radius, 0.0f, 0.0f));
|
||||
sphere->set_coords(verts);
|
||||
sphere->set_num_prims(1);
|
||||
|
||||
GeomNode *viz = new GeomNode("viz-sphere");
|
||||
|
|
|
|||
|
|
@ -612,9 +612,8 @@ compare_collider_to_geom(CollisionEntry &entry, Geom *geom,
|
|||
nassertv(ci != _colliders.end());
|
||||
|
||||
PTA_Vertexf coords;
|
||||
GeomBindType bind;
|
||||
PTA_ushort vindex;
|
||||
geom->get_coords(coords, bind, vindex);
|
||||
geom->get_coords(coords, vindex);
|
||||
PTA_ushort tris = geom->get_tris();
|
||||
|
||||
for (int i = 0; i < (int)tris.size(); i += 3) {
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ add_blind(PT(Texture) blind)
|
|||
//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);
|
||||
PTA_float tex_scales(0);
|
||||
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, G_PER_VERTEX);
|
||||
sprite->set_coords(coords);
|
||||
sprite->set_num_prims(1);
|
||||
sprite->set_texture(_blind);
|
||||
|
||||
|
|
@ -112,9 +112,10 @@ set_geometry(GeomSprite *sprite, const PTA_float &geom_scales,
|
|||
const PTA_Colorf &geom_colors, const LVector3f &delta,
|
||||
const LPoint3f &light, const float &angle)
|
||||
{
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_float tex_scales(0);
|
||||
PTA_Colorf colors(0);
|
||||
|
||||
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());
|
||||
|
|
@ -132,26 +133,26 @@ set_geometry(GeomSprite *sprite, const PTA_float &geom_scales,
|
|||
//will actually be the normal use of angle scales
|
||||
if (geom_angle_scales[i] < 0)
|
||||
{
|
||||
view_scale = (1-pow(angle, 15)) * -geom_angle_scales[i];
|
||||
view_scale = (1.0f-pow(angle, 15.0f)) * -geom_angle_scales[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
view_scale = pow(angle, 15) * geom_angle_scales[i];
|
||||
view_scale = pow(angle, 15.0f) * geom_angle_scales[i];
|
||||
}
|
||||
float offset = (angle - 1) / _flare_fall_off;
|
||||
offset = (offset < 0) ? 0 : ((offset > 1) ? 1 : offset);
|
||||
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) ? 0 : r;
|
||||
g = (g < 0) ? 0 : g;
|
||||
b = (b < 0) ? 0 : b;
|
||||
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, G_PER_VERTEX);
|
||||
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);
|
||||
|
|
@ -185,9 +186,9 @@ prepare_flares(const LVector3f &delta, const LPoint3f &light, const float &angle
|
|||
//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);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(0);
|
||||
|
||||
sprite->set_coords(coords, G_PER_VERTEX);
|
||||
sprite->set_coords(coords);
|
||||
sprite->set_num_prims(_flare_offsets[i].size());
|
||||
|
||||
node->add_geom(sprite);
|
||||
|
|
@ -228,14 +229,14 @@ prepare_blind(const float &angle, const float &tnear)
|
|||
GeomNode *node = DCAST(GeomNode, _blind_arc->get_child());
|
||||
GeomSprite *sprite = DCAST(GeomSprite, node->get_geom(0));
|
||||
|
||||
float offset = (angle - 1) / _blind_fall_off;
|
||||
float offset = (angle - 1.0f) / _blind_fall_off;
|
||||
//Make sure that it always blends some
|
||||
offset = (offset < 0.3) ? 0.3 : ((offset > 1) ? 1 : offset);
|
||||
offset = (offset < 0.3f) ? 0.3f : ((offset > 1.0f) ? 1.0f : offset);
|
||||
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_Colorf colors(0);
|
||||
PTA_float x_tex_scales(0);
|
||||
PTA_float y_tex_scales(0);
|
||||
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.
|
||||
|
|
@ -244,15 +245,15 @@ prepare_blind(const float &angle, const float &tnear)
|
|||
float x_offset_scale = width / _blind->_pbuffer->get_xsize();
|
||||
float y_offset_scale = height / _blind->_pbuffer->get_ysize();
|
||||
|
||||
float inten = 1 - offset;
|
||||
float inten = 1.0f - offset;
|
||||
|
||||
coords.push_back(Vertexf(0, 0, -tnear ));
|
||||
colors.push_back(Colorf(inten,inten,inten,1));
|
||||
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, G_PER_VERTEX);
|
||||
sprite->set_coords(coords);
|
||||
sprite->set_colors(colors, G_PER_PRIM);
|
||||
|
||||
//Tell it to recompute it's bounding volume
|
||||
|
|
@ -350,7 +351,7 @@ sub_render(const AllTransitionsWrapper &input_trans,
|
|||
LVector3f view_dir = center - origin;
|
||||
|
||||
float dot = view_dir.dot(light_dir);
|
||||
dot = (dot < 0) ? -dot : dot;
|
||||
dot = (dot < 0.0f) ? -dot : dot;
|
||||
|
||||
prepare_flares(delta, light_pos, dot);
|
||||
prepare_blind(dot, pp->get_frustum()._fnear);
|
||||
|
|
@ -462,7 +463,7 @@ fillin(DatagramIterator &scan, BamReader *manager)
|
|||
size = scan.get_uint16();
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
PTA_float temp(0);
|
||||
PTA_float temp=PTA_float::empty_array(0);
|
||||
READ_PTA(manager, scan, IPD_float::read_datagram, temp)
|
||||
_flare_scales.push_back(temp);
|
||||
}
|
||||
|
|
@ -470,7 +471,7 @@ fillin(DatagramIterator &scan, BamReader *manager)
|
|||
size = scan.get_uint16();
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
PTA_float temp(0);
|
||||
PTA_float temp=PTA_float::empty_array(0);
|
||||
READ_PTA(manager, scan, IPD_float::read_datagram, temp)
|
||||
_flare_angle_scales.push_back(temp);
|
||||
}
|
||||
|
|
@ -478,7 +479,7 @@ fillin(DatagramIterator &scan, BamReader *manager)
|
|||
size = scan.get_uint16();
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
PTA_float temp(0);
|
||||
PTA_float temp=PTA_float::empty_array(0);
|
||||
READ_PTA(manager, scan, IPD_float::read_datagram, temp)
|
||||
_flare_offsets.push_back(temp);
|
||||
}
|
||||
|
|
@ -486,7 +487,7 @@ fillin(DatagramIterator &scan, BamReader *manager)
|
|||
size = scan.get_uint16();
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
PTA_Colorf temp(0);
|
||||
PTA_Colorf temp=PTA_Colorf::empty_array(0);
|
||||
READ_PTA(manager, scan, IPD_Colorf::read_datagram, temp)
|
||||
_flare_colors.push_back(temp);
|
||||
}
|
||||
|
|
@ -688,7 +689,7 @@ prepare_sparkles(vector_relation &arcs, const vector_texture &sparkles,
|
|||
//vertices
|
||||
PTA_Vertexf coords(0);
|
||||
|
||||
sprite->set_coords(coords, G_PER_VERTEX);
|
||||
sprite->set_coords(coords);
|
||||
sprite->set_num_prims(1);
|
||||
|
||||
node->add_geom(sprite);
|
||||
|
|
@ -717,7 +718,7 @@ prepare_sparkles(vector_relation &arcs, const vector_texture &sparkles,
|
|||
|
||||
sprite_colors.push_back(colors[i]);
|
||||
|
||||
sprite->set_coords(coords, G_PER_VERTEX);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -2159,7 +2159,7 @@ xfm_s_anim_body:
|
|||
integer_list:
|
||||
empty
|
||||
{
|
||||
$$ = PTA_double(0);
|
||||
$$ = PTA_double::empty_array(0);
|
||||
}
|
||||
| integer_list integer
|
||||
{
|
||||
|
|
@ -2177,7 +2177,7 @@ integer_list:
|
|||
real_list:
|
||||
empty
|
||||
{
|
||||
$$ = PTA_double(0);
|
||||
$$ = PTA_double::empty_array(0);
|
||||
}
|
||||
| real_list real
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
AnimBundleMaker::
|
||||
AnimBundleMaker(EggTable *root) : _root(root) {
|
||||
_fps = 0.0;
|
||||
_fps = 0.0f;
|
||||
_num_frames = 1;
|
||||
|
||||
_ok_fps = true;
|
||||
|
|
@ -49,11 +49,11 @@ AnimBundleMaker(EggTable *root) : _root(root) {
|
|||
egg2sg_cat.warning()
|
||||
<< "AnimBundle " << _root->get_name()
|
||||
<< " specifies contradictory frame rates.\n";
|
||||
} else if (_fps == 0.0) {
|
||||
} else if (_fps == 0.0f) {
|
||||
egg2sg_cat.warning()
|
||||
<< "AnimBundle " << _root->get_name()
|
||||
<< " does not specify a frame rate.\n";
|
||||
_fps = 24.0;
|
||||
_fps = 24.0f;
|
||||
}
|
||||
|
||||
if (!_ok_num_frames) {
|
||||
|
|
@ -109,7 +109,7 @@ inspect_tree(EggNode *egg_node) {
|
|||
// Check frame rate.
|
||||
EggAnimData *egg_anim = DCAST(EggAnimData, egg_node);
|
||||
if (egg_anim->has_fps()) {
|
||||
if (_fps == 0.0) {
|
||||
if (_fps == 0.0f) {
|
||||
_fps = egg_anim->get_fps();
|
||||
} else if (_fps != egg_anim->get_fps()) {
|
||||
// Whoops! This table differs in opinion from the other tables.
|
||||
|
|
@ -123,7 +123,7 @@ inspect_tree(EggNode *egg_node) {
|
|||
// Check frame rate.
|
||||
EggXfmSAnim *egg_anim = DCAST(EggXfmSAnim, egg_node);
|
||||
if (egg_anim->has_fps()) {
|
||||
if (_fps == 0.0) {
|
||||
if (_fps == 0.0f) {
|
||||
_fps = egg_anim->get_fps();
|
||||
} else if (_fps != egg_anim->get_fps()) {
|
||||
// Whoops! This table differs in opinion from the other tables.
|
||||
|
|
@ -240,7 +240,7 @@ create_s_channel(EggSAnimData *egg_anim, const string &name,
|
|||
|
||||
// First we have to copy the table data from PTA_double to
|
||||
// PTA_float.
|
||||
PTA_float new_data(egg_anim->get_num_rows());
|
||||
PTA_float new_data=PTA_float::empty_array(egg_anim->get_num_rows());
|
||||
for (int i = 0; i < egg_anim->get_num_rows(); i++) {
|
||||
new_data[i] = (float)egg_anim->get_value(i);
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ create_xfm_channel(EggXfmSAnim *egg_anim, const string &name,
|
|||
|
||||
// Now we have to copy the table data from PTA_double to
|
||||
// PTA_float.
|
||||
PTA_float new_data(child->get_num_rows());
|
||||
PTA_float new_data=PTA_float::empty_array(child->get_num_rows());
|
||||
for (int i = 0; i < child->get_num_rows(); i++) {
|
||||
new_data[i] = (float)child->get_value(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,13 @@
|
|||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
ComputedVerticesMaker::
|
||||
ComputedVerticesMaker() :
|
||||
_coords(0), _norms(0), _colors(0), _texcoords(0)
|
||||
ComputedVerticesMaker()
|
||||
{
|
||||
_current_vc = NULL;
|
||||
_coords= PTA_Vertexf::empty_array(0);
|
||||
_norms= PTA_Normalf::empty_array(0);
|
||||
_colors= PTA_Colorf::empty_array(0);
|
||||
_texcoords= PTA_TexCoordf::empty_array(0);
|
||||
_current_vc = NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -96,11 +96,12 @@ pad_bytes(size_t size) {
|
|||
|
||||
if (_data == (uchar *)NULL) {
|
||||
// Create a new array.
|
||||
_data = PTA_uchar(0);
|
||||
// _data = PTA_uchar(0);
|
||||
_data = PTA_uchar::empty_array(0);
|
||||
|
||||
} else if (_data.get_ref_count() == 1) {
|
||||
// Copy on write.
|
||||
PTA_uchar new_data(0);
|
||||
PTA_uchar new_data = PTA_uchar::empty_array(0);
|
||||
new_data.v() = _data.v();
|
||||
_data = new_data;
|
||||
}
|
||||
|
|
@ -129,11 +130,11 @@ append_data(const void *data, size_t size) {
|
|||
|
||||
if (_data == (uchar *)NULL) {
|
||||
// Create a new array.
|
||||
_data = PTA_uchar(0);
|
||||
_data = PTA_uchar::empty_array(0);
|
||||
|
||||
} else if (_data.get_ref_count() != 1) {
|
||||
// Copy on write.
|
||||
PTA_uchar new_data(0);
|
||||
PTA_uchar new_data = PTA_uchar::empty_array(0);
|
||||
new_data.v() = _data.v();
|
||||
_data = new_data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,17 +34,14 @@ PointerToArray() :
|
|||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArray::Constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// return an empty array of size n
|
||||
template<class Element>
|
||||
INLINE PointerToArray<Element>::
|
||||
PointerToArray(size_type n) :
|
||||
PointerToBase<RefCountObj<pvector<Element> > >(new RefCountObj<pvector<Element> >) {
|
||||
_ptr->reserve(n);
|
||||
insert(begin(), n, Element());
|
||||
INLINE PointerToArray<Element>
|
||||
PointerToArray<Element>::empty_array(size_type n) {
|
||||
PointerToArray<Element> temp;
|
||||
temp.reserve(n);
|
||||
temp._ptr->insert(temp._ptr->begin(), n, Element());
|
||||
return temp;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@
|
|||
#include "pointerTo.h"
|
||||
#include "pvector.h"
|
||||
|
||||
#if defined(WIN32_VC) || !defined(__INTEL_COMPILER)
|
||||
// disable mysterious MSVC warning for static inline PTA::empty_array method
|
||||
// need to chk if vc 7.0 still has this problem, would like to keep it enabled
|
||||
#pragma warning (disable : 4506)
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PointerToArray
|
||||
// Description : A special kind of PointerTo that stores an array of
|
||||
|
|
@ -97,7 +103,8 @@ public:
|
|||
|
||||
PUBLISHED:
|
||||
INLINE PointerToArray();
|
||||
INLINE PointerToArray(size_type n);
|
||||
// INLINE PointerToArray(size_type n); this is too dangerous to use, since arrays created automatically for any const parameter, use empty_array instead
|
||||
INLINE static PointerToArray<Element> empty_array(size_type n);
|
||||
INLINE PointerToArray(size_type n, const Element &value);
|
||||
INLINE PointerToArray(const PointerToArray<Element> ©);
|
||||
|
||||
|
|
|
|||
|
|
@ -236,15 +236,14 @@ reached_node(Node *node, NullTransitionWrapper &, NullLevelState &) {
|
|||
}
|
||||
}
|
||||
if (vert_count > 0) {
|
||||
PTA_Vertexf verts(2 * vert_count);
|
||||
PTA_Vertexf verts=PTA_Vertexf::empty_array(2 * vert_count);
|
||||
for (i = 0; i < geom->get_num_geoms(); i++) {
|
||||
dDrawable *d = geom->get_geom(i);
|
||||
if (d->is_of_type(Geom::get_class_type())) {
|
||||
PTA_Vertexf lverts;
|
||||
PTA_ushort iverts;
|
||||
GeomBindType vbond;
|
||||
Geom *g = DCAST(Geom, d);
|
||||
g->get_coords(lverts, vbond, iverts);
|
||||
g->get_coords(lverts, iverts);
|
||||
int vert_idx = 0;
|
||||
if (g->get_binding(G_NORMAL) == G_OFF) {
|
||||
for (int j=0; j<g->get_num_prims(); ++j) {
|
||||
|
|
@ -269,7 +268,7 @@ reached_node(Node *node, NullTransitionWrapper &, NullLevelState &) {
|
|||
}
|
||||
}
|
||||
gn->set_num_prims(vert_count);
|
||||
gn->set_coords(verts, G_PER_VERTEX);
|
||||
gn->set_coords(verts);
|
||||
}
|
||||
geom->add_geom(gn);
|
||||
}
|
||||
|
|
@ -1327,7 +1326,7 @@ int framework_main(int argc, char *argv[]) {
|
|||
|
||||
PT(GeomTri) geom = new GeomTri;
|
||||
geom->set_num_prims(1);
|
||||
geom->set_coords(coords, G_PER_VERTEX);
|
||||
geom->set_coords(coords);
|
||||
geom->set_texcoords(uvs, G_PER_VERTEX);
|
||||
geom->set_normals(norms, G_PER_PRIM);
|
||||
geom->set_colors(colors, G_PER_VERTEX, cindex);
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ reset() {
|
|||
GLint max_clip_planes;
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
|
||||
_max_clip_planes = max_clip_planes;
|
||||
_available_clip_plane_ids = PTA(PlaneNode*)(_max_clip_planes);
|
||||
_available_clip_plane_ids = PTA(PlaneNode*)::empty_array(_max_clip_planes);
|
||||
_clip_plane_enabled = new bool[_max_clip_planes];
|
||||
_cur_clip_plane_enabled = new bool[_max_clip_planes];
|
||||
int i;
|
||||
|
|
@ -2185,7 +2185,7 @@ texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb,
|
|||
int w = pb->get_xsize();
|
||||
int h = pb->get_ysize();
|
||||
draw_texture(tc, dr);
|
||||
pb->_image = PTA_uchar(w * h * pb->get_num_components());
|
||||
pb->_image = PTA_uchar::empty_array(w * h * pb->get_num_components());
|
||||
copy_pixel_buffer(pb, dr);
|
||||
}
|
||||
report_errors();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ TypeHandle LOD::_type_handle;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
LOD::
|
||||
LOD(void) {
|
||||
_center.set(0, 0, 0);
|
||||
_center.set(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -207,11 +207,10 @@ operator = (const Geom ©) {
|
|||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Geom::
|
||||
set_coords(const PTA_Vertexf &coords, GeomBindType bind,
|
||||
set_coords(const PTA_Vertexf &coords,
|
||||
const PTA_ushort &vindex) {
|
||||
_coords = coords;
|
||||
assert(bind == G_PER_VERTEX);
|
||||
_bind[G_COORD] = bind;
|
||||
_bind[G_COORD] = G_PER_VERTEX;
|
||||
|
||||
if ( vindex )
|
||||
_vindex = vindex;
|
||||
|
|
@ -220,6 +219,18 @@ set_coords(const PTA_Vertexf &coords, GeomBindType bind,
|
|||
make_dirty();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::set_coords
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Geom::
|
||||
set_coords(const PTA_Vertexf &coords, GeomBindType bind,
|
||||
const PTA_ushort &vindex) {
|
||||
nassertv(bind==G_PER_VERTEX);
|
||||
set_coords(coords,vindex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::set_normals
|
||||
// Access: Public
|
||||
|
|
@ -272,6 +283,20 @@ set_texcoords(const PTA_TexCoordf &texcoords, GeomBindType bind,
|
|||
make_dirty();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::get_coords
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Geom::
|
||||
get_coords(PTA_Vertexf &coords,
|
||||
PTA_ushort &vindex) const {
|
||||
coords = _coords;
|
||||
vindex = _vindex;
|
||||
|
||||
// G_PER_VERTEX is implicit binding
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::get_coords
|
||||
// Access: Public
|
||||
|
|
@ -807,7 +832,6 @@ describe_attr(ostream &out, const Geom *geom,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void Geom::
|
||||
write_verbose(ostream &out, int indent_level) const {
|
||||
GeomBindType bind_coords;
|
||||
GeomBindType bind_normals;
|
||||
GeomBindType bind_tcoords;
|
||||
GeomBindType bind_colors;
|
||||
|
|
@ -822,7 +846,7 @@ write_verbose(ostream &out, int indent_level) const {
|
|||
PTA_ushort i_tcoords;
|
||||
PTA_ushort i_colors;
|
||||
|
||||
get_coords(g_coords, bind_coords, i_coords);
|
||||
get_coords(g_coords, i_coords);
|
||||
get_normals(g_normals, bind_normals, i_normals);
|
||||
get_texcoords(g_tcoords, bind_tcoords, i_tcoords);
|
||||
get_colors(g_colors, bind_colors, i_colors);
|
||||
|
|
@ -832,18 +856,18 @@ write_verbose(ostream &out, int indent_level) const {
|
|||
<< get_type() << " contains "
|
||||
<< get_num_prims() << " primitives:\n";
|
||||
|
||||
if (bind_coords == G_OFF) {
|
||||
if ((i_coords == NULL) && (g_coords == NULL)) {
|
||||
indent(out, indent_level)
|
||||
<< "No coords\n";
|
||||
} else if (i_coords!=(ushort*)0L) {
|
||||
indent(out, indent_level)
|
||||
<< "Indexed coords = " << (void *)g_coords << ", length = "
|
||||
<< g_coords.size() << ":\n";
|
||||
describe_attr(out, this, bind_coords, i_coords, false, indent_level + 2);
|
||||
describe_attr(out, this, G_PER_VERTEX, i_coords, false, indent_level + 2);
|
||||
} else {
|
||||
indent(out, indent_level)
|
||||
<< "Nonindexed coords:\n";
|
||||
describe_attr(out, this, bind_coords, g_coords, true, indent_level + 2);
|
||||
describe_attr(out, this, G_PER_VERTEX, g_coords, true, indent_level + 2);
|
||||
}
|
||||
|
||||
if (bind_colors == G_OFF) {
|
||||
|
|
|
|||
|
|
@ -140,11 +140,13 @@ public:
|
|||
|
||||
void get_min_max(Vertexf &min, Vertexf &max) const;
|
||||
|
||||
|
||||
void set_coords(const PTA_Vertexf &coords,
|
||||
GeomBindType bind,
|
||||
const PTA_ushort &vindex =
|
||||
PTA_ushort());
|
||||
const PTA_ushort &vindex =
|
||||
PTA_ushort());
|
||||
void set_coords(const PTA_Vertexf &coords,
|
||||
GeomBindType bind,
|
||||
const PTA_ushort &vindex =
|
||||
PTA_ushort());
|
||||
void set_normals(const PTA_Normalf &norms,
|
||||
GeomBindType bind,
|
||||
const PTA_ushort &nindex =
|
||||
|
|
@ -161,6 +163,10 @@ public:
|
|||
void get_coords(PTA_Vertexf &coords,
|
||||
GeomBindType &bind,
|
||||
PTA_ushort &vindex) const;
|
||||
|
||||
void get_coords(PTA_Vertexf &coords,
|
||||
PTA_ushort &vindex) const;
|
||||
|
||||
void get_normals(PTA_Normalf &norms,
|
||||
GeomBindType &bind,
|
||||
PTA_ushort &nindex) const;
|
||||
|
|
|
|||
|
|
@ -211,10 +211,10 @@ draw_immediate(GraphicsStateGuardianBase *gsg, GeomContext *gc) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
Geom *GeomTrifan::
|
||||
explode() const {
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_Normalf normals(0);
|
||||
PTA_TexCoordf texcoords(0);
|
||||
PTA_Colorf colors(0);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(0);
|
||||
PTA_Normalf normals=PTA_Normalf::empty_array(0);
|
||||
PTA_TexCoordf texcoords=PTA_TexCoordf::empty_array(0);
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(0);
|
||||
|
||||
VertexIterator vi = make_vertex_iterator();
|
||||
NormalIterator ni = make_normal_iterator();
|
||||
|
|
@ -295,12 +295,12 @@ explode() const {
|
|||
}
|
||||
|
||||
// Per-vertex attributes.
|
||||
if (get_binding(G_COORD) == G_PER_VERTEX) {
|
||||
f3vertex[2] = get_next_vertex(vi);
|
||||
coords.push_back(f3vertex[0]);
|
||||
coords.push_back(f3vertex[1]);
|
||||
coords.push_back(f3vertex[2]);
|
||||
}
|
||||
assert(get_binding(G_COORD) == G_PER_VERTEX);
|
||||
f3vertex[2] = get_next_vertex(vi);
|
||||
coords.push_back(f3vertex[0]);
|
||||
coords.push_back(f3vertex[1]);
|
||||
coords.push_back(f3vertex[2]);
|
||||
|
||||
if (get_binding(G_NORMAL) == G_PER_VERTEX) {
|
||||
f3normal[2] = get_next_normal(ni);
|
||||
normals.push_back(f3normal[0]);
|
||||
|
|
@ -323,7 +323,8 @@ explode() const {
|
|||
}
|
||||
|
||||
Geom *tris = new GeomTri;
|
||||
tris->set_coords(coords, get_binding(G_COORD));
|
||||
tris->set_coords(coords);
|
||||
|
||||
tris->set_normals(normals,
|
||||
get_binding(G_NORMAL) == G_PER_COMPONENT ?
|
||||
G_PER_PRIM : get_binding(G_NORMAL));
|
||||
|
|
|
|||
|
|
@ -298,10 +298,10 @@ GeomTristrip::get_num_tris() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
Geom *GeomTristrip::
|
||||
explode() const {
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_Normalf normals(0);
|
||||
PTA_TexCoordf texcoords(0);
|
||||
PTA_Colorf colors(0);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(0);
|
||||
PTA_Normalf normals=PTA_Normalf::empty_array(0);
|
||||
PTA_TexCoordf texcoords=PTA_TexCoordf::empty_array(0);
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(0);
|
||||
|
||||
VertexIterator vi = make_vertex_iterator();
|
||||
NormalIterator ni = make_normal_iterator();
|
||||
|
|
@ -420,7 +420,7 @@ explode() const {
|
|||
}
|
||||
|
||||
Geom *tris = new GeomTri;
|
||||
tris->set_coords(coords, get_binding(G_COORD));
|
||||
tris->set_coords(coords);
|
||||
tris->set_normals(normals,
|
||||
get_binding(G_NORMAL) == G_PER_COMPONENT ?
|
||||
G_PER_PRIM : get_binding(G_NORMAL));
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ make_geometry(const Colorf &color,
|
|||
lbf = yf + ((zb + xl) * fs);
|
||||
rbf = yf + ((zb + xr) * fs);
|
||||
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_ushort vindex(0);
|
||||
PTA_Colorf colors(0);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(0);
|
||||
PTA_ushort vindex=PTA_ushort::empty_array(0);
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(0);
|
||||
|
||||
// We just specify overall color
|
||||
colors.push_back(color);
|
||||
|
|
@ -121,7 +121,7 @@ make_geometry(const Colorf &color,
|
|||
vindex.push_back(8); vindex.push_back(7);
|
||||
|
||||
GeomLine* gline = new GeomLine;
|
||||
gline->set_coords(coords, G_PER_VERTEX, vindex);
|
||||
gline->set_coords(coords, vindex);
|
||||
gline->set_colors(colors, G_OVERALL);
|
||||
gline->set_num_prims(12);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ make_geometry(const Colorf &color,
|
|||
lbf = yf + ((zb + xl) * fs);
|
||||
rbf = yf + ((zb + xr) * fs);
|
||||
|
||||
PTA_Vertexf coords(0);
|
||||
PTA_ushort vindex(0);
|
||||
PTA_Colorf colors(0);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(0);
|
||||
PTA_ushort vindex=PTA_ushort::empty_array(0);
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(0);
|
||||
|
||||
// We just specify overall color
|
||||
colors.push_back(color);
|
||||
|
|
@ -122,7 +122,7 @@ make_geometry(const Colorf &color,
|
|||
vindex.push_back(8); vindex.push_back(7);
|
||||
|
||||
GeomLine* gline = new GeomLine;
|
||||
gline->set_coords(coords, G_PER_VERTEX, vindex);
|
||||
gline->set_coords(coords, vindex);
|
||||
gline->set_colors(colors, G_OVERALL);
|
||||
gline->set_num_prims(12);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pixelBuffer.h"
|
||||
#include "config_gobj.h"
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ PixelBuffer(int xsize, int ysize, int components, int component_width,
|
|||
_component_width = component_width;
|
||||
_type = type;
|
||||
_format = format;
|
||||
_image = PTA_uchar(_xsize * _ysize * _components * _component_width);
|
||||
_image = PTA_uchar::empty_array((unsigned int)(_xsize * _ysize * _components * _component_width));
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +220,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
|
|||
// Most common case: one byte per pixel, and the source image
|
||||
// shows a maxval of 255. No scaling is necessary.
|
||||
_type = T_unsigned_byte;
|
||||
_image = PTA_uchar(_xsize * _ysize * _components);
|
||||
_image = PTA_uchar::empty_array((int)(_xsize * _ysize * _components));
|
||||
int idx = 0;
|
||||
|
||||
for (int j = _ysize-1; j >= 0; j--) {
|
||||
|
|
@ -241,7 +242,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
|
|||
// Another possible case: two bytes per pixel, and the source
|
||||
// image shows a maxval of 65535. Again, no scaling is necessary.
|
||||
_type = T_unsigned_short;
|
||||
_image = PTA_uchar(_xsize * _ysize * _components * 2);
|
||||
// _image = PTA_uchar::empty_array(_xsize * _ysize * _components * 2);
|
||||
int idx = 0;
|
||||
|
||||
for (int j = _ysize-1; j >= 0; j--) {
|
||||
|
|
@ -264,7 +265,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
|
|||
// something other than 255. In this case, we should scale the
|
||||
// pixel values up to the appropriate amount.
|
||||
_type = T_unsigned_byte;
|
||||
_image = PTA_uchar(_xsize * _ysize * _components);
|
||||
_image = PTA_uchar::empty_array(_xsize * _ysize * _components);
|
||||
int idx = 0;
|
||||
double scale = 255.0 / (double)maxval;
|
||||
|
||||
|
|
@ -288,7 +289,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
|
|||
// something other than 65535. Again, we must scale the pixel
|
||||
// values.
|
||||
_type = T_unsigned_short;
|
||||
_image = PTA_uchar(_xsize * _ysize * _components * 2);
|
||||
_image = PTA_uchar::empty_array(_xsize * _ysize * _components * 2);
|
||||
int idx = 0;
|
||||
double scale = 65535.0 / (double)maxval;
|
||||
|
||||
|
|
@ -384,7 +385,7 @@ copy(const PixelBuffer *pb) {
|
|||
_border = pb->_border;
|
||||
_components = pb->_components;
|
||||
_format = pb->_format;
|
||||
_image = PTA_uchar(0);
|
||||
_image = PTA_uchar::empty_array(0);
|
||||
if (!pb->_image.empty())
|
||||
_image.v() = pb->_image.v();
|
||||
}
|
||||
|
|
@ -411,3 +412,4 @@ void PixelBuffer::draw(GraphicsStateGuardianBase *gsg, const DisplayRegion *dr,
|
|||
const RenderBuffer &rb) {
|
||||
gsg->draw_pixel_buffer(this, dr, rb);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@
|
|||
void CardMaker::
|
||||
reset() {
|
||||
_has_uvs = true;
|
||||
_ll.set(0.0, 0.0);
|
||||
_ur.set(1.0, 1.0);
|
||||
_frame.set(0.0, 1.0, 0.0, 1.0);
|
||||
_ll.set(0.0f, 0.0f);
|
||||
_ur.set(1.0f, 1.0f);
|
||||
_frame.set(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
_has_color = false;
|
||||
_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_source_geometry = (Node *)NULL;
|
||||
_source_frame.set(0.0, 0.0, 0.0, 0.0);
|
||||
_source_frame.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,19 +64,19 @@ generate() {
|
|||
float bottom = _frame[2];
|
||||
float top = _frame[3];
|
||||
|
||||
PTA_int lengths(0);
|
||||
PTA_int lengths=PTA_int::empty_array(0);
|
||||
lengths.push_back(4);
|
||||
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(Vertexf::rfu(left, 0.0, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.0, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.0, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf::rfu(left, 0.0f, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.0f, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.0f, bottom));
|
||||
|
||||
geom->set_num_prims(1);
|
||||
geom->set_lengths(lengths);
|
||||
|
||||
geom->set_coords(verts, G_PER_VERTEX);
|
||||
geom->set_coords(verts);
|
||||
|
||||
PTA_Colorf colors;
|
||||
colors.push_back(_color);
|
||||
|
|
@ -107,20 +107,20 @@ rescale_source_geometry() {
|
|||
new RenderRelation(root, _source_geometry->copy_subgraph(RenderRelation::get_class_type()));
|
||||
|
||||
// Determine the translate and scale appropriate for our geometry.
|
||||
float geom_center_x = (_source_frame[0] + _source_frame[1]) / 2.0;
|
||||
float geom_center_y = (_source_frame[2] + _source_frame[3]) / 2.0;
|
||||
float geom_center_x = (_source_frame[0] + _source_frame[1]) * 0.5f;
|
||||
float geom_center_y = (_source_frame[2] + _source_frame[3]) * 0.5f;
|
||||
|
||||
float frame_center_x = (_frame[0] + _frame[1]) / 2.0;
|
||||
float frame_center_y = (_frame[2] + _frame[3]) / 2.0;
|
||||
float frame_center_x = (_frame[0] + _frame[1]) * 0.5f;
|
||||
float frame_center_y = (_frame[2] + _frame[3]) * 0.5f;
|
||||
|
||||
float scale_x =
|
||||
(_frame[1] - _frame[0]) / (_source_frame[1] - _source_frame[0]);
|
||||
float scale_y =
|
||||
(_frame[3] - _frame[2]) / (_source_frame[3] - _source_frame[2]);
|
||||
|
||||
LVector3f trans = LVector3f::rfu(frame_center_x - geom_center_x, 0.0,
|
||||
LVector3f trans = LVector3f::rfu(frame_center_x - geom_center_x, 0.0f,
|
||||
frame_center_y - geom_center_y);
|
||||
LVector3f scale = LVector3f::rfu(scale_x, 1.0, scale_y);
|
||||
LVector3f scale = LVector3f::rfu(scale_x, 1.0f, scale_y);
|
||||
|
||||
LMatrix4f mat =
|
||||
LMatrix4f::scale_mat(scale) *
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
LineSegs::
|
||||
LineSegs() {
|
||||
_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_thick = 1.0;
|
||||
_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_thick = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ const Vertexf &LineSegs::
|
|||
get_current_position() {
|
||||
if (_list.empty()) {
|
||||
// Our pen isn't anywhere. We'll put it somewhere.
|
||||
move_to(Vertexf(0.0, 0.0, 0.0));
|
||||
move_to(Vertexf(0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
return _list.back().back()._point;
|
||||
|
|
@ -202,7 +202,7 @@ create(GeomNode *previous, bool) {
|
|||
}
|
||||
|
||||
geom->set_colors(_created_colors, G_PER_VERTEX, line_index);
|
||||
geom->set_coords(_created_verts, G_PER_VERTEX, line_index);
|
||||
geom->set_coords(_created_verts, line_index);
|
||||
|
||||
previous->add_geom(geom);
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ create(GeomNode *previous, bool) {
|
|||
geom->set_num_prims(point_index.size());
|
||||
geom->set_size(_thick);
|
||||
geom->set_colors(_created_colors, G_PER_VERTEX, point_index);
|
||||
geom->set_coords(_created_verts, G_PER_VERTEX, point_index);
|
||||
geom->set_coords(_created_verts, point_index);
|
||||
|
||||
previous->add_geom(geom);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,26 +183,26 @@ make_geometry(float intensity, float length, int num_facets)
|
|||
{
|
||||
Colorf diffuse = _color;
|
||||
diffuse[3] = intensity;
|
||||
Colorf black(0.0, 0.0, 0.0, intensity);
|
||||
Colorf black(0.0f, 0.0f, 0.0f, intensity);
|
||||
float radius = length * (float)tan(deg_2_rad(get_cutoff_angle()));
|
||||
float ang_inc = 2.0f*MathNumbers::pi_f / (float)num_facets;
|
||||
int num_verts = num_facets + 1;
|
||||
int num_indices = num_facets + 2;
|
||||
LVector3f offset(0.0, length, 0.0);
|
||||
LPoint3f first_last_vert(radius, length, 0.0);
|
||||
LVector3f offset(0.0f, length, 0.0f);
|
||||
LPoint3f first_last_vert(radius, length, 0.0f);
|
||||
|
||||
PTA_Vertexf coords(num_verts);
|
||||
PTA_ushort vindex(num_indices);
|
||||
PTA_Colorf colors(2);
|
||||
PTA_ushort cindex(num_indices);
|
||||
PTA_int lengths(1);
|
||||
PTA_Vertexf coords=PTA_Vertexf::empty_array(num_verts);
|
||||
PTA_ushort vindex=PTA_ushort::empty_array(num_indices);
|
||||
PTA_Colorf colors=PTA_Colorf::empty_array(2);
|
||||
PTA_ushort cindex=PTA_ushort::empty_array(num_indices);
|
||||
PTA_int lengths=PTA_int::empty_array(1);
|
||||
|
||||
lengths[0] = num_indices;
|
||||
|
||||
float ang = ang_inc;
|
||||
LPoint3f origin(0.0, 0.0, 0.0);
|
||||
LVector3f x_axis(1.0, 0.0, 0.0);
|
||||
LVector3f z_axis(0.0, 0.0, 1.0);
|
||||
LPoint3f origin(0.0f, 0.0f, 0.0f);
|
||||
LVector3f x_axis(1.0f, 0.0f, 0.0f);
|
||||
LVector3f z_axis(0.0f, 0.0f, 1.0f);
|
||||
LPoint3f dx, dz;
|
||||
float t;
|
||||
|
||||
|
|
@ -214,8 +214,9 @@ make_geometry(float intensity, float length, int num_facets)
|
|||
|
||||
int i;
|
||||
for (i = 2; i < num_indices-1; i++) {
|
||||
float sine,cosine;
|
||||
csincos(ang,&sine,&cosine);
|
||||
float sine,cosine;
|
||||
|
||||
csincos(ang,&sine,&cosine);
|
||||
t = cosine * radius;
|
||||
dx = x_axis * t;
|
||||
t = sine * radius;
|
||||
|
|
@ -232,7 +233,7 @@ make_geometry(float intensity, float length, int num_facets)
|
|||
cindex[i] = 1;
|
||||
|
||||
GeomTrifan* tfan = new GeomTrifan;
|
||||
tfan->set_coords(coords, G_PER_VERTEX, vindex);
|
||||
tfan->set_coords(coords, vindex);
|
||||
tfan->set_colors(colors, G_PER_VERTEX, cindex);
|
||||
tfan->set_num_prims(1);
|
||||
tfan->set_lengths(lengths);
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ kill_particle(int) {
|
|||
|
||||
void LineParticleRenderer::
|
||||
resize_pool(int new_size) {
|
||||
_vertex_array = PTA_Vertexf(new_size * 2);
|
||||
_color_array = PTA_Colorf(new_size * 2);
|
||||
_vertex_array = PTA_Vertexf::empty_array(new_size * 2);
|
||||
_color_array = PTA_Colorf::empty_array(new_size * 2);
|
||||
|
||||
_line_primitive->set_coords(_vertex_array, G_PER_VERTEX);
|
||||
_line_primitive->set_coords(_vertex_array);
|
||||
_line_primitive->set_colors(_color_array, G_PER_VERTEX);
|
||||
|
||||
_max_pool_size = new_size;
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ resize_pool(int new_size) {
|
|||
|
||||
_max_pool_size = new_size;
|
||||
|
||||
_vertex_array = PTA_Vertexf(new_size);
|
||||
_color_array = PTA_Colorf(new_size);
|
||||
_vertex_array = PTA_Vertexf::empty_array(new_size);
|
||||
_color_array = PTA_Colorf::empty_array(new_size);
|
||||
|
||||
_point_primitive->set_coords(_vertex_array, G_PER_VERTEX);
|
||||
_point_primitive->set_coords(_vertex_array);
|
||||
_point_primitive->set_colors(_color_array, G_PER_VERTEX);
|
||||
|
||||
init_geoms();
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ kill_particle(int) {
|
|||
|
||||
void SparkleParticleRenderer::
|
||||
resize_pool(int new_size) {
|
||||
_vertex_array = PTA_Vertexf(new_size * 12);
|
||||
_color_array = PTA_Colorf(new_size * 12);
|
||||
_vertex_array = PTA_Vertexf::empty_array(new_size * 12);
|
||||
_color_array = PTA_Colorf::empty_array(new_size * 12);
|
||||
|
||||
_line_primitive->set_coords(_vertex_array, G_PER_VERTEX);
|
||||
_line_primitive->set_coords(_vertex_array);
|
||||
_line_primitive->set_colors(_color_array, G_PER_VERTEX);
|
||||
|
||||
_max_pool_size = new_size;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ get_source_type() const {
|
|||
INLINE void SpriteParticleRenderer::
|
||||
set_texture(Texture *tex) {
|
||||
_sprite_primitive->set_texture(tex);
|
||||
_sprite_primitive->set_ll_uv(TexCoordf(0.0, 0.0));
|
||||
_sprite_primitive->set_ur_uv(TexCoordf(1.0, 1.0));
|
||||
_sprite_primitive->set_ll_uv(TexCoordf(0.0f, 0.0f));
|
||||
_sprite_primitive->set_ur_uv(TexCoordf(1.0f, 1.0f));
|
||||
_source_type = ST_texture;
|
||||
}
|
||||
|
||||
|
|
@ -82,11 +82,11 @@ set_color(const Colorf &color) {
|
|||
INLINE void SpriteParticleRenderer::
|
||||
set_x_scale_flag(bool animate_x_ratio) {
|
||||
if (animate_x_ratio == true && _animate_x_ratio == false) {
|
||||
_x_texel_array = PTA_float(_pool_size);
|
||||
_x_texel_array = PTA_float::empty_array(_pool_size);
|
||||
_sprite_primitive->set_x_texel_ratio(_x_texel_array, G_PER_PRIM);
|
||||
}
|
||||
else if (animate_x_ratio == false && _animate_x_ratio == true) {
|
||||
_x_texel_array = PTA_float(1);
|
||||
_x_texel_array = PTA_float::empty_array(1);
|
||||
_sprite_primitive->set_x_texel_ratio(_x_texel_array, G_OVERALL);
|
||||
}
|
||||
|
||||
|
|
@ -100,11 +100,11 @@ set_x_scale_flag(bool animate_x_ratio) {
|
|||
INLINE void SpriteParticleRenderer::
|
||||
set_y_scale_flag(bool animate_y_ratio) {
|
||||
if (animate_y_ratio == true && _animate_y_ratio == false) {
|
||||
_y_texel_array = PTA_float(_pool_size);
|
||||
_y_texel_array = PTA_float::empty_array(_pool_size);
|
||||
_sprite_primitive->set_y_texel_ratio(_y_texel_array, G_PER_PRIM);
|
||||
}
|
||||
else if (animate_y_ratio == false && _animate_y_ratio == true) {
|
||||
_y_texel_array = PTA_float(1);
|
||||
_y_texel_array = PTA_float::empty_array(1);
|
||||
_sprite_primitive->set_y_texel_ratio(_y_texel_array, G_OVERALL);
|
||||
}
|
||||
|
||||
|
|
@ -118,11 +118,11 @@ set_y_scale_flag(bool animate_y_ratio) {
|
|||
INLINE void SpriteParticleRenderer::
|
||||
set_anim_angle_flag(bool animate_theta) {
|
||||
if (animate_theta == true && _animate_theta == false) {
|
||||
_theta_array = PTA_float(_pool_size);
|
||||
_theta_array = PTA_float::empty_array(_pool_size);
|
||||
_sprite_primitive->set_thetas(_theta_array, G_PER_PRIM);
|
||||
}
|
||||
else if (animate_theta == false && _animate_theta == true) {
|
||||
_theta_array = PTA_float(_pool_size);
|
||||
_theta_array = PTA_float::empty_array(_pool_size);
|
||||
_sprite_primitive->set_thetas(_theta_array, G_OVERALL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,38 +197,38 @@ resize_pool(int new_size) {
|
|||
|
||||
// handle the x texel ratio
|
||||
if (_animate_x_ratio == true) {
|
||||
_x_texel_array = PTA_float(new_size);
|
||||
_x_texel_array = PTA_float::empty_array(new_size);
|
||||
_x_bind = G_PER_PRIM;
|
||||
}
|
||||
else {
|
||||
_x_texel_array = PTA_float(1);
|
||||
_x_texel_array = PTA_float::empty_array(1);
|
||||
_x_bind = G_OVERALL;
|
||||
}
|
||||
|
||||
// handle the y texel ratio
|
||||
if (_animate_y_ratio == true) {
|
||||
_y_texel_array = PTA_float(new_size);
|
||||
_y_texel_array = PTA_float::empty_array(new_size);
|
||||
_y_bind = G_PER_PRIM;
|
||||
}
|
||||
else {
|
||||
_y_texel_array = PTA_float(1);
|
||||
_y_texel_array = PTA_float::empty_array(1);
|
||||
_y_bind = G_OVERALL;
|
||||
}
|
||||
|
||||
// handle the theta vector
|
||||
if (_animate_theta == true) {
|
||||
_theta_array = PTA_float(new_size);
|
||||
_theta_array = PTA_float::empty_array(new_size);
|
||||
_theta_bind = G_PER_PRIM;
|
||||
}
|
||||
else {
|
||||
_theta_array = PTA_float(1);
|
||||
_theta_array = PTA_float::empty_array(1);
|
||||
_theta_bind = G_OVERALL;
|
||||
}
|
||||
|
||||
_vertex_array = PTA_Vertexf(new_size);
|
||||
_color_array = PTA_Colorf(new_size);
|
||||
_vertex_array = PTA_Vertexf::empty_array(new_size);
|
||||
_color_array = PTA_Colorf::empty_array(new_size);
|
||||
|
||||
_sprite_primitive->set_coords(_vertex_array, G_PER_VERTEX);
|
||||
_sprite_primitive->set_coords(_vertex_array);
|
||||
_sprite_primitive->set_colors(_color_array, G_PER_PRIM);
|
||||
_sprite_primitive->set_x_texel_ratio(_x_texel_array, _x_bind);
|
||||
_sprite_primitive->set_y_texel_ratio(_y_texel_array, _y_bind);
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ setup(const string &label) {
|
|||
PT_Node geom = text_node->generate();
|
||||
|
||||
LVecBase4f frame = text_node->get_card_actual();
|
||||
set_frame(frame[0] - 0.4, frame[1] + 0.4, frame[2] - 0.15, frame[3] + 0.15);
|
||||
set_frame(frame[0] - 0.4f, frame[1] + 0.4f, frame[2] - 0.15f, frame[3] + 0.15f);
|
||||
|
||||
new RenderRelation(get_state_def(S_ready), geom);
|
||||
NodeRelation *down = new RenderRelation(get_state_def(S_depressed), geom);
|
||||
|
|
@ -198,24 +198,24 @@ setup(const string &label) {
|
|||
NodeRelation *inact = new RenderRelation(get_state_def(S_inactive), geom);
|
||||
|
||||
PGFrameStyle style;
|
||||
style.set_color(0.8, 0.8, 0.8, 1.0);
|
||||
style.set_width(0.1, 0.1);
|
||||
style.set_color(0.8f, 0.8f, 0.8f, 1.0);
|
||||
style.set_width(0.1f, 0.1f);
|
||||
|
||||
style.set_type(PGFrameStyle::T_bevel_out);
|
||||
set_frame_style(S_ready, style);
|
||||
|
||||
style.set_color(0.9, 0.9, 0.9, 1.0);
|
||||
style.set_color(0.9f, 0.9f, 0.9f, 1.0);
|
||||
set_frame_style(S_rollover, style);
|
||||
|
||||
ColorTransition *ct = new ColorTransition(Colorf(0.8, 0.8, 0.8, 1.0));
|
||||
ColorTransition *ct = new ColorTransition(Colorf(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
inact->set_transition(ct);
|
||||
style.set_color(0.6, 0.6, 0.6, 1.0);
|
||||
style.set_color(0.6f, 0.6f, 0.6f, 1.0);
|
||||
set_frame_style(S_inactive, style);
|
||||
|
||||
style.set_type(PGFrameStyle::T_bevel_in);
|
||||
style.set_color(0.8, 0.8, 0.8, 1.0);
|
||||
style.set_color(0.8f, 0.8f, 0.8f, 1.0);
|
||||
set_frame_style(S_depressed, style);
|
||||
LMatrix4f translate = LMatrix4f::translate_mat(0.05, 0.0, -0.05);
|
||||
LMatrix4f translate = LMatrix4f::translate_mat(0.05f, 0.0f, -0.05f);
|
||||
TransformTransition *tt = new TransformTransition(translate);
|
||||
down->set_transition(tt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ PGEntry(const string &name) : PGItem(name)
|
|||
_cursor_position = 0;
|
||||
_cursor_stale = true;
|
||||
_max_chars = 0;
|
||||
_max_width = 0.0;
|
||||
_max_width = 0.0f;
|
||||
_num_lines = 1;
|
||||
_last_text_def = (TextNode *)NULL;
|
||||
_text_geom_stale = true;
|
||||
_blink_start = 0.0;
|
||||
_blink_rate = 1.0;
|
||||
_blink_start = 0.0f;
|
||||
_blink_rate = 1.0f;
|
||||
|
||||
_text_render_root = new NamedNode("text_root");
|
||||
_current_text_arc = (NodeRelation *)NULL;
|
||||
|
|
@ -262,7 +262,7 @@ press(const MouseWatcherParameter ¶m, bool background) {
|
|||
|
||||
// Check the length.
|
||||
bool too_long = false;
|
||||
if (_max_width > 0.0) {
|
||||
if (_max_width > 0.0f) {
|
||||
TextNode *text_node = get_text_def(S_focus);
|
||||
if (_num_lines <= 1) {
|
||||
// If we have only one line, we can check the length
|
||||
|
|
@ -420,10 +420,10 @@ setup(float width, int num_lines) {
|
|||
float line_height = text_node->get_line_height();
|
||||
|
||||
// Define determine the four corners of the frame.
|
||||
LPoint3f ll(0.0, 0.0, -0.3 * line_height - (line_height * (num_lines - 1)));
|
||||
LPoint3f ur(width, 0.0, line_height);
|
||||
LPoint3f lr(ur[0], 0.0, ll[2]);
|
||||
LPoint3f ul(ll[0], 0.0, ur[2]);
|
||||
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]);
|
||||
|
||||
// Transform each corner by the TextNode's transform.
|
||||
LMatrix4f mat = text_node->get_transform();
|
||||
|
|
@ -453,31 +453,31 @@ setup(float width, int num_lines) {
|
|||
|
||||
case TM_ALIGN_RIGHT:
|
||||
frame[0] = -width;
|
||||
frame[1] = 0.0;
|
||||
frame[1] = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
set_frame(frame[0] - 0.15, frame[1] + 0.15, frame[2], frame[3]);
|
||||
set_frame(frame[0] - 0.15f, frame[1] + 0.15f, frame[2], frame[3]);
|
||||
|
||||
PGFrameStyle style;
|
||||
style.set_width(0.1, 0.1);
|
||||
style.set_width(0.1f, 0.1f);
|
||||
style.set_type(PGFrameStyle::T_bevel_in);
|
||||
style.set_color(0.8, 0.8, 0.8, 1.0);
|
||||
style.set_color(0.8f, 0.8f, 0.8f, 1.0f);
|
||||
|
||||
set_frame_style(S_no_focus, style);
|
||||
|
||||
style.set_color(0.9, 0.9, 0.9, 1.0);
|
||||
style.set_color(0.9f, 0.9f, 0.9f, 1.0f);
|
||||
set_frame_style(S_focus, style);
|
||||
|
||||
style.set_color(0.6, 0.6, 0.6, 1.0);
|
||||
style.set_color(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
set_frame_style(S_inactive, style);
|
||||
|
||||
// Set up a default cursor: a vertical bar.
|
||||
clear_cursor_def();
|
||||
LineSegs ls;
|
||||
ls.set_color(0.0, 0.0, 0.0, 1.0);
|
||||
ls.move_to(0.0, 0.0, -0.15 * line_height);
|
||||
ls.draw_to(0.0, 0.0, 0.85 * line_height);
|
||||
ls.set_color(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ls.move_to(0.0f, 0.0f, -0.15f * line_height);
|
||||
ls.draw_to(0.0f, 0.0f, 0.85f * line_height);
|
||||
new RenderRelation(get_cursor_def(), ls.create());
|
||||
|
||||
// An underscore cursor would work too.
|
||||
|
|
@ -501,7 +501,7 @@ setup(float width, int num_lines) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void PGEntry::
|
||||
set_text_def(int state, TextNode *node) {
|
||||
nassertv(state >= 0 && state < 1000); // Sanity check.
|
||||
nassertv(state >= 0 && state < 1.0f); // Sanity check.
|
||||
if (node == (TextNode *)NULL && state >= (int)_text_defs.size()) {
|
||||
// If we're setting it to NULL, we don't need to slot a new one.
|
||||
return;
|
||||
|
|
@ -614,7 +614,7 @@ update_text() {
|
|||
// We need to regenerate.
|
||||
_last_text_def = node;
|
||||
|
||||
if (_max_width > 0.0 && _num_lines > 1) {
|
||||
if (_max_width > 0.0f && _num_lines > 1) {
|
||||
// Fold the text into multiple lines.
|
||||
string ww_text =
|
||||
_last_text_def->wordwrap_to(display_text, _max_width, true);
|
||||
|
|
@ -629,7 +629,7 @@ update_text() {
|
|||
line._str = ww_text.substr(p, q - p);
|
||||
|
||||
// Get the left edge of the text at this line.
|
||||
line._left = 0.0;
|
||||
line._left = 0.0f;
|
||||
if (_last_text_def->get_align() != TM_ALIGN_LEFT) {
|
||||
_last_text_def->set_text(line._str);
|
||||
line._left = _last_text_def->get_left();
|
||||
|
|
@ -643,7 +643,7 @@ update_text() {
|
|||
line._str = ww_text.substr(p);
|
||||
|
||||
// Get the left edge of the text at this line.
|
||||
line._left = 0.0;
|
||||
line._left = 0.0f;
|
||||
if (_last_text_def->get_align() != TM_ALIGN_LEFT) {
|
||||
_last_text_def->set_text(line._str);
|
||||
line._left = _last_text_def->get_left();
|
||||
|
|
@ -703,7 +703,7 @@ update_cursor() {
|
|||
_last_text_def->calc_width(_ww_lines[row]._str.substr(0, column));
|
||||
float line_height = _last_text_def->get_line_height();
|
||||
|
||||
LVecBase3f trans(_ww_lines[row]._left + width, 0.0, -line_height * row);
|
||||
LVecBase3f trans(_ww_lines[row]._left + width, 0.0f, -line_height * row);
|
||||
LMatrix4f mat = LMatrix4f::translate_mat(trans) * node->get_transform();
|
||||
_cursor_def->set_transition(new TransformTransition(mat));
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ generate_into(Node *node, const LVecBase4f &frame) {
|
|||
arc = new RenderRelation(node, gnode, -1);
|
||||
}
|
||||
|
||||
if (arc != (NodeRelation *)NULL && _color[3] != 1.0) {
|
||||
if (arc != (NodeRelation *)NULL && _color[3] != 1.0f) {
|
||||
// We've got some alpha on the color; we need transparency.
|
||||
TransparencyProperty::Mode mode = TransparencyProperty::M_alpha;
|
||||
TransparencyTransition *tt = new TransparencyTransition(mode);
|
||||
|
|
@ -174,19 +174,19 @@ generate_flat_geom(const LVecBase4f &frame) {
|
|||
float bottom = frame[2];
|
||||
float top = frame[3];
|
||||
|
||||
PTA_int lengths(0);
|
||||
PTA_int lengths=PTA_int::empty_array(0);
|
||||
lengths.push_back(4);
|
||||
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(Vertexf(left, 0.0, top));
|
||||
verts.push_back(Vertexf(left, 0.0, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
|
||||
geom->set_num_prims(1);
|
||||
geom->set_lengths(lengths);
|
||||
|
||||
geom->set_coords(verts, G_PER_VERTEX);
|
||||
geom->set_coords(verts);
|
||||
|
||||
PTA_Colorf colors;
|
||||
colors.push_back(_color);
|
||||
|
|
@ -316,14 +316,14 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) {
|
|||
// Tristrip 1.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0, bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0, top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cbottom);
|
||||
|
|
@ -335,12 +335,12 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) {
|
|||
// Tristrip 2.
|
||||
lengths.push_back(6);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cright);
|
||||
|
|
@ -349,7 +349,7 @@ generate_bevel_geom(const LVecBase4f &frame, bool in) {
|
|||
|
||||
geom->set_num_prims(2);
|
||||
geom->set_lengths(lengths);
|
||||
geom->set_coords(verts, G_PER_VERTEX);
|
||||
geom->set_coords(verts);
|
||||
geom->set_colors(colors, G_PER_COMPONENT);
|
||||
|
||||
return gnode.p();
|
||||
|
|
@ -468,26 +468,26 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
|||
float bottom = frame[2];
|
||||
float top = frame[3];
|
||||
|
||||
float mid_left = left + 0.5 * _width[0];
|
||||
float mid_right = right - 0.5 * _width[0];
|
||||
float mid_bottom = bottom + 0.5 * _width[1];
|
||||
float mid_top = top - 0.5 * _width[1];
|
||||
float mid_left = left + 0.5f * _width[0];
|
||||
float mid_right = right - 0.5f * _width[0];
|
||||
float mid_bottom = bottom + 0.5f * _width[1];
|
||||
float mid_top = top - 0.5f * _width[1];
|
||||
|
||||
float inner_left = left + _width[0];
|
||||
float inner_right = right - _width[0];
|
||||
float inner_bottom = bottom + _width[1];
|
||||
float inner_top = top - _width[1];
|
||||
|
||||
float left_color_scale = 1.2;
|
||||
float right_color_scale = 0.8;
|
||||
float bottom_color_scale = 0.7;
|
||||
float top_color_scale = 1.3;
|
||||
float left_color_scale = 1.2f;
|
||||
float right_color_scale = 0.8f;
|
||||
float bottom_color_scale = 0.7f;
|
||||
float top_color_scale = 1.3f;
|
||||
|
||||
if (in) {
|
||||
right_color_scale = 1.2;
|
||||
left_color_scale = 0.8;
|
||||
top_color_scale = 0.7;
|
||||
bottom_color_scale = 1.3;
|
||||
right_color_scale = 1.2f;
|
||||
left_color_scale = 0.8f;
|
||||
top_color_scale = 0.7f;
|
||||
bottom_color_scale = 1.3f;
|
||||
}
|
||||
|
||||
// Clamp all colors at white, and don't scale the alpha.
|
||||
|
|
@ -522,14 +522,14 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
|||
// Tristrip 1.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0, bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0, top));
|
||||
verts.push_back(Vertexf(mid_left, 0.0, mid_top));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
|
||||
colors.push_back(cbottom);
|
||||
colors.push_back(cbottom);
|
||||
|
|
@ -541,14 +541,14 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
|||
// Tristrip 2.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0, mid_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(mid_left, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(ctop);
|
||||
colors.push_back(ctop);
|
||||
|
|
@ -560,14 +560,14 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
|||
// Tristrip 3.
|
||||
lengths.push_back(8);
|
||||
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0, inner_top));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_bottom));
|
||||
verts.push_back(Vertexf(mid_right, 0.0f, mid_top));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_right, 0.0f, inner_top));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_bottom));
|
||||
verts.push_back(Vertexf(inner_left, 0.0f, inner_top));
|
||||
|
||||
colors.push_back(cright);
|
||||
colors.push_back(cright);
|
||||
|
|
@ -578,7 +578,7 @@ generate_groove_geom(const LVecBase4f &frame, bool in) {
|
|||
|
||||
geom->set_num_prims(3);
|
||||
geom->set_lengths(lengths);
|
||||
geom->set_coords(verts, G_PER_VERTEX);
|
||||
geom->set_coords(verts);
|
||||
geom->set_colors(colors, G_PER_COMPONENT);
|
||||
|
||||
return gnode.p();
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
ModifierButtons::
|
||||
ModifierButtons() :
|
||||
_button_list(0),
|
||||
_state(0)
|
||||
{
|
||||
_button_list= PTA(ButtonHandle)::empty_array(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -319,7 +319,8 @@ void ModifierButtons::
|
|||
modify_button_list() {
|
||||
if (_button_list.get_ref_count() > 1) {
|
||||
PTA(ButtonHandle) old_list = _button_list;
|
||||
_button_list = PTA(ButtonHandle)(0);
|
||||
|
||||
_button_list = PTA(ButtonHandle)::empty_array(0);
|
||||
|
||||
// This forces a new allocation and memberwise copy, instead of
|
||||
// just a reference-counting pointer copy.
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ sub_render(NodeRelation *arc, const AllTransitionsWrapper &input_trans,
|
|||
verts.push_back(center);
|
||||
center[0] += sphere->get_radius();
|
||||
verts.push_back(center);
|
||||
geom.set_coords(verts, G_PER_VERTEX);
|
||||
geom.set_coords(verts);
|
||||
geom.set_num_prims(1);
|
||||
|
||||
gsg->draw_sphere(&geom, NULL);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ add_path(const NodePath &node_path) {
|
|||
|
||||
if (_node_paths.get_ref_count() > 1) {
|
||||
PTA(ArcChain) old_node_paths = _node_paths;
|
||||
_node_paths = PTA(ArcChain)(0);
|
||||
_node_paths = PTA(ArcChain)::empty_array(0);
|
||||
_node_paths.v() = old_node_paths.v();
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ remove_path(const NodePath &node_path) {
|
|||
|
||||
if (_node_paths.get_ref_count() > 1) {
|
||||
PTA(ArcChain) old_node_paths = _node_paths;
|
||||
_node_paths = PTA(ArcChain)(0);
|
||||
_node_paths = PTA(ArcChain)::empty_array(0);
|
||||
_node_paths.v() = old_node_paths.v();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ add_geom(dDrawable *geom) {
|
|||
_geoms.push_back(geom);
|
||||
} else {
|
||||
// Copy on write.
|
||||
Geoms new_geoms(0);
|
||||
Geoms new_geoms = Geoms::empty_array(0);
|
||||
if (_geoms.size() != 0) {
|
||||
new_geoms.v() = _geoms.v();
|
||||
}
|
||||
|
|
@ -397,7 +397,7 @@ add_geoms_from(const GeomNode *other) {
|
|||
|
||||
} else {
|
||||
// Copy on write.
|
||||
Geoms new_geoms(0);
|
||||
Geoms new_geoms = Geoms::empty_array(0);
|
||||
if (_geoms.size() != 0) {
|
||||
new_geoms.v() = _geoms.v();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,11 @@ transform_vertices(Geom *geom, const LMatrix4f &mat) {
|
|||
nassertr(geom != (Geom *)NULL, false);
|
||||
|
||||
PTA_Vertexf coords;
|
||||
GeomBindType bind;
|
||||
PTA_ushort index;
|
||||
|
||||
geom->get_coords(coords, bind, index);
|
||||
geom->get_coords(coords, index);
|
||||
|
||||
if (bind != G_OFF) {
|
||||
if (coords != NULL) {
|
||||
// Look up the Geom's coords in our table--have we already
|
||||
// transformed this array?
|
||||
SourceVertices sv;
|
||||
|
|
@ -76,12 +75,13 @@ transform_vertices(Geom *geom, const LMatrix4f &mat) {
|
|||
nassertr(new_coords.size() == coords.size(), false);
|
||||
}
|
||||
|
||||
geom->set_coords(new_coords, bind, index);
|
||||
geom->set_coords(new_coords, index);
|
||||
transformed = true;
|
||||
}
|
||||
|
||||
// Now do the same thing for normals.
|
||||
PTA_Normalf norms;
|
||||
GeomBindType bind;
|
||||
|
||||
geom->get_normals(norms, bind, index);
|
||||
|
||||
|
|
|
|||
|
|
@ -422,9 +422,8 @@ find_characters(Node *root) {
|
|||
// origin of the next character.
|
||||
PTA_Vertexf alist;
|
||||
PTA_ushort ilist;
|
||||
GeomBindType bind;
|
||||
float width;
|
||||
dot->get_coords(alist, bind, ilist);
|
||||
dot->get_coords(alist, ilist);
|
||||
if (ilist.empty()) {
|
||||
width = alist[0][0];
|
||||
} else {
|
||||
|
|
@ -447,8 +446,7 @@ find_characters(Node *root) {
|
|||
// design size indicator.
|
||||
PTA_Vertexf alist;
|
||||
PTA_ushort ilist;
|
||||
GeomBindType bind;
|
||||
dot->get_coords(alist, bind, ilist);
|
||||
dot->get_coords(alist, ilist);
|
||||
if (ilist.empty()) {
|
||||
_font_height = alist[0][2];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -44,34 +44,34 @@ TypeHandle TextNode::_type_handle;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
TextNode::
|
||||
TextNode(const string &name) : NamedNode(name) {
|
||||
_slant = 0.0;
|
||||
_slant = 0.0f;
|
||||
|
||||
_flags = 0;
|
||||
_align = TM_ALIGN_LEFT;
|
||||
_wordwrap_width = 1.0;
|
||||
_wordwrap_width = 1.0f;
|
||||
|
||||
_text_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_frame_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_card_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_shadow_color.set(1.0, 1.0, 1.0, 1.0);
|
||||
_text_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_frame_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_card_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
_shadow_color.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
_frame_width = 1.0;
|
||||
_frame_width = 1.0f;
|
||||
|
||||
_frame_ul.set(0.0, 0.0);
|
||||
_frame_lr.set(0.0, 0.0);
|
||||
_card_ul.set(0.0, 0.0);
|
||||
_card_lr.set(0.0, 0.0);
|
||||
_shadow_offset.set(0.0, 0.0);
|
||||
_frame_ul.set(0.0f, 0.0f);
|
||||
_frame_lr.set(0.0f, 0.0f);
|
||||
_card_ul.set(0.0f, 0.0f);
|
||||
_card_lr.set(0.0f, 0.0f);
|
||||
_shadow_offset.set(0.0f, 0.0f);
|
||||
|
||||
_draw_order = 1;
|
||||
|
||||
_transform = LMatrix4f::ident_mat();
|
||||
_coordinate_system = CS_default;
|
||||
|
||||
_ul2d.set(0.0, 0.0);
|
||||
_lr2d.set(0.0, 0.0);
|
||||
_ul3d.set(0.0, 0.0, 0.0);
|
||||
_lr3d.set(0.0, 0.0, 0.0);
|
||||
_ul2d.set(0.0f, 0.0f);
|
||||
_lr2d.set(0.0f, 0.0f);
|
||||
_ul3d.set(0.0f, 0.0f, 0.0f);
|
||||
_lr3d.set(0.0f, 0.0f, 0.0f);
|
||||
_num_rows = 0;
|
||||
|
||||
_freeze_level = 0;
|
||||
|
|
@ -214,10 +214,10 @@ generate() {
|
|||
// horizontally and vertically, and for each row, there is another
|
||||
// node for each character.
|
||||
|
||||
_ul2d.set(0.0, 0.0);
|
||||
_lr2d.set(0.0, 0.0);
|
||||
_ul3d.set(0.0, 0.0, 0.0);
|
||||
_lr3d.set(0.0, 0.0, 0.0);
|
||||
_ul2d.set(0.0f, 0.0f);
|
||||
_lr2d.set(0.0f, 0.0f);
|
||||
_ul3d.set(0.0f, 0.0f, 0.0f);
|
||||
_lr3d.set(0.0f, 0.0f, 0.0f);
|
||||
_num_rows = 0;
|
||||
|
||||
// Now build a new sub-tree for all the text components.
|
||||
|
|
@ -269,8 +269,8 @@ generate() {
|
|||
_num_rows = num_rows;
|
||||
_ul2d = ul;
|
||||
_lr2d = lr;
|
||||
_ul3d.set(ul[0], 0.0, ul[1]);
|
||||
_lr3d.set(lr[0], 0.0, lr[1]);
|
||||
_ul3d.set(ul[0], 0.0f, ul[1]);
|
||||
_lr3d.set(lr[0], 0.0f, lr[1]);
|
||||
|
||||
_ul3d = _ul3d * _transform;
|
||||
_lr3d = _lr3d * _transform;
|
||||
|
|
@ -286,13 +286,13 @@ generate() {
|
|||
// this will need to be addressed in the future.
|
||||
|
||||
LMatrix4f offset =
|
||||
LMatrix4f::translate_mat(_shadow_offset[0], 0.0, -_shadow_offset[1]);
|
||||
LMatrix4f::translate_mat(_shadow_offset[0], 0.0f, -_shadow_offset[1]);
|
||||
RenderRelation *shadow_arc =
|
||||
new RenderRelation(sub_root, text_root, _draw_order + 1);
|
||||
shadow_arc->set_transition(new TransformTransition(offset));
|
||||
shadow_arc->set_transition(new ColorTransition(_shadow_color));
|
||||
|
||||
if (_shadow_color[3] != 1.0) {
|
||||
if (_shadow_color[3] != 1.0f) {
|
||||
shadow_arc->set_transition
|
||||
(new TransparencyTransition(TransparencyProperty::M_alpha));
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ generate() {
|
|||
RenderRelation *frame_arc =
|
||||
new RenderRelation(sub_root, frame_root, _draw_order + 1);
|
||||
frame_arc->set_transition(new ColorTransition(_frame_color));
|
||||
if (_frame_color[3] != 1.0) {
|
||||
if (_frame_color[3] != 1.0f) {
|
||||
frame_arc->set_transition
|
||||
(new TransparencyTransition(TransparencyProperty::M_alpha));
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ generate() {
|
|||
RenderRelation *card_arc =
|
||||
new RenderRelation(sub_root, card_root, _draw_order);
|
||||
card_arc->set_transition(new ColorTransition(_card_color));
|
||||
if (_card_color[3] != 1.0) {
|
||||
if (_card_color[3] != 1.0f) {
|
||||
card_arc->set_transition
|
||||
(new TransparencyTransition(TransparencyProperty::M_alpha));
|
||||
}
|
||||
|
|
@ -394,10 +394,10 @@ do_rebuild() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void TextNode::
|
||||
do_measure() {
|
||||
_ul2d.set(0.0, 0.0);
|
||||
_lr2d.set(0.0, 0.0);
|
||||
_ul3d.set(0.0, 0.0, 0.0);
|
||||
_lr3d.set(0.0, 0.0, 0.0);
|
||||
_ul2d.set(0.0f, 0.0f);
|
||||
_lr2d.set(0.0f, 0.0f);
|
||||
_ul3d.set(0.0f, 0.0f, 0.0f);
|
||||
_lr3d.set(0.0f, 0.0f, 0.0f);
|
||||
_num_rows = 0;
|
||||
|
||||
if (_text.empty() || _font.is_null()) {
|
||||
|
|
@ -416,8 +416,8 @@ do_measure() {
|
|||
_num_rows = num_rows;
|
||||
_ul2d = ul;
|
||||
_lr2d = lr;
|
||||
_ul3d.set(ul[0], 0.0, ul[1]);
|
||||
_lr3d.set(lr[0], 0.0, lr[1]);
|
||||
_ul3d.set(ul[0], 0.0f, ul[1]);
|
||||
_lr3d.set(lr[0], 0.0f, lr[1]);
|
||||
|
||||
_ul3d = _ul3d * _transform;
|
||||
_lr3d = _lr3d * _transform;
|
||||
|
|
@ -434,15 +434,15 @@ do_measure() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
float TextNode::
|
||||
assemble_row(const char *&source, Node *dest) {
|
||||
nassertr(_font != (TextFont *)NULL, 0.0);
|
||||
nassertr(_font != (TextFont *)NULL, 0.0f);
|
||||
|
||||
float xpos = 0.0;
|
||||
float xpos = 0.0f;
|
||||
while (*source != '\0' && *source != '\n') {
|
||||
int character = (unsigned char)*source;
|
||||
|
||||
if (character == ' ') {
|
||||
// A space is a special case.
|
||||
xpos += 0.25;
|
||||
xpos += 0.25f;
|
||||
|
||||
} else {
|
||||
// A printable character.
|
||||
|
|
@ -465,7 +465,7 @@ assemble_row(const char *&source, Node *dest) {
|
|||
const AllTransitionsWrapper &trans = def->_trans;
|
||||
|
||||
LMatrix4f mat = LMatrix4f::ident_mat();
|
||||
mat.set_row(3, LVector3f(xpos, 0, 0));
|
||||
mat.set_row(3, LVector3f(xpos, 0.0f, 0.0f));
|
||||
if (char_geom != NULL) {
|
||||
string ch(1, (char)character);
|
||||
GeomNode *geode = new GeomNode(ch);
|
||||
|
|
@ -497,13 +497,13 @@ assemble_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
nassertr(_font != (TextFont *)NULL, (Node *)NULL);
|
||||
float line_height = get_line_height();
|
||||
|
||||
ul.set(0.0, 0.8 * line_height);
|
||||
lr.set(0.0, 0.0);
|
||||
ul.set(0.0f, 0.8f * line_height);
|
||||
lr.set(0.0f, 0.0f);
|
||||
|
||||
// Make a group node to hold our formatted text geometry.
|
||||
Node *root_node = new NamedNode("text");
|
||||
|
||||
float posy = 0.0;
|
||||
float posy = 0.0f;
|
||||
int row_index = 0;
|
||||
while (*source != '\0') {
|
||||
char numstr[20];
|
||||
|
|
@ -519,26 +519,27 @@ assemble_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
|
||||
LMatrix4f mat = LMatrix4f::ident_mat();
|
||||
if (_align == TM_ALIGN_LEFT) {
|
||||
mat.set_row(3, LVector3f(0, 0, posy));
|
||||
mat.set_row(3, LVector3f(0.0f, 0.0f, posy));
|
||||
lr[0] = max(lr[0], row_width);
|
||||
|
||||
} else if (_align == TM_ALIGN_RIGHT) {
|
||||
mat.set_row(3, LVector3f(-row_width, 0, posy));
|
||||
mat.set_row(3, LVector3f(-row_width, 0.0f, posy));
|
||||
ul[0] = min(ul[0], -row_width);
|
||||
|
||||
} else {
|
||||
mat.set_row(3, LVector3f(-row_width / 2.0, 0, posy));
|
||||
lr[0] = max(lr[0], row_width / 2);
|
||||
ul[0] = min(ul[0], -row_width / 2);
|
||||
float half_row_width=0.5f*row_width;
|
||||
mat.set_row(3, LVector3f(-half_row_width, 0.0f, posy));
|
||||
lr[0] = max(lr[0], half_row_width);
|
||||
ul[0] = min(ul[0], -half_row_width);
|
||||
}
|
||||
|
||||
// Also apply whatever slant the user has asked for to the entire
|
||||
// row. This is an X shear.
|
||||
if (_slant != 0.0) {
|
||||
LMatrix4f shear(1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
_slant, 0, 1, 0,
|
||||
0, 0, 0, 1);
|
||||
if (_slant != 0.0f) {
|
||||
LMatrix4f shear(1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
_slant, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
mat = shear * mat;
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +550,7 @@ assemble_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
num_rows++;
|
||||
}
|
||||
|
||||
lr[1] = posy + 0.8 * line_height;
|
||||
lr[1] = posy + 0.8f * line_height;
|
||||
|
||||
return root_node;
|
||||
}
|
||||
|
|
@ -563,13 +564,13 @@ assemble_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
float TextNode::
|
||||
measure_row(const char *&source) {
|
||||
float xpos = 0.0;
|
||||
float xpos = 0.0f;
|
||||
while (*source != '\0' && *source != '\n') {
|
||||
int character = (unsigned char)*source;
|
||||
|
||||
if (character == ' ') {
|
||||
// A space is a special case.
|
||||
xpos += 0.25;
|
||||
xpos += 0.25f;
|
||||
|
||||
} else {
|
||||
// A printable character.
|
||||
|
|
@ -598,10 +599,10 @@ measure_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
nassertv(_font != (TextFont *)NULL);
|
||||
float line_height = get_line_height();
|
||||
|
||||
ul.set(0.0, 0.8 * line_height);
|
||||
lr.set(0.0, 0.0);
|
||||
ul.set(0.0f, 0.8f * line_height);
|
||||
lr.set(0.0f, 0.0f);
|
||||
|
||||
float posy = 0.0;
|
||||
float posy = 0.0f;
|
||||
while (*source != '\0') {
|
||||
float row_width = measure_row(source);
|
||||
if (*source != '\0') {
|
||||
|
|
@ -616,15 +617,17 @@ measure_text(const char *source, LVector2f &ul, LVector2f &lr,
|
|||
ul[0] = min(ul[0], -row_width);
|
||||
|
||||
} else {
|
||||
lr[0] = max(lr[0], row_width / 2);
|
||||
ul[0] = min(ul[0], -row_width / 2);
|
||||
float half_row_width=0.5f*row_width;
|
||||
|
||||
lr[0] = max(lr[0], half_row_width);
|
||||
ul[0] = min(ul[0], -half_row_width);
|
||||
}
|
||||
|
||||
posy -= line_height;
|
||||
num_rows++;
|
||||
}
|
||||
|
||||
lr[1] = posy + 0.8 * line_height;
|
||||
lr[1] = posy + 0.8f * line_height;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -643,19 +646,19 @@ make_frame() {
|
|||
float top = dimensions[3];
|
||||
|
||||
GeomLinestrip *geoset = new GeomLinestrip;
|
||||
PTA_int lengths(0);
|
||||
PTA_int lengths=PTA_int::empty_array(0);
|
||||
PTA_Vertexf verts;
|
||||
lengths.push_back(5);
|
||||
verts.push_back(Vertexf(left, 0.0, top));
|
||||
verts.push_back(Vertexf(left, 0.0, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0, top));
|
||||
verts.push_back(Vertexf(left, 0.0, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, bottom));
|
||||
verts.push_back(Vertexf(right, 0.0f, top));
|
||||
verts.push_back(Vertexf(left, 0.0f, top));
|
||||
|
||||
geoset->set_num_prims(1);
|
||||
geoset->set_lengths(lengths);
|
||||
|
||||
geoset->set_coords(verts, G_PER_VERTEX);
|
||||
geoset->set_coords(verts);
|
||||
geoset->set_width(_frame_width);
|
||||
frame_geode->add_geom(geoset);
|
||||
|
||||
|
|
@ -663,7 +666,7 @@ make_frame() {
|
|||
GeomPoint *geoset = new GeomPoint;
|
||||
|
||||
geoset->set_num_prims(4);
|
||||
geoset->set_coords(verts, G_PER_VERTEX);
|
||||
geoset->set_coords(verts);
|
||||
geoset->set_size(_frame_width);
|
||||
frame_geode->add_geom(geoset);
|
||||
}
|
||||
|
|
@ -687,26 +690,26 @@ make_card() {
|
|||
float top = dimensions[3];
|
||||
|
||||
GeomTristrip *geoset = new GeomTristrip;
|
||||
PTA_int lengths(0);
|
||||
PTA_int lengths=PTA_int::empty_array(0);
|
||||
lengths.push_back(4);
|
||||
|
||||
PTA_Vertexf verts;
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, bottom));
|
||||
|
||||
geoset->set_num_prims(1);
|
||||
geoset->set_lengths(lengths);
|
||||
|
||||
geoset->set_coords(verts, G_PER_VERTEX);
|
||||
geoset->set_coords(verts);
|
||||
|
||||
if (has_card_texture()) {
|
||||
PTA_TexCoordf uvs;
|
||||
uvs.push_back(TexCoordf(0.0, 1.0));
|
||||
uvs.push_back(TexCoordf(0.0, 0.0));
|
||||
uvs.push_back(TexCoordf(1.0, 1.0));
|
||||
uvs.push_back(TexCoordf(1.0, 0.0));
|
||||
uvs.push_back(TexCoordf(0.0f, 1.0f));
|
||||
uvs.push_back(TexCoordf(0.0f, 0.0f));
|
||||
uvs.push_back(TexCoordf(1.0f, 1.0f));
|
||||
uvs.push_back(TexCoordf(1.0f, 0.0f));
|
||||
|
||||
geoset->set_texcoords(uvs, G_PER_VERTEX);
|
||||
}
|
||||
|
|
@ -749,29 +752,29 @@ make_card_with_border() {
|
|||
|
||||
PTA_Vertexf verts;
|
||||
// verts 1,2,3,4
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, top - _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02,
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, top - _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02f,
|
||||
top - _card_border_size));
|
||||
// verts 5,6,7,8
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02,
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02f,
|
||||
top - _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, top - _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, top));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, top - _card_border_size));
|
||||
// verts 9,10,11,12
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02,
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(left, 0.02f, bottom));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02f,
|
||||
bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(left + _card_border_size, 0.02f, bottom));
|
||||
// verts 13,14,15,16
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02,
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02f,
|
||||
bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02, bottom));
|
||||
verts.push_back(Vertexf::rfu(right - _card_border_size, 0.02f, bottom));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, bottom + _card_border_size));
|
||||
verts.push_back(Vertexf::rfu(right, 0.02f, bottom));
|
||||
|
||||
PTA_ushort indices;
|
||||
// tristrip #1
|
||||
|
|
@ -805,30 +808,30 @@ make_card_with_border() {
|
|||
geoset->set_num_prims(3);
|
||||
geoset->set_lengths(lengths);
|
||||
|
||||
geoset->set_coords(verts, G_PER_VERTEX, indices);
|
||||
geoset->set_coords(verts,indices);
|
||||
|
||||
if (has_card_texture()) {
|
||||
PTA_TexCoordf uvs;
|
||||
uvs.push_back(TexCoordf(0.0, 1.0)); //1
|
||||
uvs.push_back(TexCoordf(0.0, 1.0 - _card_border_uv_portion)); //2
|
||||
uvs.push_back(TexCoordf(0.0 + _card_border_uv_portion, 1.0)); //3
|
||||
uvs.push_back(TexCoordf(0.0 + _card_border_uv_portion,
|
||||
1.0 - _card_border_uv_portion)); //4
|
||||
uvs.push_back(TexCoordf( 1.0 -_card_border_uv_portion, 1.0)); //5
|
||||
uvs.push_back(TexCoordf( 1.0 -_card_border_uv_portion,
|
||||
1.0 - _card_border_uv_portion)); //6
|
||||
uvs.push_back(TexCoordf(1.0, 1.0)); //7
|
||||
uvs.push_back(TexCoordf(1.0, 1.0 - _card_border_uv_portion)); //8
|
||||
uvs.push_back(TexCoordf(0.0f, 1.0f)); //1
|
||||
uvs.push_back(TexCoordf(0.0f, 1.0f - _card_border_uv_portion)); //2
|
||||
uvs.push_back(TexCoordf(0.0f + _card_border_uv_portion, 1.0f)); //3
|
||||
uvs.push_back(TexCoordf(0.0f + _card_border_uv_portion,
|
||||
1.0f - _card_border_uv_portion)); //4
|
||||
uvs.push_back(TexCoordf( 1.0f -_card_border_uv_portion, 1.0f)); //5
|
||||
uvs.push_back(TexCoordf( 1.0f -_card_border_uv_portion,
|
||||
1.0f - _card_border_uv_portion)); //6
|
||||
uvs.push_back(TexCoordf(1.0f, 1.0f)); //7
|
||||
uvs.push_back(TexCoordf(1.0f, 1.0f - _card_border_uv_portion)); //8
|
||||
|
||||
uvs.push_back(TexCoordf(0.0, _card_border_uv_portion)); //9
|
||||
uvs.push_back(TexCoordf(0.0, 0.0)); //10
|
||||
uvs.push_back(TexCoordf(0.0f, _card_border_uv_portion)); //9
|
||||
uvs.push_back(TexCoordf(0.0f, 0.0f)); //10
|
||||
uvs.push_back(TexCoordf(_card_border_uv_portion, _card_border_uv_portion)); //11
|
||||
uvs.push_back(TexCoordf(_card_border_uv_portion, 0.0)); //12
|
||||
uvs.push_back(TexCoordf(_card_border_uv_portion, 0.0f)); //12
|
||||
|
||||
uvs.push_back(TexCoordf(1.0 - _card_border_uv_portion, _card_border_uv_portion));//13
|
||||
uvs.push_back(TexCoordf(1.0 - _card_border_uv_portion, 0.0));//14
|
||||
uvs.push_back(TexCoordf(1.0, _card_border_uv_portion));//15
|
||||
uvs.push_back(TexCoordf(1.0, 0.0));//16
|
||||
uvs.push_back(TexCoordf(1.0f - _card_border_uv_portion, _card_border_uv_portion));//13
|
||||
uvs.push_back(TexCoordf(1.0f - _card_border_uv_portion, 0.0f));//14
|
||||
uvs.push_back(TexCoordf(1.0f, _card_border_uv_portion));//15
|
||||
uvs.push_back(TexCoordf(1.0f, 0.0f));//16
|
||||
|
||||
// we can use same ref's as before (same order)
|
||||
geoset->set_texcoords(uvs, G_PER_VERTEX, indices);
|
||||
|
|
|
|||
Loading…
Reference in New Issue