« first day (3462 days earlier)      last day (1547 days later) » 

4:13 AM
@Vaillancourt I don't recall. It sounds like the sort of thing I might have brought up, but when I did a quick search for meta posts by me including 'wiki' I didn't see something that looked like a match. Do you recall any other details? Was it maybe something that was raised in chat?
 
@Pikalek no more details available. I tried to search too, but couldnt find it...
Oh well, I guess it is not important.. :p
 
@Vaillancourt I have a vague memory of a question (probably on meta?) about a highly voted closed community wiki - I don't think I raised it, but I feel like I read that phrase or the like a while back. I'll poke around & if I find something, I'll let you know.
 
 
7 hours later…
11:03 AM
ye don't sweat it I'll probably revamp the entire game engine when I get closer to release, but for now I found something I can use with the least rewrites of existing code
 
 
1 hour later…
12:05 PM
@Pikalek yes I think that's something like that!
@Hakase 👍
 
 
3 hours later…
3:20 PM
Morning!
 
Good morning.
 
And I have been able to replace the inheritance in an Entity/component relationship by something more complicated!
 
I found a meta post I made that included some of the phrase you mentioned & maybe that's why it was familiar, but I don't think it's what you were after as it's not wiki related.
 
nwp
Hooray!
@Vaillancourt You know you're doing it right when template appears in the middle of an expression.
Also I hope you're not using MSVC for that.
 
@Pikalek Oh, don't look that far back in time, I think it was more recent that that; I guess I'll check the comments I made one by one during the week so that I tackle what it was about during the weekend :)
 
3:29 PM
Ah, okay. If not, this might also help: searching on wiki:yes closed:yes score:100
 
@nwp Yeah, template; using template-template parameter and such. (Using this, specifically.) And yeah, MSVC, why?
 
Or change 100 to whatever range you think it might be in.
If you think it was brought up in the last couple months though, it probably wasn't me that discussing it.
 
user92578
@nwp Man those are always the issues I spend hours trying to figure out why the compiler is failing
 
@Pikalek Yeah; I cleaned up a bit this one last weak, the content was chaotic; I might do the same for the others, to avoid repeat content..
 
nwp
@Vaillancourt That looks very old and also eww macros. I made a typelist myself and it was pretty fun. MSVC tends to be bad at this level of template stuff and just ICE on incorrect code. Clang is much better at telling you "You must put template here ^".
 
3:35 PM
@Pikalek No, it was older than that; no worries, and thanks for your help, much appreciated!
@nwp Yeah, that's what I have now; it's not in the software yet, not sure it'll ever be. How would you avoid the macros?
(I'll take a look at your link, thanks for providing it.)
 
nwp
Honestly I don't know why that is even a macro and not spelled out.
Especially since they use the same macro name for different things. It's just super confusing. Maybe there is a real reason behind it that I don't see at a glance.
 
It's to avoid having foo.h know anything about bar.h and all of the other types one would like to put in their list.
The only "common" thing among all those types would be the macro name.
 
nwp
I'm not seeing the problem. Why would you need to know about the types someone would want to put in the list? And how does that macro help with that?
I should really do the sort. I don't think it would be useful, but it seems like fun. The Stockholm syndrome sort of fun.
 
3:50 PM
@nwp hold on
Entity:
#include "Component.h"
#include "ComponentA.h"
#include "ComponentB.h"


struct list_of_types {
    typedef TYPE_LIST type;
};

class EntityVisitorConst;

struct Entity
{
  Entity() = default;
  explicit Entity( const std::string& aName ) : mName( aName ){}

  template <typename ComponentType>
  std::shared_ptr<ComponentType> getComponent()
  {
    if ( auto it = mComponentsOwned.find( ComponentType::GetComponentTypeID() );
      it != mComponentsOwned.end() )
    {
      return std::get<std::shared_ptr<ComponentType>>( it->second );
Component:
#pragma  once

#include <string>
#include <variant>

class Entity;

struct Void {};

template <typename ...> struct concat;

template <template <typename ...> class List, typename T>
struct concat<List<Void>, T>
{
  typedef List<T> type;
};

template <template <typename ...> class List, typename ...Types, typename T>
struct concat<List<Types...>, T>
{
  typedef List<Types..., T> type;
};

typedef std::variant<Void> TypelistVoid;
#define TYPE_LIST TypelistVoid

struct Component
{

  Component( std::string aName ) : mName( aName ) {}
Example component:
struct ComponentA
{
  ComponentA( std::string aName ) : mComponent( aName ) {}
  static constexpr int GetComponentTypeID() { return 0; }

  Component mComponent;

private:
  ComponentA( const ComponentA& ) = delete;
  ComponentA& operator=( const ComponentA& ) = delete;

};

typedef typename concat<TYPE_LIST, std::shared_ptr<ComponentA>>::type TypeListComponentA;
#undef TYPE_LIST
#define TYPE_LIST TypeListComponentA
@nwp My entity needs to know all the components that it could host so that it puts it in its variant.
The previous implementation had the Component as a base class for all the components, and Entity did not need to know about the actual components, it just had a map of component pointers, distinguished using a virtual getType() function...
 
nwp
@Vaillancourt Ah, I see. And you don't want a central place with all the components.
I went another route and don't have a list of allowed components. There are advantages and costs to that.
 
@nwp I don't know yet; I try to get away from "oh, you want a new component? Here is the list of files you'll have to modify to integrate it correctly to the rest of the system" when I can. We have another aspect of the software that is like that and it's giving gray hair to our devs.
In this case, I need to add all the component to Entity. I could add it there.
 
4:08 PM
I've done some macro #include magic before to help with that. Have a file with a list of components, one per line with a macro call around them, something like CREATE_COMPONENT( Health ) and then #define CREATE_COMPONENT( n ) **do stuff**; #include <EntitiesList.incl>
 
@Elva Yeah, that would be an option too.
I don't think my boss like the global idea of that update, though :P
 
Heh mebbe
 
nwp
Have you considered not requiring a list of components?
 
I've also had a simple thing of:
CREATE_COMPONENT( Health )
WITH_PROPERTY( FLOAT, Current )
WITH_PROPERTY( FLOAT, Maximum )
And then just define WITH_PROPERTY to do nothing unless you need it
 
nwp
I have a simple thing with struct Health { float current; float maximum; }; entity.add(Health{10, 20});. That part is awesome.
 
4:11 PM
Worked pretty well if memory serves
 
nwp
The part that is not so awesome is when an Entity goes out of scope and needs to clean up an unknown number of components of unknown type. That requires like 16 bytes overhead per component that can be avoided if the component types were known.
 
@nwp This works ok with inheritance. For other functions, we require that the component have a static constexpr GetTypeID() function, and this is not achievable with inheritance.
 
nwp
You can do it without inheritance and without a type list.
`template <class T> std::vector<T> components;` is incredibly powerful*.
*limitations may still apply.
 
@Elva I guess we'll need something like that when we'll need to do serialization?!
 
It definitely works well for that
 
4:16 PM
@nwp This vector is per entity or per "component manager"?
 
It also works well if you require components to have no logic themselves
 
Yeah; for now it's only in the ctor and in the dtor that we allow logic.
 
nwp
I'm not entirely sure on the words. For me it was per program.
 
@nwp ok, "component manager" will do here then, :P
 
nwp
Add a template <class T> std::vector<std::size_t> ids; and the ECS is almost done. (not really)
 
4:23 PM
@nwp our app grew...
std::set<LinkWithParent<ComponentType>, LinkWithParentSetSort<ComponentType>> mComponents;
 
nwp
Looks freaky.
 
We store our compoents as weak ptrs, using the owning entity's ptr to sort them in a set. This way, we can accommodate getComponents<Component1, Component2>: we just have to do an intersection of the Component1 and Componen2 sets...
 
nwp
Yeah, I had something like that too. Except with vectors and std::lower_bound.
To be fair the std::vector was probably the weakest point here since it needed to stay sorted. plf::colony would probably be a massive improvement.
 
That does not keep the data ordered, though
but if it's what you need!
 
user92578
@Vaillancourt I did not know of this typelist trick, might give it a go to replace my current manually maintained typelist!
 
4:36 PM
@Tyyppi_77 Once I kind of understood what was going on, I kind of found it magic :P
 
user92578
4:47 PM
Except f I can't generate that with macros since macros can't contain other preprocessor defines/undefines, I think I need to come up with something else (or just wait for the EnTT feature that would solve this use case)
 
drop the "r" and you get macos :D
 
hehe
 

« first day (3462 days earlier)      last day (1547 days later) »