[Fix] Somewhere amongs the changes docking got borked.
This commit is contained in:
parent
8ff436c193
commit
14ee542723
@ -25,7 +25,7 @@ public:
|
||||
std::string& GetLabel(void) { return m_label; }
|
||||
unsigned int GetFlags(void) { return m_flags; }
|
||||
/* Return true if we should apply damage. */
|
||||
virtual bool OnCollision(Body* b) { return false; }
|
||||
virtual bool OnCollision(Body* b, Uint32 flags) { return false; }
|
||||
void SetProjectedPos(const vector3d& projectedPos) { m_projectedPos = projectedPos; }
|
||||
/* Only valid if IsOnScreen() is true. */
|
||||
const vector3d& GetProjectedPos() const;
|
||||
|
@ -13,6 +13,16 @@ DynamicBody::DynamicBody(void) : ModelBody() {
|
||||
dBodySetMass(m_body, &m_mass);
|
||||
}
|
||||
|
||||
void DynamicBody::Enable(void) {
|
||||
ModelBody::Enable();
|
||||
dBodyEnable(m_body);
|
||||
}
|
||||
|
||||
void DynamicBody::Disable(void) {
|
||||
ModelBody::Disable();
|
||||
dBodyDisable(m_body);
|
||||
}
|
||||
|
||||
void DynamicBody::SetMassDistributionFromCollMesh(const CollMesh* m) {
|
||||
vector3d min = vector3d(FLT_MAX);
|
||||
vector3d max = vector3d(-FLT_MAX);
|
||||
|
@ -13,9 +13,11 @@ public:
|
||||
void SetVelocity(vector3d v);
|
||||
void SetAngVelocity(vector3d v);
|
||||
void SetMesh(ObjMesh* m);
|
||||
virtual bool OnCollision(Body* b) { return true; }
|
||||
virtual bool OnCollision(Body* b, Uint32 flags) { return true; }
|
||||
vector3d GetAngularMomentum(void);
|
||||
void SetMassDistributionFromCollMesh(const CollMesh* m);
|
||||
virtual void Disable(void);
|
||||
virtual void Enable(void);
|
||||
|
||||
dBodyID m_body;
|
||||
dMass m_mass;
|
||||
|
@ -18,6 +18,18 @@ ModelBody::~ModelBody(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBody::Disable(void) {
|
||||
for(unsigned int i = 0; i < geoms.size(); i++) {
|
||||
dGeomDisable(geoms[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBody::Enable(void) {
|
||||
for(unsigned int i = 0; i < geoms.size(); i++) {
|
||||
dGeomEnable(geoms[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBody::GeomsSetBody(dBodyID body) {
|
||||
for(unsigned int i = 0; i < geoms.size(); i++) {
|
||||
dGeomSetBody(geoms[i], body);
|
||||
|
@ -23,6 +23,9 @@ public:
|
||||
void GetRotMatrix(matrix4x4d& m);
|
||||
virtual void SetFrame(Frame* f);
|
||||
void GeomsSetBody(dBodyID body);
|
||||
/* To remove from simulation for a period. */
|
||||
virtual void Disable(void);
|
||||
virtual void Enable(void);
|
||||
|
||||
void TriMeshUpdateLastPos(void);
|
||||
void SetGeomFromSBREModel(int sbreModel, ObjParams* params);
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
virtual void TransformToModelCoords(const Frame* camFrame);
|
||||
virtual void TransformCameraTo(void) {};
|
||||
virtual void SetFrame(Frame* f);
|
||||
virtual bool OnCollision(Body* b) { return true; }
|
||||
virtual bool OnCollision(Body* b, Uint32 flags) { return true; }
|
||||
private:
|
||||
vector3d m_pos;
|
||||
double m_radius;
|
||||
|
@ -144,6 +144,7 @@ void Ship::SetDockedWith(SpaceStation* s) {
|
||||
/* Launching. */
|
||||
printf("Buhbai!\n");
|
||||
m_dockedWith = 0;
|
||||
Enable();
|
||||
vector3d pos = GetPosition();
|
||||
pos.x += 5000;
|
||||
SetPosition(pos);
|
||||
|
@ -162,7 +162,7 @@ static bool _OnCollision(dGeomID g1, dGeomID g2, Object* o1, Object* o2,
|
||||
} else pb2 = static_cast<Body*>(o2);
|
||||
|
||||
printf("Collision flags %x\n", flags);
|
||||
if((pb1 && !pb1->OnCollision(pb2)) || (pb2 && !pb2->OnCollision(pb1))) return false;
|
||||
if((pb1 && !pb1->OnCollision(pb2, flags)) || (pb2 && !pb2->OnCollision(pb1, flags))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -33,14 +33,16 @@ SpaceStation::~SpaceStation(void) {
|
||||
|
||||
}
|
||||
|
||||
bool SpaceStation::OnCollision(Body* b) {
|
||||
return true;
|
||||
|
||||
bool SpaceStation::OnCollision(Body* b, Uint32 flags) {
|
||||
if(flags == 1) {
|
||||
/* Hitting docking area of a station. */
|
||||
if(b->GetType() == Object::SHIP) {
|
||||
Ship* s = static_cast<Ship*>(b);
|
||||
if(!s->GetDockedWith()) {
|
||||
s->Disable();
|
||||
s->SetDockedWith(this);
|
||||
printf("docking!\n");
|
||||
printf("Docking!\n");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@ class SpaceStation : public ModelBody {
|
||||
public:
|
||||
SpaceStation(void);
|
||||
virtual ~SpaceStation(void);
|
||||
virtual bool OnCollision(Body* b);
|
||||
virtual bool OnCollision(Body* b, Uint32 flags);
|
||||
virtual Object::Type GetType(void) { return Object::SPACESTATION; }
|
||||
virtual void Render(const Frame* camFrame);
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user