Skip to content

Commit

Permalink
Traktor: Reduced default height of scene controller editor. Removed H…
Browse files Browse the repository at this point in the history
…iZ debug drawing code.
  • Loading branch information
apistol78 committed Apr 23, 2024
1 parent f5a12bb commit c0d1c53
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 64 deletions.
126 changes: 63 additions & 63 deletions code/Scene/Editor/DefaultEntityEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,69 +244,69 @@ void DefaultEntityEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer
primitiveRenderer->drawWireAabb(boundingBox, 1.0f, m_colorBoundingBox);
primitiveRenderer->popWorld();

if (m_entityAdapter->isSelected())
{
Vector4 center = (boundingBox.mn + boundingBox.mx) / 2.0_simd;
//Scalar radius = ((boundingBox.mx - boundingBox.mn) / 2.0_simd).length();

Scalar radius = max(boundingBox.mx.length(), boundingBox.mn.length());

Vector4 worldCenter = transform.translation() + center;
Vector4 viewCenter = primitiveRenderer->getView() * worldCenter.xyz1();

Scalar znear = 0.1_simd;
Scalar P00 = primitiveRenderer->getProjection().get(0, 0);
Scalar P11 = primitiveRenderer->getProjection().get(1, 1);

Vector4 aabb;
if (projectSphere(viewCenter, radius, znear, P00, P11, aabb))
{
Matrix44 proj = primitiveRenderer->getProjection();

primitiveRenderer->pushWorld(Matrix44::identity());
primitiveRenderer->pushView(Matrix44::identity());

// Setup projection as UV space.
primitiveRenderer->setProjection(orthoLh(
-1.0f, 1.0f,
1.0f, -1.0f,
-1.0f, 1.0f
) * translate(-1.0f, -1.0f, 0.0f) * scale(2.0f, 2.0f, 1.0f));

const float w = (aabb.z() - aabb.x()) * clientSize.cx;
const float h = (aabb.w() - aabb.y()) * clientSize.cy;

const int32_t level = int32_t(std::floor(std::log2(std::max(w, h))));
const float step = 4096.0f / std::max(4096 >> level, 1);
for (float y = 0.0f; y < clientSize.cy; y += step)
{
const float fy = float(y) / clientSize.cy;
primitiveRenderer->drawLine(
Vector4(0.0f, fy, 0.0f, 1.0f),
Vector4(1.0f, fy, 0.0f, 1.0f),
Color4ub(255, 255, 0, 120)
);
}
for (float x = 0.0f; x < clientSize.cx; x += step)
{
const float fx = float(x) / clientSize.cx;
primitiveRenderer->drawLine(
Vector4(fx, 0.0f, 0.0f, 1.0f),
Vector4(fx, 1.0f, 0.0f, 1.0f),
Color4ub(255, 255, 0, 120)
);
}

primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.y(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.w(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.x(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
primitiveRenderer->drawLine(Vector4(aabb.z(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));

primitiveRenderer->setProjection(proj);
primitiveRenderer->popView();
primitiveRenderer->popWorld();
}
}
// if (m_entityAdapter->isSelected())
// {
// Vector4 center = (boundingBox.mn + boundingBox.mx) / 2.0_simd;
// //Scalar radius = ((boundingBox.mx - boundingBox.mn) / 2.0_simd).length();

// Scalar radius = max(boundingBox.mx.length(), boundingBox.mn.length());

// Vector4 worldCenter = transform.translation() + center;
// Vector4 viewCenter = primitiveRenderer->getView() * worldCenter.xyz1();

// Scalar znear = 0.1_simd;
// Scalar P00 = primitiveRenderer->getProjection().get(0, 0);
// Scalar P11 = primitiveRenderer->getProjection().get(1, 1);

// Vector4 aabb;
// if (projectSphere(viewCenter, radius, znear, P00, P11, aabb))
// {
// Matrix44 proj = primitiveRenderer->getProjection();

// primitiveRenderer->pushWorld(Matrix44::identity());
// primitiveRenderer->pushView(Matrix44::identity());

// // Setup projection as UV space.
// primitiveRenderer->setProjection(orthoLh(
// -1.0f, 1.0f,
// 1.0f, -1.0f,
// -1.0f, 1.0f
// ) * translate(-1.0f, -1.0f, 0.0f) * scale(2.0f, 2.0f, 1.0f));

// const float w = (aabb.z() - aabb.x()) * clientSize.cx;
// const float h = (aabb.w() - aabb.y()) * clientSize.cy;

// const int32_t level = int32_t(std::floor(std::log2(std::max(w, h))));
// const float step = 4096.0f / std::max(4096 >> level, 1);
// for (float y = 0.0f; y < clientSize.cy; y += step)
// {
// const float fy = float(y) / clientSize.cy;
// primitiveRenderer->drawLine(
// Vector4(0.0f, fy, 0.0f, 1.0f),
// Vector4(1.0f, fy, 0.0f, 1.0f),
// Color4ub(255, 255, 0, 120)
// );
// }
// for (float x = 0.0f; x < clientSize.cx; x += step)
// {
// const float fx = float(x) / clientSize.cx;
// primitiveRenderer->drawLine(
// Vector4(fx, 0.0f, 0.0f, 1.0f),
// Vector4(fx, 1.0f, 0.0f, 1.0f),
// Color4ub(255, 255, 0, 120)
// );
// }

// primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.y(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
// primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.w(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
// primitiveRenderer->drawLine(Vector4(aabb.x(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.x(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));
// primitiveRenderer->drawLine(Vector4(aabb.z(), aabb.y(), 0.0f, 1.0f), Vector4(aabb.z(), aabb.w(), 0.0f, 1.0f), Color4ub(255, 0, 0, 255));

// primitiveRenderer->setProjection(proj);
// primitiveRenderer->popView();
// primitiveRenderer->popWorld();
// }
// }

if (m_entityAdapter->isSelected() && m_context->getSnapMode() == SceneEditorContext::SmNeighbour)
{
Expand Down
2 changes: 1 addition & 1 deletion code/Scene/Editor/SceneEditorPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ bool SceneEditorPage::create(ui::Container* parent)
m_controllerPanel->create(parent, ui::WsNone, new ui::FloodLayout());
m_controllerPanel->setText(i18n::Text(L"SCENE_EDITOR_CONTROLLER"));

m_site->createAdditionalPanel(m_controllerPanel, 280_ut, true);
m_site->createAdditionalPanel(m_controllerPanel, 140_ut, true);

// Create the scene, loads textures etc, using a background job since it might take significant amount of time.
Ref< Job > job = JobManager::getInstance().add([&]() {
Expand Down

0 comments on commit c0d1c53

Please sign in to comment.