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 Apr 15, 2024
1 parent e6205d3 commit ec8a9ed
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 124 deletions.
17 changes: 7 additions & 10 deletions code/Spray/Editor/LineSourceRenderer.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,32 +10,29 @@
#include "Spray/Sources/LineSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

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

void LineSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const
{
const LineSourceData* lineSource = checked_type_cast< const LineSourceData* >(sourceData);

Vector4 startPosition = lineSource->m_startPosition;
Vector4 endPosition = lineSource->m_endPosition;
const Vector4 startPosition = lineSource->m_startPosition;
const Vector4 endPosition = lineSource->m_endPosition;

primitiveRenderer->drawLine(startPosition, endPosition, 1.0f, Color4ub(255, 255, 0));

int32_t npoints = 2 + lineSource->m_segments;
const int32_t npoints = 2 + lineSource->m_segments;
for (int32_t i = 0; i < npoints; ++i)
{
float k = float(i) / (npoints - 1);
Vector4 position = lerp(startPosition, endPosition, Scalar(k));
const float k = float(i) / (npoints - 1);
const Vector4 position = lerp(startPosition, endPosition, Scalar(k));

const Vector4 c_size(0.1f, 0.1f, 0.1f, 0.0f);
primitiveRenderer->drawWireAabb(Aabb3(position - c_size, position + c_size), 1.0f, Color4ub(255, 255, 0));
}
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/LineSourceRenderer.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 LineSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class LineSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

12 changes: 2 additions & 10 deletions code/Spray/Editor/PointSetAsset.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,18 +10,11 @@
#include "Core/Serialization/Member.h"
#include "Spray/Editor/PointSetAsset.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_EDIT_CLASS(L"traktor.spray.PointSetAsset", 0, PointSetAsset, editor::Asset)

PointSetAsset::PointSetAsset()
: m_fromFaces(false)
{
}

bool PointSetAsset::fromFaces() const
{
return m_fromFaces;
Expand All @@ -33,5 +26,4 @@ void PointSetAsset::serialize(ISerializer& s)
s >> Member< bool >(L"fromFaces", m_fromFaces);
}

}
}
12 changes: 3 additions & 9 deletions code/Spray/Editor/PointSetAsset.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 @@ -18,26 +18,20 @@
# define T_DLLCLASS T_DLLIMPORT
#endif

namespace traktor
namespace traktor::spray
{
namespace spray
{

class T_DLLCLASS PointSetAsset : public editor::Asset
{
T_RTTI_CLASS;

public:
PointSetAsset();

bool fromFaces() const;

virtual void serialize(ISerializer& s) override final;

private:
bool m_fromFaces;
bool m_fromFaces = false;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/PointSetPipeline.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 @@ -21,10 +21,8 @@
#include "Spray/Editor/PointSetAsset.h"
#include "Spray/Editor/PointSetPipeline.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

T_IMPLEMENT_RTTI_FACTORY_CLASS(L"traktor.spray.PointSetPipeline", 4, PointSetPipeline, editor::IPipeline)

Expand Down Expand Up @@ -178,5 +176,4 @@ Ref< ISerializable > PointSetPipeline::buildProduct(
return nullptr;
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/PointSetPipeline.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 @@ -18,10 +18,8 @@
# define T_DLLCLASS T_DLLIMPORT
#endif

namespace traktor
namespace traktor::spray
{
namespace spray
{

class T_DLLCLASS PointSetPipeline : public editor::IPipeline
{
Expand Down Expand Up @@ -69,6 +67,4 @@ class T_DLLCLASS PointSetPipeline : public editor::IPipeline
std::wstring m_assetPath;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/PointSetSourceRenderer.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/Sources/PointSetSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

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

Expand All @@ -31,5 +29,4 @@ void PointSetSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer
// primitiveRenderer->drawSolidPoint(i->position + pointSetSource->getOffset(), 3.0f, Color4ub(255, 255, 0));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/PointSetSourceRenderer.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 PointSetSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class PointSetSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/PointSourceRenderer.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/PointSourceData.h"
#include "Render/PrimitiveRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

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

Expand All @@ -23,5 +21,4 @@ void PointSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, c
primitiveRenderer->drawSolidPoint(pointSource->m_position, 8.0f, Color4ub(255, 255, 0, 180));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/PointSourceRenderer.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 PointSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class PointSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

17 changes: 7 additions & 10 deletions code/Spray/Editor/QuadSourceRenderer.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,23 +10,21 @@
#include "Spray/Editor/QuadSourceRenderer.h"
#include "Spray/Sources/QuadSourceData.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

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

void QuadSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const
{
const QuadSourceData* quadSource = checked_type_cast< const QuadSourceData* >(sourceData);

Vector4 center = quadSource->m_center;
Vector4 axis1 = quadSource->m_axis1;
Vector4 axis2 = quadSource->m_axis2;
Vector4 normal = quadSource->m_normal;
const Vector4 center = quadSource->m_center;
const Vector4 axis1 = quadSource->m_axis1;
const Vector4 axis2 = quadSource->m_axis2;
const Vector4 normal = quadSource->m_normal;

Vector4 corners[] =
const Vector4 corners[] =
{
center - axis1 - axis2,
center + axis1 - axis2,
Expand All @@ -43,5 +41,4 @@ void QuadSourceRenderer::render(render::PrimitiveRenderer* primitiveRenderer, co
primitiveRenderer->drawArrowHead(center + normal, center + normal * 1.2_simd, 0.8f, Color4ub(255, 255, 0));
}

}
}
8 changes: 2 additions & 6 deletions code/Spray/Editor/QuadSourceRenderer.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 QuadSourceRenderer : public SourceRenderer
{
Expand All @@ -23,6 +21,4 @@ class QuadSourceRenderer : public SourceRenderer
virtual void render(render::PrimitiveRenderer* primitiveRenderer, const SourceData* sourceData) const override final;
};

}
}

7 changes: 2 additions & 5 deletions code/Spray/Editor/SourceRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* 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 "Spray/Editor/SourceRenderer.h"

namespace traktor
namespace traktor::spray
{
namespace spray
{

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

}
}
Loading

0 comments on commit ec8a9ed

Please sign in to comment.