Jump to content

TheComet

Member Since 02 Oct 2013
Offline Last Active May 26 2017 04:15 PM

Topics I've Started

Collision with deforming meshes

20 April 2017 - 09:37 PM

Replaying some of the older games I've started thinking about collision handling. How does one achieve this behaviour?

It seems keeping a player on a deforming mesh would require

1) Doing a line-mesh intersection on the skinned model
2) ...which requires the triangles in the mesh to be spatially partitioned
3) ...which needs to be repartitioned every so often as the mesh deforms, because it may become invalid.

With a low poly count I can see this working, but in today's games where a model like that would have over 50k polygons, this seems less feasible.

What is the general approach to this problem? Are there any papers or articles written on the subject that you can share?


Adventures in Texting - Sign up thread

19 April 2017 - 08:49 AM

It is time for fun.

We will embark on an adventure together, where we all collaboratively work on a text adventure game. The setup is simple: We begin with a minimal "framework" written in the C++ language. Code is then added incrementally according to the following rules.

The Schedule

Access to the repository is opened on Friday, 17-04-21 14:00 UTC.
Access to the repository is closed on Sunday, 17-04-23 14:00 UTC.
You may sign up at any time starting now by posting in this thread or contacting me on Discord. Please give me your github username!
 

The Rules

  • Language constraints
    • The code you submit must be well-defined and compile and run without causing abnormal program termination (such as segfaults, calls to abort() or exit(), etc.)
    • The program must have the ability to terminate normally after a finite amount of time. Inserting infinite loops is not allowed.
    • Your code must comply with the C++11 standard. You may not use compiler specific extensions, platform specific calls (e.g. winAPI or posix calls) or external dependencies (other than the C/C++ standard library).
    • You may not use preprocessor directives, with the exception of rule 5.
    • You may define constants, e.g. #define PLAYER_STATE 5. More complex macros are not allowed (such as macros that accept arguments).
    • You may not use goto.
    • All code must be contained in a single source file. In other words, you may not create additional source or header files.
  • Submitting code
    • You may modify/insert at most 5 lines at a time. Deleting existing lines is forbidden! You can only insert!
    • The maximum line length allowed is 512 characters (excluding the newline).
    • You may only submit code if the previous submitter is not you, or if 30 minutes have past since the last commit.
    • Code containing illegal information or information that would get you banned from GDNet is forbidden.

If you submit code that violates any of these rules, your access will be suspended for 2+ hours.

The Code

We will synchronise our code using github: https://github.com/gamedev-net/AdventuresInTexting

Sign up in this thread now by submitting to me your github username.

People signed up:

  1. TheComet (TheComet93)
  2. iedoc (cloudis31)
  3. Alpheus (canfucius)
  4. Naz (Ruuubb)
  5. IYP (IYP-Programer-Yeah)
  6. CulDeVu (CulDeVu)
  7. Nitewalkr (Nitewa1kr)
  8. Washu (WashuHakubi)
  9. blueshogun96 (blueshogun96)
  10. Alpheus (canfucius)
  11. MarkyPooch (markypooch)
  12. martin (MartinGrant)

 
The rules aren't yet set in stone, we can discuss and make changes to them until Friday if necessary.


New lightweight IK library

13 April 2017 - 07:24 PM

I wasn't sure where to post this, but some of you may know that I've been working on a lightweight inverse kinematics library implementing the FABRIK algorithm. I'd like some feedback and/or complaints and/or condolences on this.

https://github.com/TheComet93/ik

It's written in C89 and has no dependencies other than the C standard library.

You can find information on how to use it on the wiki page https://github.com/TheComet93/ik/wiki and also in the header files solver.h, node.h and effector.h.


Python C API: Undefined functions in module

25 October 2016 - 04:45 AM

def test():
    pass

def apply(frame):
    test()

This is the file I compile and evaluate using the following code (omitting error handling for readability's sake):

void ScriptInstance::reload()
{
    QFile file(fileName_);

    file.open(QIODevice::ReadOnly);
    QByteArray bytes = file.readAll();
    file.close();

    // these are all borrowed references
    PyObject* main = PyImport_AddModule("__main__");
    PyObject* globals = PyModule_GetDict(main);
    PyObject* locals = PyModule_GetDict(module_);

    PythonObject<> compiled = Py_CompileString(bytes.data(), fileName_.toLatin1().data(), Py_file_input);
    PythonObject<> eval = PyEval_EvalCode(compiled.get(), globals, locals);

    applyFunction_ = PyObject_GetAttrString(module_, "apply");
}

module_ was previously created using PyModule_New().
 
The problem is when I call applyFunction_ I get the error:


call to apply() failed: name 'test' not defined

What am I doing wrong here?
 
Here's the code I use to call the function:

PyObject* args = PyTuple_New(0);
PyObject_CallObject(applyFunction_, args);

Reloading Python script (C API)

23 October 2016 - 07:51 AM

I am developing an application written in C++/Qt that embeds the python interpreter and exposes some functionality through python bindings. I'm using CPython API to do this (mostly because I wanted to learn more about how to do this).

 

I want to add "hot reloading" of python scripts to this application. When the script is modified and saved to disk, I want to reload that script and re-execute it. I feel like I'm really close to the solution but I can't quite get it to work.

 

This is the function I use to load (and reload) my python script:

http://pastebin.com/1PDE7EY1

 

This works fine the first time I call it, but when I call the function a second time (and pass the same argument, namely the path to my test.py script), I get the error: ImportError("bad magic number in 'test').

 

I have also tried using PyImport_ReloadModule() instead of trying to delete the entry in sys.modules, but this also causes the same error.

 

What is really interesting is that if I place a breakpoint on PyImport_Import() and then resume execution it works! Why??

 

Now, I've been told that it's "really hard or impossible" to reload python scripts, especially when they start importing other scripts and are referenced in other scripts. HOWEVER, it works with the breakpoint "hack" and I can also get it to work just fine using the interactive console:

 

This is the content of test.py:

def test():
    print("one!")

I load and execute it in the python console:

>>> import test
>>> test.test()
one!

I now edit the script (without closing the python console) to this:

def test():
    print("two!")

In order for the change to take effect, I can do this:

>>> import sys
>>> del sys.modules['test']
>>> del test
>>> import test
>>> test.test()
two!

All I want to do is reproduce this using the C API and I can't figure out how my C++ code differs from the interactive session.