Merge branch 'master' into cmake
This commit is contained in:
commit
cc94222757
|
|
@ -1624,6 +1624,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||
|
||||
if not self.physicsMgr:
|
||||
from PhysicsManagerGlobal import physicsMgr
|
||||
from panda3d.physics import LinearEulerIntegrator
|
||||
self.physicsMgr = physicsMgr
|
||||
integrator = LinearEulerIntegrator()
|
||||
self.physicsMgr.attachLinearIntegrator(integrator)
|
||||
|
|
|
|||
|
|
@ -596,8 +596,14 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) {
|
|||
LPoint3f p;
|
||||
if (!_undist_lut.calc_bilinear_point(p, uvw[0], 1.0 - uvw[1])) {
|
||||
// Point is missing.
|
||||
uvw.set(0, 0, 0);
|
||||
|
||||
// We're better off keeping the point where it is,
|
||||
// undistorted--it's probably close to where it should
|
||||
// be--than we are changing it arbitrarily to (0, 0), which
|
||||
// might be far away from where it should be.
|
||||
//uvw.set(0, 0, 0);
|
||||
good = false;
|
||||
|
||||
} else {
|
||||
uvw = LCAST(PN_stdfloat, p);
|
||||
uvw[1] = 1.0 - uvw[1];
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ ConfigVariableEnum<EggRenderMode::AlphaMode> egg_alpha_mode
|
|||
"or because of a four-channel texture."));
|
||||
|
||||
ConfigVariableInt egg_max_vertices
|
||||
("egg-max-vertices", 65535,
|
||||
("egg-max-vertices", 65534,
|
||||
PRC_DESC("Specifies the maximum number of vertices that will be "
|
||||
"added to any one GeomVertexData by the egg loader."));
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
rock_floor.rgb_src.c shuttle_controls.bam_src.c
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
config_framework.h \
|
||||
pandaFramework.I pandaFramework.h \
|
||||
windowFramework.I windowFramework.h
|
||||
|
||||
|
|
|
|||
|
|
@ -4357,16 +4357,19 @@ prepare_shader(Shader *se) {
|
|||
ShaderContext *result = NULL;
|
||||
|
||||
switch (se->get_language()) {
|
||||
case Shader::SL_GLSL:
|
||||
result = new CLP(ShaderContext)(this, se);
|
||||
break;
|
||||
|
||||
#if defined(HAVE_CG) && !defined(OPENGLES)
|
||||
case Shader::SL_Cg:
|
||||
result = new CLP(CgShaderContext)(this, se);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Shader::SL_GLSL:
|
||||
if (_supports_glsl) {
|
||||
result = new CLP(ShaderContext)(this, se);
|
||||
break;
|
||||
}
|
||||
// Fall through.
|
||||
|
||||
default:
|
||||
GLCAT.error()
|
||||
<< "Tried to load shader with unsupported shader language!\n";
|
||||
|
|
@ -7638,6 +7641,8 @@ get_internal_image_format(Texture *tex) const {
|
|||
#ifndef OPENGLES_1
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_RGBA16F;
|
||||
} else if (tex->get_component_type() == Texture::T_unsigned_short) {
|
||||
return GL_RGBA16;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -7660,7 +7665,11 @@ get_internal_image_format(Texture *tex) const {
|
|||
#endif // OPENGLES
|
||||
#ifndef OPENGLES_1
|
||||
case Texture::F_rgba16:
|
||||
return GL_RGBA16F;
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_RGBA16F;
|
||||
} else {
|
||||
return GL_RGBA16;
|
||||
}
|
||||
case Texture::F_rgba32:
|
||||
return GL_RGBA32F;
|
||||
#endif // OPENGLES
|
||||
|
|
@ -7744,10 +7753,20 @@ get_internal_image_format(Texture *tex) const {
|
|||
case Texture::F_alpha:
|
||||
return GL_ALPHA;
|
||||
case Texture::F_luminance:
|
||||
return GL_LUMINANCE;
|
||||
if (tex->get_component_type() == Texture::T_float) {
|
||||
return GL_LUMINANCE16F_ARB;
|
||||
} else if (tex->get_component_type() == Texture::T_unsigned_short) {
|
||||
return GL_LUMINANCE16;
|
||||
} else {
|
||||
return GL_LUMINANCE;
|
||||
}
|
||||
case Texture::F_luminance_alpha:
|
||||
case Texture::F_luminance_alphamask:
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
if (tex->get_component_type() == Texture::T_float || tex->get_component_type() == Texture::T_unsigned_short) {
|
||||
return GL_LUMINANCE_ALPHA16F_ARB;
|
||||
} else {
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
}
|
||||
|
||||
#ifndef OPENGLES_1
|
||||
case Texture::F_srgb:
|
||||
|
|
@ -10944,6 +10963,9 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||
case GL_RGB12:
|
||||
format = Texture::F_rgb12;
|
||||
break;
|
||||
case GL_RGBA16:
|
||||
format = Texture::F_rgba16;
|
||||
break;
|
||||
case GL_R3_G3_B2:
|
||||
format = Texture::F_rgb332;
|
||||
break;
|
||||
|
|
@ -11027,10 +11049,13 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
|
|||
format = Texture::F_alpha;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE16:
|
||||
case GL_LUMINANCE16F_ARB:
|
||||
case 1:
|
||||
format = Texture::F_luminance;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
case GL_LUMINANCE_ALPHA16F_ARB:
|
||||
case 2:
|
||||
format = Texture::F_luminance_alpha;
|
||||
break;
|
||||
|
|
@ -11710,16 +11735,9 @@ void CLP(GraphicsStateGuardian)::
|
|||
do_issue_scissor() {
|
||||
const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot()));
|
||||
|
||||
if (target_scissor->is_off() && !_current_display_region->get_scissor_enabled()) {
|
||||
if (_scissor_enabled) {
|
||||
if (GLCAT.is_spam()) {
|
||||
GLCAT.spam()
|
||||
<< "glDisable(GL_SCISSOR_TEST)\n";
|
||||
}
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
_scissor_enabled = false;
|
||||
}
|
||||
} else {
|
||||
if (!target_scissor->is_off()) {
|
||||
// A non-off ScissorAttrib means to override the scissor setting
|
||||
// that was specified by the DisplayRegion.
|
||||
if (!_scissor_enabled) {
|
||||
if (GLCAT.is_spam()) {
|
||||
GLCAT.spam()
|
||||
|
|
|
|||
|
|
@ -3314,14 +3314,21 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa
|
|||
if (!alpha_fullpath.empty()) {
|
||||
// Make the original image a 4-component image by taking the
|
||||
// grayscale value from the second image.
|
||||
|
||||
image.add_alpha();
|
||||
|
||||
if (alpha_file_channel == 4 ||
|
||||
(alpha_file_channel == 2 && alpha_image.get_num_channels() == 2)) {
|
||||
// Use the alpha channel.
|
||||
for (int x = 0; x < image.get_x_size(); x++) {
|
||||
for (int y = 0; y < image.get_y_size(); y++) {
|
||||
image.set_alpha(x, y, alpha_image.get_alpha(x, y));
|
||||
|
||||
if (!alpha_image.has_alpha()) {
|
||||
gobj_cat.error()
|
||||
<< alpha_fullpath.get_basename() << " has no channel " << alpha_file_channel << ".\n";
|
||||
} else {
|
||||
// Use the alpha channel.
|
||||
for (int x = 0; x < image.get_x_size(); x++) {
|
||||
for (int y = 0; y < image.get_y_size(); y++) {
|
||||
image.set_alpha(x, y, alpha_image.get_alpha(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
cdata->_alpha_file_channel = alpha_image.get_num_channels();
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@
|
|||
INLINE_LINMATH FLOATNAME(LMatrix3)::Row::
|
||||
Row(FLOATTYPE *row) : _row(row) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix3::Row::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::Row::
|
||||
operator [](int i) const {
|
||||
|
|
@ -36,7 +36,7 @@ operator [](int i) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix3::Row::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix3)::Row::
|
||||
operator [](int i) {
|
||||
|
|
@ -62,11 +62,11 @@ size() {
|
|||
INLINE_LINMATH FLOATNAME(LMatrix3)::CRow::
|
||||
CRow(const FLOATTYPE *row) : _row(row) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix3::CRow::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::CRow::
|
||||
operator [](int i) const {
|
||||
|
|
@ -255,7 +255,7 @@ set_col(int col, const FLOATNAME(LVecBase2) &v) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
|
||||
get_row(int row) const {
|
||||
#ifdef HAVE_EIGEN
|
||||
#ifdef HAVE_EIGEN
|
||||
return FLOATNAME(LVecBase3)(_m.row(row));
|
||||
#else
|
||||
return FLOATNAME(LVecBase3)((*this)(row, 0), (*this)(row, 1), (*this)(row, 2));
|
||||
|
|
@ -270,7 +270,7 @@ get_row(int row) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LMatrix3)::
|
||||
get_row(FLOATNAME(LVecBase3) &result_vec,int row) const {
|
||||
#ifdef HAVE_EIGEN
|
||||
#ifdef HAVE_EIGEN
|
||||
result_vec._v = _m.row(row);
|
||||
#else
|
||||
result_vec._v(0) = (*this)(row, 0);
|
||||
|
|
@ -287,7 +287,7 @@ get_row(FLOATNAME(LVecBase3) &result_vec,int row) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3)::
|
||||
get_col(int col) const {
|
||||
#ifdef HAVE_EIGEN
|
||||
#ifdef HAVE_EIGEN
|
||||
return FLOATNAME(LVecBase3)(_m.col(col));
|
||||
#else
|
||||
return FLOATNAME(LVecBase3)((*this)(0, col), (*this)(1, col), (*this)(2, col));
|
||||
|
|
@ -589,10 +589,10 @@ xform(const FLOATNAME(LVecBase3) &v) const {
|
|||
FLOATNAME(LVecBase3) v_res;
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m;
|
||||
#else
|
||||
#else
|
||||
VECTOR3_MATRIX3_PRODUCT(v_res, v,(*this));
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
|
||||
return v_res;
|
||||
}
|
||||
|
||||
|
|
@ -609,14 +609,14 @@ xform_point(const FLOATNAME(LVecBase2) &v) const {
|
|||
FLOATNAME(LVecBase2) v_res;
|
||||
|
||||
// v._v(2) == 1.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m.block<2, 2>(0, 0) + _m.block<1, 2>(2, 0);
|
||||
#else
|
||||
#else
|
||||
v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0) + _m(2, 0);
|
||||
v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1) + _m(2, 1);
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
|
||||
return v_res;
|
||||
}
|
||||
|
||||
|
|
@ -634,14 +634,14 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const {
|
|||
FLOATNAME(LVecBase2) v_res;
|
||||
|
||||
// v._v(2) == 0.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m.block<2, 2>(0, 0);
|
||||
#else
|
||||
#else
|
||||
v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0);
|
||||
v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1);
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
|
||||
return v_res;
|
||||
}
|
||||
|
||||
|
|
@ -690,7 +690,7 @@ xform_in_place(FLOATNAME(LVecBase3) &v) const {
|
|||
TAU_PROFILE("void LMatrix3::xform_in_place(LVecBase3 &)", " ", TAU_USER);
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m;
|
||||
#else
|
||||
#else
|
||||
v = xform(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -706,10 +706,10 @@ INLINE_LINMATH void FLOATNAME(LMatrix3)::
|
|||
xform_point_in_place(FLOATNAME(LVecBase2) &v) const {
|
||||
TAU_PROFILE("void LMatrix3::xform_point_in_place(LVecBase3 &)", " ", TAU_USER);
|
||||
// v._v(2) == 1.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m.block<2, 2>(0, 0) + _m.block<1, 2>(2, 0);
|
||||
#else
|
||||
#else
|
||||
v = xform_point(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -725,10 +725,10 @@ INLINE_LINMATH void FLOATNAME(LMatrix3)::
|
|||
xform_vec_in_place(FLOATNAME(LVecBase2) &v) const {
|
||||
TAU_PROFILE("void LMatrix3::xform_vec_in_place(LVecBase3 &)", " ", TAU_USER);
|
||||
// v._v(2) == 0.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m.block<2, 2>(0, 0);
|
||||
#else
|
||||
#else
|
||||
v = xform_vec(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -943,6 +943,30 @@ operator /= (FLOATTYPE scalar) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix3::componentwise_mult
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LMatrix3)::
|
||||
componentwise_mult(const FLOATNAME(LMatrix3) &other) {
|
||||
#ifdef HAVE_EIGEN
|
||||
_m = _m.cwiseProduct(other._m);
|
||||
#else
|
||||
_m(0, 0) *= other._m(0, 0);
|
||||
_m(0, 1) *= other._m(0, 1);
|
||||
_m(0, 2) *= other._m(0, 2);
|
||||
|
||||
_m(1, 0) *= other._m(1, 0);
|
||||
_m(1, 1) *= other._m(1, 1);
|
||||
_m(1, 2) *= other._m(1, 2);
|
||||
|
||||
_m(2, 0) *= other._m(2, 0);
|
||||
_m(2, 1) *= other._m(2, 1);
|
||||
_m(2, 2) *= other._m(2, 2);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix3::transpose_from
|
||||
// Access: Published
|
||||
|
|
@ -1421,7 +1445,7 @@ shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, CoordinateSystem cs) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::
|
||||
scale_shear_mat(const FLOATNAME(LVecBase3) &scale,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
const FLOATNAME(LVecBase3) &shear,
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LMatrix3) mat;
|
||||
mat.set_scale_shear_mat(scale, shear, cs);
|
||||
|
|
|
|||
|
|
@ -175,6 +175,8 @@ PUBLISHED:
|
|||
INLINE_LINMATH FLOATNAME(LMatrix3) &operator *= (FLOATTYPE scalar);
|
||||
INLINE_LINMATH FLOATNAME(LMatrix3) &operator /= (FLOATTYPE scalar);
|
||||
|
||||
INLINE_LINMATH void componentwise_mult(const FLOATNAME(LMatrix3) &other);
|
||||
|
||||
INLINE_LINMATH FLOATTYPE determinant() const;
|
||||
|
||||
INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix3) &other);
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@
|
|||
INLINE_LINMATH FLOATNAME(LMatrix4)::Row::
|
||||
Row(FLOATTYPE *row) : _row(row) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix4::Row::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4)::Row::
|
||||
operator [](int i) const {
|
||||
|
|
@ -36,7 +36,7 @@ operator [](int i) const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix4::Row::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix4)::Row::
|
||||
operator [](int i) {
|
||||
|
|
@ -62,11 +62,11 @@ size() {
|
|||
INLINE_LINMATH FLOATNAME(LMatrix4)::CRow::
|
||||
CRow(const FLOATTYPE *row) : _row(row) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix4::CRow::operator []
|
||||
// Access: Published
|
||||
// Description:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4)::CRow::
|
||||
operator [](int i) const {
|
||||
|
|
@ -831,7 +831,7 @@ xform(const FLOATNAME(LVecBase4) &v) const {
|
|||
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m;
|
||||
#else
|
||||
#else
|
||||
VECTOR4_MATRIX4_PRODUCT(v_res, v,(*this));
|
||||
#endif // HAVE_EIGEN
|
||||
return v_res;
|
||||
|
|
@ -853,12 +853,12 @@ xform_point(const FLOATNAME(LVecBase3) &v) const {
|
|||
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m.block<3, 3>(0, 0) + _m.block<1, 3>(3, 0);
|
||||
#else
|
||||
#else
|
||||
v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0) + v._v(2)*_m(2, 0) + _m(3, 0);
|
||||
v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1) + v._v(2)*_m(2, 1) + _m(3, 1);
|
||||
v_res._v(2) = v._v(0)*_m(0, 2) + v._v(1)*_m(1, 2) + v._v(2)*_m(2, 2) + _m(3, 2);
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
|
||||
return v_res;
|
||||
}
|
||||
|
||||
|
|
@ -888,17 +888,17 @@ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4)::
|
|||
xform_vec(const FLOATNAME(LVecBase3) &v) const {
|
||||
TAU_PROFILE("LVecBase3 LMatrix4::xform_vec(const LVecBase3 &)", " ", TAU_USER);
|
||||
FLOATNAME(LVecBase3) v_res;
|
||||
|
||||
|
||||
// v._v(3) == 0.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v_res._v.noalias() = v._v * _m.block<3, 3>(0, 0);
|
||||
#else
|
||||
#else
|
||||
v_res._v(0) = v._v(0)*_m(0, 0) + v._v(1)*_m(1, 0) + v._v(2)*_m(2, 0);
|
||||
v_res._v(1) = v._v(0)*_m(0, 1) + v._v(1)*_m(1, 1) + v._v(2)*_m(2, 1);
|
||||
v_res._v(2) = v._v(0)*_m(0, 2) + v._v(1)*_m(1, 2) + v._v(2)*_m(2, 2);
|
||||
#endif // HAVE_EIGEN
|
||||
|
||||
|
||||
return v_res;
|
||||
}
|
||||
|
||||
|
|
@ -934,7 +934,7 @@ xform_in_place(FLOATNAME(LVecBase4) &v) const {
|
|||
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m;
|
||||
#else
|
||||
#else
|
||||
v = xform(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -953,7 +953,7 @@ xform_point_in_place(FLOATNAME(LVecBase3) &v) const {
|
|||
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m.block<3, 3>(0, 0) + _m.block<1, 3>(3, 0);
|
||||
#else
|
||||
#else
|
||||
v = xform_point(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -981,10 +981,10 @@ INLINE_LINMATH void FLOATNAME(LMatrix4)::
|
|||
xform_vec_in_place(FLOATNAME(LVecBase3) &v) const {
|
||||
TAU_PROFILE("void LMatrix4::xform_vec_in_place(LVecBase3 &)", " ", TAU_USER);
|
||||
// v._v(3) == 0.0f for this case
|
||||
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
v._v = v._v * _m.block<3, 3>(0, 0);
|
||||
#else
|
||||
#else
|
||||
v = xform_vec(v);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
|
@ -1069,7 +1069,7 @@ operator * (FLOATTYPE scalar) const {
|
|||
#ifdef HAVE_EIGEN
|
||||
t._m = _m * scalar;
|
||||
|
||||
#else
|
||||
#else
|
||||
t._m(0, 0) = _m(0, 0) * scalar;
|
||||
t._m(0, 1) = _m(0, 1) * scalar;
|
||||
t._m(0, 2) = _m(0, 2) * scalar;
|
||||
|
|
@ -1245,6 +1245,38 @@ operator /= (FLOATTYPE scalar) {
|
|||
return operator *= (recip_scalar);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix4::componentwise_mult
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LMatrix4)::
|
||||
componentwise_mult(const FLOATNAME(LMatrix4) &other) {
|
||||
#ifdef HAVE_EIGEN
|
||||
_m = _m.cwiseProduct(other._m);
|
||||
#else
|
||||
_m(0, 0) *= other._m(0, 0);
|
||||
_m(0, 1) *= other._m(0, 1);
|
||||
_m(0, 2) *= other._m(0, 2);
|
||||
_m(0, 3) *= other._m(0, 3);
|
||||
|
||||
_m(1, 0) *= other._m(1, 0);
|
||||
_m(1, 1) *= other._m(1, 1);
|
||||
_m(1, 2) *= other._m(1, 2);
|
||||
_m(1, 3) *= other._m(1, 3);
|
||||
|
||||
_m(2, 0) *= other._m(2, 0);
|
||||
_m(2, 1) *= other._m(2, 1);
|
||||
_m(2, 2) *= other._m(2, 2);
|
||||
_m(2, 3) *= other._m(2, 3);
|
||||
|
||||
_m(3, 0) *= other._m(3, 0);
|
||||
_m(3, 1) *= other._m(3, 1);
|
||||
_m(3, 2) *= other._m(3, 2);
|
||||
_m(3, 3) *= other._m(3, 3);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LMatrix4::transpose_from
|
||||
|
|
@ -1409,11 +1441,11 @@ invert_affine_from(const FLOATNAME(LMatrix4) &other) {
|
|||
_m(3, 0) = -(other._m(3, 0) * _m(0, 0) +
|
||||
other._m(3, 1) * _m(1, 0) +
|
||||
other._m(3, 2) * _m(2, 0));
|
||||
|
||||
|
||||
_m(3, 1) = -(other._m(3, 0) * _m(0, 1) +
|
||||
other._m(3, 1) * _m(1, 1) +
|
||||
other._m(3, 2) * _m(2, 1));
|
||||
|
||||
|
||||
_m(3, 2) = -(other._m(3, 0) * _m(0, 2) +
|
||||
other._m(3, 1) * _m(1, 2) +
|
||||
other._m(3, 2) * _m(2, 2));
|
||||
|
|
@ -1449,17 +1481,17 @@ accumulate(const FLOATNAME(LMatrix4) &other, FLOATTYPE weight) {
|
|||
_m(0, 1) += other._m(0, 1) * weight;
|
||||
_m(0, 2) += other._m(0, 2) * weight;
|
||||
_m(0, 3) += other._m(0, 3) * weight;
|
||||
|
||||
|
||||
_m(1, 0) += other._m(1, 0) * weight;
|
||||
_m(1, 1) += other._m(1, 1) * weight;
|
||||
_m(1, 2) += other._m(1, 2) * weight;
|
||||
_m(1, 3) += other._m(1, 3) * weight;
|
||||
|
||||
|
||||
_m(2, 0) += other._m(2, 0) * weight;
|
||||
_m(2, 1) += other._m(2, 1) * weight;
|
||||
_m(2, 2) += other._m(2, 2) * weight;
|
||||
_m(2, 3) += other._m(2, 3) * weight;
|
||||
|
||||
|
||||
_m(3, 0) += other._m(3, 0) * weight;
|
||||
_m(3, 1) += other._m(3, 1) * weight;
|
||||
_m(3, 2) += other._m(3, 2) * weight;
|
||||
|
|
@ -1653,7 +1685,7 @@ shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) {
|
|||
// shear in each of the three planes.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::
|
||||
shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz,
|
||||
shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz,
|
||||
CoordinateSystem cs) {
|
||||
FLOATNAME(LMatrix4) mat;
|
||||
mat.set_shear_mat(FLOATNAME(LVecBase3)(shxy, shxz, shyz), cs);
|
||||
|
|
|
|||
|
|
@ -177,6 +177,8 @@ PUBLISHED:
|
|||
INLINE_LINMATH FLOATNAME(LMatrix4) &operator *= (FLOATTYPE scalar);
|
||||
INLINE_LINMATH FLOATNAME(LMatrix4) &operator /= (FLOATTYPE scalar);
|
||||
|
||||
INLINE_LINMATH void componentwise_mult(const FLOATNAME(LMatrix4) &other);
|
||||
|
||||
INLINE_LINMATH void transpose_from(const FLOATNAME(LMatrix4) &other);
|
||||
INLINE_LINMATH void transpose_in_place();
|
||||
|
||||
|
|
|
|||
|
|
@ -733,6 +733,21 @@ operator /= (FLOATTYPE scalar) {
|
|||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase2::componentwise_mult
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LVecBase2)::
|
||||
componentwise_mult(const FLOATNAME(LVecBase2) &other) {
|
||||
#ifdef HAVE_EIGEN
|
||||
_v = _v.cwiseProduct(other._v);
|
||||
#else
|
||||
_v(0) *= other._v(0);
|
||||
_v(1) *= other._v(1);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase2::fmax
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ PUBLISHED:
|
|||
INLINE_LINMATH void operator *= (FLOATTYPE scalar);
|
||||
INLINE_LINMATH void operator /= (FLOATTYPE scalar);
|
||||
|
||||
INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase2) &other);
|
||||
|
||||
EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase2) __pow__(FLOATTYPE exponent) const);
|
||||
EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
|
||||
|
||||
|
|
|
|||
|
|
@ -909,6 +909,22 @@ operator /= (FLOATTYPE scalar) {
|
|||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase3::componentwise_mult
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LVecBase3)::
|
||||
componentwise_mult(const FLOATNAME(LVecBase3) &other) {
|
||||
#ifdef HAVE_EIGEN
|
||||
_v = _v.cwiseProduct(other._v);
|
||||
#else
|
||||
_v(0) *= other._v(0);
|
||||
_v(1) *= other._v(1);
|
||||
_v(2) *= other._v(2);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase3::fmax
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ PUBLISHED:
|
|||
INLINE_LINMATH void operator *= (FLOATTYPE scalar);
|
||||
INLINE_LINMATH void operator /= (FLOATTYPE scalar);
|
||||
|
||||
INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase3) &other);
|
||||
|
||||
EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase3) __pow__(FLOATTYPE exponent) const);
|
||||
EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
|
||||
|
||||
|
|
|
|||
|
|
@ -892,6 +892,23 @@ operator /= (FLOATTYPE scalar) {
|
|||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase4::componentwise_mult
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_LINMATH void FLOATNAME(LVecBase4)::
|
||||
componentwise_mult(const FLOATNAME(LVecBase4) &other) {
|
||||
#ifdef HAVE_EIGEN
|
||||
_v = _v.cwiseProduct(other._v);
|
||||
#else
|
||||
_v(0) *= other._v(0);
|
||||
_v(1) *= other._v(1);
|
||||
_v(2) *= other._v(2);
|
||||
_v(3) *= other._v(3);
|
||||
#endif // HAVE_EIGEN
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LVecBase4::fmax
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ PUBLISHED:
|
|||
INLINE_LINMATH void operator *= (FLOATTYPE scalar);
|
||||
INLINE_LINMATH void operator /= (FLOATTYPE scalar);
|
||||
|
||||
INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase4) &other);
|
||||
|
||||
EXTENSION(INLINE_LINMATH FLOATNAME(LVecBase4) __pow__(FLOATTYPE exponent) const);
|
||||
EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ if(WANT_NATIVE_NET)
|
|||
buffered_datagramreader.h buffered_datagramreader.i
|
||||
ringbuffer.h ringbuffer.i socket_ip.h
|
||||
socket_tcp_listen.h time_accumulator.h time_out.h
|
||||
socket_address.h
|
||||
socket_address.I socket_address.h
|
||||
socket_portable.h time_base.h time_span.h buffered_datagramwriter.h
|
||||
socket_base.h socket_selector.h
|
||||
socket_udp.h
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
buffered_datagramreader.h buffered_datagramreader.i \
|
||||
ringbuffer.h ringbuffer.i socket_ip.h \
|
||||
socket_tcp_listen.h time_accumulator.h time_out.h \
|
||||
socket_address.h \
|
||||
socket_address.I socket_address.h \
|
||||
socket_portable.h time_base.h time_span.h buffered_datagramwriter.h \
|
||||
socket_base.h socket_selector.h \
|
||||
socket_udp.h \
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
ringbuffer.h ringbuffer.i socket_ip.h socket_tcp_listen.h \
|
||||
time_accumulator.h time_out.h \
|
||||
buffered_datagramreader.h buffered_datagramreader.i \
|
||||
socket_address.h \
|
||||
socket_address.I socket_address.h \
|
||||
socket_portable.h time_base.h time_span.h buffered_datagramwriter.h \
|
||||
socket_base.h socket_selector.h \
|
||||
socket_udp.h \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,278 @@
|
|||
// Filename: socket_address.I
|
||||
// Created by: rdb (19Oct14)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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: Socket_Address::GetIPAdddressRaw
|
||||
// Access: Public
|
||||
// Description: Return a RAW sockaddr_in
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE unsigned long Socket_Address::
|
||||
GetIPAddressRaw() const {
|
||||
return _addr.sin_addr.s_addr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address
|
||||
// Access: Published
|
||||
// Description: Constructor that lets us set a port value
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Socket_Address::
|
||||
Socket_Address(unsigned short port) {
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(port);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::Copy constructor
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Socket_Address::
|
||||
Socket_Address(const Socket_Address &inaddr) {
|
||||
_addr.sin_family = inaddr._addr.sin_family;
|
||||
_addr.sin_addr.s_addr = inaddr._addr.sin_addr.s_addr;
|
||||
_addr.sin_port = inaddr._addr.sin_port;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Socket_Address::
|
||||
Socket_Address(const AddressType &inaddr) {
|
||||
_addr.sin_family = inaddr.sin_family;
|
||||
_addr.sin_addr.s_addr = inaddr.sin_addr.s_addr;
|
||||
_addr.sin_port = inaddr.sin_port;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::~Destructor
|
||||
// Access: Published
|
||||
// Description: Normal Destructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Socket_Address::
|
||||
~Socket_Address() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::operator ==
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
operator == (const Socket_Address &in) const {
|
||||
return ((_addr.sin_family == in._addr.sin_family) &&
|
||||
(_addr.sin_addr.s_addr == in._addr.sin_addr.s_addr) &&
|
||||
(_addr.sin_port == in._addr.sin_port));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::operator !=
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
operator != (const Socket_Address &in) const {
|
||||
return ((_addr.sin_family != in._addr.sin_family) ||
|
||||
(_addr.sin_addr.s_addr != in._addr.sin_addr.s_addr) ||
|
||||
(_addr.sin_port != in._addr.sin_port));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_broadcast
|
||||
// Access: Published
|
||||
// Description: Set to the broadcast address and a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_broadcast(int port) {
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = 0xffffffff;
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_any_IP
|
||||
// Access: Published
|
||||
// Description: Set to any address and a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_any_IP(int port) {
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_port
|
||||
// Access: Published
|
||||
// Description: Set to a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_port(int port) {
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::clear
|
||||
// Access: Published
|
||||
// Description: Set the internal values to a suitable known value
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void Socket_Address::
|
||||
clear() {
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::get_port
|
||||
// Access: Published
|
||||
// Description: Get the port portion as an integer
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE unsigned short Socket_Address::
|
||||
get_port() const {
|
||||
return ntohs(_addr.sin_port);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::get_ip
|
||||
// Access: Published
|
||||
// Description: Return the IP address portion in dot notation string
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE std::string Socket_Address::
|
||||
get_ip() const {
|
||||
return std::string(inet_ntoa(_addr.sin_addr));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::get_ip_port
|
||||
// Access: Published
|
||||
// Description: Return the ip address/port in dot notation string
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE std::string Socket_Address::
|
||||
get_ip_port() const {
|
||||
char buf1[100]; // 100 is more than enough for any ip address:port combo..
|
||||
sprintf(buf1, "%s:%d", inet_ntoa(_addr.sin_addr), get_port());
|
||||
return std::string(buf1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_host
|
||||
// Access: Published
|
||||
// Description: This function will take a port and string-based
|
||||
// TCP address and initialize the address with this
|
||||
// information. Returns true on success; on failure,
|
||||
// it returns false and the address may be undefined.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_host(const std::string &hostname, int port) {
|
||||
struct hostent *hp = NULL;
|
||||
|
||||
//
|
||||
// hmm inet_addr does not resolve 255.255.255.255 on ME/98 ??
|
||||
//
|
||||
// * HACK * ??
|
||||
if (hostname == "255.255.255.255") {
|
||||
return set_broadcast(port);
|
||||
}
|
||||
//
|
||||
//
|
||||
|
||||
PN_uint32 addr = (long)inet_addr(hostname.c_str());
|
||||
if (addr == INADDR_NONE) {
|
||||
hp = gethostbyname(hostname.c_str());
|
||||
if (hp == NULL) {
|
||||
return false;
|
||||
} else {
|
||||
memcpy(&_addr.sin_addr, hp->h_addr_list[0], (unsigned int) hp->h_length);
|
||||
}
|
||||
} else {
|
||||
memcpy(&_addr.sin_addr, &addr, sizeof(addr));
|
||||
}
|
||||
|
||||
_addr.sin_port = htons(port);
|
||||
_addr.sin_family = AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_host
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_host(const std::string &hostname) {
|
||||
std::string::size_type pos = hostname.find(':');
|
||||
if (pos == std::string::npos)
|
||||
return false;
|
||||
|
||||
std::string host = hostname.substr(0, pos);
|
||||
std::string port = hostname.substr(pos + 1, 100);;
|
||||
|
||||
int port_dig = atoi(port.c_str());
|
||||
return set_host(host, port_dig);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: Socket_Address::set_host
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
set_host(PN_uint32 in_hostname, int port) {
|
||||
memcpy(&_addr.sin_addr, &in_hostname, sizeof(in_hostname));
|
||||
_addr.sin_port = htons(port);
|
||||
_addr.sin_family = AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: <
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
operator < (const Socket_Address &in) const {
|
||||
if (_addr.sin_port < in._addr.sin_port)
|
||||
return true;
|
||||
|
||||
if (_addr.sin_port > in._addr.sin_port)
|
||||
return false;
|
||||
|
||||
if (_addr.sin_addr.s_addr < in._addr.sin_addr.s_addr)
|
||||
return true;
|
||||
|
||||
if (_addr.sin_addr.s_addr > in._addr.sin_addr.s_addr)
|
||||
return false;
|
||||
|
||||
return (_addr.sin_family < in._addr.sin_family);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: is_mcast_range
|
||||
// Access: Published
|
||||
// Description: True if the address is in the multicast range.
|
||||
//////////////////////////////////////////////////////////////
|
||||
INLINE bool Socket_Address::
|
||||
is_mcast_range(void) const {
|
||||
PN_uint32 address = ntohl(_addr.sin_addr.s_addr);
|
||||
//224.0.0.0-239.255.255.255 .. e0,ef
|
||||
return (address >= 0xe0000000 && address < 0xefffffff);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __SOCKET_ADDRESS_H__
|
||||
#define __SOCKET_ADDRESS_H__
|
||||
#ifndef SOCKET_ADDRESS_H
|
||||
#define SOCKET_ADDRESS_H
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "numeric_types.h"
|
||||
|
|
@ -12,277 +12,43 @@
|
|||
// communication layer
|
||||
//
|
||||
//////////////////////////////
|
||||
class EXPCL_PANDA_NATIVENET Socket_Address
|
||||
{
|
||||
class EXPCL_PANDA_NATIVENET Socket_Address {
|
||||
public:
|
||||
typedef struct sockaddr_in AddressType;
|
||||
Socket_Address(const AddressType &inaddr);
|
||||
AddressType & GetAddressInfo() { return _addr; }
|
||||
const AddressType & GetAddressInfo() const { return _addr; }
|
||||
typedef struct sockaddr_in AddressType;
|
||||
Socket_Address(const AddressType &inaddr);
|
||||
AddressType &GetAddressInfo() { return _addr; }
|
||||
const AddressType &GetAddressInfo() const { return _addr; }
|
||||
|
||||
PUBLISHED:
|
||||
|
||||
inline Socket_Address(short port = 0);
|
||||
inline Socket_Address(const Socket_Address &inaddr);
|
||||
INLINE Socket_Address(unsigned short port = 0);
|
||||
INLINE Socket_Address(const Socket_Address &inaddr);
|
||||
|
||||
inline virtual ~Socket_Address();
|
||||
|
||||
inline bool set_any_IP(int port);
|
||||
inline bool set_port(int port);
|
||||
inline bool set_broadcast(int port);
|
||||
|
||||
inline bool set_host(const std::string &hostname, int port) ;
|
||||
inline bool set_host(const std::string &hostname) ;
|
||||
inline bool set_host(unsigned int ip4adr, int port);
|
||||
inline void clear();
|
||||
|
||||
inline unsigned short get_port() const;
|
||||
inline std::string get_ip() const ;
|
||||
inline std::string get_ip_port() const;
|
||||
inline unsigned long GetIPAddressRaw() const;
|
||||
|
||||
inline bool operator== (const Socket_Address &in) const;
|
||||
inline bool operator < (const Socket_Address &in) const;
|
||||
|
||||
INLINE virtual ~Socket_Address();
|
||||
|
||||
inline bool isMcastRange();
|
||||
INLINE bool set_any_IP(int port);
|
||||
INLINE bool set_port(int port);
|
||||
INLINE bool set_broadcast(int port);
|
||||
|
||||
INLINE bool set_host(const std::string &hostname, int port) ;
|
||||
INLINE bool set_host(const std::string &hostname) ;
|
||||
INLINE bool set_host(unsigned int ip4adr, int port);
|
||||
INLINE void clear();
|
||||
|
||||
INLINE unsigned short get_port() const;
|
||||
INLINE std::string get_ip() const ;
|
||||
INLINE std::string get_ip_port() const;
|
||||
INLINE unsigned long GetIPAddressRaw() const;
|
||||
|
||||
INLINE bool operator ==(const Socket_Address &in) const;
|
||||
INLINE bool operator !=(const Socket_Address &in) const;
|
||||
INLINE bool operator < (const Socket_Address &in) const;
|
||||
|
||||
INLINE bool is_mcast_range() const;
|
||||
|
||||
private:
|
||||
AddressType _addr;
|
||||
|
||||
AddressType _addr;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address::GetIPAdddressRaw
|
||||
// Description : Return a RAW sockaddr_in
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline unsigned long Socket_Address::GetIPAddressRaw() const
|
||||
{
|
||||
return _addr.sin_addr.s_addr;
|
||||
}
|
||||
#include "socket_address.I"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address
|
||||
// Description : Constructor that lets us set a port value
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline Socket_Address::Socket_Address(short port)
|
||||
{
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(port);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address Constructor
|
||||
// Description : Copy Constructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline Socket_Address::Socket_Address(const Socket_Address &inaddr)
|
||||
{
|
||||
_addr.sin_family = inaddr._addr.sin_family;
|
||||
_addr.sin_addr.s_addr = inaddr._addr.sin_addr.s_addr;
|
||||
_addr.sin_port = inaddr._addr.sin_port;
|
||||
}
|
||||
|
||||
inline Socket_Address::Socket_Address(const AddressType &inaddr)
|
||||
{
|
||||
_addr.sin_family = inaddr.sin_family;
|
||||
_addr.sin_addr.s_addr = inaddr.sin_addr.s_addr;
|
||||
_addr.sin_port = inaddr.sin_port;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : ~Socket_Address::Socket_Address
|
||||
// Description : Normal Destructor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline Socket_Address::~Socket_Address()
|
||||
{}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address::operator==
|
||||
// Description : Allow for normal == operation on a address item..
|
||||
// Will simplify the use in sorted containers..
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::operator==(const Socket_Address &in) const
|
||||
{
|
||||
return ((_addr.sin_family == in._addr.sin_family) &&
|
||||
(_addr.sin_addr.s_addr == in._addr.sin_addr.s_addr) &&
|
||||
(_addr.sin_port == in._addr.sin_port)
|
||||
);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : set_broadcast
|
||||
// Description : Set to the broadcast address and a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_broadcast(int port)
|
||||
{
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = 0xffffffff;
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : set_any_IP
|
||||
// Description : Set to any address and a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_any_IP(int port)
|
||||
{
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : set_port
|
||||
// Description : Set to a specified port
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_port(int port)
|
||||
{
|
||||
_addr.sin_port = htons(port);
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : clear
|
||||
// Description : Set the internal values to a suitable known value
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline void Socket_Address::clear()
|
||||
{
|
||||
_addr.sin_family = AF_INET;
|
||||
_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
_addr.sin_port = htons(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : get_port
|
||||
// Description : Get the port portion as an integer
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline unsigned short Socket_Address::get_port() const
|
||||
{
|
||||
return ntohs(_addr.sin_port);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : get_ip
|
||||
// Description : Return the ip address portion in dot notation string
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline std::string Socket_Address::get_ip() const
|
||||
{
|
||||
return std::string(inet_ntoa(_addr.sin_addr));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : get_ip_port
|
||||
// Description : Return the ip address/port in dot notation string
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline std::string Socket_Address::get_ip_port() const
|
||||
{
|
||||
char buf1[100]; // 100 is more than enough for any ip address:port combo..
|
||||
sprintf(buf1, "%s:%d", inet_ntoa(_addr.sin_addr), get_port());
|
||||
return std::string(buf1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function name : set_host
|
||||
// Description : this function will take a port and string-based tcp address and initialize
|
||||
// the address with the information
|
||||
//
|
||||
// Return type : bool (address is undefined after an error)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_host(const std::string &hostname, int port)
|
||||
{
|
||||
struct hostent *hp = NULL;
|
||||
|
||||
//
|
||||
// hmm inet_addr does not resolve 255.255.255.255 on ME/98 ??
|
||||
//
|
||||
// * HACK * ??
|
||||
if(hostname == "255.255.255.255")
|
||||
return set_broadcast(port);
|
||||
//
|
||||
//
|
||||
|
||||
PN_uint32 addr = (long)inet_addr (hostname.c_str());
|
||||
if(addr == INADDR_NONE)
|
||||
{
|
||||
hp = gethostbyname(hostname.c_str());
|
||||
if(hp== NULL)
|
||||
return false;
|
||||
else
|
||||
memcpy(&(_addr.sin_addr),hp->h_addr_list[0] , (unsigned int) hp->h_length);
|
||||
}
|
||||
else
|
||||
(void) memcpy(&_addr.sin_addr,&addr,sizeof(addr));
|
||||
|
||||
_addr.sin_port = htons(port);
|
||||
_addr.sin_family = AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address::set_host
|
||||
// Description :
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_host(const std::string &hostname)
|
||||
{
|
||||
std::string::size_type pos = hostname.find(':');
|
||||
if (pos == std::string::npos)
|
||||
return false;
|
||||
|
||||
std::string host = hostname.substr(0, pos);
|
||||
std::string port = hostname.substr(pos + 1, 100);;
|
||||
|
||||
int port_dig = atoi(port.c_str());
|
||||
|
||||
return set_host(host, port_dig);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : Socket_Address::set_host
|
||||
// Description :
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::set_host(PN_uint32 in_hostname, int port)
|
||||
{
|
||||
memcpy(&_addr.sin_addr, &in_hostname, sizeof(in_hostname));
|
||||
_addr.sin_port = htons(port);
|
||||
_addr.sin_family = AF_INET;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : <
|
||||
// Description :
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::operator < (const Socket_Address &in) const
|
||||
{
|
||||
if (_addr.sin_port < in._addr.sin_port)
|
||||
return true;
|
||||
|
||||
if (_addr.sin_port > in._addr.sin_port)
|
||||
return false;
|
||||
|
||||
if (_addr.sin_addr.s_addr < in._addr.sin_addr.s_addr)
|
||||
return true;
|
||||
|
||||
if (_addr.sin_addr.s_addr > in._addr.sin_addr.s_addr)
|
||||
return false;
|
||||
|
||||
|
||||
return (_addr.sin_family < in._addr.sin_family);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function name : isMcastRange
|
||||
// Description : return true if the address is in the mcast range.
|
||||
//////////////////////////////////////////////////////////////
|
||||
inline bool Socket_Address::isMcastRange(void)
|
||||
{
|
||||
PN_uint32 address = ntohl(_addr.sin_addr.s_addr);
|
||||
//224.0.0.0-239.255.255.255 .. e0,ef
|
||||
if(address >= 0xe0000000 && address < 0xefffffff)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endif //__SOCKET_ADDRESS_H__
|
||||
#endif // SOCKET_ADDRESS_H
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::Constructor
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Constructs an unspecified address.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NetAddress::
|
||||
|
|
@ -27,7 +27,7 @@ NetAddress() {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::Constructor
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Constructs an address from a given Socket_Address.
|
||||
// Normally, this constructor should not be used by user
|
||||
// code; instead, create a default NetAddress and use
|
||||
|
|
@ -40,7 +40,7 @@ NetAddress(const Socket_Address &addr) : _addr(addr) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::set_any
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Sets the address up to refer to a particular port,
|
||||
// but not to any particular IP. Returns true if
|
||||
// successful, false otherwise (currently, this only
|
||||
|
|
@ -53,7 +53,7 @@ set_any(int port) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::set_localhost
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Sets the address up to refer to a particular port,
|
||||
// on this host.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -64,7 +64,7 @@ set_localhost(int port) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::set_broadcast
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Sets the address to the broadcast address.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool NetAddress::
|
||||
|
|
@ -74,7 +74,7 @@ set_broadcast(int port) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::set_host
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Sets the address up to refer to a particular port
|
||||
// on a particular host. Returns true if the hostname
|
||||
// is known, false otherwise.
|
||||
|
|
@ -86,7 +86,7 @@ set_host(const string &hostname, int port) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::clear
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Resets the NetAddress to its initial state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NetAddress::
|
||||
|
|
@ -96,7 +96,7 @@ clear() {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_port
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns the port number to which this address refers.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int NetAddress::
|
||||
|
|
@ -106,7 +106,7 @@ get_port() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::set_port
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Resets the port number without otherwise changing the
|
||||
// address.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -117,7 +117,7 @@ set_port(int port) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_ip_string
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns the IP address to which this address refers,
|
||||
// formatted as a string.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -128,7 +128,7 @@ get_ip_string() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_ip
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns the IP address to which this address refers,
|
||||
// as a 32-bit integer, in host byte order.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -139,7 +139,7 @@ get_ip() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_ip_component
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns the nth 8-bit component of the IP address.
|
||||
// An IP address has four components; component 0 is the
|
||||
// first (leftmost), and component 3 is the last
|
||||
|
|
@ -156,7 +156,7 @@ get_ip_component(int n) const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_addr
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Returns the Socket_Address for this address.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const Socket_Address &NetAddress::
|
||||
|
|
@ -166,10 +166,40 @@ get_addr() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::output
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NetAddress::
|
||||
output(ostream &out) const {
|
||||
out << get_ip_string();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::get_hash
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
size_t NetAddress::
|
||||
get_hash() const {
|
||||
return (size_t)(((int)get_ip()) ^ ((int)get_port() << 16));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::operator ==
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
bool NetAddress::
|
||||
operator == (const NetAddress &other) const {
|
||||
return _addr == other._addr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Function: NetAddress::operator !=
|
||||
// Access: Published
|
||||
// Description:
|
||||
//////////////////////////////////////////////////////////////
|
||||
bool NetAddress::
|
||||
operator != (const NetAddress &other) const {
|
||||
return _addr != other._addr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ PUBLISHED:
|
|||
|
||||
void output(ostream &out) const;
|
||||
|
||||
size_t get_hash() const;
|
||||
bool operator == (const NetAddress &other) const;
|
||||
bool operator != (const NetAddress &other) const;
|
||||
|
||||
private:
|
||||
Socket_Address _addr;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ ConfigVariableBool depth_offset_decals
|
|||
"their depth offset implementation."));
|
||||
|
||||
ConfigVariableInt max_collect_vertices
|
||||
("max-collect-vertices", 65535,
|
||||
("max-collect-vertices", 65534,
|
||||
PRC_DESC("Specifies the maximum number of vertices that are allowed to be "
|
||||
"accumulated into any one GeomVertexData structure as a result "
|
||||
"of collecting objects together during a flatten operation. "
|
||||
|
|
|
|||
|
|
@ -1899,7 +1899,9 @@ copy_sub_image(const PfmFile ©, int xto, int yto,
|
|||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
set_point1(x, y, copy.get_point1(x - xmin + xfrom, y - ymin + yfrom));
|
||||
if (copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point1(x, y, copy.get_point1(x - xmin + xfrom, y - ymin + yfrom));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1909,7 +1911,9 @@ copy_sub_image(const PfmFile ©, int xto, int yto,
|
|||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
set_point2(x, y, copy.get_point2(x - xmin + xfrom, y - ymin + yfrom));
|
||||
if (copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point2(x, y, copy.get_point2(x - xmin + xfrom, y - ymin + yfrom));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1919,7 +1923,9 @@ copy_sub_image(const PfmFile ©, int xto, int yto,
|
|||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
set_point(x, y, copy.get_point(x - xmin + xfrom, y - ymin + yfrom));
|
||||
if (copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point(x, y, copy.get_point(x - xmin + xfrom, y - ymin + yfrom));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1929,7 +1935,9 @@ copy_sub_image(const PfmFile ©, int xto, int yto,
|
|||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
set_point4(x, y, copy.get_point4(x - xmin + xfrom, y - ymin + yfrom));
|
||||
if (copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point4(x, y, copy.get_point4(x - xmin + xfrom, y - ymin + yfrom));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1937,6 +1945,206 @@ copy_sub_image(const PfmFile ©, int xto, int yto,
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::add_sub_image
|
||||
// Access: Published
|
||||
// Description: Behaves like copy_sub_image(), except the copy pixels
|
||||
// are added to the pixels of the destination, after
|
||||
// scaling by the specified pixel_scale.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PfmFile::
|
||||
add_sub_image(const PfmFile ©, int xto, int yto,
|
||||
int xfrom, int yfrom, int x_size, int y_size,
|
||||
double pixel_scale) {
|
||||
int xmin, ymin, xmax, ymax;
|
||||
setup_sub_image(copy, xto, yto, xfrom, yfrom, x_size, y_size,
|
||||
xmin, ymin, xmax, ymax);
|
||||
|
||||
int x, y;
|
||||
switch (_num_channels) {
|
||||
case 1:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point1(x, y, get_point1(x, y) + copy.get_point1(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point2(x, y, get_point2(x, y) + copy.get_point2(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point3(x, y, get_point3(x, y) + copy.get_point3(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point4(x, y, get_point4(x, y) + copy.get_point4(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::mult_sub_image
|
||||
// Access: Published
|
||||
// Description: Behaves like copy_sub_image(), except the copy pixels
|
||||
// are multiplied to the pixels of the destination, after
|
||||
// scaling by the specified pixel_scale.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PfmFile::
|
||||
mult_sub_image(const PfmFile ©, int xto, int yto,
|
||||
int xfrom, int yfrom, int x_size, int y_size,
|
||||
double pixel_scale) {
|
||||
int xmin, ymin, xmax, ymax;
|
||||
setup_sub_image(copy, xto, yto, xfrom, yfrom, x_size, y_size,
|
||||
xmin, ymin, xmax, ymax);
|
||||
|
||||
int x, y;
|
||||
switch (_num_channels) {
|
||||
case 1:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
set_point1(x, y, get_point1(x, y) * (copy.get_point1(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
modify_point2(x, y).componentwise_mult(copy.get_point2(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
modify_point3(x, y).componentwise_mult(copy.get_point3(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
if (has_point(x, y) && copy.has_point(x - xmin + xfrom, y - ymin + yfrom)) {
|
||||
modify_point4(x, y).componentwise_mult(copy.get_point4(x - xmin + xfrom, y - ymin + yfrom) * pixel_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::operator *=
|
||||
// Access: Published
|
||||
// Description: Multiplies every point value in the image by
|
||||
// a constant floating-point multiplier value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PfmFile::
|
||||
operator *= (double multiplier) {
|
||||
nassertv(is_valid());
|
||||
|
||||
switch (_num_channels) {
|
||||
case 1:
|
||||
{
|
||||
for (int y = 0; y < _y_size; ++y) {
|
||||
for (int x = 0; x < _x_size; ++x) {
|
||||
if (has_point(x, y)) {
|
||||
PN_float32 p = get_point1(x, y);
|
||||
p *= multiplier;
|
||||
set_point1(x, y, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
for (int y = 0; y < _y_size; ++y) {
|
||||
for (int x = 0; x < _x_size; ++x) {
|
||||
if (has_point(x, y)) {
|
||||
LPoint2f &p = modify_point2(x, y);
|
||||
p *= multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
for (int y = 0; y < _y_size; ++y) {
|
||||
for (int x = 0; x < _x_size; ++x) {
|
||||
if (has_point(x, y)) {
|
||||
LPoint3f &p = modify_point3(x, y);
|
||||
p *= multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
{
|
||||
for (int y = 0; y < _y_size; ++y) {
|
||||
for (int x = 0; x < _x_size; ++x) {
|
||||
if (has_point(x, y)) {
|
||||
LPoint4f &p = modify_point4(x, y);
|
||||
p *= multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PfmFile::output
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -140,6 +140,16 @@ PUBLISHED:
|
|||
void copy_sub_image(const PfmFile ©, int xto, int yto,
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1);
|
||||
void add_sub_image(const PfmFile ©, int xto, int yto,
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1,
|
||||
double pixel_scale = 1.0);
|
||||
void mult_sub_image(const PfmFile ©, int xto, int yto,
|
||||
int xfrom = 0, int yfrom = 0,
|
||||
int x_size = -1, int y_size = -1,
|
||||
double pixel_scale = 1.0);
|
||||
|
||||
void operator *= (double multiplier);
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -214,13 +214,4 @@ init_libputil() {
|
|||
|
||||
BamCacheIndex::register_with_read_factory();
|
||||
BamCacheRecord::register_with_read_factory();
|
||||
|
||||
// Initialize the num_bits_on table, for BitMask::get_num_on_bits().
|
||||
for (int bit = 0; bit < 16; ++bit) {
|
||||
int w = (1 << bit);
|
||||
for (int i = 0; i < w; ++i) {
|
||||
num_bits_on[i + w] = num_bits_on[i] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,11 @@ count_bits_in_word(PN_uint16 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
count_bits_in_word(PN_uint32 x) {
|
||||
#if defined(__GNUC__) && defined(__POPCNT__)
|
||||
return __builtin_popcount((unsigned int) x);
|
||||
#else
|
||||
return (int)num_bits_on[x & 0xffff] + (int)num_bits_on[(x >> 16) & 0xffff];
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -37,7 +41,11 @@ count_bits_in_word(PN_uint32 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
count_bits_in_word(PN_uint64 x) {
|
||||
#if defined(__GNUC__) && defined(__POPCNT__)
|
||||
return __builtin_popcountll((unsigned long long) x);
|
||||
#else
|
||||
return count_bits_in_word((PN_uint32)x) + count_bits_in_word((PN_uint32)(x >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -137,12 +145,19 @@ flood_bits_up(PN_uint64 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_lowest_on_bit(PN_uint16 x) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result;
|
||||
return (_BitScanForward(&result, (unsigned long) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return __builtin_ffs((unsigned int) x) - 1;
|
||||
#else
|
||||
if (x == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PN_uint16 w = (x & (~x + 1));
|
||||
return (int)num_bits_on[w - 1];
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -152,12 +167,19 @@ get_lowest_on_bit(PN_uint16 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_lowest_on_bit(PN_uint32 x) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result;
|
||||
return (_BitScanForward(&result, (unsigned long) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return __builtin_ffs((unsigned int) x) - 1;
|
||||
#else
|
||||
if (x == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PN_uint32 w = (x & (~x + 1));
|
||||
return count_bits_in_word(w - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -167,12 +189,19 @@ get_lowest_on_bit(PN_uint32 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_lowest_on_bit(PN_uint64 x) {
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
unsigned long result;
|
||||
return (_BitScanForward64(&result, (unsigned __int64) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return __builtin_ffsll((unsigned long long) x) - 1;
|
||||
#else
|
||||
if (x == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PN_uint64 w = (x & (~x + 1));
|
||||
return count_bits_in_word(w - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -182,8 +211,15 @@ get_lowest_on_bit(PN_uint64 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_highest_on_bit(PN_uint16 x) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result;
|
||||
return (_BitScanReverse(&result, (unsigned long) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return (x == 0) ? -1 : 31 - __builtin_clz((unsigned int) x);
|
||||
#else
|
||||
PN_uint16 w = flood_bits_down(x);
|
||||
return count_bits_in_word(w) - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -193,8 +229,15 @@ get_highest_on_bit(PN_uint16 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_highest_on_bit(PN_uint32 x) {
|
||||
#if defined(_MSC_VER)
|
||||
unsigned long result;
|
||||
return (_BitScanReverse(&result, (unsigned long) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return (x == 0) ? -1 : 31 - __builtin_clz((unsigned int) x);
|
||||
#else
|
||||
PN_uint32 w = flood_bits_down(x);
|
||||
return count_bits_in_word(w) - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -204,8 +247,15 @@ get_highest_on_bit(PN_uint32 x) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int
|
||||
get_highest_on_bit(PN_uint64 x) {
|
||||
#if defined(_MSC_VER) && defined(_M_X64)
|
||||
unsigned long result;
|
||||
return (_BitScanReverse64(&result, (unsigned __int64) x) == 0) ? -1 : result;
|
||||
#elif defined(__GNUC__)
|
||||
return (x == 0) ? -1 : 63 - __builtin_clzll((unsigned long long) x);
|
||||
#else
|
||||
PN_uint64 w = flood_bits_down(x);
|
||||
return count_bits_in_word(w) - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -18,6 +18,10 @@
|
|||
#include "pandabase.h"
|
||||
#include "numeric_types.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// This file defines a few low-level bit-operation routines, optimized
|
||||
// all to heck.
|
||||
|
|
@ -46,7 +50,7 @@ INLINE int get_next_higher_bit(PN_uint32 x);
|
|||
INLINE int get_next_higher_bit(PN_uint64 x);
|
||||
|
||||
// This table precomputes the number of on bits in each 16-bit word.
|
||||
extern EXPCL_PANDA_PUTIL unsigned char num_bits_on[65536];
|
||||
extern EXPCL_PANDA_PUTIL const unsigned char num_bits_on[65536];
|
||||
|
||||
#include "pbitops.I"
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ PUBLISHED:
|
|||
const string &data,
|
||||
BamReader *reader = NULL);
|
||||
|
||||
public:
|
||||
private:
|
||||
void add_bam_writer(BamWriter *writer);
|
||||
void remove_bam_writer(BamWriter *writer);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ main(int argc, char *argv[]) {
|
|||
// application by closing the main window.
|
||||
g_signal_connect(G_OBJECT(main_window), "delete_event",
|
||||
G_CALLBACK(delete_event), NULL);
|
||||
|
||||
|
||||
g_signal_connect(G_OBJECT(main_window), "destroy",
|
||||
G_CALLBACK(destroy), NULL);
|
||||
|
||||
|
|
@ -82,18 +82,18 @@ main(int argc, char *argv[]) {
|
|||
server = new GtkStatsServer;
|
||||
if (!server->listen()) {
|
||||
ostringstream stream;
|
||||
stream
|
||||
stream
|
||||
<< "Unable to open port " << pstats_port
|
||||
<< ". Try specifying a different\n"
|
||||
<< "port number using pstats-port in your Config file.";
|
||||
string str = stream.str();
|
||||
|
||||
GtkWidget *dialog =
|
||||
GtkWidget *dialog =
|
||||
gtk_message_dialog_new(GTK_WINDOW(main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
str.c_str());
|
||||
"%s", str.c_str());
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
exit(1);
|
||||
|
|
|
|||
|
|
@ -26,21 +26,21 @@
|
|||
typedef void vc();
|
||||
|
||||
GtkItemFactoryEntry GtkStatsMonitor::menu_entries[] = {
|
||||
{ "/Options", NULL, NULL, 0, "<Branch>" },
|
||||
{ "/Options/Units", NULL, NULL, 0, "<Branch>" },
|
||||
{ "/Options/Units/ms", NULL, (vc *)&handle_menu_command, MI_time_ms, "<RadioItem>" },
|
||||
{ "/Options/Units/Hz", NULL, (vc *)&handle_menu_command, MI_time_hz, "/Options/Units/ms" },
|
||||
{ "/Speed", NULL, NULL, 0, "<Branch>" },
|
||||
{ "/Speed/1", NULL, (vc *)&handle_menu_command, MI_speed_1, "<RadioItem>" },
|
||||
{ "/Speed/2", NULL, (vc *)&handle_menu_command, MI_speed_2, "/Speed/1" },
|
||||
{ "/Speed/3", NULL, (vc *)&handle_menu_command, MI_speed_3, "/Speed/1" },
|
||||
{ "/Speed/6", NULL, (vc *)&handle_menu_command, MI_speed_6, "/Speed/1" },
|
||||
{ "/Speed/12", NULL, (vc *)&handle_menu_command, MI_speed_12, "/Speed/1" },
|
||||
{ "/Speed/sep", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/Speed/pause", NULL, (vc *)&handle_menu_command, MI_pause, "<CheckItem>" },
|
||||
{ (gchar *)"/Options", NULL, NULL, 0, (gchar *)"<Branch>" },
|
||||
{ (gchar *)"/Options/Units", NULL, NULL, 0, (gchar *)"<Branch>" },
|
||||
{ (gchar *)"/Options/Units/ms", NULL, (vc *)&handle_menu_command, MI_time_ms, (gchar *)"<RadioItem>" },
|
||||
{ (gchar *)"/Options/Units/Hz", NULL, (vc *)&handle_menu_command, MI_time_hz, (gchar *)"/Options/Units/ms" },
|
||||
{ (gchar *)"/Speed", NULL, NULL, 0, (gchar *)"<Branch>" },
|
||||
{ (gchar *)"/Speed/1", NULL, (vc *)&handle_menu_command, MI_speed_1, (gchar *)"<RadioItem>" },
|
||||
{ (gchar *)"/Speed/2", NULL, (vc *)&handle_menu_command, MI_speed_2, (gchar *)"/Speed/1" },
|
||||
{ (gchar *)"/Speed/3", NULL, (vc *)&handle_menu_command, MI_speed_3, (gchar *)"/Speed/1" },
|
||||
{ (gchar *)"/Speed/6", NULL, (vc *)&handle_menu_command, MI_speed_6, (gchar *)"/Speed/1" },
|
||||
{ (gchar *)"/Speed/12", NULL, (vc *)&handle_menu_command, MI_speed_12, (gchar *)"/Speed/1" },
|
||||
{ (gchar *)"/Speed/sep", NULL, NULL, 0, (gchar *)"<Separator>" },
|
||||
{ (gchar *)"/Speed/pause", NULL, (vc *)&handle_menu_command, MI_pause, (gchar *)"<CheckItem>" },
|
||||
};
|
||||
int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFactoryEntry);
|
||||
|
||||
int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFactoryEntry);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GtkStatsMonitor::Constructor
|
||||
|
|
@ -122,9 +122,9 @@ void GtkStatsMonitor::
|
|||
got_bad_version(int client_major, int client_minor,
|
||||
int server_major, int server_minor) {
|
||||
ostringstream str;
|
||||
str << "Unable to honor connection attempt from "
|
||||
<< get_client_progname() << " on " << get_client_hostname()
|
||||
<< ": unsupported PStats version "
|
||||
str << "Unable to honor connection attempt from "
|
||||
<< get_client_progname() << " on " << get_client_hostname()
|
||||
<< ": unsupported PStats version "
|
||||
<< client_major << "." << client_minor;
|
||||
|
||||
if (server_minor == 0) {
|
||||
|
|
@ -134,14 +134,14 @@ got_bad_version(int client_major, int client_minor,
|
|||
str << " (server understands versions " << server_major
|
||||
<< ".0 through " << server_major << "." << server_minor << ").";
|
||||
}
|
||||
|
||||
|
||||
string message = str.str();
|
||||
GtkWidget *dialog =
|
||||
GtkWidget *dialog =
|
||||
gtk_message_dialog_new(GTK_WINDOW(main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
message.c_str());
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", message.c_str());
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ process(const Filename &filename) {
|
|||
|
||||
write_faces(*file, _egg_data);
|
||||
|
||||
bool success = (void *)(*file) != NULL;
|
||||
bool success = (file != (ostream *)NULL);
|
||||
vfs->close_write_file(file);
|
||||
|
||||
return success;
|
||||
|
|
|
|||
Loading…
Reference in New Issue