[BlockCursor] 'selectedBlock' now uses 'glm::ivec4' instead of 'glm::vec4'.
This commit is contained in:
parent
8f25100a8a
commit
d47d5d39e4
@ -49,7 +49,7 @@ class BlockCursor : public gk::Drawable {
|
||||
|
||||
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;
|
||||
|
||||
glm::vec4 findSelectedBlock() const;
|
||||
glm::ivec4 findSelectedBlock() const;
|
||||
|
||||
ClientPlayer &m_player;
|
||||
ClientWorld &m_world;
|
||||
@ -59,7 +59,7 @@ class BlockCursor : public gk::Drawable {
|
||||
gk::VertexBuffer m_animationVBO;
|
||||
|
||||
unsigned int m_animationStart = 0;
|
||||
glm::vec4 m_selectedBlock{0, 0, 0, -1};
|
||||
glm::ivec4 m_selectedBlock{0, 0, 0, -1};
|
||||
const Block *m_currentBlock = nullptr;
|
||||
const ItemStack *m_currentTool = nullptr;
|
||||
};
|
||||
|
@ -42,10 +42,10 @@ class ClientCommandHandler {
|
||||
|
||||
void sendPlayerInvUpdate();
|
||||
void sendPlayerPosUpdate();
|
||||
void sendPlayerDigBlock(const glm::vec4 &selectedBlock);
|
||||
void sendPlayerDigBlock(const glm::ivec4 &selectedBlock);
|
||||
void sendPlayerPlaceBlock(s32 x, s32 y, s32 z, u32 block);
|
||||
void sendPlayerInventoryRequest();
|
||||
void sendBlockActivated(const glm::vec4 &selectedBlock);
|
||||
void sendBlockActivated(const glm::ivec4 &selectedBlock);
|
||||
void sendBlockInvUpdate(Inventory &inventory);
|
||||
void sendChunkRequest(s32 chunkX, s32 chunkY, s32 chunkZ);
|
||||
|
||||
|
@ -133,7 +133,7 @@ void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) {
|
||||
|
||||
void BlockCursor::update(const Hotbar &hotbar) {
|
||||
bool selectedBlockChanged = false;
|
||||
glm::vec4 selectedBlock = findSelectedBlock();
|
||||
glm::ivec4 selectedBlock = findSelectedBlock();
|
||||
if (selectedBlock.x != m_selectedBlock.x || selectedBlock.y != m_selectedBlock.y || selectedBlock.z != m_selectedBlock.z)
|
||||
selectedBlockChanged = true;
|
||||
|
||||
@ -234,7 +234,7 @@ void BlockCursor::draw(gk::RenderTarget &target, gk::RenderStates states) const
|
||||
glCheck(glDisable(GL_POLYGON_OFFSET_FILL));
|
||||
glCheck(glDisable(GL_CULL_FACE));
|
||||
|
||||
states.transform.translate({m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z});
|
||||
states.transform.translate(m_selectedBlock.x, m_selectedBlock.y, m_selectedBlock.z);
|
||||
|
||||
target.draw(m_vbo, GL_LINES, 0, 24, states);
|
||||
|
||||
@ -249,7 +249,7 @@ void BlockCursor::draw(gk::RenderTarget &target, gk::RenderStates states) const
|
||||
glCheck(glEnable(GL_POLYGON_OFFSET_FILL));
|
||||
}
|
||||
|
||||
glm::vec4 BlockCursor::findSelectedBlock() const {
|
||||
glm::ivec4 BlockCursor::findSelectedBlock() const {
|
||||
glm::dvec3 lookAt{m_player.pointTargetedX() - m_player.camera().getPosition().x,
|
||||
m_player.pointTargetedY() - m_player.camera().getPosition().y,
|
||||
m_player.pointTargetedZ() - m_player.camera().getPosition().z};
|
||||
@ -270,6 +270,6 @@ glm::vec4 BlockCursor::findSelectedBlock() const {
|
||||
BlockCursorRaycast::rayCastToAxis(AXIS_Y, position, lookAtN, maxReach, bestX, bestY, bestZ, bestFace, bestDepth, m_world);
|
||||
BlockCursorRaycast::rayCastToAxis(AXIS_Z, position, lookAtN, maxReach, bestX, bestY, bestZ, bestFace, bestDepth, m_world);
|
||||
|
||||
return {bestX, bestY, bestZ, bestFace};
|
||||
return glm::ivec4{bestX, bestY, bestZ, bestFace};
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ void ClientCommandHandler::sendPlayerPosUpdate() {
|
||||
m_client.send(packet);
|
||||
}
|
||||
|
||||
void ClientCommandHandler::sendPlayerDigBlock(const glm::vec4 &selectedBlock) {
|
||||
void ClientCommandHandler::sendPlayerDigBlock(const glm::ivec4 &selectedBlock) {
|
||||
sf::Packet packet;
|
||||
packet << Network::Command::PlayerDigBlock
|
||||
<< s32(selectedBlock.x)
|
||||
@ -72,7 +72,7 @@ void ClientCommandHandler::sendPlayerInventoryRequest() {
|
||||
m_client.send(packet);
|
||||
}
|
||||
|
||||
void ClientCommandHandler::sendBlockActivated(const glm::vec4 &selectedBlock) {
|
||||
void ClientCommandHandler::sendBlockActivated(const glm::ivec4 &selectedBlock) {
|
||||
sf::Packet packet;
|
||||
packet << Network::Command::BlockActivated
|
||||
<< s32(selectedBlock.x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user