Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 07:30:08 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 261 262 [263] 264 265 ... 279
Print
Author Topic: The happy programmer room  (Read 677803 times)
Ordnas
Level 10
*****



View Profile WWW
« Reply #5240 on: January 23, 2018, 11:38:07 PM »

 Gentleman
Logged

Games:

JWki
Level 4
****


View Profile
« Reply #5241 on: January 26, 2018, 06:14:10 AM »

Pretty fucking happy about having written a big part of a new reflection system for C++, again based on libclang and code generation. Already has proper enum reflection with enum constants, class reflection including (single) inheritance, field reflection, ability to create (default constructible) types by name, etc.
Content with the current state given that it was mostly a day worth of work.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5242 on: January 26, 2018, 07:01:21 AM »

Is the code open source? I've been dealing with C++ reflection systems a LOT lately and I'm interested to see how people implemented them.

Funny I dislike how so many things are going into modern c++ but I WISH it had a decent reflection system like most other languages.
Logged

JWki
Level 4
****


View Profile
« Reply #5243 on: January 26, 2018, 08:47:27 AM »

Is the code open source? I've been dealing with C++ reflection systems a LOT lately and I'm interested to see how people implemented them.

Funny I dislike how so many things are going into modern c++ but I WISH it had a decent reflection system like most other languages.

The code is literally no older than two days, so I'm not confident in releasing it to a public audience atm but I'm happy to talk about how it works.
The basic gist of it is I wrote some relatively straightforward code that manually registers types with a template based interface to access that information and then I used libclang to parse my headers and generate that code for me.

And yeah the lack of reflection is what bugs me most about C++.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5244 on: January 26, 2018, 10:02:41 AM »

Cool. So if you had class X it would kind of look like this? :

class SomeClass
{
public :
int X();
int Y();

private:
int Z();
}

And then somewhere else

RegisterReflectedClass<SomeClass>();

Logged

JWki
Level 4
****


View Profile
« Reply #5245 on: January 26, 2018, 01:52:00 PM »

Sort of yeah, I'll post some code later tonight if I remember.
Logged
InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5246 on: January 26, 2018, 02:15:34 PM »

So I guess this would go in both the happy and grumpy programmer threads.

I'm having to learn regular expressions for real as I have to do language parsing in a language that doesn't have pattern matching (up until now I've always been able to get away with that).

It's going pretty good but I wish the language I was parsing wasn't C++. Thankfully I only need to do an extremely limited subset.

So anyways. Regular expressions are interesting and they can be pretty cool in some situations and do the job a lot better than me manually parsing with basic language constructs. On the other hand some problems include different languages have different implementations of regex, the severe performance issues, the global flags and just the general readability of an expression is grumpy.

I do see a lot of value in it and I'm glad I'm finally getting around to learning them. I've been putting this off for over a decade :D
Logged

JWki
Level 4
****


View Profile
« Reply #5247 on: January 26, 2018, 04:45:14 PM »

Oh is this related to reflection too? Tongue

Anyways so here's some code

Code:
class MetaType;

template <class T>
MetaType* GetMetaType();

This is the basic interface to retrieve the meta type for a type.
Not how it is only declared, but not defined.

A definition looks like this:

Code:
template <>
reflect::MetaType* reflect::GetMetaType<Mesh>()
{
    static MetaProperty properties[] = {
        MetaProperty(GetMetaType<gfx::Buffer>(), "vertexBuffer", 0),
        MetaProperty(GetMetaType<gfx::Buffer>(), "indexBuffer", 0),
        MetaProperty(GetMetaType<unsigned int>(), "vertexOffset", 0),
        MetaProperty(GetMetaType<unsigned int>(), "vertexStride", 0),
        MetaProperty(GetMetaType<unsigned int>(), "numElements", 0),
    };
    auto ctor = []() { return static_cast<void*>(new Mesh()); };
    static auto metaType = new MetaClass("Mesh", "Mesh", sizeof(Mesh), properties, 5, nullptr, ctor);
    return metaType;
}

I actually started out with just typing that out for a few types to see what the API should look like. Obviously that's not really feasible for day to day use so I wrote a rough something using libclang that can generate those definitions. Basically it runs as a pre-built step for each project and generates a single .cpp file that contains these defintions for all the types.
Would work as well with multiple .cpp files, like one for each header or something.

Then there's a really simple runtime API and also a mechanism to register type instances with a per-binary global list so you can iterate all the types to retrieve all implementations of a given interface for example.
This also supports registration across ABI boundaries - atm I'm experimenting with a setup where the main app loads modules dynamically and modules can basically bind their type information into the main apps registry and then use that registry for itself so basically all modules have access to all the type information even when they don't have access to the actual c++ definitions.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5248 on: January 27, 2018, 05:33:43 AM »

I can finally move on with my planet generation, I got stuck on a hard problem for very long and it didn't go away easily after I solve it, it really tried to screw me by sending a last curveball in the form of a trolling with a trivial problem, but damn I'm happy I'm pas that, everything is square now, I can port all my experiment verbatim. Although there is a last challenge, I must see if I can connect properly the different tile on the face of the cube across seam.
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5249 on: January 27, 2018, 10:33:19 AM »

Oh is this related to reflection too? Tongue


Haha not directly but reflection macros are something I have to take into account :D

Interesting implementation. Is this for self study mainly or are you doing something like a game editor?
« Last Edit: January 27, 2018, 10:39:16 AM by InfiniteStateMachine » Logged

JWki
Level 4
****


View Profile
« Reply #5250 on: January 28, 2018, 10:33:31 AM »

Oh is this related to reflection too? Tongue


Haha not directly but reflection macros are something I have to take into account :D

Interesting implementation. Is this for self study mainly or are you doing something like a game editor?

This is for a game related project editor is only one aspect of it tho.
Not sure if I'm going to go down this route however. There's a bit of bloat smell due to the tooling and stuff around it.
Logged
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5251 on: February 10, 2018, 08:10:41 AM »

after years YEARS



Okay now the crossing of edge and corner  Crazy
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5252 on: March 07, 2018, 11:24:42 PM »

Wrote a simple voxel landscape renderer ala comanche on blitz3D, took age to debug

Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #5253 on: March 09, 2018, 07:27:55 AM »

cool!
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5254 on: March 20, 2018, 12:00:03 AM »

I'm getting somewhere at least, now let' see if I can get adjacency right Cry

Logged

oahda
Level 10
*****



View Profile
« Reply #5255 on: March 20, 2018, 03:18:19 AM »

I've quite forgotten what you were going to be using this for!
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5256 on: March 20, 2018, 03:17:57 PM »

no man's sky clone
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5257 on: March 22, 2018, 02:34:32 AM »

Progress +1,
got the projection to work in all direction:

remain in order of complexity
1 - face adjacency (check of boundary + hardcoded selection)
2 - tile adjacency bleed over (basically assigning tile to face when bleeding over the current one see 1)
3 - circular array update (basically when moving only update tile that are in the offset direction)

The big test is if I can iterate the neighbor of a tile to spawn connection line between them, with consistent hashed seed.

Then I'll stop a bit to tackle convexhull again, which is needed for further pcg
Logged

ferreiradaselva
Level 3
***



View Profile
« Reply #5258 on: April 11, 2018, 06:11:05 AM »

All I know is that that is a beautiful ball.

I have a question. Those quads that form the sphere, does the triangles bend or are they perfectly plane?
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #5259 on: April 11, 2018, 07:59:52 AM »

I place all vertex on a sphere position they follow the curvature, so I guess the QUAD bend, triangle don't, they can't. BUT I'm not sure the curvature will be any significant.
Logged

Pages: 1 ... 261 262 [263] 264 265 ... 279
Print
Jump to:  

Theme orange-lt created by panic