• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

118 Neutral

About WoLfuluss

  • Rank
  1. Almirante Engine

    This is a game engine that I coded back in 2012 I think, and now I'm posting the whole source code to everybody! There's nothing "special" at all in the engine - its a collection of features that many times I missed on engines and are useful while creating a game.   Hopefully it will be useful for someone just like it was fun for me to code this whole project.   Source @ Github: https://github.com/WoLfulus/Almirante   Feedbacks please?  
  2. AngelScript <-> C++ binder class.

    [quote name='_orm_' timestamp='1315573997' post='4859473'] You could also make the size of the pool dynamic if you wanted to. In my project, I wrap the script engine in another class that also implements the pool and listens to the update loop. It cleans up contexts that have been inactive for a certain time. Other expensive operations you will want to watch out for: * Getting function ID's. * Getting type ID's. Andreas, care to expand on this list? As far as the function ID's are concerned, I actually made a post about it [url="http://www.gamedev.net/topic/592424-the-importance-of-pre-caching-function-handles/page__p__592424__fromsearch__1#entry592424"]here[/url]. (Note: my code doesn't suck as much now as it did when I made this post.) [/quote] I'll try changing the pool to a dynamic one... but a little different from your way. About the function ID's... that's exactly why you must store the function "pointer" like this: [quote]Function<void(int, float)> cached_function = module->getFunction<void(int, float)>("name");[/quote] and avoid code like this: [quote]module->getFunction<void(int, float)>("name")(1234, 12.34f)[/quote] It will keep a reference to the engine (for getting the context from the pool) and it's own function id... avoiding the search each call you make. [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img] Edit ----- I've updated the context pool class, it's now dynamic, creating a new context each time there's none available for usage. [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]
  3. AngelScript <-> C++ binder class.

    [quote name='_orm_' timestamp='1315530266' post='4859307'] Contexts are pretty expensive to be constantly creating and destroying. You would probably be better served using a context pool where you can automatically manage the lifetime of context instances. I do this for sharing contexts between scripted game entities in my engine so that I can parallelize the updating of entities and not have to allocate a context for each one. Hope that helped a bit. [/quote] Sure it helped. I'll write the context pool then. [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img] BTW, I'll need to thread-lock the instance being used by a call until its "release", right? --- EDIT --- Holy crap! I did 150.000 calls to calculate the "time" with the current algorithm and it took 300ms avg. Then I've implemented the context pool, and it took 15~20ms! Btw, you will be able to set the contextpool's object count into the engine I'll commit the changes right now! [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img]
  4. AngelScript <-> C++ binder class.

    Alright, I've fixed some things on function import. Now I've managed to add a function "decomposition" too to find the functions by it's declaration, not only the name. [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img] So now you can import overloaded functions from script. Like this: [quote] Function<int(int,int)> sumi = module->getFunction<int(int,int)>("sum"); sumi(10, 20); // sum ints Function<float(float,float)> sumf = module->getFunction<float(float,float)>("sum"); sumf(10.4f, 14.3f); // sum floats [/quote] [quote name='_orm_' timestamp='1315482753' post='4859005'] Here is an example. Suppose that you have a game object class called GameObject. In your implementation, you want to be able to inherit from this object and add new features to it, such as and Enemy that can ShootAtPlayer. The current solution is something like the following, assuming GameObject is registered as Core_GameObject with the functions AddModel and SomeOtherMethod. [code]// Angelscript class GameObject { GameObject() { m_Core = Core_GameObject(); } GameObject( const Core_GameObject@ obj) { @m_Core = obj; } // Let's assume that ScenegraphNode is doing the same thing as this class. ScenegraphNode@ AddModel(const string@ resource) { return ScenegraphNode(m_Core.AddModel(resource)); } void SomeOtherMethod() { m_Core.SomeOtherMethod(); } private Core_GameObject@ m_Core; }; // Then your enemy class. class Enemy : GameObject { void ShootAtPlayer() { // Implementation here. } }; [/code] [/quote] It's a possibility. I'll push that feature into the queue ([img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]) since it needs some "investigation" [quote name='WitchLord' timestamp='1315520538' post='4859250'] [quote name='WoLfezito' timestamp='1315467495' post='4858947'] Updates! Script functions can be called now without any pain [/quote] Nice! I've been thinking of implementing a helper add-on for doing this myself for sometime. One thing you need to think about, is how this would work with shared asIScriptContext's. Ideally the application would only allocate one asIScriptContext for each script function that runs in parallel. If all script functions are executed in sequence then only one asIScriptContext should be used by all executions, otherwise you would be wasting resources if all function objects hold their own asIScriptContext, or have a performance impact if a new asIScriptContext is allocated for each execution. [/quote] What you mean? I'm currently creating a new context for each call and then releasing it with asIScriptContext::Release()... should I create only one context for each function? Now I'm confused on how to handle this. [img]http://public.gamedev.net/public/style_emoticons/default/huh.gif[/img]
  5. Compatibility Issues with C4 Engine [Solved]

    this doesn't seems to be an issue with angelscript itself. [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img] have you tried removing angelscript includes? does it compiles?
  6. AngelScript <-> C++ binder class.

    Updates! [list][*]Script functions can be called now without any pain [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img][/list] like this: [code] /// Creates the engine Engine engine; /// Creates a module and compiles a script into it /// these modules doesn't needs to be released (it's automatic when Engine goes out of scope or gets destroyed Module* myModule = engine.createModule("MyModuleName"); myModule->compile("script.as"); // First way to call - not recommended myModule->getFunction<void()>("main")(); // Second way to call - holds the function "pointer" and can be called many times. Function<int(int,int)> sum = myModule->getFunction<int(int,int)>("sum")(); int a = sum(5, 10); // Returns 15 int b = sum(6, 13); // Returns 19 [/code] Suggestions? [img]http://public.gamedev.net/public/style_emoticons/default/cool.gif[/img] BTW, it isn't on SVN yet, since it still support only 2 arguments - I'm writing the code generator for that... I'll commit in some hours. [quote name='_orm_' timestamp='1315342142' post='4858327'] Something I just thought about that would be immensely helpful you might want to consider. We all know that we can;t inherit registered types from script, but there is a way around this restriction in the form of writing a script-based wrapper around the registered object. What if there was a flag in the exporter you are writing that would automatically generate and compile the script for classes we would want to inherit from? [/quote] I'll take a look into this. Can you provide me an example of what you're exactly talking about? I have an idea, but I need a working example. [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]
  7. AngelScript <-> C++ binder class.

    Some updates:[list][*]Object members / offset detection being supported now via Class<MyClass>().member("life", &MyClass::_life);[*]Object accessors are supported now via Class<MyClass>().property("name", &MyClass::getName, &MyClass::setName());[/list] [quote name='brianempson' timestamp='1315277602' post='4858047'] [quote name='WoLfuluss' timestamp='1315277546' post='4858046'] Feedbacks are always welcome. Feel free You know It's not fully featured yet. But I'm on the way! [/quote] Let me know when templates are supported!! That's what I struggle with currently... [/quote] I think this will be the last thing I'll add [img]http://public.gamedev.net/public/style_emoticons/default/unsure.gif[/img] Lets see [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img]
  8. AngelScript <-> C++ binder class.

    Feedbacks are always welcome. Feel free You know It's not fully featured yet. But I'm on the way!
  9. AngelScript <-> C++ binder class.

    Alright, here's the weekend changes [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img] [list][*]Finished support for constructors / destructors[*]Dummy constructors/destructors are supported by setting .ctor_dummy() or .dtor_dummy()[*]Support for class methods exports (overload supported too)[*]asOBJ_POD flag being detected (thanks SiCrane)[*]Added support for AS namespaces[/list] I'll add support for properties now... It isn't on SVN yet, but I'll commit in some minutes. Initial/special flags are supported too: [color=#660066][font=CourierNew, monospace][size=2]Exporter[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]::[/size][/font][/color][color=#660066][font=CourierNew, monospace][size=2]Export[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]([/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2]module[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2])[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2] [/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2][[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2] [/size][/font][/color][color=#660066][font=CourierNew, monospace][size=2]Exporter[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]::[/size][/font][/color][color=#660066][font=CourierNew, monospace][size=2]Class[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]<[/size][/font][/color][color=#660066][font=CourierNew, monospace][size=2]MyClass[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]>(asOBJ_NOHANDLE) // Here[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2] [/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2].[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2]ctor_dummy[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]()[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2] [/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2].[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2]dtor_dummy[/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]()[/size][/font][/color][color=#000000][font=CourierNew, monospace][size=2] [/size][/font][/color][color=#666600][font=CourierNew, monospace][size=2]];[/size][/font][/color]
  10. AngelScript <-> C++ binder class.

    Finally got the type exporter to work. + Type exporter + Constructor support + Constructor overload support + Destructor support + Dummy constructor/destructor support I'll implement methods and properties later. Btw... It sets the current type flags automatically (asOBJ_APP_CLASS_CONSTRUCTOR, asOBJ_APP_CLASS_DESTRUCTOR, ...) to avoid user errors. [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img] Syntax currently like this: [code] class MyClass { private: int test; public: MyClass() : test(0) { } MyClass(int val) : test(val) { } ~MyClass() { } }; ... AB_TRANSLATE_TYPE(MyClass, "myclass") ... /// /// Exports your global classes to the script /// Exporter::Export(script) [ Exporter::Class<MyClass>() .ctor() .ctor<int>() .dtor() ];[/code] Output [code][Script] Registering type 'myclass' [Script] Registering constructor for 'myclass' as 'void f()' [Script] Registering constructor for 'myclass' as 'void f(int)' [Script] Registering destructor for 'myclass' as 'void f()'[/code]
  11. AngelScript <-> C++ binder class.

    [quote name='SiCrane' timestamp='1314799725' post='4855888'] has_trivial_* are templates, not macros. If you don't want a boost dependency, they've also migrated to the std namespace in C++0x, std::tr1 in TR1 and generally have compiler intrinsics for implementation on modern compilers. [/quote] good to know! thanks! I'll play with it a little before start using them. [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]
  12. AngelScript <-> C++ binder class.

    @WitchLord: I'm not using boost anymore. Everything is being coded without any external dependencies. About constructors... I already have an idea on how I'll implement it... I'll make some changes... lets see. @SiCrane: About the "metaprogramming" stuff... I'm trying to avoid macros, but sometimes they become handy. Take a look into the SVN project. I'll rework the struct export stuff right now... lets see how it goes. BTW, I've just updated the first post with a more "clear" information about it. [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]
  13. AngelScript <-> C++ binder class.

    I was looking on the docs, but I couldn't find anything talking about allowing types to be passed by value. Any tips on this? Anyways... I had updated the library... now it can exports POD types. constructors / destructors is still missing, but will be the next feature to add. The syntax for function exports is simplified now, and it detects the calling convention. [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img] Here's a sample: [code]#include <iostream> #include <string> #include <AngelBinder.h> #include <scriptstdstring/scriptstdstring.h> /// /// Namespaces /// using namespace std; using namespace AngelBinder; /// /// Exported types /// typedef struct { int member1; unsigned int member2; } TestClass; /// /// Exported global functions /// int sum(int a, int b); int subtract(int a, int b); int multiply(int a, int b); int divide(int a, int b); void log(std::string message); /// /// Type translation /// AB_TRANSLATE_TYPE(TestClass, "test") AB_TRANSLATE_TYPE(std::string, "string") /// /// Message event handler /// void onScriptMessage(Script* script, std::string message) { cout << "[Script] " << message << endl; } /// /// Usage Example /// int main(int argc, char* argv[]) { /// Startup Script script("script"); script.messages() = &onScriptMessage; /// Custom settings RegisterStdString(&script.engine()); /// Exports the structure Exporter::Export(script) [ Exporter::Struct<TestClass>() .member("member1", &TestClass::member1) // registers as int on offset 0 .member("member2", &TestClass::member2) // registers as unsigned int on offset 4 ]; /// Exports the functions Exporter::Export(script) [ Exporter::Functions() .def("sum", &sum) .def("subtract", &subtract) .def("multiply", &multiply) .def("divide", &divide) ]; script.compileFile("AngelBinder.as"); return 0; } /// /// Implementations ///...[/code] The output: [quote][Script] Registering type 'test' [Script] Registering member 'test::member1' as 'int' [Script] Registering member 'test::member2' as 'uint' [Script] Register function 'sum' as 'int sum(int, int)' [Script] Register function 'subtract' as 'int subtract(int, int)' [Script] Register function 'multiply' as 'int multiply(int, int)' [Script] Register function 'divide' as 'int divide(int, int)'[/quote] I was asking about passing by value because this function prototype for example, fails at runtime with the message saying that it can't be passed as value. [code]TestClass init(int a, int b)[/code] It registers fine as "test (int, int)" but when compiling a script, the message pops up.
  14. AngelScript <-> C++ binder class.

    WitchLord, can you provide me a list of prototype strings that angelscript parses and when it's used?? I mean something like this: [code] int - by value const int - constant variable int@ - "pointer" int& - "reference"[/code]
  15. AngelScript <-> C++ binder class.

    Alright guys! Big news... I've created the google code project, and the new syntax I have 100% sure you guys know... [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img] I tried to keep it simple to the max... also, if there's any suggestions, please let me know. [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img] here's the link: [url="https://code.google.com/p/angelbinder/"]https://code.google.com/p/angelbinder/[/url]
  • Advertisement