1 // groundcache.cxx -- carries a small subset of the scenegraph near the vehicle
3 // Written by Mathias Froehlich, started Nov 2004.
5 // Copyright (C) 2004 Mathias Froehlich - Mathias.Froehlich@web.de
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <osg/CullFace>
31 #include <osg/Drawable>
33 #include <osg/Geometry>
34 #include <osg/TriangleFunctor>
36 #include <simgear/sg_inlines.h>
37 #include <simgear/constants.h>
38 #include <simgear/debug/logstream.hxx>
39 #include <simgear/math/sg_geodesy.hxx>
40 #include <simgear/scene/material/mat.hxx>
41 #include <simgear/scene/material/matlib.hxx>
42 #include <simgear/scene/util/SGNodeMasks.hxx>
44 #include <Main/globals.hxx>
45 #include <Scenery/scenery.hxx>
46 #include <Scenery/tilemgr.hxx>
47 #include <AIModel/AICarrier.hxx>
50 #include "groundcache.hxx"
53 fgdPointInTriangle( const SGVec3d& point, const SGVec3d tri[3] )
57 // Some tolerance in meters we accept a point to be outside of the triangle
58 // and still return that it is inside.
61 // punt if outside bouding cube
62 SG_MIN_MAX3 ( min, max, tri[0][0], tri[1][0], tri[2][0] );
63 if( (point[0] < min - eps) || (point[0] > max + eps) )
67 SG_MIN_MAX3 ( min, max, tri[0][1], tri[1][1], tri[2][1] );
68 if( (point[1] < min - eps) || (point[1] > max + eps) )
72 SG_MIN_MAX3 ( min, max, tri[0][2], tri[1][2], tri[2][2] );
73 if( (point[2] < min - eps) || (point[2] > max + eps) )
77 // drop the smallest dimension so we only have to work in 2d.
78 SGDfloat min_dim = SG_MIN3 (dif[0], dif[1], dif[2]);
79 SGDfloat x1, y1, x2, y2, x3, y3, rx, ry;
80 if ( fabs(min_dim-dif[0]) <= DBL_EPSILON ) {
81 // x is the smallest dimension
90 } else if ( fabs(min_dim-dif[1]) <= DBL_EPSILON ) {
91 // y is the smallest dimension
100 } else if ( fabs(min_dim-dif[2]) <= DBL_EPSILON ) {
101 // z is the smallest dimension
111 // all dimensions are really small so lets call it close
112 // enough and return a successful match
116 // check if intersection point is on the same side of p1 <-> p2 as p3
117 SGDfloat tmp = (y2 - y3);
118 SGDfloat tmpn = (x2 - x3);
119 int side1 = SG_SIGN (tmp * (rx - x3) + (y3 - ry) * tmpn);
120 int side2 = SG_SIGN (tmp * (x1 - x3) + (y3 - y1) * tmpn
121 + side1 * eps * fabs(tmpn));
122 if ( side1 != side2 ) {
123 // printf("failed side 1 check\n");
127 // check if intersection point is on correct side of p2 <-> p3 as p1
130 side1 = SG_SIGN (tmp * (x2 - rx) + (ry - y2) * tmpn);
131 side2 = SG_SIGN (tmp * (x1 - rx) + (ry - y1) * tmpn
132 + side1 * eps * fabs(tmpn));
133 if ( side1 != side2 ) {
134 // printf("failed side 2 check\n");
138 // check if intersection point is on correct side of p1 <-> p3 as p2
141 side1 = SG_SIGN (tmp * (x3 - rx) + (ry - y3) * tmpn);
142 side2 = SG_SIGN (tmp * (x1 - rx) + (ry - y1) * tmpn
143 + side1 * eps * fabs(tmpn));
144 if ( side1 != side2 ) {
145 // printf("failed side 3 check\n");
152 // Test if the line given by the point on the line pt_on_line and the
153 // line direction dir intersects the sphere sp.
154 // Adapted from plib.
156 fgdIsectSphereInfLine(const SGVec3d& sphereCenter, double radius,
157 const SGVec3d& pt_on_line, const SGVec3d& dir)
159 SGVec3d r = sphereCenter - pt_on_line;
160 double projectedDistance = dot(r, dir);
161 double dist = dot(r, r) - projectedDistance * projectedDistance;
162 return dist < radius*radius;
166 class SGExtendedTriangleFunctor : public osg::TriangleFunctor<T> {
168 // Ok, to be complete we should also implement the indexed variants
169 // For now this one appears to be enough ...
170 void drawArrays(GLenum mode, GLint first, GLsizei count)
172 if (_vertexArrayPtr==0 || count==0) return;
174 const osg::Vec3* vlast;
175 const osg::Vec3* vptr;
178 vlast = &_vertexArrayPtr[first+count];
179 for(vptr=&_vertexArrayPtr[first];vptr<vlast;vptr+=2)
180 this->operator()(*(vptr),*(vptr+1),_treatVertexDataAsTemporary);
183 vlast = &_vertexArrayPtr[first+count-1];
184 for(vptr=&_vertexArrayPtr[first];vptr<vlast;++vptr)
185 this->operator()(*(vptr),*(vptr+1),_treatVertexDataAsTemporary);
188 vlast = &_vertexArrayPtr[first+count-1];
189 for(vptr=&_vertexArrayPtr[first];vptr<vlast;++vptr)
190 this->operator()(*(vptr),*(vptr+1),_treatVertexDataAsTemporary);
191 this->operator()(_vertexArrayPtr[first+count-1],
192 _vertexArrayPtr[first],_treatVertexDataAsTemporary);
195 osg::TriangleFunctor<T>::drawArrays(mode, first, count);
200 using osg::TriangleFunctor<T>::_vertexArrayPtr;
201 using osg::TriangleFunctor<T>::_treatVertexDataAsTemporary;
204 class GroundCacheFillVisitor : public osg::NodeVisitor {
207 /// class to just redirect triangles to the GroundCacheFillVisitor
208 class GroundCacheFill {
210 void setGroundCacheFillVisitor(GroundCacheFillVisitor* gcfv)
211 { mGroundCacheFillVisitor = gcfv; }
213 void operator () (const osg::Vec3& v1, const osg::Vec3& v2,
214 const osg::Vec3& v3, bool)
215 { mGroundCacheFillVisitor->addTriangle(v1, v2, v3); }
217 void operator () (const osg::Vec3& v1, const osg::Vec3& v2, bool)
218 { mGroundCacheFillVisitor->addLine(v1, v2); }
221 GroundCacheFillVisitor* mGroundCacheFillVisitor;
225 GroundCacheFillVisitor(FGGroundCache* groundCache,
227 const SGVec3d& cacheReference,
229 double wireCacheRadius) :
230 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN),
231 mGroundCache(groundCache)
233 setTraversalMask(SG_NODEMASK_TERRAIN_BIT);
236 mBackfaceCulling = false;
237 mCacheReference = cacheReference;
238 mCacheRadius = cacheRadius;
239 mWireCacheRadius = wireCacheRadius;
241 mTriangleFunctor.setGroundCacheFillVisitor(this);
243 mGroundProperty.wire_id = -1;
244 mGroundProperty.vel = SGVec3d(0, 0, 0);
245 mGroundProperty.rot = SGVec3d(0, 0, 0);
246 mGroundProperty.pivot = SGVec3d(0, 0, 0);
249 void updateCullMode(osg::StateSet* stateSet)
254 osg::StateAttribute* stateAttribute;
255 stateAttribute = stateSet->getAttribute(osg::StateAttribute::CULLFACE);
258 osg::CullFace* cullFace = static_cast<osg::CullFace*>(stateAttribute);
259 mBackfaceCulling = cullFace->getMode() == osg::CullFace::BACK;
262 bool enterBoundingSphere(const osg::BoundingSphere& bs)
267 SGVec3d cntr(osg::Vec3d(bs.center())*mLocalToGlobal);
268 double rc = bs.radius() + mCacheRadius;
269 // Ok, this node might intersect the cache. Visit it in depth.
270 double centerDist2 = distSqr(mCacheReference, cntr);
271 if (centerDist2 < rc*rc) {
274 // Check if the down direction touches the bounding sphere of the node
275 // if so, do at least croase agl computations.
276 // Ther other thing is that we must check if we are in range of
278 double rw = bs.radius() + mWireCacheRadius;
279 if (rw*rw < centerDist2 &&
280 !fgdIsectSphereInfLine(cntr, bs.radius(), mCacheReference, mDown))
288 bool enterNode(osg::Node& node)
290 if (!enterBoundingSphere(node.getBound()))
293 updateCullMode(node.getStateSet());
295 FGGroundCache::GroundProperty& gp = mGroundProperty;
296 // get some material information for use in the gear model
297 gp.material = globals->get_matlib()->findMaterial(&node);
299 gp.type = gp.material->get_solid() ? FGInterface::Solid : FGInterface::Water;
302 osg::Referenced* base = node.getUserData();
305 FGAICarrierHardware *ud =
306 dynamic_cast<FGAICarrierHardware*>(base);
311 case FGAICarrierHardware::Wire:
312 gp.type = FGInterface::Wire;
315 case FGAICarrierHardware::Catapult:
316 gp.type = FGInterface::Catapult;
319 gp.type = FGInterface::Solid;
322 // Copy the velocity from the carrier class.
323 ud->carrier->getVelocityWrtEarth( gp.vel, gp.rot, gp.pivot );
328 void fillWith(osg::Drawable* drawable)
330 bool oldSphIsec = sphIsec;
331 if (!enterBoundingSphere(drawable->getBound()))
334 bool oldBackfaceCulling = mBackfaceCulling;
335 updateCullMode(drawable->getStateSet());
337 drawable->accept(mTriangleFunctor);
339 mBackfaceCulling = oldBackfaceCulling;
340 sphIsec = oldSphIsec;
343 virtual void apply(osg::Geode& geode)
345 bool oldBackfaceCulling = mBackfaceCulling;
346 bool oldSphIsec = sphIsec;
347 FGGroundCache::GroundProperty oldGp = mGroundProperty;
348 if (!enterNode(geode))
351 for(unsigned i = 0; i < geode.getNumDrawables(); ++i)
352 fillWith(geode.getDrawable(i));
353 sphIsec = oldSphIsec;
354 mGroundProperty = oldGp;
355 mBackfaceCulling = oldBackfaceCulling;
358 virtual void apply(osg::Group& group)
360 bool oldBackfaceCulling = mBackfaceCulling;
361 bool oldSphIsec = sphIsec;
362 FGGroundCache::GroundProperty oldGp = mGroundProperty;
363 if (!enterNode(group))
366 sphIsec = oldSphIsec;
367 mBackfaceCulling = oldBackfaceCulling;
368 mGroundProperty = oldGp;
371 virtual void apply(osg::Transform& transform)
373 /// transform the caches center to local coords
374 osg::Matrix oldLocalToGlobal = mLocalToGlobal;
375 transform.computeLocalToWorldMatrix(mLocalToGlobal, this);
378 apply((osg::Group&)transform);
381 mLocalToGlobal = oldLocalToGlobal;
384 void addTriangle(const osg::Vec3& v1, const osg::Vec3& v2,
387 FGGroundCache::Triangle t;
388 osg::Vec3d gv1 = osg::Vec3d(v1)*mLocalToGlobal;
389 osg::Vec3d gv2 = osg::Vec3d(v2)*mLocalToGlobal;
390 osg::Vec3d gv3 = osg::Vec3d(v3)*mLocalToGlobal;
391 for (unsigned i = 0; i < 3; ++i) {
392 t.vertices[0][i] = gv1[i];
393 t.vertices[1][i] = gv2[i];
394 t.vertices[2][i] = gv3[i];
396 // FIXME: can do better ...
397 t.boundCenter = (1.0/3)*(t.vertices[0] + t.vertices[1] + t.vertices[2]);
398 t.boundRadius = std::max(length(t.vertices[0] - t.boundCenter),
399 length(t.vertices[1] - t.boundCenter));
400 t.boundRadius = std::max(t.boundRadius,
401 length(t.vertices[2] - t.boundCenter));
403 sgdMakePlane(t.plane.sg(), t.vertices[0].sg(), t.vertices[1].sg(),
405 double d = sgdScalarProductVec3(mDown.sg(), t.plane.sg());
407 if (mBackfaceCulling) {
408 // Surface points downwards, ignore for altitude computations.
414 // Check if the sphere around the vehicle intersects the sphere
415 // around that triangle. If so, put that triangle into the cache.
417 distSqr(t.boundCenter, mCacheReference)
418 < (t.boundRadius + mCacheRadius)*(t.boundRadius + mCacheRadius) ) {
419 t.velocity = mGroundProperty.vel;
420 t.rotation = mGroundProperty.rot;
421 t.rotation_pivot = mGroundProperty.pivot - mGroundCache->cache_center;
422 t.type = mGroundProperty.type;
423 mGroundCache->triangles.push_back(t);
426 // In case the cache is empty, we still provide agl computations.
427 // But then we use the old way of having a fixed elevation value for
428 // the whole lifetime of this cache.
429 if ( fgdIsectSphereInfLine(t.boundCenter, t.boundRadius,
430 mCacheReference, mDown) ) {
432 if ( sgdIsectInfLinePlane( isectpoint.sg(), mCacheReference.sg(),
433 mDown.sg(), t.plane.sg() ) &&
434 fgdPointInTriangle( isectpoint, t.vertices ) ) {
435 // Only accept the altitude if the intersection point is below the
436 // ground cache midpoint
437 if (0 < dot(isectpoint - mCacheReference, mDown)) {
438 mGroundCache->found_ground = true;
439 isectpoint += mGroundCache->cache_center;
440 double this_radius = length(isectpoint);
441 if (mGroundCache->ground_radius < this_radius)
442 mGroundCache->ground_radius = this_radius;
448 void addLine(const osg::Vec3& v1, const osg::Vec3& v2)
450 SGVec3d gv1 = SGVec3d(osg::Vec3d(v1)*mLocalToGlobal);
451 SGVec3d gv2 = SGVec3d(osg::Vec3d(v2)*mLocalToGlobal);
453 SGVec3d boundCenter = 0.5*(gv1 + gv2);
454 double boundRadius = length(gv1 - boundCenter);
456 if (distSqr(boundCenter, mCacheReference)
457 < (boundRadius + mWireCacheRadius)*(boundRadius + mWireCacheRadius) ) {
458 if (mGroundProperty.type == FGInterface::Wire) {
459 FGGroundCache::Wire wire;
462 wire.velocity = mGroundProperty.vel;
463 wire.rotation = mGroundProperty.rot;
464 wire.rotation_pivot = mGroundProperty.pivot - mGroundCache->cache_center;
465 wire.wire_id = mGroundProperty.wire_id;
467 mGroundCache->wires.push_back(wire);
469 if (mGroundProperty.type == FGInterface::Catapult) {
470 FGGroundCache::Catapult cat;
471 // Trick to get the ends in the right order.
472 // Use the x axis in the original coordinate system. Choose the
473 // most negative x-axis as the one pointing forward
481 cat.velocity = mGroundProperty.vel;
482 cat.rotation = mGroundProperty.rot;
483 cat.rotation_pivot = mGroundProperty.pivot - mGroundCache->cache_center;
485 mGroundCache->catapults.push_back(cat);
490 SGExtendedTriangleFunctor<GroundCacheFill> mTriangleFunctor;
491 FGGroundCache* mGroundCache;
492 SGVec3d mCacheReference;
494 double mWireCacheRadius;
495 osg::Matrix mLocalToGlobal;
498 bool mBackfaceCulling;
499 FGGroundCache::GroundProperty mGroundProperty;
502 FGGroundCache::FGGroundCache()
504 cache_center = SGVec3d(0, 0, 0);
506 cache_ref_time = 0.0;
508 reference_wgs84_point = SGVec3d(0, 0, 0);
509 reference_vehicle_radius = 0.0;
510 found_ground = false;
513 FGGroundCache::~FGGroundCache()
518 FGGroundCache::velocityTransformTriangle(double dt,
519 FGGroundCache::Triangle& dst,
520 const FGGroundCache::Triangle& src)
524 if (fabs(dt*dot(src.velocity, src.velocity)) < SGLimitsd::epsilon())
527 for (int i = 0; i < 3; ++i) {
528 SGVec3d pivotoff = src.vertices[i] - src.rotation_pivot;
529 dst.vertices[i] += dt*(src.velocity + cross(src.rotation, pivotoff));
532 // Transform the plane equation
533 SGVec3d pivotoff, vel;
534 sgdSubVec3(pivotoff.sg(), dst.plane.sg(), src.rotation_pivot.sg());
535 vel = src.velocity + cross(src.rotation, pivotoff);
536 dst.plane[3] += dt*sgdScalarProductVec3(dst.plane.sg(), vel.sg());
538 dst.boundCenter += dt*src.velocity;
542 FGGroundCache::prepare_ground_cache(double ref_time, const SGVec3d& pt,
547 found_ground = false;
552 // Store the parameters we used to build up that cache.
553 reference_wgs84_point = pt;
554 reference_vehicle_radius = rad;
555 // Store the time reference used to compute movements of moving triangles.
556 cache_ref_time = ref_time;
558 // Get a normalized down vector valid for the whole cache
559 SGQuatd hlToEc = SGQuatd::fromLonLat(SGGeod::fromCart(pt));
560 down = hlToEc.rotate(SGVec3d(0, 0, 1));
562 // Decide where we put the scenery center.
563 SGVec3d old_cntr = globals->get_scenery()->get_center();
565 // Only move the cache center if it is unacceptable far away.
566 if (40*40 < distSqr(old_cntr, cntr))
567 globals->get_scenery()->set_center(cntr);
571 // The center of the cache.
574 // Prepare sphere around the aircraft.
575 SGVec3d ptoff = pt - cache_center;
576 double cacheRadius = rad;
578 // Prepare bigger sphere around the aircraft.
579 // This one is required for reliably finding wires we have caught but
580 // have already left the hopefully smaller sphere for the ground reactions.
581 const double max_wire_dist = 300.0;
582 double wireCacheRadius = max_wire_dist < rad ? rad : max_wire_dist;
584 // Walk the scene graph and extract solid ground triangles and carrier data.
585 GroundCacheFillVisitor gcfv(this, down, ptoff, cacheRadius, wireCacheRadius);
586 globals->get_scenery()->get_scene_graph()->accept(gcfv);
589 SG_LOG(SG_FLIGHT,SG_DEBUG, "prepare_ground_cache(): ac radius = " << rad
590 << ", # triangles = " << triangles.size()
591 << ", # wires = " << wires.size()
592 << ", # catapults = " << catapults.size()
593 << ", ground_radius = " << ground_radius );
595 // If the ground radius is still below 5e6 meters, then we do not yet have
597 found_ground = found_ground && 5e6 < ground_radius;
599 SG_LOG(SG_FLIGHT, SG_WARN, "prepare_ground_cache(): trying to build cache "
600 "without any scenery below the aircraft" );
602 if (cntr != old_cntr)
603 globals->get_scenery()->set_center(old_cntr);
609 FGGroundCache::is_valid(double& ref_time, SGVec3d& pt, double& rad)
611 pt = reference_wgs84_point;
612 rad = reference_vehicle_radius;
613 ref_time = cache_ref_time;
618 FGGroundCache::get_cat(double t, const SGVec3d& dpt,
619 SGVec3d end[2], SGVec3d vel[2])
621 // start with a distance of 1e10 meters...
624 // Time difference to the reference time.
627 size_t sz = catapults.size();
628 for (size_t i = 0; i < sz; ++i) {
629 SGVec3d pivotoff, rvel[2];
630 pivotoff = catapults[i].start - catapults[i].rotation_pivot;
631 rvel[0] = catapults[i].velocity + cross(catapults[i].rotation, pivotoff);
632 pivotoff = catapults[i].end - catapults[i].rotation_pivot;
633 rvel[1] = catapults[i].velocity + cross(catapults[i].rotation, pivotoff);
636 thisEnd[0] = cache_center + catapults[i].start + t*rvel[0];
637 thisEnd[1] = cache_center + catapults[i].end + t*rvel[1];
640 sgdCopyVec3(ls.a, thisEnd[0].sg());
641 sgdCopyVec3(ls.b, thisEnd[1].sg());
642 double this_dist = sgdDistSquaredToLineSegmentVec3( ls, dpt.sg() );
644 if (this_dist < dist) {
645 SG_LOG(SG_FLIGHT,SG_INFO, "Found catapult "
646 << this_dist << " meters away");
656 // At the end take the root, we only computed squared distances ...
661 FGGroundCache::get_agl(double t, const SGVec3d& dpt, double max_altoff,
662 SGVec3d& contact, SGVec3d& normal, SGVec3d& vel,
663 int *type, const SGMaterial** material, double *agl)
667 *type = FGInterface::Unknown;
671 vel = SGVec3d(0, 0, 0);
672 contact = SGVec3d(0, 0, 0);
673 normal = SGVec3d(0, 0, 0);
675 // Time difference to th reference time.
678 // The double valued point we start to search for intersection.
679 SGVec3d pt = dpt - cache_center;
681 // Initialize to something sensible
682 double current_radius = 0.0;
684 size_t sz = triangles.size();
685 for (size_t i = 0; i < sz; ++i) {
687 velocityTransformTriangle(t, triangle, triangles[i]);
688 if (!fgdIsectSphereInfLine(triangle.boundCenter, triangle.boundRadius, pt, down))
691 // Check for intersection.
693 if ( sgdIsectInfLinePlane( isecpoint.sg(), pt.sg(), down.sg(), triangle.plane.sg() ) &&
694 fgdPointInTriangle( isecpoint, triangle.vertices ) ) {
695 // Compute the vector from pt to the intersection point ...
696 SGVec3d off = isecpoint - pt;
697 // ... and check if it is too high or not
698 if (-max_altoff < dot(off, down)) {
699 // Transform to the wgs system
700 isecpoint += cache_center;
701 // compute the radius, good enough approximation to take the geocentric radius
702 double radius = dot(isecpoint, isecpoint);
703 if (current_radius < radius) {
704 current_radius = radius;
706 // Save the new potential intersection point.
708 // The first three values in the vector are the plane normal.
709 sgdCopyVec3( normal.sg(), triangle.plane.sg() );
710 // The velocity wrt earth.
711 SGVec3d pivotoff = pt - triangle.rotation_pivot;
712 vel = triangle.velocity + cross(triangle.rotation, pivotoff);
713 // Save the ground type.
714 *type = triangle.type;
715 *agl = dot(down, contact - dpt);
717 *material = triangle.material;
726 // Whenever we did not have a ground triangle for the requested point,
727 // take the ground level we found during the current cache build.
728 // This is as good as what we had before for agl.
729 double r = length(dpt);
731 contact *= ground_radius/r;
733 vel = SGVec3d(0, 0, 0);
735 // The altitude is the distance of the requested point from the
737 *agl = dot(down, contact - dpt);
738 *type = FGInterface::Unknown;
743 bool FGGroundCache::caught_wire(double t, const SGVec3d pt[4])
745 size_t sz = wires.size();
749 // Time difference to the reference time.
752 // Build the two triangles spanning the area where the hook has moved
753 // during the past step.
756 sgdMakePlane( plane[0].sg(), pt[0].sg(), pt[1].sg(), pt[2].sg() );
760 sgdMakePlane( plane[1].sg(), pt[0].sg(), pt[2].sg(), pt[3].sg() );
765 // Intersect the wire lines with each of these triangles.
766 // You have caught a wire if they intersect.
767 for (size_t i = 0; i < sz; ++i) {
769 for (int k = 0; k < 2; ++k) {
770 le[k] = wires[i].ends[k];
771 SGVec3d pivotoff = le[k] - wires[i].rotation_pivot;
772 SGVec3d vel = wires[i].velocity + cross(wires[i].rotation, pivotoff);
773 le[k] += t*vel + cache_center;
776 for (int k=0; k<2; ++k) {
778 double isecval = sgdIsectLinesegPlane(isecpoint.sg(), le[0].sg(),
779 le[1].sg(), plane[k].sg());
780 if ( 0.0 <= isecval && isecval <= 1.0 &&
781 fgdPointInTriangle( isecpoint, tri[k] ) ) {
782 SG_LOG(SG_FLIGHT,SG_INFO, "Caught wire");
783 // Store the wire id.
784 wire_id = wires[i].wire_id;
793 bool FGGroundCache::get_wire_ends(double t, SGVec3d end[2], SGVec3d vel[2])
795 // Fast return if we do not have an active wire.
799 // Time difference to the reference time.
802 // Search for the wire with the matching wire id.
803 size_t sz = wires.size();
804 for (size_t i = 0; i < sz; ++i) {
805 if (wires[i].wire_id == wire_id) {
806 for (size_t k = 0; k < 2; ++k) {
807 SGVec3d pivotoff = end[k] - wires[i].rotation_pivot;
808 vel[k] = wires[i].velocity + cross(wires[i].rotation, pivotoff);
809 end[k] = cache_center + wires[i].ends[k] + t*vel[k];
818 void FGGroundCache::release_wire(void)