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