本文整理汇总了C++中ChunkManager::getChunkHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ ChunkManager::getChunkHandle方法的具体用法?C++ ChunkManager::getChunkHandle怎么用?C++ ChunkManager::getChunkHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChunkManager
的用法示例。
在下文中一共展示了ChunkManager::getChunkHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Player::update(float32 deltaSeconds)
{
const static float32 JUMP_POWER = 7.0f;
const static float32 SPEED = 5.0f;
const static float32 ROTATE_SPEED = 0.01f;
const static int MAX_JUMP_FRAMES = 15;
m_currentPosition = glm::vec3(transform.xPos, transform.yPos, transform.zPos);
m_lastPosition = m_currentPosition;
// Get current chunk
ChunkManager* cm = ChunkManager::instance();
m_chunkValid = cm->getChunkHandle(cm->getCurrentChunk(m_currentPosition), m_currentChunk);
// DONT UPDATE ME IF MY CHUNK ISNT VALID YET GOOOSH
if (!m_chunkValid) {
return;
}
static bool hasLanded = false;
float32 dx = 0;
float32 dy = 0;
float32 dz = 0;
if (m_forwardPressed) {
--dz;
}
if (m_backwardPressed) {
++dz;
}
if (m_leftPressed) {
--dx;
}
if (m_rightPressed) {
++dx;
}
glm::vec3 displacement = glm::rotate(transform.rotation, glm::vec3(dx, 0, dz));
displacement.y = 0;
displacement = glm::normalize(displacement);
displacement *= SPEED * deltaSeconds;
// Numerical approximation via Euler Integration
dy = m_velocityY * deltaSeconds;
m_velocityY += GRAVITY * deltaSeconds;
//displacement.y = dy;
//transform.translate(displacement);
if (dx || dz) {
transform.translate(displacement);
}
if (!m_glueToGround) {
transform.translate(0, dy, 0);
}
if (dx || (dy && !m_glueToGround) || dz) {
m_movedDuringFrame = true;
}
else {
m_movedDuringFrame = false;
}
//transform.translateLocal(dx, 0, dz);
//transform.translate(0, dy, 0);
// Apply jump
if (m_jumpPressed) {
// Apply impulse and cancel gravity
m_velocityY = JUMP_POWER;
m_jumpPressed = false;
m_glueToGround = false;
}
//if (m_jumpPressed) {
// if (!m_isJumping && hasLanded)
// {
// m_isJumping = true;
// hasLanded = false;
// }
//}
//
//if(m_ready && !m_isJumping)
// dy += GRAVITY * deltaSeconds;
//else if (m_ready && m_isJumping)
//{
// dy -= GRAVITY * deltaSeconds;
// m_jumpedFrames++;
//
// if (m_jumpedFrames > MAX_JUMP_FRAMES)
// {
// m_jumpedFrames = 0;
// m_isJumping = false;
// }
//}
glm::vec3 deltaPos(dx, dy, dz);
deltaPos = (glm::normalize(deltaPos) * SPEED * deltaSeconds);
//.........这里部分代码省略.........