mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 00:45:36 +00:00
Use flag enums instead of hard-coded hex values
This commit is contained in:
parent
4ce98e9bd6
commit
36170c5374
3 changed files with 32 additions and 24 deletions
|
@ -128,13 +128,17 @@ struct NiNode : Node
|
||||||
NodeList children;
|
NodeList children;
|
||||||
NodeList effects;
|
NodeList effects;
|
||||||
|
|
||||||
/* Known NiNode flags:
|
enum Flags {
|
||||||
0x01 hidden
|
Flag_Hidden = 0x0001,
|
||||||
0x02 use mesh for collision
|
Flag_MeshCollision = 0x0002,
|
||||||
0x04 use bounding box for collision (?)
|
Flag_BBoxCollision = 0x0004
|
||||||
0x08 unknown, but common
|
};
|
||||||
0x20, 0x40, 0x80 unknown
|
enum BSAnimFlags {
|
||||||
*/
|
AnimFlag_AutoPlay = 0x0020
|
||||||
|
};
|
||||||
|
enum BSParticleFlags {
|
||||||
|
ParticleFlag_AutoPlay = 0x0020
|
||||||
|
};
|
||||||
|
|
||||||
void read(NIFStream *nif)
|
void read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
|
|
|
@ -255,9 +255,9 @@ void ManualBulletShapeLoader::handleNiTriShape(btTriangleMesh* mesh, const Nif::
|
||||||
assert(shape != NULL);
|
assert(shape != NULL);
|
||||||
|
|
||||||
// Interpret flags
|
// Interpret flags
|
||||||
bool hidden = (flags & 0x01) != 0; // Not displayed
|
bool hidden = (flags&Nif::NiNode::Flag_Hidden) != 0;
|
||||||
bool collide = (flags & 0x02) != 0; // Use mesh for collision
|
bool collide = (flags&Nif::NiNode::Flag_MeshCollision) != 0;
|
||||||
bool bbcollide = (flags & 0x04) != 0; // Use bounding box for collision
|
bool bbcollide = (flags&Nif::NiNode::Flag_BBoxCollision) != 0;
|
||||||
|
|
||||||
// If the object was marked "NCO" earlier, it shouldn't collide with
|
// If the object was marked "NCO" earlier, it shouldn't collide with
|
||||||
// anything. So don't do anything.
|
// anything. So don't do anything.
|
||||||
|
|
|
@ -394,7 +394,7 @@ class NIFObjectLoader
|
||||||
NIFMeshLoader::createMesh(name, fullname, group, shape->recIndex);
|
NIFMeshLoader::createMesh(name, fullname, group, shape->recIndex);
|
||||||
|
|
||||||
Ogre::Entity *entity = sceneMgr->createEntity(fullname);
|
Ogre::Entity *entity = sceneMgr->createEntity(fullname);
|
||||||
entity->setVisible(!(flags&0x01));
|
entity->setVisible(!(flags&Nif::NiNode::Flag_Hidden));
|
||||||
|
|
||||||
objectlist.mEntities.push_back(entity);
|
objectlist.mEntities.push_back(entity);
|
||||||
if(objectlist.mSkelBase)
|
if(objectlist.mSkelBase)
|
||||||
|
@ -417,10 +417,11 @@ class NIFObjectLoader
|
||||||
const Nif::NiUVController *uv = static_cast<const Nif::NiUVController*>(ctrl.getPtr());
|
const Nif::NiUVController *uv = static_cast<const Nif::NiUVController*>(ctrl.getPtr());
|
||||||
|
|
||||||
const Ogre::MaterialPtr &material = entity->getSubEntity(0)->getMaterial();
|
const Ogre::MaterialPtr &material = entity->getSubEntity(0)->getMaterial();
|
||||||
Ogre::ControllerValueRealPtr srcval((animflags&0x20) ? Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ?
|
||||||
|
Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
||||||
Ogre::ControllerValueRealPtr());
|
Ogre::ControllerValueRealPtr());
|
||||||
Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(material, uv->data.getPtr()));
|
Ogre::ControllerValueRealPtr dstval(OGRE_NEW UVController::Value(material, uv->data.getPtr()));
|
||||||
Ogre::ControllerFunctionRealPtr func(OGRE_NEW UVController::Function(uv, (animflags&0x20)));
|
Ogre::ControllerFunctionRealPtr func(OGRE_NEW UVController::Function(uv, (animflags&Nif::NiNode::AnimFlag_AutoPlay)));
|
||||||
|
|
||||||
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
||||||
}
|
}
|
||||||
|
@ -551,10 +552,11 @@ class NIFObjectLoader
|
||||||
objectlist.mSkelBase->attachObjectToBone(trgtbone->getName(), partsys);
|
objectlist.mSkelBase->attachObjectToBone(trgtbone->getName(), partsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::ControllerValueRealPtr srcval((partflags&0x20) ? Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
Ogre::ControllerValueRealPtr srcval((partflags&Nif::NiNode::ParticleFlag_AutoPlay) ?
|
||||||
|
Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
||||||
Ogre::ControllerValueRealPtr());
|
Ogre::ControllerValueRealPtr());
|
||||||
Ogre::ControllerValueRealPtr dstval(OGRE_NEW ParticleSystemController::Value(partsys, partctrl));
|
Ogre::ControllerValueRealPtr dstval(OGRE_NEW ParticleSystemController::Value(partsys, partctrl));
|
||||||
Ogre::ControllerFunctionRealPtr func(OGRE_NEW ParticleSystemController::Function(partctrl, (partflags&0x20)));
|
Ogre::ControllerFunctionRealPtr func(OGRE_NEW ParticleSystemController::Function(partctrl, (partflags&Nif::NiNode::ParticleFlag_AutoPlay)));
|
||||||
|
|
||||||
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
||||||
}
|
}
|
||||||
|
@ -568,7 +570,7 @@ class NIFObjectLoader
|
||||||
objectlist.mSkelBase->attachObjectToBone(trgtbone->getName(), partsys);
|
objectlist.mSkelBase->attachObjectToBone(trgtbone->getName(), partsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
partsys->setVisible(!(flags&0x01));
|
partsys->setVisible(!(flags&Nif::NiNode::Flag_Hidden));
|
||||||
objectlist.mParticles.push_back(partsys);
|
objectlist.mParticles.push_back(partsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,10 +629,11 @@ class NIFObjectLoader
|
||||||
|
|
||||||
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex);
|
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex);
|
||||||
Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
|
Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
|
||||||
Ogre::ControllerValueRealPtr srcval((animflags&0x20) ? Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ?
|
||||||
|
Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
||||||
Ogre::ControllerValueRealPtr());
|
Ogre::ControllerValueRealPtr());
|
||||||
Ogre::ControllerValueRealPtr dstval(OGRE_NEW VisController::Value(trgtbone, vis->data.getPtr()));
|
Ogre::ControllerValueRealPtr dstval(OGRE_NEW VisController::Value(trgtbone, vis->data.getPtr()));
|
||||||
Ogre::ControllerFunctionRealPtr func(OGRE_NEW VisController::Function(vis, (animflags&0x20)));
|
Ogre::ControllerFunctionRealPtr func(OGRE_NEW VisController::Function(vis, (animflags&Nif::NiNode::AnimFlag_AutoPlay)));
|
||||||
|
|
||||||
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
||||||
}
|
}
|
||||||
|
@ -641,10 +644,11 @@ class NIFObjectLoader
|
||||||
{
|
{
|
||||||
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex);
|
int trgtid = NIFSkeletonLoader::lookupOgreBoneHandle(name, ctrl->target->recIndex);
|
||||||
Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
|
Ogre::Bone *trgtbone = objectlist.mSkelBase->getSkeleton()->getBone(trgtid);
|
||||||
Ogre::ControllerValueRealPtr srcval((animflags&0x20) ? Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
Ogre::ControllerValueRealPtr srcval((animflags&Nif::NiNode::AnimFlag_AutoPlay) ?
|
||||||
|
Ogre::ControllerManager::getSingleton().getFrameTimeSource() :
|
||||||
Ogre::ControllerValueRealPtr());
|
Ogre::ControllerValueRealPtr());
|
||||||
Ogre::ControllerValueRealPtr dstval(OGRE_NEW KeyframeController::Value(trgtbone, key->data.getPtr()));
|
Ogre::ControllerValueRealPtr dstval(OGRE_NEW KeyframeController::Value(trgtbone, key->data.getPtr()));
|
||||||
Ogre::ControllerFunctionRealPtr func(OGRE_NEW KeyframeController::Function(key, (animflags&0x20)));
|
Ogre::ControllerFunctionRealPtr func(OGRE_NEW KeyframeController::Function(key, (animflags&Nif::NiNode::AnimFlag_AutoPlay)));
|
||||||
|
|
||||||
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
objectlist.mControllers.push_back(Ogre::Controller<Ogre::Real>(srcval, dstval, func));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue