joseph.howell Posted February 3, 2016 Posted February 3, 2016 I am trying to load a world after another world has already been loaded. I am loading data/testproject/testproject first on startup, then once in game, attempting to load data/lights I looked in your script examples to see how this was done, and discovered it was done through the world_load <world_name> console command. I tried replicating this in c++. with this command: Console::get()->run(command); where command is: world_load data/lights However, it crashes. I can't say for certain why it crashes, but there is some debug output about the materials being already defined. I don't know if that's an error message or just a warning. But right now, it's all I have to go on. Both world files include the same material files (it looks like this is how your sample files are set up too). These files are ground.mat and iceMaterials.mat Here is my debug output (first, loading data/testproject/testproject): Loading "data/testproject/testproject.cpp" 69ms Loading "testproject/materials/testproject.mat" 2 materials 0ms Loading "world/iceMaterials.mat" 10 materials 1ms Loading "world/ground.mat" 0 materials 0ms Loading "data/testproject/testproject.world" 125ms Now I try to load through my c++ command the new world, lights. Here is the debug output Unigine~# world_load data/lights Loading "data/lights.cpp" 18ms Loading "world/ground.mat" 1 material 0ms Loading "data/lights.mat" 1 material 0ms Loading "data/lights.world" 9ms ALWrapper::init(): can't load "openal32.dll" library NameSpace::check(): unused variable "Unigine::Input::DeviceManager::MAX_XPAD360_CONTROLLERS" MaterialManager::load(): "ground_grid" material is already defined MaterialManager::clear(): can't clear "world/iceMaterials.mat" materials library And then it crashes. This is all I know about the crash: First-chance exception at 0x000007FED6A846DB (Unigine_x64d.dll) in javaw.exe 0xC0000005: Access violation reading location 0x000007FE00000104. If I load data/lights first, then it loads data/lights fine. So I know there are no problems with that world. It's only when I load it after loading another world that it crashes. Any help here? Thanks
silent Posted February 4, 2016 Posted February 4, 2016 Hi Joseph, Unfortunately, without stable reproduction and debugging it is hard to say what is going on. Could you please provide a simple test scene, so our QA guys and dev team can launch it and debug?Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
joseph.howell Posted February 4, 2016 Author Posted February 4, 2016 Well here is our data folder. I'll explain what we're doing, and maybe that will shed some more light. Our app is written in Java. It's kind of like a 3D design studio. We've wrapped Unigine in a dll and use JNI to interface with it. The worlds we create in the Unigine editor are kind of just backgrounds for the stuff we're designing in our editor and transferring over through JNI. (So actually, most of the meshes, textures and stuff we're creating on the fly by transferring it through code). And actually, there isn't really much in the worlds right now. In fact, both of my test worlds are pretty much just the default world you get when you create a new project in the Unigine editor. So in the data.rar file I've attached, we have two test worlds, data/lights and data/testproject/testproject. These are the two worlds we're switching between as described in my post above. Like I say, they're fairly empty files that we're just using for testing right now. Here are some diffs: In lights.world and testproject.world we're pointing to two additional mat files we've created that provide some materials for the meshes we create on the fly that we transfer through JNI. system.h -- changed this to create a class we call "Camera", that basically maps all the keyboard and mouse movements to mappings we use in our software. Camera.h -- Our camera class as described above. I'll have to ask around if I can send you our c++ code. data.rar
silent Posted February 5, 2016 Posted February 5, 2016 Hi Joseph, I can see that you highly modified system.h and other scripts :) The first thing I did - restore back original contents of core / editor / scripts folders. After that no crash occurred while loading data/lights world from C++. I will continue my research if needed, but I think you know better what modifications you made and can trace (by commenting the parts of the code, for example) which exactly modification cause such issue. Probably, some camera-related code causing such behavior. Maybe memory management article can help a little bit (take a look at the new / delete operators usage). Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
joseph.howell Posted February 5, 2016 Author Posted February 5, 2016 Oh, ok, that's interesting. Yes I'll try reverting my system.h changes and see if I can isolate which change causes the crash, and I'll let you know. Thanks
joseph.howell Posted February 8, 2016 Author Posted February 8, 2016 Ok, the problem was that I was caching off a pointer to the current player instead of grabbing it every frame. After the world reloaded, there was a new player and so using the old one crashed. So my fix was to just get the player pointer on each update call instead of caching it. The question is, is there a way in the scripts that I can tell when a new world is loaded? Some sort of call back method or something? Thanks
silent Posted February 9, 2016 Posted February 9, 2016 Hi Joseph, Try this one engine.world.isLoaded(). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts