Merge branch 'master' of https://gitlab.com/prophecy-rp/noggit-red
This commit is contained in:
@@ -27,3 +27,7 @@ build:
|
||||
# cache:
|
||||
# paths:
|
||||
# - "*.o"
|
||||
only:
|
||||
- web
|
||||
allow_failure: false
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ float contour_alpha(float unit_size, vec2 pos, vec2 line_width)
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
float dist_from_camera = distance(camera, vary_position);
|
||||
|
||||
vec3 fw = fwidth(vary_position.xyz);
|
||||
|
||||
@@ -36,16 +36,74 @@ out vec3 vary_normal;
|
||||
out vec3 vary_mccv;
|
||||
flat out int instanceID;
|
||||
|
||||
bool isHoleVertex(uint vertexId, uint hole)
|
||||
{
|
||||
if (hole == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint blockRow = vertexId / 34;
|
||||
uint blockVertexId = vertexId % 34;
|
||||
uint shiftedHole = hole >> (blockRow * 4);
|
||||
|
||||
|
||||
if ((shiftedHole & 0x1u) != 0)
|
||||
{
|
||||
if (blockVertexId == 9 || blockVertexId == 10 || blockVertexId == 26 || blockVertexId == 27)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((shiftedHole & 0x2u) != 0)
|
||||
{
|
||||
if (blockVertexId == 11 || blockVertexId == 12 || blockVertexId == 28 || blockVertexId == 29)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((shiftedHole & 0x4u) != 0)
|
||||
{
|
||||
if (blockVertexId == 13 || blockVertexId == 14 || blockVertexId == 30 || blockVertexId == 31)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((shiftedHole & 0x8u) != 0)
|
||||
{
|
||||
if (blockVertexId == 15 || blockVertexId == 16 || blockVertexId == 32 || blockVertexId == 33)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float makeNaN(float nonneg)
|
||||
{
|
||||
return sqrt(-nonneg-1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 normal_pos = texelFetch(heightmap, ivec2(gl_VertexID, gl_InstanceID), 0);
|
||||
vec3 pos_base = instances[gl_InstanceID].ChunkXYZBase_Pad1.xyz;
|
||||
vec3 pos = vec3(position.x + pos_base.x, pos_base.y + normal_pos.a, position.y + pos_base.z);
|
||||
|
||||
gl_Position = projection * model_view * vec4(pos, 1.0);
|
||||
bool is_hole = isHoleVertex(gl_VertexID, instances[gl_InstanceID].ChunkHoles_DrawImpass_TexLayerCount_CantPaint.r);
|
||||
|
||||
float NaN = makeNaN(1);
|
||||
|
||||
gl_Position = projection * model_view * (is_hole ? vec4(NaN, NaN, NaN, 1.0) : vec4(pos, 1.0));
|
||||
|
||||
vary_normal = normal_pos.rgb;
|
||||
vary_position = pos;
|
||||
vary_texcoord = texcoord;
|
||||
vary_mccv = texelFetch(mccv, ivec2(gl_VertexID, gl_InstanceID), 0).rgb;
|
||||
instanceID = gl_InstanceID;
|
||||
|
||||
}
|
||||
|
||||
@@ -630,6 +630,28 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
|
||||
static constexpr std::array idiff{-9, -8, 9, 8};
|
||||
|
||||
float vertex_x = mVertices[i].x + xdiff[dir];
|
||||
float vertex_z = mVertices[i].z + zdiff[dir];
|
||||
|
||||
tile_index tile({vertex_x, 0, vertex_z});
|
||||
math::vector_3d result{};
|
||||
|
||||
if (tile.x == mt->index.x && tile.z == mt->index.z)
|
||||
{
|
||||
mt->getVertexInternal(vertex_x, vertex_z, &result);
|
||||
}
|
||||
else if (mt->_world->mapIndex.tileLoaded(tile))
|
||||
{
|
||||
mt->_world->mapIndex.getTile(tile)->getVertexInternal(vertex_x, vertex_z, &result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = {vertex_x, mVertices[i].y, vertex_z};
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
/*
|
||||
if ((i >= 1 && i <= 7 && dir < 2 && !py)
|
||||
|| (i >= 137 && i <= 143 && (dir == 2 || dir == 3) && py == 15)
|
||||
|| (!i && (dir < 2 && !py || (!dir || dir == 3) && !px))
|
||||
@@ -718,6 +740,8 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
|
||||
}
|
||||
|
||||
return mVertices[i + idiff[dir]];
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void MapChunk::recalcNorms()
|
||||
|
||||
@@ -3884,47 +3884,53 @@ void MapView::update_cursor_pos()
|
||||
{
|
||||
static bool buffer_switch = false;
|
||||
|
||||
float mx = _last_mouse_pos.x(), mz = _last_mouse_pos.y();
|
||||
|
||||
//gl.readBuffer(GL_FRONT);
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, _buffers[static_cast<unsigned>(buffer_switch)]);
|
||||
|
||||
gl.readPixels(mx, height() - mz - 1, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, _buffers[static_cast<unsigned>(!buffer_switch)]);
|
||||
GLushort* ptr = static_cast<GLushort*>(gl.mapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
|
||||
|
||||
buffer_switch = !buffer_switch;
|
||||
|
||||
if(ptr)
|
||||
if (terrainMode != editing_mode::holes)
|
||||
{
|
||||
glm::vec4 viewport = glm::vec4(0, 0, width(), height());
|
||||
glm::vec3 wincoord = glm::vec3(mx, height() - mz - 1, static_cast<float>(*ptr) / std::numeric_limits<unsigned short>::max());
|
||||
float mx = _last_mouse_pos.x(), mz = _last_mouse_pos.y();
|
||||
|
||||
math::matrix_4x4 model_view_ = model_view().transposed();
|
||||
math::matrix_4x4 projection_ = projection().transposed();
|
||||
//gl.readBuffer(GL_FRONT);
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, _buffers[static_cast<unsigned>(buffer_switch)]);
|
||||
|
||||
glm::vec3 objcoord = glm::unProject(wincoord, glm::make_mat4(reinterpret_cast<float*>(&model_view_)),
|
||||
glm::make_mat4(reinterpret_cast<float*>(&projection_)), viewport);
|
||||
gl.readPixels(mx, height() - mz - 1, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0);
|
||||
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, _buffers[static_cast<unsigned>(!buffer_switch)]);
|
||||
GLushort* ptr = static_cast<GLushort*>(gl.mapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY));
|
||||
|
||||
tile_index tile({objcoord.x, objcoord.y, objcoord.z});
|
||||
buffer_switch = !buffer_switch;
|
||||
|
||||
if (!_world->mapIndex.tileLoaded(tile))
|
||||
if(ptr)
|
||||
{
|
||||
glm::vec4 viewport = glm::vec4(0, 0, width(), height());
|
||||
glm::vec3 wincoord = glm::vec3(mx, height() - mz - 1, static_cast<float>(*ptr) / std::numeric_limits<unsigned short>::max());
|
||||
|
||||
math::matrix_4x4 model_view_ = model_view().transposed();
|
||||
math::matrix_4x4 projection_ = projection().transposed();
|
||||
|
||||
glm::vec3 objcoord = glm::unProject(wincoord, glm::make_mat4(reinterpret_cast<float*>(&model_view_)),
|
||||
glm::make_mat4(reinterpret_cast<float*>(&projection_)), viewport);
|
||||
|
||||
|
||||
tile_index tile({objcoord.x, objcoord.y, objcoord.z});
|
||||
|
||||
if (!_world->mapIndex.tileLoaded(tile))
|
||||
{
|
||||
gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
_cursor_pos = {objcoord.x, objcoord.y, objcoord.z};
|
||||
|
||||
gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
_cursor_pos = {objcoord.x, objcoord.y, objcoord.z};
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
|
||||
gl.unmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
return;
|
||||
}
|
||||
|
||||
gl.bindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
// use raycasting for holes
|
||||
|
||||
return;
|
||||
selection_result results (intersect_result (true));
|
||||
|
||||
if (!results.empty())
|
||||
|
||||
Reference in New Issue
Block a user