mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Merge pull request #2704 from akortunov/collisionswitch
Handle NiCollisionSwitch node
This commit is contained in:
commit
c907cd98c8
@ -48,6 +48,7 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
|
||||
newFactory.insert(makeEntry("NiSwitchNode", &construct <NiSwitchNode> , RC_NiSwitchNode ));
|
||||
newFactory.insert(makeEntry("NiLODNode", &construct <NiLODNode> , RC_NiLODNode ));
|
||||
newFactory.insert(makeEntry("AvoidNode", &construct <NiNode> , RC_AvoidNode ));
|
||||
newFactory.insert(makeEntry("NiCollisionSwitch", &construct <NiNode> , RC_NiCollisionSwitch ));
|
||||
newFactory.insert(makeEntry("NiBSParticleNode", &construct <NiNode> , RC_NiBSParticleNode ));
|
||||
newFactory.insert(makeEntry("NiBSAnimationNode", &construct <NiNode> , RC_NiBSAnimationNode ));
|
||||
newFactory.insert(makeEntry("NiBillboardNode", &construct <NiNode> , RC_NiBillboardNode ));
|
||||
|
@ -84,7 +84,8 @@ struct NiNode : Node
|
||||
enum Flags {
|
||||
Flag_Hidden = 0x0001,
|
||||
Flag_MeshCollision = 0x0002,
|
||||
Flag_BBoxCollision = 0x0004
|
||||
Flag_BBoxCollision = 0x0004,
|
||||
Flag_ActiveCollision = 0x0020
|
||||
};
|
||||
enum BSAnimFlags {
|
||||
AnimFlag_AutoPlay = 0x0020
|
||||
|
@ -40,6 +40,7 @@ enum RecordType
|
||||
RC_NiLODNode,
|
||||
RC_NiBillboardNode,
|
||||
RC_AvoidNode,
|
||||
RC_NiCollisionSwitch,
|
||||
RC_NiTriShape,
|
||||
RC_NiTriStrips,
|
||||
RC_NiRotatingParticles,
|
||||
|
@ -254,6 +254,10 @@ bool BulletNifLoader::hasAutoGeneratedCollision(const Nif::Node* rootNode)
|
||||
void BulletNifLoader::handleNode(const std::string& fileName, const Nif::Node *node, int flags,
|
||||
bool isCollisionNode, bool isAnimated, bool autogenerated, bool avoid)
|
||||
{
|
||||
// TODO: allow on-the fly collision switching via toggling this flag
|
||||
if (node->recType == Nif::RC_NiCollisionSwitch && !(node->flags & Nif::NiNode::Flag_ActiveCollision))
|
||||
return;
|
||||
|
||||
// Accumulate the flags from all the child nodes. This works for all
|
||||
// the flags we currently use, at least.
|
||||
flags |= node->flags;
|
||||
|
@ -168,6 +168,20 @@ namespace
|
||||
|
||||
namespace NifOsg
|
||||
{
|
||||
class CollisionSwitch : public osg::Group
|
||||
{
|
||||
public:
|
||||
CollisionSwitch(bool enabled) : osg::Group()
|
||||
{
|
||||
setEnabled(enabled);
|
||||
}
|
||||
|
||||
void setEnabled(bool enabled)
|
||||
{
|
||||
setNodeMask(enabled ? SceneUtil::Mask_Default : SceneUtil::Mask_Effect);
|
||||
}
|
||||
};
|
||||
|
||||
bool Loader::sShowMarkers = false;
|
||||
|
||||
void Loader::setShowMarkers(bool show)
|
||||
@ -460,6 +474,14 @@ namespace NifOsg
|
||||
case Nif::RC_NiBillboardNode:
|
||||
dataVariance = osg::Object::DYNAMIC;
|
||||
break;
|
||||
case Nif::RC_NiCollisionSwitch:
|
||||
{
|
||||
bool enabled = nifNode->flags & Nif::NiNode::Flag_ActiveCollision;
|
||||
node = new CollisionSwitch(enabled);
|
||||
dataVariance = osg::Object::STATIC;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// The Root node can be created as a Group if no transformation is required.
|
||||
// This takes advantage of the fact root nodes can't have additional controllers
|
||||
|
Loading…
Reference in New Issue
Block a user