fix confusion with depth range of Lens::project()
This commit is contained in:
parent
6a1beaf609
commit
93bd44e85e
|
|
@ -1144,7 +1144,7 @@ get_supports_render_texture() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::flip_ready
|
||||
// Access: Public, Virtual
|
||||
// Access: Published, Virtual
|
||||
// Description: Returns true if a frame has been rendered and needs
|
||||
// to be flipped, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1155,7 +1155,7 @@ flip_ready() const {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::get_host
|
||||
// Access: Public, Virtual
|
||||
// Access: Published, Virtual
|
||||
// Description: This is normally called only from within
|
||||
// make_texture_buffer(). When called on a
|
||||
// ParasiteBuffer, it returns the host of that buffer;
|
||||
|
|
|
|||
|
|
@ -215,14 +215,16 @@ PUBLISHED:
|
|||
|
||||
virtual bool get_supports_render_texture() const;
|
||||
|
||||
public:
|
||||
// These are not intended to be called directly by the user.
|
||||
PUBLISHED:
|
||||
// These are not intended to be called directly by the user, but
|
||||
// they're published anyway since they might occasionally be useful
|
||||
// for low-level debugging.
|
||||
virtual bool flip_ready() const;
|
||||
|
||||
INLINE bool operator < (const GraphicsOutput &other) const;
|
||||
|
||||
virtual GraphicsOutput *get_host();
|
||||
|
||||
public:
|
||||
INLINE bool operator < (const GraphicsOutput &other) const;
|
||||
|
||||
virtual void request_open();
|
||||
virtual void request_close();
|
||||
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &
|
|||
// (-1,-1) is the lower-left corner.
|
||||
//
|
||||
// Some lens types also set the z coordinate of the 2-d
|
||||
// point to a value in the range (-1, 1), where 1
|
||||
// represents a point on the near plane, and -1
|
||||
// point to a value in the range (-1, 1), where -1
|
||||
// represents a point on the near plane, and 1
|
||||
// represents a point on the far plane.
|
||||
//
|
||||
// Returns true if the 3-d point is in front of the lens
|
||||
|
|
@ -159,8 +159,8 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point
|
|||
// The y position is the Z height divided by the perspective
|
||||
// distance.
|
||||
p[2] * focal_length / pdist,
|
||||
// Z is the distance scaled into the range 1 .. -1.
|
||||
1.0 - 2.0 * z
|
||||
// Z is the distance scaled into the range -1 .. 1.
|
||||
2.0 * z - 1.0
|
||||
);
|
||||
|
||||
// Now we have to transform the point according to the film
|
||||
|
|
|
|||
|
|
@ -149,8 +149,8 @@ do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &
|
|||
// (-1,-1) is the lower-left corner.
|
||||
//
|
||||
// Some lens types also set the z coordinate of the 2-d
|
||||
// point to a value in the range (-1, 1), where 1
|
||||
// represents a point on the near plane, and -1
|
||||
// point to a value in the range (-1, 1), where -1
|
||||
// represents a point on the near plane, and 1
|
||||
// represents a point on the far plane.
|
||||
//
|
||||
// Returns true if the 3-d point is in front of the lens
|
||||
|
|
@ -204,8 +204,8 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point
|
|||
point2d.set
|
||||
(y[0] * factor,
|
||||
y[1] * factor,
|
||||
// Z is the distance scaled into the range 1 .. -1.
|
||||
1.0 - 2.0 * z
|
||||
// Z is the distance scaled into the range -1 .. 1.
|
||||
2.0 * z - 1.0
|
||||
);
|
||||
|
||||
// Now we have to transform the point according to the film
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ do_extrude(const Lens::CData *lens_cdata,
|
|||
// (-1,-1) is the lower-left corner.
|
||||
//
|
||||
// Some lens types also set the z coordinate of the 2-d
|
||||
// point to a value in the range (-1, 1), where 1
|
||||
// represents a point on the near plane, and -1
|
||||
// point to a value in the range (-1, 1), where -1
|
||||
// represents a point on the near plane, and 1
|
||||
// represents a point on the far plane.
|
||||
//
|
||||
// Returns true if the 3-d point is in front of the lens
|
||||
|
|
@ -126,8 +126,8 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point
|
|||
rad_2_deg(catan2(xy[0], xy[1])) * focal_length / ospherical_k,
|
||||
// The y position is the Z height.
|
||||
p[2],
|
||||
// Z is the distance scaled into the range 1 .. -1.
|
||||
1.0 - 2.0 * z
|
||||
// Z is the distance scaled into the range -1 .. 1.
|
||||
2.0 * z - 1.0
|
||||
);
|
||||
|
||||
// Now we have to transform the point according to the film
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ do_extrude(const Lens::CData *lens_cdata,
|
|||
// (-1,-1) is the lower-left corner.
|
||||
//
|
||||
// Some lens types also set the z coordinate of the 2-d
|
||||
// point to a value in the range (-1, 1), where 1
|
||||
// represents a point on the near plane, and -1
|
||||
// point to a value in the range (-1, 1), where -1
|
||||
// represents a point on the near plane, and 1
|
||||
// represents a point on the far plane.
|
||||
//
|
||||
// Returns true if the 3-d point is in front of the lens
|
||||
|
|
@ -124,8 +124,8 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point
|
|||
rad_2_deg(catan2(xy[0], xy[1])) * focal_length / pspherical_k,
|
||||
// The y position is the angle about the X axis.
|
||||
rad_2_deg(catan2(yz[1], yz[0])) * focal_length / pspherical_k,
|
||||
// Z is the distance scaled into the range 1 .. -1.
|
||||
1.0 - 2.0 * z
|
||||
// Z is the distance scaled into the range -1 .. 1.
|
||||
2.0 * z - 1.0
|
||||
);
|
||||
|
||||
// Now we have to transform the point according to the film
|
||||
|
|
|
|||
|
|
@ -1254,7 +1254,11 @@ do_extrude_depth(const CData *cdata,
|
|||
const LPoint3 &point2d, LPoint3 &point3d) const {
|
||||
LPoint3 near_point, far_point;
|
||||
bool result = extrude(point2d, near_point, far_point);
|
||||
point3d = near_point + (far_point - near_point) * point2d[2];
|
||||
|
||||
// The depth point is, by convention, in the range -1 to 1. Scale
|
||||
// this to 0 .. 1 for the linear interpolation.
|
||||
PN_stdfloat t = point2d[2] * 0.5 + 0.5;
|
||||
point3d = near_point + (far_point - near_point) * t;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1317,8 +1321,8 @@ do_extrude_vec(const CData *cdata, const LPoint3 &point2d, LVector3 &vec) const
|
|||
// (-1,-1) is the lower-left corner.
|
||||
//
|
||||
// The z coordinate will also be set to a value in the
|
||||
// range (-1, 1), where 1 represents a point on the near
|
||||
// plane, and -1 represents a point on the far plane.
|
||||
// range (-1, 1), where -1 represents a point on the near
|
||||
// plane, and 1 represents a point on the far plane.
|
||||
//
|
||||
// Returns true if the 3-d point is in front of the lens
|
||||
// and within the viewing frustum (in which case point2d
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ extrude(const Lens *lens) {
|
|||
|
||||
static LMatrix4 from_uv(2.0, 0.0, 0.0, 0.0,
|
||||
0.0, 2.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
-1.0, -1.0, 0.0, 1.0);
|
||||
0.0, 0.0, 2.0, 0.0,
|
||||
-1.0, -1.0, -1.0, 1.0);
|
||||
|
||||
PfmFile result;
|
||||
result.clear(_pfm.get_x_size(), _pfm.get_y_size(), 3);
|
||||
|
|
|
|||
Loading…
Reference in New Issue