mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
move matrix computation
This commit is contained in:
parent
d7d049375c
commit
63ee254de2
@ -173,6 +173,37 @@ evaluate(const NodePath &rel_to) const {
|
|||||||
(int)_vertices.size());
|
(int)_vertices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NurbsCurveEvaluator::evaluate
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a NurbsCurveResult object that represents the
|
||||||
|
// result of applying the knots to all of the current
|
||||||
|
// values of the vertices, transformed into the
|
||||||
|
// indicated coordinate space, and then further
|
||||||
|
// transformed by the indicated matrix.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
PT(NurbsCurveResult) NurbsCurveEvaluator::
|
||||||
|
evaluate(const NodePath &rel_to, const LMatrix4f &mat) const {
|
||||||
|
if (_basis_dirty) {
|
||||||
|
((NurbsCurveEvaluator *)this)->recompute_basis();
|
||||||
|
}
|
||||||
|
|
||||||
|
// First, transform the vertices as appropriate.
|
||||||
|
pvector<LVecBase4f> vecs;
|
||||||
|
get_vertices(vecs, rel_to);
|
||||||
|
|
||||||
|
// And then apply the indicated matrix.
|
||||||
|
pvector<LVecBase4f>::iterator vi;
|
||||||
|
for (vi = vecs.begin(); vi != vecs.end(); ++vi) {
|
||||||
|
(*vi) = (*vi) * mat;
|
||||||
|
}
|
||||||
|
|
||||||
|
// And apply those transformed vertices to the basis matrices to
|
||||||
|
// derive the result.
|
||||||
|
return new NurbsCurveResult(_basis, &vecs[0], &_vertices[0],
|
||||||
|
(int)_vertices.size());
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NurbsCurveEvaluator::output
|
// Function: NurbsCurveEvaluator::output
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -78,6 +78,8 @@ PUBLISHED:
|
|||||||
INLINE int get_num_segments() const;
|
INLINE int get_num_segments() const;
|
||||||
|
|
||||||
PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const;
|
PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const;
|
||||||
|
PT(NurbsCurveResult) evaluate(const NodePath &rel_to,
|
||||||
|
const LMatrix4f &mat) const;
|
||||||
|
|
||||||
void output(ostream &out) const;
|
void output(ostream &out) const;
|
||||||
|
|
||||||
|
@ -154,7 +154,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
|||||||
if (get_num_subdiv() > 0) {
|
if (get_num_subdiv() > 0) {
|
||||||
NurbsCurveEvaluator *curve = get_curve();
|
NurbsCurveEvaluator *curve = get_curve();
|
||||||
if (curve != (NurbsCurveEvaluator *)NULL) {
|
if (curve != (NurbsCurveEvaluator *)NULL) {
|
||||||
PT(NurbsCurveResult) result = curve->evaluate(data._node_path.get_node_path());
|
PT(NurbsCurveResult) result =
|
||||||
|
curve->evaluate(data._node_path.get_node_path(), get_matrix());
|
||||||
|
|
||||||
if (result->get_num_segments() > 0) {
|
if (result->get_num_segments() > 0) {
|
||||||
switch (get_render_mode()) {
|
switch (get_render_mode()) {
|
||||||
@ -555,12 +556,9 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments,
|
|||||||
CurveSegment *curve_segment = NULL;
|
CurveSegment *curve_segment = NULL;
|
||||||
LPoint3f last_point;
|
LPoint3f last_point;
|
||||||
|
|
||||||
const LMatrix4f &matrix = get_matrix();
|
|
||||||
|
|
||||||
for (int segment = 0; segment < num_segments; ++segment) {
|
for (int segment = 0; segment < num_segments; ++segment) {
|
||||||
LPoint3f point;
|
LPoint3f point;
|
||||||
result->eval_segment_point(segment, 0.0f, point);
|
result->eval_segment_point(segment, 0.0f, point);
|
||||||
point = point * matrix;
|
|
||||||
|
|
||||||
if (curve_segment == (CurveSegment *)NULL ||
|
if (curve_segment == (CurveSegment *)NULL ||
|
||||||
!point.almost_equal(last_point)) {
|
!point.almost_equal(last_point)) {
|
||||||
@ -586,7 +584,6 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments,
|
|||||||
|
|
||||||
CurveVertex vtx;
|
CurveVertex vtx;
|
||||||
result->eval_segment_point(segment, t, vtx._p);
|
result->eval_segment_point(segment, t, vtx._p);
|
||||||
vtx._p = vtx._p * matrix;
|
|
||||||
vtx._t = result->get_segment_t(segment, t);
|
vtx._t = result->get_segment_t(segment, t);
|
||||||
if (use_vertex_color) {
|
if (use_vertex_color) {
|
||||||
result->eval_segment_extended_points(segment, t, 0, &vtx._c[0], 4);
|
result->eval_segment_extended_points(segment, t, 0, &vtx._c[0], 4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user