mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-25 12:05:53 +00:00
Some cleanup of scene and scene related code.
This commit is contained in:
parent
934a90d05c
commit
a42ffed5cb
@ -1186,7 +1186,7 @@ void L1_WalkActorVector() {
|
||||
moveVert = luaL_check_number(4);
|
||||
|
||||
// Get the direction the camera is pointing
|
||||
Graphics::Vector3d cameraVector = g_grim->getCurrScene()->_currSetup->_interest - g_grim->getCurrScene()->_currSetup->_pos;
|
||||
Graphics::Vector3d cameraVector = g_grim->getCurrScene()->getCurrSetup()->_interest - g_grim->getCurrScene()->getCurrSetup()->_pos;
|
||||
// find the angle the camera direction is around the unit circle
|
||||
float cameraYaw = cameraVector.unitCircleAngle();
|
||||
|
||||
@ -1292,20 +1292,21 @@ void L1_PutActorAtInterest() {
|
||||
return;
|
||||
|
||||
Actor *actor = getactor(actorObj);
|
||||
if (!g_grim->getCurrScene())
|
||||
Scene *scene = g_grim->getCurrScene();
|
||||
if (!scene)
|
||||
return;
|
||||
|
||||
Graphics::Vector3d p = g_grim->getCurrScene()->_currSetup->_interest;
|
||||
Graphics::Vector3d p = scene->getCurrSetup()->_interest;
|
||||
Graphics::Vector3d resultPt = p;
|
||||
float minDist = -1.f;
|
||||
|
||||
for (int i = 0; i < g_grim->getCurrScene()->getSectorCount(); ++i) {
|
||||
Sector *sector = g_grim->getCurrScene()->getSectorBase(i);
|
||||
for (int i = 0; i < scene->getSectorCount(); ++i) {
|
||||
Sector *sector = scene->getSectorBase(i);
|
||||
if (sector->getType() != Sector::WalkType || !sector->isVisible())
|
||||
continue;
|
||||
|
||||
Graphics::Vector3d closestPt = sector->getClosestPoint(p);
|
||||
if (g_grim->getCurrScene()->findPointSector(closestPt, Sector::HotType))
|
||||
if (scene->findPointSector(closestPt, Sector::HotType))
|
||||
continue;
|
||||
float thisDist = (closestPt - p).magnitude();
|
||||
if (minDist < 0 || thisDist < minDist) {
|
||||
|
@ -521,7 +521,7 @@ void Scene::drawBitmaps(ObjectState::Position stage) {
|
||||
}
|
||||
}
|
||||
|
||||
Sector *Scene::findPointSector(Graphics::Vector3d p, Sector::SectorType type) {
|
||||
Sector *Scene::findPointSector(const Graphics::Vector3d &p, Sector::SectorType type) {
|
||||
for (int i = 0; i < _numSectors; i++) {
|
||||
Sector *sector = _sectors[i];
|
||||
if (sector && (sector->getType() & type) && sector->isVisible() && sector->isPointInSector(p))
|
||||
@ -530,7 +530,7 @@ Sector *Scene::findPointSector(Graphics::Vector3d p, Sector::SectorType type) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Scene::findClosestSector(Graphics::Vector3d p, Sector **sect, Graphics::Vector3d *closestPoint) {
|
||||
void Scene::findClosestSector(const Graphics::Vector3d &p, Sector **sect, Graphics::Vector3d *closestPoint) {
|
||||
Sector *resultSect = NULL;
|
||||
Graphics::Vector3d resultPt = p;
|
||||
float minDist = 0.0;
|
||||
@ -588,7 +588,7 @@ void Scene::setLightIntensity(int light, float intensity) {
|
||||
_lightsConfigured = false;
|
||||
}
|
||||
|
||||
void Scene::setLightPosition(const char *light, Graphics::Vector3d pos) {
|
||||
void Scene::setLightPosition(const char *light, const Graphics::Vector3d &pos) {
|
||||
for (int i = 0; i < _numLights; ++i) {
|
||||
Light &l = _lights[i];
|
||||
if (l._name == light) {
|
||||
@ -599,7 +599,7 @@ void Scene::setLightPosition(const char *light, Graphics::Vector3d pos) {
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::setLightPosition(int light, Graphics::Vector3d pos) {
|
||||
void Scene::setLightPosition(int light, const Graphics::Vector3d &pos) {
|
||||
Light &l = _lights[light];
|
||||
l._pos = pos;
|
||||
_lightsConfigured = false;
|
||||
@ -626,6 +626,13 @@ void Scene::setSoundPosition(const char *soundName, Graphics::Vector3d pos, int
|
||||
//g_imuse->setPan(soundName, pan);
|
||||
}
|
||||
|
||||
Sector *Scene::getSectorBase(int id) {
|
||||
if ((_numSectors >= 0) && (id < _numSectors))
|
||||
return _sectors[id];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Scene::setSoundParameters(int minVolume, int maxVolume) {
|
||||
_minVolume = minVolume;
|
||||
_maxVolume = maxVolume;
|
||||
|
@ -73,24 +73,19 @@ public:
|
||||
}
|
||||
void setLightIntensity(const char *light, float intensity);
|
||||
void setLightIntensity(int light, float intensity);
|
||||
void setLightPosition(const char *light, Graphics::Vector3d pos);
|
||||
void setLightPosition(int light, Graphics::Vector3d pos);
|
||||
void setLightPosition(const char *light, const Graphics::Vector3d &pos);
|
||||
void setLightPosition(int light, const Graphics::Vector3d &pos);
|
||||
|
||||
void setSetup(int num);
|
||||
int getSetup() const { return _currSetup - _setups; }
|
||||
|
||||
// Sector access functions
|
||||
int getSectorCount() {
|
||||
return _numSectors;
|
||||
}
|
||||
Sector *getSectorBase(int id) {
|
||||
if ((_numSectors >= 0) && (id < _numSectors))
|
||||
return _sectors[id];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
Sector *findPointSector(Graphics::Vector3d p, Sector::SectorType type);
|
||||
void findClosestSector(Graphics::Vector3d p, Sector **sect, Graphics::Vector3d *closestPt);
|
||||
int getSectorCount() { return _numSectors; }
|
||||
|
||||
Sector *getSectorBase(int id);
|
||||
|
||||
Sector *findPointSector(const Graphics::Vector3d &p, Sector::SectorType type);
|
||||
void findClosestSector(const Graphics::Vector3d &p, Sector **sect, Graphics::Vector3d *closestPt);
|
||||
|
||||
void addObjectState(ObjectState *s) {
|
||||
_states.push_back(s);
|
||||
@ -125,14 +120,16 @@ public:
|
||||
float _intensity, _umbraangle, _penumbraangle;
|
||||
};
|
||||
|
||||
bool _locked;
|
||||
CMap *getCMap() {
|
||||
if (!_cmaps || ! _numCmaps)
|
||||
return NULL;
|
||||
return _cmaps[0];
|
||||
};
|
||||
|
||||
Setup *getCurrSetup() { return _currSetup; }
|
||||
|
||||
private:
|
||||
bool _locked;
|
||||
void setId(int32 id);
|
||||
Common::String _name;
|
||||
int _numCmaps;
|
||||
@ -143,9 +140,8 @@ private:
|
||||
Light *_lights;
|
||||
Setup *_setups;
|
||||
bool _lightsConfigured;
|
||||
public:
|
||||
|
||||
Setup *_currSetup;
|
||||
private:
|
||||
typedef Common::List<ObjectState*> StateList;
|
||||
StateList _states;
|
||||
|
||||
|
@ -162,7 +162,7 @@ void Sector::setVisible(bool vis) {
|
||||
_visible = vis;
|
||||
}
|
||||
|
||||
bool Sector::isPointInSector(Graphics::Vector3d point) const {
|
||||
bool Sector::isPointInSector(const Graphics::Vector3d &point) const {
|
||||
// The algorithm: for each edge A->B, check whether the z-component
|
||||
// of (B-A) x (P-A) is >= 0. Then the point is at least in the
|
||||
// cylinder above&below the polygon. (This works because the polygons'
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
int getSectorId() const { return _id; }
|
||||
SectorType getType() const { return _type; } // FIXME: Implement type de-masking
|
||||
bool isVisible() const { return _visible; }
|
||||
bool isPointInSector(Graphics::Vector3d point) const;
|
||||
bool isPointInSector(const Graphics::Vector3d &point) const;
|
||||
Common::List<Graphics::Line3d> getBridgesTo(Sector *sector) const;
|
||||
|
||||
Graphics::Vector3d getProjectionToPlane(const Graphics::Vector3d &point) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user