Jump to content
  • Advertisement
Sign in to follow this  
Khatharr

Better method than smart-pointers for dealing with circular dependency?

This topic is 2186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hmm...
 
The staggered loading part makes sense in the case of actual resources. I didn't think that was what you meant, though, since you were talking about plugging things into the world. Do you mean like loading configuration data for the object from files?
 
I don't get why this pattern is associated with improved performance, though. A constructor is just a function. It would have to do the same work as the other functions are doing. Do you mean that performance is improved by the staggered loading?
 
In my mind I'm thinking that an entity would be created, then plugged in. Any resources (graphics, audio, etc) that it needs should be owned remotely (by a cache or something) so that they can be shared between instances. The entity may trigger loads from the cache, but the cache could be designed to provide a placeholder 'blank' resource until the loading is complete. I get that the loading could be moved to the plug-in/activate stage rather than the construction, which would spread the work out.
 
I guess what I don't get is why you can't do something like:
 

class Thing {
  Thing() {
    //set default values here
    commonCtor();
  }
 
  Thing(SerialThing*) {
    //deserialize here? (or deserialize externally and pass in a pimpl?)
    commonCtor();
  }
 
  void commonCtor() {
    //construction (maybe notify the cache of impending resource requests so that it can get a head start if it's not busy?)
  }
 
  void OnPlacedInWorld() {
    //activate the object
  }
};

 
I'm thinking that it would make more sense if I saw it in action. I just don't get why the actual ctor would be left blank and then have a number of initialization functions. Possibly this relates to that fact that I've not yet worked with the Entity-Component pattern.
 
I don't fully understand what you mean by point 7. Does GameObject() have a meaningful constructor or is it left blank? From your earlier post I had the impression that the ctor was doing nothing, and either the OnCreate() function or some kind of external(?) deserialization was being used instead. So what you're saying is that the base ctor is doing some kind of common work, and then OnCreate() or alternative is doing the local construction?

 

It isn't a case of non-construction. The game object is fully constructed after the constructor.

 

?

 

Yeah, I'd need to see what kind of overall framework this is in before I'd understand the reasoning behind it.

Share this post


Link to post
Share on other sites
Advertisement
What he means is that object is 'valid' for a given definition of 'valid'.

For example we have two types in our engine; 'surfaces' and 'shader resource views'. The latter requires the former to work yet the latter can be created before the former.

The 'construction' and initialisation just allows the surfaces to say 'hey, I require this resource, let me know when it exists' and then it is informed when it comes into existence so it can hook itself up.

This 'ready' message can happen 1 or more frames after the view is constructed.
(This is a centralised dispatch which allows you to limit the number of 'ready' messages sent per frame and also capture all the new ones to dispatch later instead of throwing them all out at once.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!