Flatland

Documentation

SourceForge.net Logo

composite-all.cpp

Go to the documentation of this file.
00001 // Summary: Test for composite-all intersection and generate contacts.
00002 // Copyright: 2007  Philip Rideout.  All rights reserved.
00003 // License: see bsd-license.txt
00004 
00005 #include <flatland/shapes.hpp>
00006 #include <flatland/intersection.hpp>
00007 
00008 using namespace Flatland;
00009 
00010 bool TestCompositeGeometry(const Geometry &g1, const Geometry &g2)
00011 {
00012     assert(g1.GetShape() == Shape::Composite);
00013     const Composite &c = static_cast<const Composite&>(g1);
00014 
00015     for (Composite::const_iterator g = c.begin(); g != c.end(); ++g)
00016         if (Intersection::Test(**g, g2))
00017             return true;
00018 
00019     return false;
00020 }
00021 
00022 void FindCompositeGeometry(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00023 {
00024     assert(g1.GetShape() == Shape::Composite);
00025     const Composite &c = static_cast<const Composite&>(g1);
00026 
00027     for (Composite::const_iterator g = c.begin(); g != c.end(); ++g)
00028     {
00029         if (Intersection::Test(**g, g2))
00030             Intersection::Find(**g, g2, contacts);
00031     }
00032 }
00033 
00034 void Intersection::FindCompositeQuad(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00035 {
00036     FindCompositeGeometry(g1, g2, contacts);
00037 }
00038 
00039 void Intersection::FindCompositeCircle(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00040 {
00041     FindCompositeGeometry(g1, g2, contacts);
00042 }
00043 
00044 void Intersection::FindCompositeTerrain(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00045 {
00046     FindCompositeGeometry(g1, g2, contacts);
00047 }
00048 
00049 void Intersection::FindCompositeComposite(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00050 {
00051     FindCompositeGeometry(g1, g2, contacts);
00052 }
00053 
00054 void Intersection::FindQuadComposite(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00055 {
00056     contacts.ToggleNormalInversion();
00057     FindCompositeGeometry(g2, g1, contacts);
00058     contacts.ToggleNormalInversion();
00059 }
00060 
00061 void Intersection::FindCircleComposite(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00062 {
00063     contacts.ToggleNormalInversion();
00064     FindCompositeGeometry(g2, g1, contacts);
00065     contacts.ToggleNormalInversion();
00066 }
00067 
00068 void Intersection::FindTerrainComposite(const Geometry &g1, const Geometry &g2, ContactList &contacts)
00069 {
00070     contacts.ToggleNormalInversion();
00071     FindCompositeGeometry(g2, g1, contacts);
00072     contacts.ToggleNormalInversion();
00073 }
00074 
00075 bool Intersection::TestCompositeQuad(const Geometry &g1, const Geometry &g2)
00076 {
00077     return TestCompositeGeometry(g1, g2);
00078 }
00079 
00080 bool Intersection::TestCompositeCircle(const Geometry &g1, const Geometry &g2)
00081 {
00082     return TestCompositeGeometry(g1, g2);
00083 }
00084 
00085 bool Intersection::TestCompositeTerrain(const Geometry &g1, const Geometry &g2)
00086 {
00087     return TestCompositeGeometry(g1, g2);
00088 }
00089 
00090 bool Intersection::TestCompositeComposite(const Geometry &g1, const Geometry &g2)
00091 {
00092     return TestCompositeGeometry(g1, g2);
00093 }
00094 
00095 bool Intersection::TestQuadComposite(const Geometry &g1, const Geometry &g2)
00096 {
00097     return TestCompositeGeometry(g2, g1);
00098 }
00099 
00100 bool Intersection::TestCircleComposite(const Geometry &g1, const Geometry &g2)
00101 {
00102     return TestCompositeGeometry(g2, g1);
00103 }
00104 
00105 bool Intersection::TestTerrainComposite(const Geometry &g1, const Geometry &g2)
00106 {
00107     return TestCompositeGeometry(g2, g1);
00108 }

Generated on Sat Jan 13 17:20:21 2007 for Flatland by doxygen 1.5.1