Skip to content

Commit

Permalink
Tried to fix ANGLES in GOTO
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Dec 10, 2023
1 parent 783cef3 commit 898e678
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cfg/language.ini
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ LANG_0363 = Model {}: swap mins/maxs\n
LANG_0364 = Fix texture data buffer overrun in {} texture. {} data size to {}.\n
LANG_0365 = Found unnamed texture in face {}. Replaced by aaatrigger.\n
LANG_0366 = Origin: {} {} {}
LANG_0367 = Angles: {} {} {}
LANG_0367 = GL Angles: {} {} {}
LANG_0368 = Selected faces: {}
LANG_0369 = PickMode: {}
LANG_0370 = Name: {}
Expand Down Expand Up @@ -679,7 +679,7 @@ LANG_0677 = Coordinates
LANG_0678 = ##xpos
LANG_0679 = ##ypos
LANG_0680 = ##zpos
LANG_0681 = Angles
LANG_0681 = HL Angles
LANG_0682 = ##xangles
LANG_0683 = ##yangles
LANG_0684 = ##zangles
Expand Down
2 changes: 2 additions & 0 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ void Bsp::get_bounding_box(vec3& mins, vec3& maxs)

void Bsp::get_model_vertex_bounds(int modelIdx, vec3& mins, vec3& maxs)
{
if (modelIdx < 0)
return;
mins = vec3(FLT_MAX_COORD, FLT_MAX_COORD, FLT_MAX_COORD);
maxs = vec3(-FLT_MAX_COORD, -FLT_MAX_COORD, -FLT_MAX_COORD);

Expand Down
8 changes: 2 additions & 6 deletions src/editor/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ BspRenderer::BspRenderer(Bsp* _map, PointEntRenderer* _pointEntRenderer)
this->renderClipnodes = NULL;

renderCameraOrigin = renderCameraAngles = vec3();

renderCameraAngles.flip();
renderCameraAngles.z += 90.0f;
// Setup Deafult Camera

if (g_settings.start_at_entity)
Expand Down Expand Up @@ -105,14 +106,9 @@ BspRenderer::BspRenderer(Bsp* _map, PointEntRenderer* _pointEntRenderer)
}
}



renderCameraAngles = renderCameraAngles.flip();

renderCameraAngles.z = renderCameraAngles.z + 90.0f;

renderCameraAngles = renderCameraAngles.normalize_angles();

}


Expand Down
27 changes: 18 additions & 9 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4645,6 +4645,11 @@ void Gui::drawGOTOWidget()
entid = g_app->pickInfo.GetSelectedEnt();
coordinates = cameraOrigin;
angles = cameraAngles;
angles.normalize_angles();
angles.z -= 90.0f;
angles.y = angles.z;
angles.y = 0.0f;
angles.unflip();
showGOTOWidget_update = false;
}
ImGui::Text(get_localized_string(LANG_0677).c_str());
Expand All @@ -4657,13 +4662,11 @@ void Gui::drawGOTOWidget()
ImGui::PopItemWidth();
ImGui::Text(get_localized_string(LANG_0681).c_str());
ImGui::PushItemWidth(inputWidth);
ImGui::DragFloat(get_localized_string(LANG_0683).c_str(), &angles.x, 0.1f, 0, 0, "X: %.0f");
ImGui::DragFloat(get_localized_string(LANG_0683).c_str(), &angles.x, 0.1f, 0, 0, "PITCH: %.0f");
ImGui::SameLine();
ImGui::BeginDisabled();
ImGui::DragFloat(get_localized_string(LANG_0682).c_str(), &angles_y, 0.0f, 0, 0, "Z: %.0f");
ImGui::EndDisabled();
ImGui::DragFloat(get_localized_string(LANG_0682).c_str(), &angles.z, 0.1f, 0, 0, "YAW: %.0f");
ImGui::SameLine();
ImGui::DragFloat(get_localized_string(LANG_0684).c_str(), &angles.z, 0.1f, 0, 0, "Y: %.0f");
ImGui::DragFloat(get_localized_string(LANG_0684).c_str(), &angles.y, 0.1f, 0, 0, "ROLL: %.0f");
ImGui::PopItemWidth();

Bsp* map = app->getSelectedMap();
Expand All @@ -4673,11 +4676,17 @@ void Gui::drawGOTOWidget()
if (ImGui::Button("Go to"))
{
cameraOrigin = coordinates;
cameraAngles = angles;
map->getBspRender()->renderCameraAngles = cameraAngles;
map->getBspRender()->renderCameraOrigin = cameraOrigin;
//cameraAngles.z += 90.0f;
makeVectors(angles, app->cameraForward, app->cameraRight, app->cameraUp);



cameraAngles = angles.flip();
cameraAngles.z = cameraAngles.y + 90.0f;
cameraAngles.y = 0.0f;
cameraAngles = cameraAngles.normalize_angles();
map->getBspRender()->renderCameraAngles = cameraAngles;

makeVectors(cameraAngles, app->cameraForward, app->cameraRight, app->cameraUp);
}
ImGui::PopStyleColor(3);
if (map && !map->is_mdl_model)
Expand Down
13 changes: 3 additions & 10 deletions src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,12 @@ void Renderer::renderLoop()
}


colorShader->bind();
if (SelectedMap)
{
if (debugClipnodes && modelIdx > 0)
{
colorShader->bind();
matmodel.loadIdentity();
colorShader->pushMatrix(MAT_MODEL);
vec3 offset = (SelectedMap->getBspRender()->mapOffset + (entIdx > 0 ? SelectedMap->ents[entIdx]->getOrigin() : vec3())).flip();
matmodel.translate(offset.x, offset.y, offset.z);
colorShader->updateMatrixes();
Expand All @@ -544,14 +543,11 @@ void Renderer::renderLoop()
drawClipnodes(SelectedMap, pickModel.iHeadnodes[1], currentPlane, debugInt, pickModel.vOrigin);
glEnable(GL_CULL_FACE);
debugIntMax = currentPlane - 1;
colorShader->popMatrix(MAT_MODEL);
}

if (debugNodes && modelIdx > 0)
{
colorShader->bind();
matmodel.loadIdentity();
colorShader->pushMatrix(MAT_MODEL);
vec3 offset = (SelectedMap->getBspRender()->mapOffset + (entIdx > 0 ? SelectedMap->ents[entIdx]->getOrigin() : vec3())).flip();
matmodel.translate(offset.x, offset.y, offset.z);
colorShader->updateMatrixes();
Expand All @@ -561,14 +557,11 @@ void Renderer::renderLoop()
drawNodes(SelectedMap, pickModel.iHeadnodes[0], currentPlane, debugNode, pickModel.vOrigin);
glEnable(GL_CULL_FACE);
debugNodeMax = currentPlane - 1;
colorShader->popMatrix(MAT_MODEL);
}

if (g_render_flags & RENDER_ORIGIN)
{
colorShader->bind();
matmodel.loadIdentity();
colorShader->pushMatrix(MAT_MODEL);
vec3 offset = SelectedMap->getBspRender()->mapOffset.flip();
matmodel.translate(offset.x, offset.y, offset.z);
colorShader->updateMatrixes();
Expand All @@ -581,7 +574,6 @@ void Renderer::renderLoop()
p1 = debugPoint - vec3(0.0f, 0.0f, 32.0f);
p2 = debugPoint + vec3(0.0f, 0.0f, 32.0f);
drawLine(p1, p2, { 0, 0, 255, 255 });
colorShader->popMatrix(MAT_MODEL);
}
}

Expand Down Expand Up @@ -969,6 +961,7 @@ void Renderer::drawTransformAxes()
{
if (SelectedMap->ents[pickInfo.selectedEnts[0]]->getBspModelIdx() > 0)
{
matmodel.loadIdentity();
glDepthMask(GL_FALSE);
glDepthFunc(GL_ALWAYS);
updateDragAxes();
Expand All @@ -986,6 +979,7 @@ void Renderer::drawTransformAxes()
{
if (transformTarget != TRANSFORM_VERTEX || (anyVertSelected || anyEdgeSelected))
{
matmodel.loadIdentity();
glDepthMask(GL_FALSE);
glDepthFunc(GL_ALWAYS);
updateDragAxes();
Expand Down Expand Up @@ -2322,7 +2316,6 @@ void Renderer::updateDragAxes(vec3 delta)
{
if (ent && ent->isBspModel())
{

map->get_model_vertex_bounds(ent->getBspModelIdx(), entMin, entMax);
vec3 modelOrigin = entMin + (entMax - entMin) * 0.5f;

Expand Down
9 changes: 9 additions & 0 deletions src/util/vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ vec3 vec3::flipUV()
return vec3(x, -z, y);
}

vec3 vec3::unflip()
{
return vec3(x, -z, y);
}

vec3 vec3::unflipUV()
{
return vec3(x, z, -y);
}

bool operator==(const vec2& v1, const vec2& v2)
{
Expand Down
2 changes: 2 additions & 0 deletions src/util/vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ struct vec3
std::string toString();
vec3 flip(); // flip from opengl to Half-life coordinate system and vice versa
vec3 flipUV(); // flip from opengl to Half-life coordinate system and vice versa
vec3 unflip();
vec3 unflipUV();

void operator-=(const vec3& v);
void operator+=(const vec3& v);
Expand Down

0 comments on commit 898e678

Please sign in to comment.