Browse Source

fixes for small point rendering

David Rose 19 years ago
parent
commit
6257151e81
2 changed files with 8 additions and 7 deletions
  1. 7 5
      panda/src/text/dynamicTextGlyph.cxx
  2. 1 2
      panda/src/text/textNode.cxx

+ 7 - 5
panda/src/text/dynamicTextGlyph.cxx

@@ -116,11 +116,13 @@ make_geom(int bitmap_top, int bitmap_left, float advance, float poly_margin,
   float bottom = origin_y - tex_y_size / tex_pixels_per_unit - tex_poly_margin;
   float bottom = origin_y - tex_y_size / tex_pixels_per_unit - tex_poly_margin;
   float right = origin_x + tex_x_size / tex_pixels_per_unit + tex_poly_margin;
   float right = origin_x + tex_x_size / tex_pixels_per_unit + tex_poly_margin;
 
 
-  // And the corresponding corners in UV units.
-  float uv_top = 1.0f - (float)(_y - poly_margin) / _page->get_y_size();
-  float uv_left = (float)(_x - poly_margin) / _page->get_x_size();
-  float uv_bottom = 1.0f - (float)(_y + poly_margin + tex_y_size) / _page->get_y_size();
-  float uv_right = (float)(_x + poly_margin + tex_x_size) / _page->get_x_size();
+  // And the corresponding corners in UV units.  We add 0.5f to center
+  // the UV in the middle of its texel, to minimize roundoff errors
+  // when we are close to 1-to-1 pixel size.
+  float uv_top = 1.0f - ((float)(_y - poly_margin) + 0.5f) / _page->get_y_size();
+  float uv_left = ((float)(_x - poly_margin) + 0.5f) / _page->get_x_size();
+  float uv_bottom = 1.0f - ((float)(_y + poly_margin + tex_y_size) + 0.5f) / _page->get_y_size();
+  float uv_right = ((float)(_x + poly_margin + tex_x_size) + 0.5f) / _page->get_x_size();
   // Create a corresponding triangle pair.  We use a pair of indexed
   // Create a corresponding triangle pair.  We use a pair of indexed
   // triangles rther than a single triangle strip, to avoid the bad
   // triangles rther than a single triangle strip, to avoid the bad
   // vertex duplication behavior with lots of two-triangle strips.
   // vertex duplication behavior with lots of two-triangle strips.

+ 1 - 2
panda/src/text/textNode.cxx

@@ -237,8 +237,7 @@ output(ostream &out) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void TextNode::
 void TextNode::
 write(ostream &out, int indent_level) const {
 write(ostream &out, int indent_level) const {
-  indent(out, indent_level)
-    << "TextNode " << get_name() << "\n";
+  PandaNode::write(out, indent_level);
   TextProperties::write(out, indent_level + 2);
   TextProperties::write(out, indent_level + 2);
   indent(out, indent_level + 2)
   indent(out, indent_level + 2)
     << "transform is: " << *TransformState::make_mat(_transform) << "\n";
     << "transform is: " << *TransformState::make_mat(_transform) << "\n";