3D physics/collision libraries that work on DC?

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

3D physics/collision libraries that work on DC?

Post by bbmario »

Does anyone know any physics/collision libraries that can work or easily be ported to DC? I tried Tokamak, but seemed like a huge effort.
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by bogglez »

CubicVR is a game engine that runs on the Dreamcast, they seem to have used Bullet..
https://github.com/cjcliffe/CubicVR/tre ... /dreamcast
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
Tvspelsfreak
Team Screamcast
Team Screamcast
Posts: 144
Joined: Tue Dec 23, 2003 6:04 pm
Location: Umeå, Sweden
Has thanked: 0
Been thanked: 0
Contact:

Re: 3D physics/collision libraries that work on DC?

Post by Tvspelsfreak »

ODE has been ported over. It's from 2003 though.
http://www.boob.co.uk/devtools.html
https://github.com/tvspelsfreak/texconv - Converts images into any texture format supported on the DC.
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: 3D physics/collision libraries that work on DC?

Post by bbmario »

CubicVR seems abandoned... has anyone used it?
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by bogglez »

bbmario wrote:CubicVR seems abandoned... has anyone used it?
I'm afraid I have not, but it's a sign that bullet should be usable.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
Chilly Willy
DC Developer
DC Developer
Posts: 414
Joined: Thu Aug 20, 2009 11:00 am
Has thanked: 0
Been thanked: 2 times

Re: 3D physics/collision libraries that work on DC?

Post by Chilly Willy »

Funny, I was going to mention a port of Bullet I helped with on the PSP. The biggest problem that port ran into was the HUGE amount of stack you can wind up using. The issue I helped track down was the demo the guy was using was using almost 1MByte of stack space (the default PSP stack was 64K).
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: 3D physics/collision libraries that work on DC?

Post by BlueCrab »

Chilly Willy wrote:Funny, I was going to mention a port of Bullet I helped with on the PSP. The biggest problem that port ran into was the HUGE amount of stack you can wind up using. The issue I helped track down was the demo the guy was using was using almost 1MByte of stack space (the default PSP stack was 64K).
Wow... That's more than a bit ridiculous stack space wise.

Also on that note, the default stack size in KOS is 32KiB (set at compile-time in <arch/arch.h>). I've been pondering the idea of making that configurable at run-time on a per-thread basis, as POSIX allows.
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by bogglez »

Seems like they have an object pool on the stack, but the size can be configured.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: 3D physics/collision libraries that work on DC?

Post by bbmario »

Tokamak seems lighter than Bullet, so, i'll start trying to port that. Are there any common caveats when porting libraries to DC?
User avatar
Bouz
DCEmu Junior
DCEmu Junior
Posts: 46
Joined: Mon May 10, 2010 3:42 pm
Location: St. Bauzille de Putois (France)
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by Bouz »

Tvspelsfreak wrote:ODE has been ported over. It's from 2003 though.
http://www.boob.co.uk/devtools.html
DC-ODE is used in DC-Stunt-Racer:
http://dcstuntracer.sourceforge.net/

Here is a video of this little game:
https://www.youtube.com/watch?v=q9EPQCd5ZY8
User avatar
Indiket
DC Developer
DC Developer
Posts: 99
Joined: Sun Sep 05, 2010 5:44 am
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by Indiket »

I did some time ago (2011) a newer ODE quick port to Dreamcast (ODE 0.11.1 with OPCODE).
http://www.dreamcast.es/downloads.php?c ... oad_id=276

It is used in a little homebrew game (Skunks) that I used to test it :)
http://www.dreamcast.es/news.php?readmore=429
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: 3D physics/collision libraries that work on DC?

Post by PH3NOM »

bbmario wrote:Tokamak seems lighter than Bullet, so, i'll start trying to port that. Are there any common caveats when porting libraries to DC?
Tonight, I decided to compile Chipmunk (2D Physics) Engine for DC.
http://en.wikipedia.org/wiki/Physics_engine

I wrote a makefile for dc-kos:

Code: Select all

OBJS = cpVect.o cpSweep1D.o cpSpatialIndex.o cpSpaceStep.o cpSpaceQuery.o
OBJS += cpSpaceHash.o cpSpaceComponent.o cpSpace.o cpShape.o 
OBJS += cpPolyShape.o cpHashSet.o cpCollision.o cpBody.o 
OBJS += cpBBTree.o cpBB.o cpArray.o cpArbiter.o chipmunk.o

OBJS += constraints/cpConstraint.o
OBJS += constraints/cpDampedRotarySpring.o
OBJS += constraints/cpDampedSpring.o
OBJS += constraints/cpGearJoint.o
OBJS += constraints/cpGrooveJoint.o
OBJS += constraints/cpPinJoint.o
OBJS += constraints/cpPivotJoint.o
OBJS += constraints/cpRatchetJoint.o
OBJS += constraints/cpRotaryLimitJoint.o
OBJS += constraints/cpSimpleMotor.o
OBJS += constraints/cpSlideJoint.o

KOS_CFLAGS += -I. -I../include/chipmunk

CFLAGS += -O3 -std=c99

all: libchipmunk.a

libchipmunk.a: $(OBJS)
	$(KOS_AR) rcs libchipmunk.a $(OBJS)

include $(KOS_BASE)/Makefile.rules
Quite simple, really.
I only had to make a modification to cpCollision.c, because the code did not compile as-is.
I simply added the code

Code: Select all

/* DC-KOS Begin (C) PH3NOM 2014 */
#include <malloc.h>
#define alloca(n) memalign(32, n) 
/* End (C) PH3NOM 2014 */
Everything works fine on DC, I tested using some of the provided examples in the Chipmunk source.

However, just because the code compiles for DC, does not necessarily mean the code has been "ported" to the DC.
I see a lot of places in the code that the DC's fast vector math instructions should be implemented instead of the plain C code, for a true "port".
Ayla
DC Developer
DC Developer
Posts: 142
Joined: Thu Apr 03, 2008 7:01 am
Has thanked: 0
Been thanked: 4 times
Contact:

Re: 3D physics/collision libraries that work on DC?

Post by Ayla »

Why is that hack necesary? Including <alloca.h> does not work?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5658
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: 3D physics/collision libraries that work on DC?

Post by BlueCrab »

Also, replacing alloca() with malloc(), memalign(), or anything else of the like will leak all kinds of memory.

That said, as far as I know, <alloca.h> should work fine.
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: 3D physics/collision libraries that work on DC?

Post by PH3NOM »

Right, thanks for that correction.

The only change needed was to #include <alloca.h> on cpCollision.c.

Not sure if it will be that easy with other libs, but I guess that's a start :lol:

But my main point is that for optimized performance of a physics library, some of the code should be re-written to take advantage of the SH4's fast vector math instructions...
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: 3D physics/collision libraries that work on DC?

Post by bbmario »

Does anyone know a port of Box2D? Also, regarding DC's math functions, is there an API doc on them?
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: 3D physics/collision libraries that work on DC?

Post by bogglez »

What kind of physics are you trying to do anyway, just collision or more? How many objects are we talking here?
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: 3D physics/collision libraries that work on DC?

Post by bbmario »

As of Box2D, i was just curious about it's port. Regarding Bullet and Tokamak, i'm looking for simple ball physics since i'm planning to work on a Marble Blast clone.
Post Reply