void cSimCharSoftFall::Reset()
{
	cSimCharacter::Reset();
	ResetFallDistCounter();
	mPrevCheckPos = GetRootPos();
	mFailFallDist = false;
	ResetFallContactCounter();
	mSumFallContact = 0;
}
bool cSimCharSoftFall::Init(std::shared_ptr<cWorld> world, const tParams& params)
{
	bool succ = cSimCharacter::Init(world, params);
	ResetFallDistCounter();
	mPrevCheckPos = GetRootPos();
	mFailFallDist = false;
	ResetFallContactCounter();
	mSumFallContact = 0;
	return succ;
}
Exemple #3
0
bool CXml::GetBasePos()
{
    if (NULL == m_pBaseXmlNode)
    {
        GetRootPos();
    }
    else
    {
        m_pXmlNode = m_pBaseXmlNode;
        m_pXmlElem = m_pBaseXmlElem;
    }
    return true;
}
Exemple #4
0
/**************************************************************************
* name       : AddElemBeforeCurNode
* description: 在当前节点前添加元素
* input      : pszElemName 待添加的元素名
* output     : NA
* return     : true - 成功,false - 失败
* remark     : NA
**************************************************************************/
bool CXml::AddElemBeforeCurNode(const char *pszElemName)
{
	CHECK_POINTER(pszElemName, false);

	//Tinyxml会管理所有的申请的内存,不需要调用者delete
	TiXmlElement *pXmlAddElem = NULL;
	try
	{
		pXmlAddElem = new TiXmlElement(pszElemName);
	}
	catch (...)
	{
		pXmlAddElem = NULL;

		return false;//lint !e438
	}
    CHECK_POINTER(pXmlAddElem, false);//lint !e774

	if (NULL == m_pXmlNode)
	{
		if (NULL == m_pXMlDoc)
		{
			SAFE_NEW(m_pXMlDoc, TiXmlDocument);//lint !e774
		}

		CHECK_POINTER(m_pXMlDoc, false);//lint !e774
		(void)(m_pXMlDoc->LinkEndChild(pXmlAddElem));
		GetRootPos();

		return true;
	}

	// 判断指针是否为空
	CHECK_POINTER(m_pXmlNode, false); //lint !e774

	TiXmlNode *pParent = m_pXmlNode->Parent();

	CHECK_POINTER(pParent,false);	

	TiXmlNode *pXmlNode = pParent->InsertBeforeChild(m_pXmlNode,(*pXmlAddElem));

	if (NULL == pXmlNode)
	{
		return false;
	}
	m_pXmlNode = pXmlNode;
	m_pXmlElem = m_pXmlNode->ToElement();

	return true;
}
void cSimCharSoftFall::UpdateFallDistCheck(double time_step)
{
	mFallDistCounter -= time_step;
	if (mFallDistCounter <= 0)
	{
		tVector root_pos = GetRootPos();
		tVector dist = root_pos - mPrevCheckPos;

		if (dist.squaredNorm() < gMaxFallDist * gMaxFallDist)
		{
			mFailFallDist = true;
		}

		mPrevCheckPos = root_pos;
		ResetFallDistCounter();
	}
}
Exemple #6
0
/**************************************************************************
* name       : Load
* description: 加载一个xml文件
* input      : NA
* output     : NA
* return     : true - 成功,false - 失败
* remark     : NA
**************************************************************************/
bool CXml::Load(TiXmlEncoding encode)
{
    CHECK_POINTER(m_pszFileName, false);

    SAFE_NEW(m_pXMlDoc, TiXmlDocument);//lint !e774

    // 判断指针是否为空
    CHECK_POINTER(m_pXMlDoc, false); //lint !e774

    if (m_pXMlDoc->LoadFile(m_pszFileName, encode))
    {
        GetRootPos();

        return true;
    }
	
    return false;
}
Exemple #7
0
/**************************************************************************
* name       : Parse
* description: 解析一个xml流到xml文件
* input      : pszStream xml流
* output     : NA
* return     : true - 成功,false - 失败
* remark     : NA
**************************************************************************/
bool CXml::Parse(const char *pszStream, TiXmlEncoding encode)
{
    CHECK_POINTER(pszStream, false);

    //songyiqun
	SAFE_DELETE(m_pXMlDoc);
    SAFE_NEW(m_pXMlDoc, TiXmlDocument);//lint !e774

    CHECK_POINTER(m_pXMlDoc, false);//lint !e774

    //TIXML_ENCODING_LEGACY为Tinyxml使用的编码方式
    (void)(m_pXMlDoc->Parse(pszStream, NULL, encode));
    if (0 != m_pXMlDoc->Error())
    {
        return false;
    }

    GetRootPos();

    return true;
}