00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "LampBasic.h"
00026 #include "Collision/Leaf/StaticSphereCollision.h"
00027 #include "Collision/System/CollisionScene.h"
00028 #include "Geometry/System/IntersectionResult.h"
00029
00030 namespace Lamp{
00031
00032
00033
00034
00035
00036 StaticSphereCollision::StaticSphereCollision(
00037 const String& name, CollisionScene* scene) :
00038 StaticCollisionLeaf(name, scene),
00039 sphere_(Sphere::zero), worldSphere_(Sphere::zero){
00040 }
00041
00042
00043 StaticSphereCollision::~StaticSphereCollision(){
00044 }
00045
00046
00047
00048
00049 StaticSphereCollision*
00050 StaticSphereCollision::copyStaticSphereCollision() const{
00051 StaticSphereCollision* destination =
00052 getScene()->createStaticSphereCollision(
00053 getScene()->renameLeaf(getName()));
00054
00055 copyStaticCollisionLeafValue(destination);
00056
00057 destination->sphere_ = sphere_;
00058 destination->worldSphere_ = worldSphere_;
00059 return destination;
00060 }
00061
00062
00063
00064
00065 void StaticSphereCollision::intersection(
00066 IntersectionResult* result, const Sphere& sphere, u_int collisionMask){
00067
00068 if(!isGlobalEnabled()){ return; }
00069
00070 if((getCollisionMask() & collisionMask) == 0){ return; }
00071
00072 Intersection intersection;
00073 if(worldSphere_.intersect(&intersection, sphere)){
00074 result->add(intersection);
00075 }
00076 }
00077
00078
00079 void StaticSphereCollision::intersection(IntersectionResult* result,
00080 StaticSphereCollision* sphere, u_int collisionMask){
00081
00082 if(sphere == this){ return; }
00083
00084 if(!isGlobalEnabled()){ return; }
00085
00086 if((getCollisionMask() & collisionMask) == 0){ return; }
00087
00088 Intersection intersection;
00089 if(worldSphere_.intersect(&intersection, sphere->getWorldSphere())){
00090 result->add(intersection);
00091 }
00092 }
00093
00094
00095
00096
00097 void StaticSphereCollision::traverseImplement(
00098 const Matrix34& parentMatrix, bool parentEnabled, bool parentScaled,
00099 bool parentChanged){
00100
00101 if(!traverseSetup(parentEnabled, parentChanged)){ return; }
00102
00103
00104 if(parentScaled){
00105
00106 worldSphere_ = sphere_.scaledTransform(parentMatrix);
00107 }else{
00108
00109 worldSphere_ = sphere_.transform(parentMatrix);
00110 }
00111
00112
00113 }
00114
00115 }
00116