Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

293 Neutral

About vdaras

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. vdaras

    AI will lead to the death of capitalism?

    Capitalism is what happens when people are allowed to trade resources and services freely and it's how civilisations have been running themselves the past thousands of years. It will exist as long as there are scarce resources. In a post-scarcity world there is no need for it, but we are millennia away from the technology(ies) that will allow it, if it's even possible.
  2.   That's really interestering.  Could you give an example or two where another engine is that much faster than Unity or UE4?     Fox engine seems superior to both Unity and UE4 performance wise.
  3.   As you saying, don't store lambdas in std::function unless you need to (i.e. passing a lambda into a function that takes std::function as a parameter), or are you saying never use std::function to store a lambda?   I store lambdas in std::function all the time. Ofcourse if the lambda doesn't need to be stored for later calling, I just use auto, but since I still use std::function alot, I'd like to know if there's a problem with that that I'm not aware of.   Are you saying that std::function's member vars takes a few extra bytes to hold the object, which requires a separate allocation (definitely worth pointing out), or are you warning about something more dangerous?      You are right I didn't put that correctly. It's totally fine storing them in std::function objects if there is no alternative to the task at hand.   The problem with std::function is that its the same size for every kind of function it could store, so it does extra allocations if its memory is not enough to store bookkeeping information about the lambda.   Imagine having a game with tons of those small allocations each frame because you just define and store some lambdas. It could hinder performance.
  4. Also, it's advisable not to store lambdas in std::function objects. It might cost extra memory allocation.   The type of each different lambda is known only to the compiler, so use auto instead.
  5. vdaras

    Game programming architecture

    A good reading people often recommend is Game Coding Complete by Mike McShaffry. I've read it myself too and I suggest that it is a great one! It covers a lot of introductory topics on game development and game code architecture as well as some advanced ones. It has some great advice on how you can decouple your game's subsystems.   Another good one is Game Engine Archtecture by Jason Gregory. It covers a lot of ground on game engines but in a more abstract manner than the previous one.
  6. On a side note, if an integer can't be divided by 2 then it also can't be divided by any other even number, so you can try 2 and then only try odd numbers from 3 to sqrt(x), where x the integer that you check for primality.
  7. vdaras

    Ooops... XNA is dead?!.

    Monogame is definitely possible on WP8. As is Microsoft's XNA. The problem with XNA is that, from what we know so far, it won't be supported anymore..so no new WP8 features for XNA apps.
  8. vdaras

    Problem with destructors in C++

    My bet is that sooner123 doesn't understand the pointer concept very well. sooner123, [source lang="cpp"]Node* sentinel = new Node;[/source] This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object. So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this [source lang="cpp"]Node* sentinel = list;[/source] Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the new node was unnecessary.
  9. You ask for someone to leave his/her country, move to a foreign country where English is needed but English is not the native speaking language. Then you need him/her to move to an expensive city as Barcelona, where paying the rent would effectively diminish the 800E salary to 1/3 and probably more. Otherwise, if he/she chooses to leave in a suburban area of Barcelona, much more money will be paid on transport every month. Sorry but you need much better arguments than 'I have super project idea' that no one knows anything about and ' I'm a badass programmer' in order to convice someone to do that.
  10. Aha, ok, I'll try releasing the context before the script object and see if the reference count drops by one. Thanks [color="#660066"] [color="#660066"][color="#000000"]It was design choice, we thought that having multiple contexts would later allow us to integrate concurrent script execution more easily. As for now, it's indeed a waste of space to have a context for each script object. [color="#660066"] [color="#660066"][color="#000000"] Thanks for the tip. Regards, Vassilis
  11. Unfortunately that is the case, thanks for the clarification. The asIScriptObject I create is wrapped inside a class that handles its lifetime and executing its methods. Here is the class' interface class ScriptLogic : public AbstractLogic, public NonCopyable { private: asIScriptObject *m_script; asIObjectType *m_scriptObjectType; asIScriptContext *m_ctx; public: /** * Constrcutor initializes this logic by getting the script object * that handles the behavior of this Entity. * * @param object - the script object managed by the script logic. */ ScriptLogic(asIScriptObject *object); virtual ~ScriptLogic(); /** * Clones this script logic. * * @return a replicate of ths Script Logic component. (deep copy) */ ScriptLogic* Clone(); /** * Executes the Initialize method of the script object. */ void ExecuteInitialize(); /** * Executes the Update method of the script object. */ void ExecuteUpdate(); /** * Executes the Update method of the script object. */ void ExecuteOnTileCollision(std::string* tile, Math::Vector2F& contactNormal); /** * Executes the Update method of the script object. */ void ExecuteOnEntityCollision(Entity* collided, Math::Vector2F& contactNormal); /** * Executes the OnKeyButtonUp method of the script object. * * @param info for the released key */ void ExecuteOnKeyButtonUp(KeyboardEventInfo *info); /** * Executes the OnKeyButtonDown method of the script object. * * @param info for the pressed key */ void ExecuteOnKeyButtonDown(KeyboardEventInfo *info); /** * Execute the OnDeath method of the script object. */ void ExecuteOnDeath(); /** * Sets the Entity that this script logic controls. * * @param parent */ virtual void SetParent(Entity *parent); /** * Returns the name of this script's class. */ const char *getName(); }; Here is the constructor's, the destructor's, Clone method and a sample script object's method execution implementations. ScriptLogic::ScriptLogic(asIScriptObject *object) { ScriptManager *scriptManager = ScriptManager::GetInstance(); //get the type of the script m_scriptObjectType = object->GetObjectType(); //create an object of the given type m_script = object; //give a context to this script logic m_ctx = scriptManager->CreateContext(); } ScriptLogic::~ScriptLogic() { m_script->Release(); m_scriptObjectType->Release(); m_ctx->Release(); } ScriptLogic* ScriptLogic::Clone() { ScriptManager *scriptManager = ScriptManager::GetInstance(); asIScriptEngine *engine = scriptManager->GetEngine(); //create a copy of the script object asIScriptObject *replicate = (asIScriptObject *) engine->CreateScriptObjectCopy(m_script, m_scriptObjectType->GetTypeId()); return new ScriptLogic(replicate); } void ScriptLogic::ExecuteUpdate() { //get the method 'Update' ID int methodID = m_scriptObjectType->GetMethodIdByDecl("void Update()", true); //prepare the method for execution m_ctx->Prepare(methodID); //pass the script logic's script object as the object which calls the method m_ctx->SetObject(m_script); //execute the method m_ctx->Execute(); } Here is the creation of the asIScriptObject object. //create the object int typeID = entityModule->GetTypeIdByDecl(scriptObjectType.c_str()); asIScriptObject *scriptObject = (asIScriptObject *) engine->CreateScriptObject(typeID); [irrelevant code omitted] //add the script object to the prototype entity cacheEntity->AddScriptLogic(scriptObject); //this creates a ScriptLogic object, with the asIScriptObject as an argument The asIScriptObject objects in ScriptLogic object are not accessed by any other part of the engine's code. Based on this code, I can only count 1 reference added during creation and 1 reference held by the garbage collector. So.. there is extra reference that I can't justify.
  12. Hello, Got another question regarding memory management. I explicitly create asIScriptOjbect s in C++ code, which are only manipulated by the C++ engine and angelscript code doesn't use them. When I try to deallocate them by calling asIScriptObject::Release I see that there are 3 references to each one of them and I call this method in a do-while loop until the object's references reach 0. Will these objects be deallocated by the garbage collector? If not, what can I do to deallocate them explicitly? I don't want to mess with angelscript's code and mark asIScriptObject destructor as public, I don't think it would be safe either. Regards, Vassilis
  13. Thank you for your fast response Andreas, you really helped a lot
  14. Hello, I need to disable angelscript's garbage collector. The lifetime of the objects that the scripts manipulate is managed by C++ code, thus my only need is to pass non-refcounted handles to the scripts. Also, if I manage to disable garbage collection, is there a way to prevent the instantiation of reference types in scripts in order to avoid memory leaks? Thank you in advance.
  15. Use std::vector and you are golden.
  • 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!