# Collision Response: game character vs. density function

## Introduction

I am working on my own "novelty" game-engine project, where the world is represented by a continuous density function. It has only one interface, a function that returns the density at a given point:

float sample(float x,float y,float z);

I triangulate this density into an iso-surface for density == 1.0 using marching cubes. The iso-surface is then rendered using OpenGL to display the result on screen.

I have made a function using newton's method to approximate the nearest point in the volume with density equal to 1 (within an error margin) for a certain direction, like this:

vec3d hitTest(vec3d &origin, vec3d &direction);

I can use this to perform collision detection between my main character and the volume, by seeing if the character has transitioned from "outside" to "inside" of the volume during update. I am also able to find the normal at the hit point by doing 3 hit-tests and doing some simple vector math "(a-b).crossProduct(a-c)" or some such.

## Question

How would I be able to calculate the proper collision response?

I am no expert in collision detection/response, so what I am after is a clear and consise explanation of what makes a "physically correct" impulse collision under my foretold circumstances.

Source code in pseudo/C++ is a big bonus!

Thanks!

• I forget to mention, by "main character" i mean a single 3d point. I will have to elaborate my character further, but right now a single point is good enough! Commented Mar 5, 2013 at 11:06