mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
interim save
This commit is contained in:
parent
53a7e319d8
commit
78c82c3747
@ -96,11 +96,11 @@ traverse(const NodePath &root, bool python_cull_control) {
|
|||||||
portal_viewer.draw_camera_frustum();
|
portal_viewer.draw_camera_frustum();
|
||||||
|
|
||||||
// for each portal draw its frustum
|
// for each portal draw its frustum
|
||||||
for (int portal_idx=1; portal_idx<2; ++portal_idx) {
|
for (int portal_idx=2; portal_idx<3; ++portal_idx) {
|
||||||
PT(BoundingVolume) reduced_frustum;
|
PT(BoundingVolume) reduced_frustum;
|
||||||
|
|
||||||
portal_viewer.prepare_portal(portal_idx);
|
portal_viewer.prepare_portal(portal_idx);
|
||||||
portal_viewer.clip_portal(portal_idx);
|
//portal_viewer.clip_portal(portal_idx);
|
||||||
if ((reduced_frustum = portal_viewer.get_reduced_frustum(portal_idx))) {
|
if ((reduced_frustum = portal_viewer.get_reduced_frustum(portal_idx))) {
|
||||||
// This reduced frustum is in camera space
|
// This reduced frustum is in camera space
|
||||||
pgraph_cat.debug() << "got reduced frustum " << reduced_frustum << endl;
|
pgraph_cat.debug() << "got reduced frustum " << reduced_frustum << endl;
|
||||||
|
@ -363,46 +363,62 @@ get_reduced_frustum(int idx)
|
|||||||
// than bounding planes (which I might have to implement soon)
|
// than bounding planes (which I might have to implement soon)
|
||||||
|
|
||||||
if (!_num_vert)
|
if (!_num_vert)
|
||||||
return false;
|
return NULL;
|
||||||
|
|
||||||
float t;
|
float t;
|
||||||
|
bool visible = true;
|
||||||
// find intersection of 7->0 with far
|
// find intersection of 7->0 with far
|
||||||
LPoint3f from_origin = _hex_frustum->get_point(7);
|
LPoint3f from_origin = _hex_frustum->get_point(7);
|
||||||
LVector3f from_direction = _coords[0] - from_origin;
|
LVector3f from_direction = _coords[0] - from_origin;
|
||||||
bool is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
bool is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
||||||
if (is_intersect) {
|
if (is_intersect && t >= 0.0) { // has to be positive, else camera is not looking at the portal
|
||||||
pgraph_cat.debug() << "far plane intersected 7->0 at t=" << t << endl;
|
pgraph_cat.debug() << "far plane intersected 7->0 at t=" << t << endl;
|
||||||
intersect_points[0] = from_origin + t*from_direction;
|
intersect_points[0] = from_origin + t*from_direction;
|
||||||
pgraph_cat.debug() << intersect_points[0] << endl;
|
pgraph_cat.debug() << intersect_points[0] << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
visible = false;
|
||||||
|
|
||||||
// find intersection of 4->1 with far
|
// find intersection of 4->1 with far
|
||||||
from_origin = _hex_frustum->get_point(4);
|
from_origin = _hex_frustum->get_point(4);
|
||||||
from_direction = _coords[1] - from_origin;
|
from_direction = _coords[1] - from_origin;
|
||||||
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
||||||
if (is_intersect) {
|
if (is_intersect && t >= 0.0) { // has to be positive, else camera is not looking at the portal
|
||||||
pgraph_cat.debug() << "far plane intersected 4->1 at t=" << t << endl;
|
pgraph_cat.debug() << "far plane intersected 4->1 at t=" << t << endl;
|
||||||
intersect_points[1] = from_origin + t*from_direction;
|
intersect_points[1] = from_origin + t*from_direction;
|
||||||
pgraph_cat.debug() << intersect_points[1] << endl;
|
pgraph_cat.debug() << intersect_points[1] << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
visible = false;
|
||||||
|
|
||||||
// find intersection of 5->2 with far
|
// find intersection of 5->2 with far
|
||||||
from_origin = _hex_frustum->get_point(5);
|
from_origin = _hex_frustum->get_point(5);
|
||||||
from_direction = _coords[2] - from_origin;
|
from_direction = _coords[2] - from_origin;
|
||||||
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
||||||
if (is_intersect) {
|
if (is_intersect && t >= 0.0) { // has to be positive, else camera is not looking at the portal
|
||||||
pgraph_cat.debug() << "far plane intersected 5->2 at t=" << t << endl;
|
pgraph_cat.debug() << "far plane intersected 5->2 at t=" << t << endl;
|
||||||
intersect_points[2] = from_origin + t*from_direction;
|
intersect_points[2] = from_origin + t*from_direction;
|
||||||
pgraph_cat.debug() << intersect_points[2] << endl;
|
pgraph_cat.debug() << intersect_points[2] << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
visible = false;
|
||||||
|
|
||||||
// find intersection of 6->3 with far
|
// find intersection of 6->3 with far
|
||||||
from_origin = _hex_frustum->get_point(6);
|
from_origin = _hex_frustum->get_point(6);
|
||||||
from_direction = _coords[3] - from_origin;
|
from_direction = _coords[3] - from_origin;
|
||||||
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
is_intersect = _hex_frustum->get_plane(0).intersects_line(t, from_origin, from_direction);
|
||||||
if (is_intersect) {
|
if (is_intersect && t >= 0.0) { // has to be positive, else camera is not looking at the portal
|
||||||
pgraph_cat.debug() << "far plane intersected 6->3 at t=" << t << endl;
|
pgraph_cat.debug() << "far plane intersected 6->3 at t=" << t << endl;
|
||||||
intersect_points[3] = from_origin + t*from_direction;
|
intersect_points[3] = from_origin + t*from_direction;
|
||||||
pgraph_cat.debug() << intersect_points[3] << endl;
|
pgraph_cat.debug() << intersect_points[3] << endl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
visible = false;
|
||||||
|
|
||||||
|
if (!visible) {
|
||||||
|
pgraph_cat.debug() << "portal" << idx << " is not visible from current camera look at" << endl;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// With these intersect_points, construct the new reduced frustum
|
// With these intersect_points, construct the new reduced frustum
|
||||||
PT(BoundingVolume) reduced_frustum = new
|
PT(BoundingVolume) reduced_frustum = new
|
||||||
|
@ -229,7 +229,17 @@ recompute_internal_bound() {
|
|||||||
BoundingVolume *bound = PandaNode::recompute_internal_bound();
|
BoundingVolume *bound = PandaNode::recompute_internal_bound();
|
||||||
nassertr(bound != (BoundingVolume *)NULL, bound);
|
nassertr(bound != (BoundingVolume *)NULL, bound);
|
||||||
|
|
||||||
|
GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound);
|
||||||
|
|
||||||
// Now actually compute the bounding volume by putting it around all
|
// Now actually compute the bounding volume by putting it around all
|
||||||
|
// of our vertices.
|
||||||
|
|
||||||
|
const LPoint3f *vertices_begin = &_vertices[0];
|
||||||
|
const LPoint3f *vertices_end = vertices_begin + _vertices.size();
|
||||||
|
|
||||||
|
// Now actually compute the bounding volume by putting it around all
|
||||||
|
gbv->around(vertices_begin, vertices_end);
|
||||||
|
|
||||||
return bound;
|
return bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user