-
Posts
2,953 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Roland
-
-
I mean entity pointers should work just fine with ToLua++.
Really. Could you give a simple example.
class Test { public: Test( Leadwerks::Entity* e ); };
gives an error at runtime saying that argument #2 is a Leadwerks::Model
This works though
class Test { public: Test( void* e ); };
in LUA
Script.cpp = nil function Script:Start() cpp = Test:new( self.entity) end
-
It's not an official feature at this time.
Aha. That explains it
-
Thanks and glad you liked it
-
To be picky
The public method ClearAnimations also have a potential memory leak as it can be called from anywhere and it erases all elements without deleting them.
Easy fixed by moving the delete loop from the destructor to ClearAnimations
AnimationManager::~AnimationManager() { ClearAnimations(); } void AnimationManager::ClearAnimations() { for (auto it = animations.begin(); it != animations.end(); ++it) { delete *it; } animations.clear(); }
- 1
-
Tested the C++ version. There's a memory leak here
if (n < maxanim) { if (completedanimation->mode == false || completedanimation->endOfSequenceReached == true) { animations.erase(animations.begin() + n); } }
should be something like
if (n < maxanim) { if (completedanimation->mode == false || completedanimation->endOfSequenceReached == true) { delete animations[n]; // prevent memory leak animations.erase(animations.begin() + n); } }
- 1
-
Great and thanks. Would be great if we didn't have to guess though
-
I like the idea. I'm making my game for both Windows and Linux. Thumbs up!
-
You can't pass entity objects from Lua to C++. I recommend setting a UUID field on the Key map for Entities and loop through all entities in World to get the entity in C++.
Of course you can pass Entitys from LUA to C++. Here is a fictional example on how I do that. Say we have a LUA script containing some Entity, say a Box Shape. Now we want to pass this Script and its entity to a C++ class for some work. I type in this just from my head so there might be some minor errors but you get the idea.
What was talking about was those void* pointers. That works but it would have been nicer to use Leadwerks::Entity* pointers which they really are.
RotatingBox.lua: LUA Script
Script.TheBox box = nil --entity "The Box"
Script.Speed speed = 0.5 --float "Speed"
Script.cppworker = nil
function Script.Start()
cpp = CppWorker:new( self.entity ) -- passing our self to C++
end
function Script:Update()
cpp:rotate( self.box ) -- passing the box entity to C++
end
CppWorker.h: C++ Class Header
#pragma once
#include "Leadwerks.h"
class CppWorker
{
float _speed;
public:
// Have to use void* instead of Leadwerks::Entity*
CppWorker( void* luascript_entity );
// Same here. Have to use void* instead of Leadwerks::Entity*
void rotate(void* entity);
};
CppWorker.cpp: C++ Class Source
#include "CppWorker.h"
CppWorker::CppWorker( void* luascript_entity )
{
Leadwerks::Entity* luaentity = reinterpret_cast<Leadwerks::Entity*>(luascript_entity); //Script Entity from LUA
// reading speed from LUA
int stacksize = Leadwerks::Interpreter::GetStackSize();
luaentity->Push();
Leadwerks::Interpreter::GetField("script");
if (Leadwerks::Interpreter::IsTable())
{
Leadwerks::Interpreter::GetField("Speed");
_speed = atof(Leadwerks::Interpreter::GetVariableValue().c_str());
}
Leadwerks::Interpreter::SetStackSize(stacksize);
}
void CppWorker::rotate(void* entity)
{
Leadwerks::Entity* e = reinterpret_cast<Leadwerks::Entity*>(entity);
e->Turn( 0, Leadwerks::Time::GetSpeed() * _speed, 0 );
}
CppWorker: ToLua++ Source
$#include "Leadwerks.h"
$#include "CppWorker.h"
class CppWorker
{
public:
CppWorker( void* luascript_entity );
void rotate(void* entity);
};
tolua++ -o CppWorker_.cpp -n CppWorker -H CppWorker_.h CppWorker.pkg
Compilation
Add CppWorker_.h and CppWorker_.cpp to the project and in App.cpp add #include "CppWorker_.h" at the top and then add this line at some convinient place in your App.cpp, something like this
...
tolua_FpsPlayer_open(Leadwerks::Interpreter::L);
if (!Interpreter::ExecuteFile(scriptpath))
...
..
Test
Add the script RotatingBox.lua to some Entity in you scene and if your the
box will rotate. The CppWorker does the rotation of the Lua Entity 'box'
using the Lua value 'speed'.
PS:
Oh how I hate this forum editor that removes the tab-indentations in code
-
It's actually mostly annoying. It works with void* but typeless pointers isn't anything I really like having. And inside the function it's that extra reinterpret_cast<Leadwerks:: Entity*>(pointervalue) to do. Just wondered if anyone had come up with a way to make it cleanly
-
These guys are not documented
virtual void Entity::SetElasticity(const float elasticity);//lua
virtual float Entity::GetElasticity();//lua
-
I have successfully managed to use toLua++ in order to expose my C++ classes to LUA. All works fine and dandy, however I have to use void* pointers in functions where there is a Entity* pointer. Its really no big problem but I would like to now if any one else know something about this. Example:
class MyClass { public: MyClass(); void some_function( Leadwerks::Entity* e ); }
That one causes a crash in LUA when some_function is called
function Script.Start() myclass = MyClass:new() -- OK myclass:some_function( self.entity ) -- KRASH end
Now if I instead use a void* all works great
class MyClass { public: MyClass(); void some_function( void* e ); }
This one works in LUA when some_function is called
function Script.Start() myclass = MyClass:new() -- OK myclass:some_function( self.entity ) -- OK end
I can understand that toLua++ apparently doesn't handle the Leadwerks::Entity* as expected. Is there anyone that have come across this little problem and if so how to fix it? I couldn't come up with something. Meanwhile I can live with the void* although I don't like it.
-
This happend to me a while back with an ubuntu update.
Check this blog entry for my fix:
http://www.leadwerks.com/werkspace/blog/175/entry-1574-leadwerks-and-gcc-521-regarding-c-abi/
Great. Awesome and thanks
-
Update:
It seems to be a Ubuntu 16.04 TLS problem.
I backed to Ubuntu 14.04 TLS and the problem was gone.
- 1
-
Okay Josh. Thanks for testing. Will get a new look at it when I home again
-
I will obey the rules
-
14.04 seems a bit old
Release Released End of life
Ubuntu 16.04 LTS Apr-2016 Apr-2021
Ubuntu 15.10 Oct-2015 Dec-2015
Ubuntu 15.04 Apr-2015 Jun-2015
Ubuntu 14.10 Oct-2014 Dec-2014
Ubuntu 14.04 LTS Apr-2014 Apr-2019
Ubuntu 12.04 LTS Apr-2012 Apr-2017
Ubuntu 10.04 LTS Apr-2010 Apr-2015
- 1
-
I'm on my way for a 3-week trip so I won't have any possibility to test until I'm back anyway.
-
Ubuntu 16.04 TLS
CodeBlocks 16.01
gcc 5.4.0
1. Create a new blank project, Test
2. Open Test/Projects/Linux/Test.cbp in CodeBlocks
3. Compile
This is what you will get
-------------------------------------
||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|
/mnt/Store/Leadwerks/Test/Source/main.cpp||In function ‘void DebugErrorHook(char*)’:|
/mnt/Store/Leadwerks/Test/Source/main.cpp|12|warning: unused variable ‘n’ [-Wunused-variable]|
/mnt/Store/Leadwerks/Test/Source/main.cpp||In function ‘int main(int, const char**)’:|
/mnt/Store/Leadwerks/Test/Source/main.cpp|76|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
../../Source/App.o||In function `App::Start()':|
/mnt/Store/Leadwerks/Test/Source/App.cpp|16|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|22|undefined reference to `Leadwerks::Interpreter::SetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|25|undefined reference to `Leadwerks::FileSystem::GetFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|28|undefined reference to `Leadwerks::Interpreter::ExecuteFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|30|undefined reference to `Leadwerks::System::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|35|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|38|undefined reference to `Leadwerks::Interpreter::PushString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
../../Source/App.o||In function `App::Loop()':|
/mnt/Store/Leadwerks/Test/Source/App.cpp|72|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|77|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/App.cpp|80|undefined reference to `Leadwerks::Interpreter::PushString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
../../Source/main.o||In function `main':|
/mnt/Store/Leadwerks/Test/Source/main.cpp|35|undefined reference to `Leadwerks::FileSystem::StripAll(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|36|undefined reference to `Leadwerks::String::Right(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|36|undefined reference to `Leadwerks::String::Left(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|37|undefined reference to `Leadwerks::System::AppName[abi:cxx11]'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|38|undefined reference to `Leadwerks::FileSystem::GetAppDataPath[abi:cxx11]()'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|41|undefined reference to `Leadwerks::String::Lower(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|48|undefined reference to `Leadwerks::FileSystem::GetFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|48|undefined reference to `Leadwerks::FileSystem::CreateDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|50|undefined reference to `Leadwerks::System::LoadSettings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|53|undefined reference to `Leadwerks::FileSystem::ExtractDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|53|undefined reference to `Leadwerks::System::AppPath[abi:cxx11]'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|59|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|59|undefined reference to `Leadwerks::String::Int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|62|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|65|undefined reference to `Leadwerks::Package::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|73|undefined reference to `Leadwerks::FileSystem::LoadDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|79|undefined reference to `Leadwerks::FileSystem::ExtractExt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|79|undefined reference to `Leadwerks::String::Lower(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|82|undefined reference to `Leadwerks::Package::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|89|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|93|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|93|undefined reference to `Leadwerks::String::Int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|94|undefined reference to `Leadwerks::Interpreter::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|96|undefined reference to `Leadwerks::String[abi:cxx11](int)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|96|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|99|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|100|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|103|undefined reference to `Leadwerks::Interpreter::LoadBreakpoints(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|105|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|148|undefined reference to `Leadwerks::System::SaveSettings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|
/mnt/Store/Leadwerks/Test/Source/main.cpp|148|undefined reference to `Leadwerks::System::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
||error: ld returned 1 exit status|
||=== Build failed: 42 error(s), 18 warning(s) (0 minute(s), 1 second(s)) ===|
Seems all static functions in the Leadwerks library is unresolved.
-
As Fuse/Mixamo is such a great resource for us small developers it's really a tragedy that it doesn't work in Linux. Again. It's remarkable that this problem has been allowed to exist for more than one year, specially as it's not a problem on another Linux friendly engine. Let's hope this can be solved so I can answer Yes if I get the question "Does Leadwerks work good in Linux"
- 2
-
It the problem was just an editor thing I could live with that for a while. But the problem exists in both the scene and when the program is executed as this video shows. This is really a severe problem on Linux and needs urgent attention.
-
All characters containing an animation renders out partially on Ubuntu. Here is an example with the Merc-model I bought from Leadwerks, including as much info as I could come up with.
Edit: Later... I can see this is the active drivers report so I guess this was no news. What trouble's me then is that the report dates back to April 2015. As this apparently is still a problem, is there any workaround? As a note I have tested with another engine with same models (except the Merc the) without any problem which leads me to think thats it's a Leadwerks problem more than a driver problem
-
Okay. I get what you mean. One way to avoid snapping would be to snap the pieces in Blender (or whatever) and export them. That would solve the problem I guess. Will go for that and see how it works.
-
Isn't it quite common to make modular pieces just in order to be able to snap them together. Such as wall parts for dungeons. No offense Josh but I don't buy that argument
-
In my humble opinion the answer is simply "No"
- 1
Entity pointers in C++ and toLua++
in Programming
Posted
Thanks Josh. That changed nothing.
However I have found that the reason why its working for you is that you are having
"using namespace Leadwerks;" in your headers. I tested by adding that to my example
Doesn't work
This works
Pgk-file (same in both cases)
I don't like to have 'using' in my headers but I'll guess I can live with that for my Lua-exposed classes so I guess we can say its solved then. Thanks for taking the time.