Better protect allocated Ogre character data; proper blend path setting

This commit is contained in:
2026-02-08 18:17:48 +03:00
parent afc5ab02a3
commit 56436ea652
4 changed files with 42 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ class ExportMappingMale:
self.files.append({"name": fobj})
class ExportMappingMaleEdited:
blend_path = "assets/blender/" + "edited-normal-male.blend"
blend_path = "assets/blender/characters/" + "edited-normal-male.blend"
gltf_path = "characters/male/normal-male.gltf"
ogre_scene = "characters/male/vroid-normal-male.scene"
inner_path = "Object"
@@ -68,7 +68,7 @@ class ExportMappingMaleEdited:
self.files.append({"name": fobj})
class ExportMappingMaleClothedEdited:
blend_path = "assets/blender/" + "edited-normal-male.blend"
blend_path = "assets/blender/characters/" + "edited-normal-male.blend"
gltf_path = "characters/male/normal-male.gltf"
ogre_scene = "characters/male/vroid-normal-male.scene"
inner_path = "Object"
@@ -82,7 +82,7 @@ class ExportMappingMaleClothedEdited:
self.files.append({"name": fobj})
class ExportMappingFemaleEdited:
blend_path = "assets/blender/" + "edited-normal-female.blend"
blend_path = "assets/blender/characters/" + "edited-normal-female.blend"
gltf_path = "characters/female/normal-female.gltf"
ogre_scene = "characters/female/vroid-normal-female.scene"
inner_path = "Object"

View File

@@ -328,6 +328,15 @@ public:
if (action == "sit") {
jactionPrereq["is_seated"] = 0;
jactionEffect["is_seated"] = 1;
} else if (action == "use") {
if (props["tags"].find("toilet") !=
props["tags"].end()) {
std::cout << "toilet" << std::endl;
OgreAssert(false, "props: " + props.dump(4));
} else
OgreAssert(false, "props: " + props.dump(4));
} else {
OgreAssert(false, "props: " + props.dump(4));
}
Blackboard actionPrereq({ jactionPrereq });
Blackboard actionEffect({ jactionEffect });

View File

@@ -17,7 +17,14 @@ CharacterModule::CharacterModule(flecs::world &ecs)
ecs.module<CharacterModule>();
ecs.component<Character>();
ecs.component<Player>();
ecs.component<CharacterBase>();
ecs.component<CharacterBase>().on_remove([this](flecs::entity e,
CharacterBase &ch) {
if (characterEntities.find(e) != characterEntities.end() ||
characterNodes.find(e) != characterNodes.end()) {
characterEntities.erase(e);
characterNodes.erase(e);
}
});
ecs.component<CharacterGravity>();
ecs.component<CharacterLocation>();
ecs.component<CharacterBuoyancy>();
@@ -211,9 +218,21 @@ CharacterModule::CharacterModule(flecs::world &ecs)
.each([&](flecs::entity e, const EngineData &eng,
const CharacterLocation &loc,
const CharacterConf &conf, CharacterBase &ch) {
ch.mBodyEnt = eng.mScnMgr->createEntity(conf.type);
ch.mBodyNode = eng.mScnMgr->getRootSceneNode()
->createChildSceneNode();
CharacterModule &module =
ECS::get().get_mut<CharacterModule>();
if (module.characterNodes.find(e) ==
module.characterNodes.end()) {
Ogre::SceneNode *bodyNode =
eng.mScnMgr->getRootSceneNode()
->createChildSceneNode();
Ogre::Entity *bodyEnt =
eng.mScnMgr->createEntity(conf.type);
module.characterNodes[e] = bodyNode;
module.characterEntities[e] = bodyEnt;
ECS::modified<CharacterModule>();
}
ch.mBodyEnt = module.characterEntities[e];
ch.mBodyNode = module.characterNodes[e];
ch.mBodyNode->setOrientation(loc.orientation);
ch.mBodyNode->setPosition(loc.position);
ch.mBodyNode->attachObject(ch.mBodyEnt);
@@ -613,6 +632,8 @@ void CharacterModule::createCharacter(flecs::entity e,
{
if (e.has<CharacterBase>() || e.has<AnimationControl>())
return;
if (characterNodes.find(e) != characterNodes.end())
return;
e.set<CharacterLocation>({ rotation, position });
e.set<CharacterConf>({ model });
e.add<CharacterBase>();

View File

@@ -19,12 +19,12 @@ struct Female {};
struct CharacterBase {
Ogre::String type;
float mTimer;
Ogre::SceneNode *mBodyNode;
Ogre::Entity *mBodyEnt;
Ogre::Vector3 mBoneMotion;
Ogre::Vector3 mBonePrevMotion;
Ogre::Vector3 mGoalDirection; // actual intended direction in world-space
bool is_submerged;
Ogre::SceneNode *mBodyNode;
Ogre::Entity *mBodyEnt;
bool is_submerged;
};
struct CharacterLocation {
Ogre::Quaternion orientation;
@@ -45,6 +45,8 @@ struct CharacterModule {
void createCharacter(flecs::entity e, const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
const Ogre::String model);
std::unordered_map<flecs::entity_t, Ogre::SceneNode *> characterNodes;
std::unordered_map<flecs::entity_t, Ogre::Entity *> characterEntities;
};
}
#endif