• Create Account

# JohnnyLightwave

Member Since 11 Jul 2011
Offline Last Active Oct 07 2015 06:31 PM

### Getting the extends of a plane intersection the view frustrum

27 July 2015 - 07:18 AM

Hi all,

I'm trying to get four corner coordinates of a plane, where it is bound in my view frustrum.

As illustrated here:

I want to get the XYZ coordinates of the intersection of the view frustrum with my plane in real space.  The plane is infinite, and always with a normal pointing straight upwards.

Is there an easy way to do this?

### Circle embedded in line-- fastest vector to unembed

19 May 2015 - 06:54 PM

Hi all,

This is for 2D...

Say I have a circle at Point pt, with radius r ...

And I have a line that goes from Point p1 to Point p2.

Assuming the circle is embedded in the line, I want to know-- as fast as possible, without normalizes, etc, if that's even possible-- what direction to push my circle in to unembed it most efficiently.

I currently have a pretty simple method where I do this:

1. Find closest point on line to center of circle

2. Take vector of that to center of circle and normalize it

3. Move circle in that direction.

Is there a faster, math wizardy way?

Thanks!

### Collision/Unembedding/Pushing... and a seemingly impossible case

10 May 2015 - 11:15 AM

Hi all,

I asked a few questions about Box2D a few days ago, and learned a whole lot about how that system works.  As a result of that, for fun and optimization, I'm trying to roll a stripped down system of my own for kicks, learning, and edification... with one enhancement that seems "impossible" in a simultaneous physics simulation.

Impossible is usually a result of looking at things from the wrong perspective!  Show me the other angle!

I want to develop a process where the density of an object, and the object's ability to display another object are two seperate variables.  Every physics simulation I've run into represents their object something like this:

```struct
{
Point        mPosition;
Point        mMoveDirection;
float        mDensity;
}
```

For the purposes of gameplay elements, I want to represent an object like this:

```struct
{
Point        mPosition;
Point        mMoveDirection;
float        mStrength;
float        mWeight;
};
```

Let's further say that:

if ObjectA.mStrength<=ObjectB.mWeight, then ObjectA cannot displace object B.

else if ObjectA.mStrength>=ObjectB.mWeight*10, then ObjectA pushes object B at normal "collision seperation."

else (ObjectA pushes ObjectB at an interpolation between 0*CollisionSeperation and 1*CollisionSeperation).

With those rules in mind, consider a simulation where ObjectA and ObjectB are both in motion, and they end up overlapped after their mMoveDirection has been applied.

The following rules come into play:

I've managed to make the whole simulation work with every condition except the very last one.  It's a problem!

There's two circles that are overlapping, but are NOT allowed to displace eachother.

Can anyone think of how one would resolve this situation?  If one circle is at rest, it's pretty simple, you treat it like one of the conditions where one cannot move the other.  But if both circles are in motion, then their unembed essentially should hold them in place relative to each other-- while still granting them the ability to slide and jostle around eachother as they both push but cannot advance.

(Note that conditions 1 and 2 are really the same as condition 3, just with the midpoint position weighted properly... the equation to get that is incredibly fiddly and I still haven't come up with one that works, but I think it exists)

* * *

I can solve "condition impossible" by making the simulation non-simultaneous-- moving each object one by one, and unembedding it and it alone, and then moving on to the next object.  The speed hit from this is horrible, not to mention you get unfair situations because whoever is higher in the list gets primacy!  So I'm looking for a way to make it simultaneous.

Any ideas?

### Collision System: Question about recursion

06 May 2015 - 06:48 PM

Hi everyone,

I'm sort of asking this out of the blue... it's something I've always wondered.

When doing simultaneous collision, if you have a couple circles and some line segments, and you collide the circles so that their unembedding causes them to be embedded in something else, what do you do?  Do you just wait until the next iteration for it to push out?  Do you change the end-positions of the objects that reacted to the collision and rerun the simulation?  It seems like that would have potential to infinite loop.

Anyway, I just wanted to see what the "correct" way of handing this is.  I wrote one up that's recursion, but when a lot of things get jammed up together it becomes a framerate disaster.  Meanwhile Box2D can collide 500x as many items as mine, in worse situations, and never slows down at all.

### Box-- Absorbing impulse after collide

06 May 2015 - 06:40 PM

Hi all,

I'm trying to get an effect from Box2D.  I have a game that is overhead, basically with all physics turned off, and I'm only using Box2D for collision response.

I have a player character-- represented as a sphere-- and anywhere from 5 to 50 other spheres constantly are converging on him, Robotron style.  The idea of the game is to not get swarmed too badly.

So here's the problem:  I want my player character to get pushed around-- but not too much.  So if I make him very dense, no problem... he doesn't get shoved around by the horde of chasing objects much.

Except: I want the player's pushing power to be very limited!  That is to say, he doesn't have the "strength" to push his way out of the horde.  But with Box2D, when I make him dense enough to not be pushed all over the screen by the pursuing bad guys, he's strong enough to shove them all out of his way without a problem.

What I want to do is sort of break my character's attributes apart... I want everyone to have "density" and "strength."  Density is how heavy you are, strength is how well you can push away someone else's density.  This is also important because my horde of monsters is able to shove their friends out of the way too, so when I try to do some effects like having one pause and "think" it just gets shoved along, because they all have the same density.

I got the idea that I could grab the PostSolve collision impulse and modify it based on the strength, so that the pushing behaves differently... except I can't seem to access the impulse data, and I'm not sure it hasn't already been applied at that point anyway.

Can anyone help?  I'm willing to modify the Box2D code-- in fact, I've been trying to, and I've had very limited success mostly because the collisions are simultaneous and I'm trying to adjust the object's mass on the fly to reflect their strength relative to eachother.  That ain't working out so well.