00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "BVHStaticTriangle.hxx"
00019
00020 #include "BVHVisitor.hxx"
00021
00022 namespace simgear {
00023
00024 BVHStaticTriangle::BVHStaticTriangle(unsigned material,
00025 const unsigned indices[3]) :
00026 _material(material)
00027 {
00028 for (unsigned i = 0; i < 3; ++i)
00029 _indices[i] = indices[i];
00030 }
00031
00032 BVHStaticTriangle::~BVHStaticTriangle()
00033 {
00034 }
00035
00036 void
00037 BVHStaticTriangle::accept(BVHVisitor& visitor, const BVHStaticData& data) const
00038 {
00039 visitor.apply(*this, data);
00040 }
00041
00042 SGBoxf
00043 BVHStaticTriangle::computeBoundingBox(const BVHStaticData& data) const
00044 {
00045 SGBoxf box;
00046 box.expandBy(data.getVertex(_indices[0]));
00047 box.expandBy(data.getVertex(_indices[1]));
00048 box.expandBy(data.getVertex(_indices[2]));
00049 return box;
00050 }
00051
00052 SGVec3f
00053 BVHStaticTriangle::computeCenter(const BVHStaticData& data) const
00054 {
00055 return getTriangle(data).getCenter();
00056 }
00057
00058 }