• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ fixed类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中fixed的典型用法代码示例。如果您正苦于以下问题:C++ fixed类的具体用法?C++ fixed怎么用?C++ fixed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了fixed类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: clamp

fixed CTerrain::GetExactGroundLevelFixed(fixed x, fixed z) const
{
	// Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1)
	const ssize_t xi = clamp((ssize_t)(x / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);
	const ssize_t zi = clamp((ssize_t)(z / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);

	const fixed one = fixed::FromInt(1);

	const fixed xf = clamp((x / (int)TERRAIN_TILE_SIZE) - fixed::FromInt(xi), fixed::Zero(), one);
	const fixed zf = clamp((z / (int)TERRAIN_TILE_SIZE) - fixed::FromInt(zi), fixed::Zero(), one);

	u16 h00 = m_Heightmap[zi*m_MapSize + xi];
	u16 h01 = m_Heightmap[(zi+1)*m_MapSize + xi];
	u16 h10 = m_Heightmap[zi*m_MapSize + (xi+1)];
	u16 h11 = m_Heightmap[(zi+1)*m_MapSize + (xi+1)];

	// Intermediate scaling of xf, so we don't overflow in the multiplications below
	// (h00 <= 65535, xf <= 1, max fixed is < 32768; divide by 2 here so xf1*h00 <= 32767.5)
	const fixed xf0 = xf / 2;
	const fixed xf1 = (one - xf) / 2;

	// Linearly interpolate
	return ((one - zf).Multiply(xf1 * h00 + xf0 * h10)
	              + zf.Multiply(xf1 * h01 + xf0 * h11)) / (int)(HEIGHT_UNITS_PER_METRE / 2);

	// TODO: This should probably be more like GetExactGroundLevel()
	// in handling triangulation properly
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例2: Rotate

  void Rotate(const Angle alpha) {
    const auto sc = alpha.SinCos();
    const fixed sin = sc.first, cos = sc.second;
#ifdef FIXED_MATH
    long s = sin.as_glfixed();
    long c = cos.as_glfixed();
#else
    long s = sin * (1<<16);
    long c = cos * (1<<16);
#endif
    Rotatex(s, c);
  }
开发者ID:,项目名称:,代码行数:12,代码来源:


示例3: Scale

  void Scale(const fixed &factor) {
#ifdef FIXED_MATH
    Scalex(factor.as_glfixed_scale());
#else
    Scalex(factor * (1LL<<32));
#endif
  }
开发者ID:,项目名称:,代码行数:7,代码来源:


示例4: Deserialize

	virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize)
	{
		Init(paramNode);

		u32 oldSeed = GetActorSeed();

		SerializeCommon(deserialize);

		// If we serialized a different seed, reload actor
		if (oldSeed != GetActorSeed())
			ReloadActor();

		fixed repeattime = m_AnimSyncRepeatTime; // save because SelectAnimation overwrites it

		if (m_AnimRunThreshold.IsZero())
			SelectAnimation(m_AnimName, m_AnimOnce, m_AnimSpeed, m_SoundGroup);
		else
			SelectMovementAnimation(m_AnimRunThreshold);

		SetAnimationSyncRepeat(repeattime);

		if (m_Unit)
		{
			CmpPtr<ICmpOwnership> cmpOwnership(GetSimContext(), GetEntityId());
			if (cmpOwnership)
				m_Unit->GetModel().SetPlayerID(cmpOwnership->GetOwner());
		}
	}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例5: AdjustedColour

const Color Faction::AdjustedColour(fixed population, bool inRange)
{
	Color result;
	result   = population == 0 ? BAD_FACTION_COLOUR : colour;
	result.a = population > 0  ? FACTION_BASE_ALPHA + (M_E + (logf(population.ToFloat() / 1.25))) / ((2 * M_E) + FACTION_BASE_ALPHA) : FACTION_BASE_ALPHA;
	result.a = inRange         ? 1.f : result.a;
	return result;
}
开发者ID:Mike-Cowley,项目名称:pioneer,代码行数:8,代码来源:Factions.cpp


示例6: SetAnimationSyncOffset

	virtual void SetAnimationSyncOffset(fixed actiontime)
	{
		if (m_Unit)
		{
			if (m_Unit->GetAnimation())
				m_Unit->GetAnimation()->SetAnimationSyncOffset(actiontime.ToFloat());
		}
	}
开发者ID:stonefruit,项目名称:0ad,代码行数:8,代码来源:CCmpVisualActor.cpp


示例7: SetAnimationSyncRepeat

	virtual void SetAnimationSyncRepeat(fixed repeattime)
	{
		m_AnimSyncRepeatTime = repeattime;

		if (m_Unit)
		{
			if (m_Unit->GetAnimation())
				m_Unit->GetAnimation()->SetAnimationSyncRepeat(m_AnimSyncRepeatTime.ToFloat());
		}
	}
开发者ID:stonefruit,项目名称:0ad,代码行数:10,代码来源:CCmpVisualActor.cpp


示例8: SelectAnimation

	virtual void SelectAnimation(std::string name, bool once, fixed speed, std::wstring soundgroup)
	{
		m_AnimRunThreshold = fixed::Zero();
		m_AnimName = name;
		m_AnimOnce = once;
		m_AnimSpeed = speed;
		m_SoundGroup = soundgroup;
		m_AnimDesync = fixed::FromInt(1)/20; // TODO: make this an argument
		m_AnimSyncRepeatTime = fixed::Zero();

		if (m_Unit)
		{
			m_Unit->SetEntitySelection(m_AnimName);
			if (m_Unit->GetAnimation())
				m_Unit->GetAnimation()->SetAnimationState(m_AnimName, m_AnimOnce, m_AnimSpeed.ToFloat(), m_AnimDesync.ToFloat(), m_SoundGroup.c_str());
		}
	}
开发者ID:stonefruit,项目名称:0ad,代码行数:17,代码来源:CCmpVisualActor.cpp


示例9: tanx

fixed tanx(fixed x)
{
	return x.tan();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例10: cosx

fixed cosx(fixed x)
{
	return x.cos();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例11: sinx

fixed sinx(fixed x)
{
	return x.sin();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例12: ceilx

fixed ceilx(fixed fixedVal)
{
	return fixedVal.ceil();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例13: floorx

fixed floorx(fixed fixedVal)
{
	return fixedVal.floor();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例14: logx

fixed logx(fixed fixedVal)
{
	return fixedVal.log();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例15: expx

fixed expx(fixed fixedVal)
{
	return fixedVal.exp();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例16:

template <> void XMLWriter_File::ElementAttribute<fixed>(const char* name, const fixed& value, bool newelement)
{
	ElementAttribute(name, value.ToString().c_str(), newelement);
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:4,代码来源:XMLWriter.cpp


示例17: NumberFixed_Unbounded

void IDeserializer::NumberFixed_Unbounded(const char* name, fixed& out)
{
	int32_t n;
	NumberI32_Unbounded(name, n);
	out.SetInternalValue(n);
}
开发者ID:righnatios,项目名称:0ad,代码行数:6,代码来源:IDeserializer.cpp


示例18:

fixed operator*(fixed a, long b)
{
	return a.multiply(b);
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp


示例19: PutNumber

void CDebugSerializer::PutNumber(const char* name, fixed value)
{
	m_Stream << INDENT << name << ": " << value.ToString() << "\n";
}
开发者ID:righnatios,项目名称:0ad,代码行数:4,代码来源:DebugSerializer.cpp


示例20: sqrtx

fixed sqrtx(fixed fixedVal)
{
	return fixedVal.sqrt();
}
开发者ID:proton,项目名称:ireon,代码行数:4,代码来源:fixed.cpp



注:本文中的fixed类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ flat_set类代码示例发布时间:2022-05-31
下一篇:
C++ fitness_vector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap