diff --git a/code/Shape/Editor/EditorProfile.cpp b/code/Shape/Editor/EditorProfile.cpp index 87bce7a78f..9b031381c1 100644 --- a/code/Shape/Editor/EditorProfile.cpp +++ b/code/Shape/Editor/EditorProfile.cpp @@ -16,7 +16,7 @@ #include "Shape/Editor/Solid/SolidEditorPlugin.h" #include "Shape/Editor/Solid/SolidEntityEditorFactory.h" #include "Shape/Editor/Spline/ControlPointComponentEditorFactory.h" -#include "Shape/Editor/Spline/SplineEntityEditorFactory.h" +#include "Shape/Editor/Spline/SplineComponentEditorFactory.h" namespace traktor { @@ -96,7 +96,6 @@ void EditorProfile::createEntityEditorFactories( ) const { outEntityEditorFactories.push_back(new SolidEntityEditorFactory()); - outEntityEditorFactories.push_back(new SplineEntityEditorFactory()); } void EditorProfile::createComponentEditorFactories( @@ -105,6 +104,7 @@ void EditorProfile::createComponentEditorFactories( ) const { outComponentEditorFactories.push_back(new ControlPointComponentEditorFactory()); + outComponentEditorFactories.push_back(new SplineComponentEditorFactory()); } Ref< world::EntityData > EditorProfile::createEntityData( diff --git a/code/Shape/Editor/Spline/ControlPointComponentEditor.cpp b/code/Shape/Editor/Spline/ControlPointComponentEditor.cpp index 76d9669a27..4a0aeb3ba8 100644 --- a/code/Shape/Editor/Spline/ControlPointComponentEditor.cpp +++ b/code/Shape/Editor/Spline/ControlPointComponentEditor.cpp @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,10 +10,8 @@ #include "Scene/Editor/EntityAdapter.h" #include "Shape/Editor/Spline/ControlPointComponentEditor.h" -namespace traktor +namespace traktor::shape { - namespace shape - { T_IMPLEMENT_RTTI_CLASS(L"traktor.shape.ControlPointComponentEditor", ControlPointComponentEditor, scene::DefaultComponentEditor) @@ -24,19 +22,16 @@ ControlPointComponentEditor::ControlPointComponentEditor(scene::SceneEditorConte void ControlPointComponentEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer) const { - primitiveRenderer->pushDepthState(false, false, false); - - bool selected = m_entityAdapter->isSelected() || m_entityAdapter->getParent()->isSelected(); - + const bool selected = m_entityAdapter->isSelected() || m_entityAdapter->getParent()->isSelected(); const auto& T = m_entityAdapter->getTransform(); + + primitiveRenderer->pushDepthState(false, false, false); primitiveRenderer->drawSolidPoint( T.translation(), - 4.0f, + 8.0f, selected ? Color4ub(100, 100, 255, 220) : Color4ub(255, 255, 255, 100) ); - primitiveRenderer->popDepthState(); } - } } diff --git a/code/Shape/Editor/Spline/SplineEntityEditor.cpp b/code/Shape/Editor/Spline/SplineComponentEditor.cpp similarity index 60% rename from code/Shape/Editor/Spline/SplineEntityEditor.cpp rename to code/Shape/Editor/Spline/SplineComponentEditor.cpp index d2889b4264..4e971b95cd 100644 --- a/code/Shape/Editor/Spline/SplineEntityEditor.cpp +++ b/code/Shape/Editor/Spline/SplineComponentEditor.cpp @@ -9,28 +9,24 @@ #include "Render/PrimitiveRenderer.h" #include "Scene/Editor/EntityAdapter.h" #include "Shape/Editor/Spline/SplineComponent.h" -#include "Shape/Editor/Spline/SplineEntityEditor.h" +#include "Shape/Editor/Spline/SplineComponentEditor.h" -namespace traktor +namespace traktor::shape { - namespace shape - { -T_IMPLEMENT_RTTI_CLASS(L"traktor.shape.SplineEntityEditor", SplineEntityEditor, scene::DefaultEntityEditor) +T_IMPLEMENT_RTTI_CLASS(L"traktor.shape.SplineComponentEditor", SplineComponentEditor, scene::DefaultComponentEditor) -SplineEntityEditor::SplineEntityEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter) -: scene::DefaultEntityEditor(context, entityAdapter) +SplineComponentEditor::SplineComponentEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter, world::IEntityComponentData* componentData) +: scene::DefaultComponentEditor(context, entityAdapter, componentData) { } -void SplineEntityEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer) const +void SplineComponentEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer) const { - auto splineComponent = getEntityAdapter()->getComponent< SplineComponent >(); + auto splineComponent = m_entityAdapter->getComponent< SplineComponent >(); if (!splineComponent) return; - primitiveRenderer->pushDepthState(false, false, false); - const auto& path = splineComponent->getPath(); const auto& keys = path.keys(); if (keys.empty()) @@ -39,6 +35,8 @@ void SplineEntityEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer) const float st = path.getStartTime(); const float et = path.getEndTime(); + primitiveRenderer->pushDepthState(false, false, false); + const uint32_t nsteps = (uint32_t)keys.size() * 10; for (uint32_t i = 0; i < nsteps; ++i) { @@ -47,12 +45,11 @@ void SplineEntityEditor::drawGuide(render::PrimitiveRenderer* primitiveRenderer) primitiveRenderer->drawLine( path.evaluate(t1, true).position, path.evaluate(t2, true).position, - getEntityAdapter()->isSelected() ? Color4ub(100, 100, 255, 220) : Color4ub(255, 255, 255, 80) + m_entityAdapter->isSelected() ? Color4ub(100, 100, 255, 220) : Color4ub(255, 255, 255, 80) ); } primitiveRenderer->popDepthState(); } - } } diff --git a/code/Shape/Editor/Spline/SplineEntityEditor.h b/code/Shape/Editor/Spline/SplineComponentEditor.h similarity index 54% rename from code/Shape/Editor/Spline/SplineEntityEditor.h rename to code/Shape/Editor/Spline/SplineComponentEditor.h index da630069c0..f23ced7bfc 100644 --- a/code/Shape/Editor/Spline/SplineEntityEditor.h +++ b/code/Shape/Editor/Spline/SplineComponentEditor.h @@ -1,6 +1,6 @@ /* * TRAKTOR - * Copyright (c) 2022 Anders Pistol. + * Copyright (c) 2022-2024 Anders Pistol. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,25 +8,22 @@ */ #pragma once -#include "Scene/Editor/DefaultEntityEditor.h" +#include "Scene/Editor/DefaultComponentEditor.h" -namespace traktor +namespace traktor::shape { - namespace shape - { /*! * \ingroup Shape */ -class SplineEntityEditor : public scene::DefaultEntityEditor +class SplineComponentEditor : public scene::DefaultComponentEditor { T_RTTI_CLASS; public: - SplineEntityEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter); + explicit SplineComponentEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter, world::IEntityComponentData* componentData); virtual void drawGuide(render::PrimitiveRenderer* primitiveRenderer) const override final; }; - } } diff --git a/code/Shape/Editor/Spline/SplineComponentEditorFactory.cpp b/code/Shape/Editor/Spline/SplineComponentEditorFactory.cpp new file mode 100644 index 0000000000..d338f972da --- /dev/null +++ b/code/Shape/Editor/Spline/SplineComponentEditorFactory.cpp @@ -0,0 +1,33 @@ +/* + * TRAKTOR + * Copyright (c) 2022-2024 Anders Pistol. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#include "Shape/Editor/Spline/SplineComponentData.h" +#include "Shape/Editor/Spline/SplineComponentEditor.h" +#include "Shape/Editor/Spline/SplineComponentEditorFactory.h" + +namespace traktor::shape +{ + +T_IMPLEMENT_RTTI_CLASS(L"traktor.shape.SplineComponentEditorFactory", SplineComponentEditorFactory, scene::IComponentEditorFactory) + +const TypeInfoSet SplineComponentEditorFactory::getComponentDataTypes() const +{ + return makeTypeInfoSet< SplineComponentData >(); +} + +bool SplineComponentEditorFactory::alwaysRebuild(const world::IEntityComponentData* componentData) const +{ + return false; +} + +Ref< scene::IComponentEditor > SplineComponentEditorFactory::createComponentEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter, world::IEntityComponentData* componentData) const +{ + return new SplineComponentEditor(context, entityAdapter, componentData); +} + +} diff --git a/code/Shape/Editor/Spline/SplineComponentEditorFactory.h b/code/Shape/Editor/Spline/SplineComponentEditorFactory.h new file mode 100644 index 0000000000..2fbeea6c08 --- /dev/null +++ b/code/Shape/Editor/Spline/SplineComponentEditorFactory.h @@ -0,0 +1,31 @@ +/* + * TRAKTOR + * Copyright (c) 2022-2024 Anders Pistol. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include "Scene/Editor/IComponentEditorFactory.h" + +namespace traktor::shape +{ + +/*! + * \ingroup Shape + */ +class SplineComponentEditorFactory : public scene::IComponentEditorFactory +{ + T_RTTI_CLASS; + +public: + virtual const TypeInfoSet getComponentDataTypes() const override final; + + virtual bool alwaysRebuild(const world::IEntityComponentData* componentData) const override final; + + virtual Ref< scene::IComponentEditor > createComponentEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter, world::IEntityComponentData* componentData) const override final; +}; + +} diff --git a/code/Shape/Editor/Spline/SplineEntityEditorFactory.cpp b/code/Shape/Editor/Spline/SplineEntityEditorFactory.cpp deleted file mode 100644 index d65f40902f..0000000000 --- a/code/Shape/Editor/Spline/SplineEntityEditorFactory.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * TRAKTOR - * Copyright (c) 2022 Anders Pistol. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#include "Shape/Editor/Spline/SplineComponentData.h" -#include "Shape/Editor/Spline/SplineEntityEditor.h" -#include "Shape/Editor/Spline/SplineEntityEditorFactory.h" - -namespace traktor -{ - namespace shape - { - -T_IMPLEMENT_RTTI_CLASS(L"traktor.shape.SplineEntityEditorFactory", SplineEntityEditorFactory, scene::IEntityEditorFactory) - -const TypeInfoSet SplineEntityEditorFactory::getEntityDataTypes() const -{ - return makeTypeInfoSet< SplineComponentData >(); -} - -Ref< scene::IEntityEditor > SplineEntityEditorFactory::createEntityEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter) const -{ - return new SplineEntityEditor(context, entityAdapter); -} - - } -} diff --git a/code/Shape/Editor/Spline/SplineEntityEditorFactory.h b/code/Shape/Editor/Spline/SplineEntityEditorFactory.h deleted file mode 100644 index d88d74583c..0000000000 --- a/code/Shape/Editor/Spline/SplineEntityEditorFactory.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * TRAKTOR - * Copyright (c) 2022 Anders Pistol. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -#pragma once - -#include "Scene/Editor/IEntityEditorFactory.h" - -namespace traktor -{ - namespace shape - { - -/*! - * \ingroup Shape - */ -class SplineEntityEditorFactory : public scene::IEntityEditorFactory -{ - T_RTTI_CLASS; - -public: - virtual const TypeInfoSet getEntityDataTypes() const override final; - - virtual Ref< scene::IEntityEditor > createEntityEditor(scene::SceneEditorContext* context, scene::EntityAdapter* entityAdapter) const override final; -}; - - } -}