mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Merge branch 'addMesh_lua' into 'master'
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / Ubuntu (push) Waiting to run
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
addMesh lua calls See merge request OpenMW/openmw!4494
This commit is contained in:
commit
fcaf93ffbf
3 changed files with 60 additions and 0 deletions
|
@ -286,6 +286,35 @@ namespace MWLua
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
api["addMesh"] = [context](const sol::object& object, std::string_view model, std::string_view bonename,
|
||||||
|
std::string_view meshId) {
|
||||||
|
context.mLuaManager->addAction(
|
||||||
|
[object = ObjectVariant(object), model = std::string(model), bonename = std::string(bonename),
|
||||||
|
meshId = std::string(meshId)] {
|
||||||
|
MWRender::Animation* anim = getMutableAnimationOrThrow(object);
|
||||||
|
anim->addCustomMesh(model, bonename, meshId);
|
||||||
|
},
|
||||||
|
"addMeshAction");
|
||||||
|
};
|
||||||
|
|
||||||
|
api["removeMesh"] = [context](const sol::object& object, std::string_view meshId) {
|
||||||
|
context.mLuaManager->addAction(
|
||||||
|
[object = ObjectVariant(object), meshId = std::string(meshId)] {
|
||||||
|
MWRender::Animation* anim = getMutableAnimationOrThrow(object);
|
||||||
|
anim->removeCustomMesh(meshId);
|
||||||
|
},
|
||||||
|
"removeMeshAction");
|
||||||
|
};
|
||||||
|
|
||||||
|
api["removeAllMeshes"] = [context](const sol::object& object) {
|
||||||
|
context.mLuaManager->addAction(
|
||||||
|
[object = ObjectVariant(object)] {
|
||||||
|
MWRender::Animation* anim = getMutableAnimationOrThrow(object);
|
||||||
|
anim->removeCustomMeshes();
|
||||||
|
},
|
||||||
|
"removeAllMeshesAction");
|
||||||
|
};
|
||||||
|
|
||||||
api["removeVfx"] = [context](const sol::object& object, std::string_view effectId) {
|
api["removeVfx"] = [context](const sol::object& object, std::string_view effectId) {
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[object = ObjectVariant(object), effectId = std::string(effectId)] {
|
[object = ObjectVariant(object), effectId = std::string(effectId)] {
|
||||||
|
|
|
@ -1708,6 +1708,31 @@ namespace MWRender
|
||||||
mExtraLightSource->setActorFade(mAlpha);
|
mExtraLightSource->setActorFade(mAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Animation::removeCustomMesh(std::string_view meshId)
|
||||||
|
{
|
||||||
|
mCustomMeshesMap.erase(std::string(meshId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animation::removeCustomMeshes()
|
||||||
|
{
|
||||||
|
mCustomMeshesMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Animation::addCustomMesh(std::string_view model, std::string_view bonename, std::string_view meshId)
|
||||||
|
{
|
||||||
|
SceneUtil::FindByNameVisitor findVisitor(bonename);
|
||||||
|
mObjectRoot->accept(findVisitor);
|
||||||
|
osg::Group* parent = findVisitor.mFoundNode;
|
||||||
|
|
||||||
|
if (!parent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VFS::Path::Normalized mesh(model);
|
||||||
|
osg::ref_ptr<osg::Node> instance = mResourceSystem->getSceneManager()->getInstance(mesh, parent);
|
||||||
|
PartHolderPtr holder = std::make_unique<PartHolder>(instance);
|
||||||
|
mCustomMeshesMap.insert(std::pair<std::string, PartHolderPtr>(meshId, std::move(holder)));
|
||||||
|
}
|
||||||
|
|
||||||
void Animation::addEffect(std::string_view model, std::string_view effectId, bool loop, std::string_view bonename,
|
void Animation::addEffect(std::string_view model, std::string_view effectId, bool loop, std::string_view bonename,
|
||||||
std::string_view texture, bool useAmbientLight)
|
std::string_view texture, bool useAmbientLight)
|
||||||
{
|
{
|
||||||
|
|
|
@ -209,6 +209,8 @@ namespace MWRender
|
||||||
|
|
||||||
mutable NodeMap mNodeMap;
|
mutable NodeMap mNodeMap;
|
||||||
mutable bool mNodeMapCreated;
|
mutable bool mNodeMapCreated;
|
||||||
|
mutable std::unordered_map<std::string, PartHolderPtr, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual>
|
||||||
|
mCustomMeshesMap;
|
||||||
|
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
|
|
||||||
|
@ -349,6 +351,10 @@ namespace MWRender
|
||||||
void addEffect(std::string_view model, std::string_view effectId, bool loop = false,
|
void addEffect(std::string_view model, std::string_view effectId, bool loop = false,
|
||||||
std::string_view bonename = {}, std::string_view texture = {}, bool useAmbientLight = true);
|
std::string_view bonename = {}, std::string_view texture = {}, bool useAmbientLight = true);
|
||||||
|
|
||||||
|
void addCustomMesh(std::string_view model, std::string_view bonename, std::string_view meshId);
|
||||||
|
void removeCustomMesh(std::string_view meshId);
|
||||||
|
void removeCustomMeshes();
|
||||||
|
|
||||||
void removeEffect(std::string_view effectId);
|
void removeEffect(std::string_view effectId);
|
||||||
void removeEffects();
|
void removeEffects();
|
||||||
std::vector<std::string_view> getLoopingEffects() const;
|
std::vector<std::string_view> getLoopingEffects() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue