forked from mirror/openmw-tes3mp
Merge pull request #174 from OpenMW/master
Add OpenMW commits up to 26 Feb 2017, part 2
This commit is contained in:
commit
4110fac629
6 changed files with 40 additions and 50 deletions
|
@ -362,7 +362,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// If set in the settings file, player followers and escorters will become aggressive toward enemies in combat with them or the player
|
// If set in the settings file, player followers and escorters will become aggressive toward enemies in combat with them or the player
|
||||||
if (!aggressive && isPlayerFollowerOrEscorter && Settings::Manager::getBool("followers attack on sight", "Game"))
|
static const bool followersAttackOnSight = Settings::Manager::getBool("followers attack on sight", "Game");
|
||||||
|
if (!aggressive && isPlayerFollowerOrEscorter && followersAttackOnSight)
|
||||||
{
|
{
|
||||||
if (actor2.getClass().getCreatureStats(actor2).getAiSequence().isInCombat(actor1))
|
if (actor2.getClass().getCreatureStats(actor2).getAiSequence().isInCombat(actor1))
|
||||||
aggressive = true;
|
aggressive = true;
|
||||||
|
|
|
@ -1338,6 +1338,7 @@ namespace MWPhysics
|
||||||
bool cmode = found->second->getCollisionMode();
|
bool cmode = found->second->getCollisionMode();
|
||||||
cmode = !cmode;
|
cmode = !cmode;
|
||||||
found->second->enableCollisionMode(cmode);
|
found->second->enableCollisionMode(cmode);
|
||||||
|
found->second->enableCollisionBody(cmode);
|
||||||
return cmode;
|
return cmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,11 @@ void NiSkinInstance::post(NIFFile *nif)
|
||||||
if(bnum != data->bones.size())
|
if(bnum != data->bones.size())
|
||||||
nif->fail("Mismatch in NiSkinData bone count");
|
nif->fail("Mismatch in NiSkinData bone count");
|
||||||
|
|
||||||
root->makeRootBone(&data->trafo);
|
|
||||||
|
|
||||||
for(size_t i=0; i<bnum; i++)
|
for(size_t i=0; i<bnum; i++)
|
||||||
{
|
{
|
||||||
if(bones[i].empty())
|
if(bones[i].empty())
|
||||||
nif->fail("Oops: Missing bone! Don't know how to handle this.");
|
nif->fail("Oops: Missing bone! Don't know how to handle this.");
|
||||||
bones[i]->makeBone(i, data->bones[i]);
|
bones[i]->setBone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,7 @@ public:
|
||||||
|
|
||||||
parent = NULL;
|
parent = NULL;
|
||||||
|
|
||||||
boneTrafo = NULL;
|
isBone = false;
|
||||||
boneIndex = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void post(NIFFile *nif)
|
void post(NIFFile *nif)
|
||||||
|
@ -69,27 +68,11 @@ public:
|
||||||
// NiNodes (or types derived from NiNodes) can be parents.
|
// NiNodes (or types derived from NiNodes) can be parents.
|
||||||
NiNode *parent;
|
NiNode *parent;
|
||||||
|
|
||||||
// Bone transformation. If set, node is a part of a skeleton.
|
bool isBone;
|
||||||
const Transformation *boneTrafo;
|
|
||||||
|
|
||||||
// Bone weight info, from NiSkinData
|
void setBone()
|
||||||
const NiSkinData::BoneInfo *boneInfo;
|
|
||||||
|
|
||||||
// Bone index. If -1, this node is either not a bone, or if
|
|
||||||
// boneTrafo is set it is the root bone in the skeleton.
|
|
||||||
short boneIndex;
|
|
||||||
|
|
||||||
void makeRootBone(const Transformation *tr)
|
|
||||||
{
|
{
|
||||||
boneTrafo = tr;
|
isBone = true;
|
||||||
boneIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void makeBone(short ind, const NiSkinData::BoneInfo &bi)
|
|
||||||
{
|
|
||||||
boneInfo = &bi;
|
|
||||||
boneTrafo = &bi.trafo;
|
|
||||||
boneIndex = ind;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -512,10 +512,10 @@ namespace NifOsg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a default dataVariance for this node to be used as a hint by optimization (post)routines
|
// Get a default dataVariance for this node to be used as a hint by optimization (post)routines
|
||||||
osg::Object::DataVariance getDataVariance(const Nif::Node* nifNode)
|
osg::ref_ptr<osg::Group> createNode(const Nif::Node* nifNode)
|
||||||
{
|
{
|
||||||
if (nifNode->boneTrafo || nifNode->boneIndex != -1)
|
osg::ref_ptr<osg::Group> node;
|
||||||
return osg::Object::DYNAMIC;
|
osg::Object::DataVariance dataVariance = osg::Object::UNSPECIFIED;
|
||||||
|
|
||||||
switch (nifNode->recType)
|
switch (nifNode->recType)
|
||||||
{
|
{
|
||||||
|
@ -524,10 +524,35 @@ namespace NifOsg
|
||||||
case Nif::RC_NiRotatingParticles:
|
case Nif::RC_NiRotatingParticles:
|
||||||
// Leaf nodes in the NIF hierarchy, so won't be able to dynamically attach children.
|
// Leaf nodes in the NIF hierarchy, so won't be able to dynamically attach children.
|
||||||
// No support for keyframe controllers (just crashes in the original engine).
|
// No support for keyframe controllers (just crashes in the original engine).
|
||||||
return osg::Object::STATIC;
|
if (nifNode->trafo.isIdentity())
|
||||||
|
node = new osg::Group;
|
||||||
|
dataVariance = osg::Object::STATIC;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return osg::Object::DYNAMIC;
|
// 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
|
||||||
|
// loaded from an external .kf file (original engine just throws "can't find node" errors if you try).
|
||||||
|
if (!nifNode->parent && nifNode->controller.empty())
|
||||||
|
{
|
||||||
|
node = new osg::Group;
|
||||||
|
dataVariance = osg::Object::STATIC;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataVariance = (nifNode->controller.empty() ? osg::Object::STATIC : osg::Object::DYNAMIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nifNode->isBone)
|
||||||
|
dataVariance = osg::Object::DYNAMIC;
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (!node)
|
||||||
|
node = new osg::MatrixTransform(nifNode->trafo.toMatrix());
|
||||||
|
|
||||||
|
node->setDataVariance(dataVariance);
|
||||||
|
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> handleNode(const Nif::Node* nifNode, osg::Group* parentNode, Resource::ImageManager* imageManager,
|
osg::ref_ptr<osg::Node> handleNode(const Nif::Node* nifNode, osg::Group* parentNode, Resource::ImageManager* imageManager,
|
||||||
|
@ -536,30 +561,12 @@ namespace NifOsg
|
||||||
if (rootNode != NULL && Misc::StringUtils::ciEqual(nifNode->name, "Bounding Box"))
|
if (rootNode != NULL && Misc::StringUtils::ciEqual(nifNode->name, "Bounding Box"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
osg::Object::DataVariance dataVariance = getDataVariance(nifNode);
|
osg::ref_ptr<osg::Group> node = createNode(nifNode);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> node;
|
|
||||||
if (dataVariance == osg::Object::STATIC && nifNode->trafo.isIdentity())
|
|
||||||
node = new osg::Group;
|
|
||||||
else
|
|
||||||
node = new osg::MatrixTransform(nifNode->trafo.toMatrix());
|
|
||||||
node->setDataVariance(dataVariance);
|
|
||||||
|
|
||||||
if (nifNode->controller.empty())
|
|
||||||
node->setDataVariance(osg::Object::STATIC);
|
|
||||||
|
|
||||||
if (nifNode->recType == Nif::RC_NiBillboardNode)
|
if (nifNode->recType == Nif::RC_NiBillboardNode)
|
||||||
{
|
{
|
||||||
node->addCullCallback(new BillboardCallback);
|
node->addCullCallback(new BillboardCallback);
|
||||||
}
|
}
|
||||||
else if (!rootNode && nifNode->controller.empty() && nifNode->trafo.isIdentity())
|
|
||||||
{
|
|
||||||
// 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
|
|
||||||
// loaded from an external .kf file (original engine just throws "can't find node" errors if you try).
|
|
||||||
node = new osg::Group;
|
|
||||||
node->setDataVariance(osg::Object::STATIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nifNode->controller.empty() && nifNode->controller->recType == Nif::RC_NiKeyframeController)
|
if (!nifNode->controller.empty() && nifNode->controller->recType == Nif::RC_NiKeyframeController)
|
||||||
isAnimated = true;
|
isAnimated = true;
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace SceneUtil
|
||||||
|
|
||||||
osgParticle::ParticleProcessor* CopyOp::operator() (const osgParticle::ParticleProcessor* processor) const
|
osgParticle::ParticleProcessor* CopyOp::operator() (const osgParticle::ParticleProcessor* processor) const
|
||||||
{
|
{
|
||||||
osgParticle::ParticleProcessor* cloned = osg::clone(processor, osg::CopyOp::SHALLOW_COPY);
|
osgParticle::ParticleProcessor* cloned = osg::clone(processor, osg::CopyOp::DEEP_COPY_CALLBACKS);
|
||||||
mMap[cloned] = processor->getParticleSystem();
|
mMap[cloned] = processor->getParticleSystem();
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue