New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature #3523: Light source on magic projectiles #1144
Conversation
…usion properties from spells
@@ -2,6 +2,8 @@ | |||
|
|||
#include <iomanip> | |||
|
|||
#include <osg/Light> | |||
#include <osg/LightSource> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct include is components/sceneutil/lightmanager.hpp
@@ -136,7 +138,7 @@ namespace MWWorld | |||
}; | |||
|
|||
|
|||
void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, std::string texture) | |||
void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, bool isMagic, std::string texture) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isMagic should be renamed to createLight to reflect the variable's real purpose.
Retrieval of colors from the relevant magic effects is complete. Testing on several spells shows that the blended diffusion values match the projectile colors in vanilla Morrowind. |
That sounds very.. scientific ;) |
@scrawl, can we agree not to use C-style casts anymore? |
Oh, I didn't notice the casts. A Regarding this cast: int numberOfEffects = ((MagicBoltState&)state).mEffects.mList.size(); Is a problem, the function will crash if for some reason state.mIdMagic has a value with a non-magic projectile. @Aussiemon: could you make a new PR updating the code to not use C-style casts, and remove the MagicBoltState cast? It's probably easiest to just compute the light color before hand and then pass it to createModel. |
I was primarily referring to non-trivial types. The ability to fall back to reinterpret_cast sounds like an accident waiting to happen. C++ casts express their intent much more clearly. |
Yes, that is my stance. For non-trivial types, we should always use C++ casts. In this case, the cast shouldn't be there in the first place though. |
Agreed. |
Thanks for the review of my work. I'll definitely take this into account in the future. I've created a pull request with the recommended changes to casts. If there's a better way to make these fixes, I'd be happy to learn. |
Feature #3523
Attached light to magic bolt projectiles.
Thread discussion of this pull request