-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,974 additions
and
1,744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// | ||
/// Langulus::Entity | ||
/// Copyright (c) 2013 Dimo Markov <[email protected]> | ||
/// Part of the Langulus framework, see https://langulus.com | ||
/// | ||
/// Distributed under GNU General Public License v3+ | ||
/// See LICENSE file, or https://www.gnu.org/licenses | ||
/// | ||
#pragma once | ||
#include "../../source/Module.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/// | ||
/// Langulus::Entity | ||
/// Copyright (c) 2013 Dimo Markov <[email protected]> | ||
/// Part of the Langulus framework, see https://langulus.com | ||
/// | ||
/// Distributed under GNU General Public License v3+ | ||
/// See LICENSE file, or https://www.gnu.org/licenses | ||
/// | ||
#pragma once | ||
#include "../Entity/Thing.hpp" | ||
#include <Flow/Factory.hpp> | ||
|
||
|
||
namespace Langulus::A | ||
{ | ||
|
||
/// | ||
/// Abstract asset module | ||
/// | ||
struct AssetModule : Module { | ||
LANGULUS_BASES(Module); | ||
using Module::Module; | ||
}; | ||
|
||
/// | ||
/// Abstract asset unit | ||
/// | ||
struct Asset : Unit, ProducedFrom<AssetModule> { | ||
LANGULUS(PRODUCER) AssetModule; | ||
LANGULUS_BASES(Unit); | ||
|
||
Asset(DMeta, AssetModule*, const Neat&); | ||
|
||
using Data = Any; | ||
using DataList = TAny<Data>; | ||
using DataListMap = TUnorderedMap<TMeta, DataList>; | ||
|
||
protected: | ||
NOD() const DataListMap& GetDataListMap() const noexcept; | ||
|
||
// Map of lists of generated data | ||
DataListMap mDataListMap; | ||
|
||
public: | ||
virtual bool Generate(TMeta, Offset = 0) = 0; | ||
|
||
template<CT::Trait, template<class> class S, CT::Block B> | ||
requires CT::Semantic<S<B>> | ||
void Commit(S<B>&&); | ||
|
||
template<CT::Trait> | ||
NOD() const Data* GetData(Offset = 0) const noexcept; | ||
NOD() const Data* GetData(TMeta, Offset = 0) const noexcept; | ||
|
||
template<CT::Trait> | ||
NOD() const DataList* GetDataList() const noexcept; | ||
NOD() const DataList* GetDataList(TMeta) const noexcept; | ||
}; | ||
|
||
} // namespace Langulus::A | ||
|
||
namespace Langulus::CT | ||
{ | ||
|
||
/// A concept for any kind of asset | ||
template<class T> | ||
concept Asset = DerivedFrom<T, A::Asset>; | ||
|
||
} // namespace Langulus::CT | ||
|
||
#include "Asset.inl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/// | ||
/// Langulus::Entity | ||
/// Copyright (c) 2013 Dimo Markov <[email protected]> | ||
/// Part of the Langulus framework, see https://langulus.com | ||
/// | ||
/// Distributed under GNU General Public License v3+ | ||
/// See LICENSE file, or https://www.gnu.org/licenses | ||
/// | ||
#pragma once | ||
#include "Asset.hpp" | ||
|
||
|
||
namespace Langulus::A | ||
{ | ||
|
||
/// Asset constructor | ||
/// @param type - concrete type of the asset | ||
/// @param producer - the asset library and producer | ||
/// @param desc - messy descriptor for the content | ||
LANGULUS(INLINED) | ||
Asset::Asset(RTTI::DMeta type, AssetModule* producer, const Neat& desc) | ||
: Unit {type} | ||
, ProducedFrom<AssetModule> {producer, desc} {} | ||
|
||
/// Get the entire content data map | ||
/// @attention this doesn't generate any data | ||
/// @return a reference to the contents | ||
LANGULUS(INLINED) | ||
const Asset::DataListMap& Asset::GetDataListMap() const noexcept { | ||
return mDataListMap; | ||
} | ||
|
||
/// Get a single data entry from the contents | ||
/// @tparam T - the trait to search for | ||
/// @param index - the Nth data associated to the trait | ||
/// @return a pointer to the data entry, or nullptr if none exists | ||
template<CT::Trait T> LANGULUS(INLINED) | ||
const Asset::Data* Asset::GetData(Offset index) const noexcept { | ||
return GetData(MetaTraitOf<T>(), index); | ||
} | ||
|
||
/// Get a single data entry from the contents | ||
/// @param trait - the trait to search for | ||
/// @param index - the Nth data associated to the trait | ||
/// @return a pointer to the data entry, or nullptr if none exists | ||
LANGULUS(INLINED) | ||
const Asset::Data* Asset::GetData(TMeta trait, Offset index) const noexcept { | ||
if (not const_cast<Asset*>(this)->Generate(trait, index)) | ||
return nullptr; | ||
|
||
const auto datalist = GetDataList(trait); | ||
return datalist and datalist->GetCount() > index | ||
? &(*datalist)[index] | ||
: nullptr; | ||
} | ||
|
||
/// Get a data list from the contents | ||
/// @tparam T - the trait to search for | ||
/// @return a pointer to the data list, or nullptr if none exists | ||
template<CT::Trait T> | ||
LANGULUS(INLINED) | ||
const Asset::DataList* Asset::GetDataList() const noexcept { | ||
return GetDataList(MetaTraitOf<T>()); | ||
} | ||
|
||
/// Get a data list from the contents | ||
/// @param trait - the trait to search for | ||
/// @return a pointer to the data list, or nullptr if none exists | ||
LANGULUS(INLINED) | ||
const Asset::DataList* Asset::GetDataList(TMeta trait) const noexcept { | ||
if (not const_cast<Asset*>(this)->Generate(trait)) | ||
return nullptr; | ||
|
||
const auto found = mDataListMap.FindIt(trait); | ||
return found ? found.mValue : nullptr; | ||
} | ||
|
||
/// Commit data to an asset | ||
/// @attention data is always commited, even if such trait already exists | ||
/// @tparam T - data trait, the intent we're commiting with | ||
/// @param content - the data and semantic to commit | ||
template<CT::Trait T, template<class> class S, CT::Block B> | ||
requires CT::Semantic<S<B>> LANGULUS(INLINED) | ||
void Asset::Commit(S<B>&& content) { | ||
const auto found = mDataListMap.FindIt(MetaTraitOf<T>()); | ||
if (found) | ||
*found.mValue << Any {content.Forward()}; | ||
else | ||
mDataListMap.Insert(MetaTraitOf<T>(), content.Forward()); | ||
} | ||
|
||
} // namespace Langulus::A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/// | ||
/// Langulus::Entity | ||
/// Copyright (c) 2013 Dimo Markov <[email protected]> | ||
/// Part of the Langulus framework, see https://langulus.com | ||
/// | ||
/// Distributed under GNU General Public License v3+ | ||
/// See LICENSE file, or https://www.gnu.org/licenses | ||
/// | ||
#pragma once | ||
#include "Module.hpp" | ||
#include "Unit.hpp" | ||
#include "Runtime.hpp" | ||
#include <Anyness/Path.hpp> | ||
#include <Flow/Factory.hpp> | ||
#include <Flow/Rate.hpp> | ||
#include <Math/LOD.hpp> | ||
#include <Math/Mapping.hpp> | ||
#include <Math/Scale.hpp> | ||
|
||
LANGULUS_DEFINE_TRAIT(FOV, | ||
"Horizontal field of view angle, usually a real number"); | ||
LANGULUS_DEFINE_TRAIT(AspectRatio, | ||
"Aspect ratio trait (width / height), usually a real number"); | ||
LANGULUS_DEFINE_TRAIT(Viewport, | ||
"Viewport and depth clipping, usually a Range4"); | ||
|
||
|
||
namespace Langulus::A | ||
{ | ||
|
||
/// | ||
/// Abstract graphics module | ||
/// | ||
struct GraphicsModule : Module { | ||
LANGULUS_BASES(Module); | ||
using Module::Module; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics units | ||
/// | ||
struct Graphics : Unit { | ||
LANGULUS_BASES(Unit); | ||
using Unit::Unit; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics renderer | ||
/// | ||
struct Renderer : Graphics { | ||
LANGULUS(PRODUCER) GraphicsModule; | ||
LANGULUS_BASES(Graphics); | ||
using Graphics::Graphics; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics layer | ||
/// | ||
struct Layer : Graphics { | ||
LANGULUS(PRODUCER) Renderer; | ||
LANGULUS_BASES(Graphics); | ||
using Graphics::Graphics; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics camera | ||
/// | ||
struct Camera : Graphics { | ||
LANGULUS(PRODUCER) Layer; | ||
LANGULUS_BASES(Graphics); | ||
using Graphics::Graphics; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics renderable | ||
/// | ||
struct Renderable : Graphics { | ||
LANGULUS(PRODUCER) Layer; | ||
LANGULUS_BASES(Graphics); | ||
using Graphics::Graphics; | ||
}; | ||
|
||
/// | ||
/// Abstract graphics light | ||
/// | ||
struct Light : Graphics { | ||
LANGULUS(PRODUCER) Layer; | ||
LANGULUS_BASES(Graphics); | ||
using Graphics::Graphics; | ||
}; | ||
|
||
} // namespace Langulus::A | ||
|
||
namespace Langulus::CT | ||
{ | ||
|
||
/// A concept for any kind of a graphics unit | ||
template<class T> | ||
concept Graphics = DerivedFrom<T, A::Graphics>; | ||
|
||
} // namespace Langulus::CT |
Oops, something went wrong.