Skip to content

Commit

Permalink
Traktor: Some cleanup in Spray editor module.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed May 10, 2024
1 parent 447a0ab commit ed5d1f3
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 142 deletions.
9 changes: 3 additions & 6 deletions code/Spray/Editor/BoxSourceRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/*
* 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
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "Render/PrimitiveRenderer.h"
#include "Spray/Editor/BoxSourceRenderer.h"
#include "Spray/Sources/BoxSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.BoxSourceRenderer", BoxSourceRenderer, SourceRenderer)

Expand All @@ -23,5 +21,4 @@ void BoxSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, con
primitiveRenderer->drawWireAabb(boxSource->m_position, boxSource->m_extent, 1.0f, Color4ub(255, 255, 0));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/BoxSourceRenderer.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,10 +10,8 @@

#include "Spray/Editor/SourceRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

class BoxSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class BoxSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/ClipboardData.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,10 +11,8 @@
#include "Spray/EffectLayerData.h"
#include "Spray/Editor/ClipboardData.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_FACTORY_CLASS(L"traktor.spray.ClipboardData", 0, ClipboardData, ISerializable)

Expand All @@ -33,5 +31,4 @@ void ClipboardData::serialize(ISerializer& s)
s >> MemberRefArray< const EffectLayerData >(L"layers", m_layers);
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/ClipboardData.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,10 +11,8 @@
#include "Core/RefArray.h"
#include "Core/Serialization/ISerializable.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

class EffectLayerData;

Expand All @@ -33,6 +31,4 @@ class ClipboardData : public ISerializable
RefArray< const EffectLayerData > m_layers;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/ConeSourceRenderer.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,10 +10,8 @@
#include "Spray/Sources/ConeSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.ConeSourceRenderer", ConeSourceRenderer, SourceRenderer)

Expand All @@ -31,5 +29,4 @@ void ConeSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, co
primitiveRenderer->drawLine(coneSource->m_position, coneSource->m_position + coneSource->m_normal, Color4ub(255, 255, 0));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/ConeSourceRenderer.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,10 +10,8 @@

#include "Spray/Editor/SourceRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

class ConeSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class ConeSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

31 changes: 14 additions & 17 deletions code/Spray/Editor/DiscSourceRenderer.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,36 +11,34 @@
#include "Spray/Sources/DiscSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.DiscSourceRenderer", DiscSourceRenderer, SourceRenderer)

void DiscSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const
{
const DiscSourceData* discSource = checked_type_cast< const DiscSourceData* >(sourceData);

Vector4 position = discSource->m_position;
Vector4 normal = discSource->m_normal;
Scalar minRadius = Scalar(discSource->m_radius.min);
Scalar maxRadius = Scalar(discSource->m_radius.max);
const Vector4 position = discSource->m_position;
const Vector4 normal = discSource->m_normal;
const Scalar minRadius = Scalar(discSource->m_radius.min);
const Scalar maxRadius = Scalar(discSource->m_radius.max);

const Vector4 c_axisZ(0.0f, 0.0f, 1.0f, 0.0f);

Vector4 axisX = cross(normal, c_axisZ).normalized();
Vector4 axisZ = cross(axisX, normal).normalized();
const Vector4 axisX = cross(normal, c_axisZ).normalized();
const Vector4 axisZ = cross(axisX, normal).normalized();

for (int i = 0; i < 20; ++i)
{
float a1 = float(i / 20.0f) * PI * 2.0f;
float a2 = float((i + 1) / 20.0f) * PI * 2.0f;
float s1 = sinf(a1), s2 = sinf(a2);
float c1 = cosf(a1), c2 = cosf(a2);
const float a1 = float(i / 20.0f) * PI * 2.0f;
const float a2 = float((i + 1) / 20.0f) * PI * 2.0f;
const float s1 = sinf(a1), s2 = sinf(a2);
const float c1 = cosf(a1), c2 = cosf(a2);

Vector4 d1 = Scalar(c1) * axisZ + Scalar(s1) * axisX;
Vector4 d2 = Scalar(c2) * axisZ + Scalar(s2) * axisX;
const Vector4 d1 = Scalar(c1) * axisZ + Scalar(s1) * axisX;
const Vector4 d2 = Scalar(c2) * axisZ + Scalar(s2) * axisX;

primitiveRenderer->drawLine(position + d1 * minRadius, position + d2 * minRadius, Color4ub(255, 255, 0));
primitiveRenderer->drawLine(position + d1 * maxRadius, position + d2 * maxRadius, Color4ub(255, 255, 0));
Expand All @@ -49,5 +47,4 @@ void DiscSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, co
primitiveRenderer->drawLine(position, position + normal, Color4ub(255, 255, 0));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/DiscSourceRenderer.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,10 +10,8 @@

#include "Spray/Editor/SourceRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

class DiscSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class DiscSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

11 changes: 4 additions & 7 deletions code/Spray/Editor/EffectEditorPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,17 @@
#include "Resources/ToggleGuideLines.h"
#include "Resources/ToggleMoveEmitter.h"

namespace traktor
namespace traktor::spray
{
namespace spray
namespace
{
namespace
{

class SequenceDataKey : public Object
{
T_RTTI_CLASS;

public:
SequenceDataKey(SequenceData* sequenceData, int32_t key)
explicit SequenceDataKey(SequenceData* sequenceData, int32_t key)
: m_sequenceData(sequenceData)
, m_key(key)
{
Expand All @@ -112,7 +110,7 @@ class SequenceDataKey : public Object

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.SequenceDataKey", SequenceDataKey, Object)

}
}

T_IMPLEMENT_RTTI_CLASS(L"traktor.spray.EffectEditorPage", EffectEditorPage, editor::IEditorPage)

Expand Down Expand Up @@ -721,5 +719,4 @@ void EffectEditorPage::eventPropertiesChanged(ui::ContentChangeEvent* event)
updateEffectPreview();
}

}
}
34 changes: 15 additions & 19 deletions code/Spray/Editor/EffectEditorPage.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,20 +19,18 @@
# define T_DLLCLASS T_DLLIMPORT
#endif

namespace traktor
namespace traktor::editor
{
namespace editor
{

class IEditor;
class IEditorPageSite;
class IDocument;
class PropertiesView;

}
}

namespace ui
{
namespace traktor::ui
{

class Container;
class ContentChangeEvent;
Expand All @@ -47,24 +45,24 @@ class ToolBar;
class ToolBarButton;
class ToolBarButtonClickEvent;

}
}

namespace resource
{
namespace traktor::resource
{

class IResourceManager;

}
}

namespace sound
{
namespace traktor::sound
{

class AudioSystem;

}
}

namespace spray
{
namespace traktor::spray
{

class EffectData;
class EffectPreviewControl;
Expand All @@ -74,7 +72,7 @@ class T_DLLCLASS EffectEditorPage : public editor::IEditorPage
T_RTTI_CLASS;

public:
EffectEditorPage(editor::IEditor* editor, editor::IEditorPageSite* site, editor::IDocument* document);
explicit EffectEditorPage(editor::IEditor* editor, editor::IEditorPageSite* site, editor::IDocument* document);

virtual bool create(ui::Container* parent) override final;

Expand Down Expand Up @@ -131,6 +129,4 @@ class T_DLLCLASS EffectEditorPage : public editor::IEditorPage
void eventPropertiesChanged(ui::ContentChangeEvent* event);
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/EffectEditorPageFactory.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,10 +12,8 @@
#include "Spray/Editor/EffectEditorPageFactory.h"
#include "Ui/Command.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_FACTORY_CLASS(L"traktor.spray.EffectEditorPageFactory", 0, EffectEditorPageFactory, editor::IEditorPageFactory)

Expand Down Expand Up @@ -59,5 +57,4 @@ Ref< ISerializable > EffectEditorPageFactory::cloneAsset(const ISerializable* as
return DeepClone(asset).create();
}

}
}
Loading

0 comments on commit ed5d1f3

Please sign in to comment.