commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
73
include/engine/physic/physic_constraint_desc.cpp
Normal file
73
include/engine/physic/physic_constraint_desc.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "physic/physic_constraint_desc.h"
|
||||
#include "metafile/nml.h"
|
||||
#include "log/log.h"
|
||||
|
||||
using namespace GS::S3D;
|
||||
using GS::NML::Tag;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool PhysicConstraintDesc::FromMetaTag(Tag &tag)
|
||||
{
|
||||
if (tag.name != "Constraint")
|
||||
__ERR__(__LOG_E__ << "Could not parse physic constraint, incorrect root tag (" << tag.name << ").\n", false)
|
||||
|
||||
type = TypeNone;
|
||||
item_a = item_b = NULL;
|
||||
pivot_a = pivot_b = Matrix4::IdentityMatrix();
|
||||
|
||||
NMLTagForeach(pt, tag)
|
||||
{
|
||||
if (pt->name == "Type")
|
||||
{
|
||||
String _type(pt->GetString());
|
||||
|
||||
if (_type == "Point")
|
||||
type = TypePoint;
|
||||
else if (_type == "Hinge")
|
||||
type = TypeHinge;
|
||||
}
|
||||
|
||||
else if (pt->name == "PivotA")
|
||||
pivot_a.FromMetaTag(*pt);
|
||||
else if (pt->name == "PivotB")
|
||||
pivot_b.FromMetaTag(*pt);
|
||||
|
||||
else __LOG_W__ << "Unknown tag '" << pt->name << "' in <PhysicConstraint>.\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Tag *PhysicConstraintDesc::AsMetaTag() const
|
||||
{
|
||||
Tag *root = new Tag("Constraint");
|
||||
if (!root)
|
||||
__ERR__(__LOG_E__ << "Could not create physic constraint root tag to serialize.\n", NULL)
|
||||
|
||||
if (type != TypeNone)
|
||||
{
|
||||
String _type = "None";
|
||||
switch (type)
|
||||
{
|
||||
case TypePoint: _type = "Point"; break;
|
||||
case TypeHinge: _type = "Hinge"; break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
root->AddChild("Type", _type.c_str());
|
||||
}
|
||||
|
||||
// Save pivot informations.
|
||||
root->AddChild(pivot_a.AsMetaTag("PivotA"));
|
||||
root->AddChild(pivot_b.AsMetaTag("PivotB"));
|
||||
return root;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user