Coder Social home page Coder Social logo

Comments (4)

dougbinks avatar dougbinks commented on May 29, 2024

Hi @Platforming-Mayhem,

Namespaces

I'll take a look at fixing this at some point, but for now there is a workaround:

// in a .cpp file:
using namespace K;
REGISTERCLASS(Component);

Constructing

You cannot construct RuntimeCompiledCPlusPlus objects using new this way.

To construct an IObject derived class you need to use the constructor:

IObject* pObj = 0;
IObjectConstructor* pConstructor = 
PerModuleInterface::g_pRuntimeObjectSystem->GetObjectFactorySystem()->GetConstructor( "Sprite" ); // name is not namepaced due to above issue
pObj = pConstructor->Construct();
K::Sprite* pSprite = 0;
pObj->GetInterface( &pSprite );

See the ConsoleExample.cpp for a simple example.

You can make the above into a template class. There are also ways to make it a static member of the interface for the class. If you want to improve the performance of construction by storing the constructor for each type then remember you will need to reacquire them when the Runtime Compiler runs, again see the ConsoleExample and the OnConstructorsAdded callback.

A proposal which would be a larger change to your codebase is to consider using an Entity Component System approach where each entity is just an identifier value, and the components are singletons which own an array of their children indexed by the entity identifier. Components usually have a map of entityids to components in some way so the array of components is not the size of all entities for all components.

There is a relatively short overview of this technique in the following posts:
Building a Data-Oriented Entity System (part 1)
Building a Data-Oriented Entity System (part 2)

This is very similar to what I use in Avoyd.

Note that it is better to submit each issue separately on Github rather than together like this as then it will be easier to track resolution of them.

from runtimecompiledcplusplus.

Platforming-Mayhem avatar Platforming-Mayhem commented on May 29, 2024

image
@dougbinks I'm getting this error now instead, any idea why it's happening?

from runtimecompiledcplusplus.

dougbinks avatar dougbinks commented on May 29, 2024

It looks like the constructor for "Sprite" was not registered.

You can use the following code after initializing RCC++ to check which constructors you have registered:

AUDynArray<IObjectConstructor*> constructors;
PerModuleInteraface::g_pRuntimeObjectSystem->GetObjectFactorySystem()->GetAll( constructors );
for(int i = 0; i < constructors.Size(); ++i )
{
     PerModuleInteraface::g_pRuntimeObjectSystem->GetLogger()->LogInfo("Constructor %d: Name: %s\n", i, constructors[i]->GetName() );
}

Alternatively you can put a breakpoint in ObjectFactorySystem::AddConstructors in ObjectFactorySystem.cpp line 248 or so and check what the constructors being assigned are.

from runtimecompiledcplusplus.

Platforming-Mayhem avatar Platforming-Mayhem commented on May 29, 2024

cool, thank you this helped alot :)

from runtimecompiledcplusplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.