« first day (2865 days earlier)      last day (2145 days later) » 

11:10 AM
QVector3D LMOpenGLWidget::generateDirection() const
{
static std::random_device rd{};
static std::mt19937 gen{ rd() };
std::normal_distribution<float> normal_dist;

// Generate direction.
QVector3D direction(normal_dist(gen), normal_dist(gen), normal_dist(gen));

return direction.normalized();
}
@Tyyppi_77 that's my generating method we talked yesterday
 
user92578
looks good
 
user92578
just out of curiosity, what's the Q prefix for?
 
its qt
 
user92578
ah
 
maybe i should the normal distrubution do als static
but anyway it solved my problem and it works good...so thx
 
user92578
11:18 AM
glad to hear that
 
11:36 AM
the next problem what i want to solve: i have a red dot in my application as cursor which i control with my index finger. to press a menu button the dot as indicator goes over the button...the button timer is startet and after running out the action is executed. the timer will not interrupted as long the dot is over the button....so i emulate a hover effect. what i now want to achieve, to indicatie to the user how long he has to wait to press the button.
maybe through the coloring of the dot depending on the time he has to wait
 
user92578
I would do a circular bar that fills up
 
sounds good but realization is the thing
 
user92578
11:53 AM
what?
 
1:43 PM
@DMGregory The same as how you would get the x-axis on an aabb
 
user92578
what x-axis? are you talking about the width?
 
user92578
makes no sense
 
user92578
also wtf is going on with the stars again
 
There are a lot of things we could measure along an x-axis, so it's helpful to be precise with descriptions.
 
@DMGregory A projection of the sphere along the x-axis
that is what i am talking about
 
user92578
1:47 PM
its not you who is starring the random messages is it?
 
@TheMaskedRebel ie. the range from sphere.centerPosition.x - sphere.radius to sphere.centerPosition.x + sphere.radius - right?
 
@DMGregory Ah yes but infinite
 
user92578
wat
 
"infinite" is another one of those words that can mean lots of things depending on the context. Can you tell us what you're trying to do?
 
@DMGregory BoxPruning
 
1:59 PM
So you're trying to decide whether to do further collision checks with a sphere, based on its bounding box? Where are you encountering infinities in this situation?
 
@DMGregory Yes DMGregory that is what I want
 
Note that sphere checks are so simple, you'll rarely save much if anything by checking their AABB first. That's a step we usually use only for more complicated colliders like oriented boxes or meshes, unless it's required as part of your broadphase.
 
@DMGregory It is required
my broadphase implements a BubbleSort algorithm and it needs to sort by x-axis @DMGregory
 
Okay, we'll come back to the choice of sorting algorithm later, I think... for now, the example above gives you everything you need to sort the interval along the x-axis.
Where does the "infinite" come in?
 
2:15 PM
@DMGregory That was just a misunderstanding. Thanks DMGregory
 
2:33 PM
is there a question on gamedev about frustum culling with a sphere
 
I mean... did you try literally keying frustum and sphere into the search box to check?
 
1
Q: Fast exact frustum culling for sphere

PrisGiven a view frustum and a sphere, how do I exactly determine whether or not the sphere intersects the frustum? The typical way of checking a sphere against a frustum finds the signed distance of the sphere center from each frustum plane, but this isn't an exact test and will sometimes fail: ...

 
3:05 PM
please may someone review my code.
	public boolean isInBounds(Entity entity) {
			Sphere s = entity.getSphere();
			Vector4f center = new Vector4f(s.getCenter().x,s.getCenter().y,s.getCenter().z,1);
			for(Vector4f plane : coeficients){
				if(Vector4f.dot(center, plane) <= -s.getRadius()) return false;
			}
			return true;
		}
 
I presume your plane is stored as a unit normal in the x, y, z, and the distance to the origin along that direction in the w?
This will count as "in bounds" a sphere that's juuuust slightly outside the corner of the frustum, but that may or may not be a problem for your application.
 
		private void setCooeficients(Matrix4f a) {
			coeficients[0] = new Vector4f(a.m00 + a.m03, a.m10 + a.m13, a.m20 + a.m23, a.m30 + a.m33);
			coeficients[0] = new Vector4f(a.m00 + a.m03, a.m10 + a.m13, a.m20 + a.m23, a.m30 + a.m33);
			coeficients[1] = new Vector4f(-a.m00 + a.m03, -a.m10 + a.m13, -a.m20 + a.m23, -a.m30 + a.m33);
			coeficients[2] = new Vector4f(a.m01 + a.m03, a.m11 + a.m13, a.m21 + a.m23, a.m31 + a.m33);
			coeficients[3] = new Vector4f(-a.m01 + a.m03, -a.m11 + a.m13, -a.m21 + a.m23, -a.m31 + a.m33);
 
user92578
coeficients -> coefficients
 
user92578
do Vector3 sphereCenter = s.getCenter() too
 
private Vector4f[] coeficients= new Vector4f[6];
 
user92578
3:12 PM
setCooeficients -> setCoefficients
 
user92578
that looks pretty awful though
 
user92578
but if it's correct, meh
 
Why do you set coefficients[0] twice?
 
@DMGregory A mistake
 
user92578
also a is a terrible name for the matrix
 
3:18 PM
@Tyyppi_77 changed it
 
I'm betting this is coming from a view projection matrix?
 
@DMGregory setCooeficients(Matrix4f.mul(camera.createProjectionMatrix(),Maths.createViewMa‌​trix(camera),null));
the view matrix and the projection matrix is multiplied together
 
Making what's commonly called a view projection matrix, yes.
 
user92578
^
 
@TheMaskedRebel, your edit to your bounding sphere question is a little confusing.
Originally you'd argued that the question was not a duplicate of the previous one, because you needed to guarantee you got the smallest such sphere.
Now you've edited it to ask for approximations, ie. spheres that aren't necessarily the smallest. So that brings it back to the original duplicate.
 
3:24 PM
@DMGregory Ill look at it
@DMGregory edited question
 
In that case I don't think the answer you gave satisfies the criterion of "finds the smallest sphere in most cases," since as Pikalek points out it generates the wrong sphere for regular polygons & polyhedra.
 
here is the improved code
	public boolean isInBounds(Entity entity) {
			Sphere s = entity.getSphere();
			Vector3f sphereCenter = s.getCenter();

			float radius = s.getRadius();

			Vector4f center = new Vector4f(sphereCenter.x,sphereCenter.y,sphereCenter.z,1);
			for(Vector4f plane : coeficients){
				if(Vector4f.dot(center, plane) >= radius) return false;
			}
			return true;
		}
 
user92578
might as well call s as a sphere
 
maybe I should switch the returns around.
like this
`	public boolean isInBounds(Entity entity) {
			Sphere sphere = entity.getSphere();
			Vector3f sphereCenter = sphere.getCenter();

			float radius = sphere.getRadius();

			Vector4f center = new Vector4f(sphereCenter.x,sphereCenter.y,sphereCenter.z,1);
			for(Vector4f plane : coeficients){
				if(Vector4f.dot(center, plane) <= radius) return true;
			}
			return false;
		}
 
maybe it would be better to stop randomly trying stuff and asking if it's right
 
user92578
3:37 PM
I'd prefer the other way around
 
user92578
^ what almo said
 
@Almo To be fair, this isn't random. There's a clear logic to this method.
 
if you say so.
 
user92578
can mods see who starred stuff?
 
I don't think they can
 
3:42 PM
@TheMaskedRebel No, switching the return values is not correct. You know the sphere is out of bounds if it's outside ANY plane of the frustum, but you don't know if it's inside the bounds until (at minimum) you know it's on the inside of EVERY plane.
 
@DMGregory I see
 
eg. If it's between the near plane and far plane, but ten billion kilometers off-screen to the left, it should fail the test, not pass. ;)
I think the way you're normalizing the coefficient rows might not be correct. I haven't worked out the full math yet, but it has my spidey sense tingling.
 
@DMGregory I copied the code from a stackoverflow post a year ago
or maybe less
 
user92578
well then theres no way its incorrect
 
I think it preserves the sidedness test (so positive is outside, negative inside, zero is on the plane), but does not preserve the magnitude (so the dot product result is no longer directly comparable to the radius)
 
3:46 PM
about 6 months :P
@DMGregory So what is the correct way
 
In the StackOverflow post, was it being used as a point-in-frustum test, or was it being used to compare against a sphere radius as you're using it for here?
 
@DMGregory I'm not sure, but I was doing point in frustum before I moved on to spheres and aabb's so the post was probably (?) point in frustum.
 
The difference won't matter for points, but it can make a difference when you want to compare against a distance value. Double-checking my hunch now...
 
user92578
Does this happen to be the post? stackoverflow.com/questions/19982798/…
 
@Tyyppi_77 yup
 
user92578
3:53 PM
yeah so you thought that copying code from a question was a good idea?
 
user92578
it's broken code
 
user92578
that's why he asked the question
 
@Tyyppi_77 It worked
 
user92578
suuuuuure
 
It's not unusual for code in a question to work for some cases - but usually it fails for some important case the asker cared about.
 
3:54 PM
the problem was not with the coefficients it was in his method to check is the sphere was in the frustum
 
user92578
wait so you've solved the issue(s)?
 
I don't see any mention of a sphere on that page...
 
@DMGregory There isn't, its point in frustum code
 
So who is "he" in this phrase? "the problem was not with the coefficients it was in his method to check is the sphere was in the frustum"
Anyway, for the dot product vs radius check you're doing, I think you'll want each vector of plane coefficients to be composed like this: (n.x, n.y, n.z, - dot(n, p)) where n is an outward-pointing unit normal to the plane, and p is a point on the plane.
 
@DMGregory Sorry i meant point in frustum
 
4:00 PM
What was the problem with that method?
The reason for this change to the coefficients is so that dot(sphereCenter, (n.x, n.y, n.z, - dot(n, p)) ) will give you the signed distance of the sphere from the plane, in worldspace units, so you can directly compare it against the sphere's radius.
 
@DMGregory My method:
public boolean isInBounds(final Vector3f point) {
			  final Vector4f v = new Vector4f(point.x,point.y,point.z,1);
			  for (int i = 0; i < 6; i++) {
			        float value = Vector4f.dot(coeficients[i],v);
			        if (value < 0.0f) {
			            return true;
			        }
			    }

			    return false;

		}
@DMGregory his method:
public boolean contains(final Vector4f v) {
    for (int i = 0; i < 6; i++) {
        float value = Vector4f.dot(coefficients[i], v);
        if (value < 0.0f) {
            return false;
        }
    }

    return true;
}
@jondoe3 are you new here
 
user92578
he wont be able to answer you
 
@Tyyppi_77 Why??
 
user92578
he doesnt have the reputation
 
if someone has 1 rep and they suffer a serries of lowering rep events do they get minus rep
 
4:14 PM
No, rep is capped.
@TheMaskedRebel I explained to you above why flipping the return values is not appropriate in this case.
 
@DMGregory I know, but I don't use that method anymore
 
....so why did you post it if it's not what you're using?
 
@DMGregory Because it worked for me when I was using it
 
Then you didn't test it sufficiently, because it has some clear flaws.
Going AFK for a bit. Good luck all, in the meantime. :)
 
Does anyone have github code for collision detection. AABB vs AABB
 
user92578
4:24 PM
that's very easily googlable but if you want to I can share my code
 
yes please @Tyyppi_77
 
user92578
bool CBoundingBox::Collide(const CBoundingBox* other) const
{
	if (m_Max.X <= other->m_Min.X ||
		m_Max.Y <= other->m_Min.Y ||
		m_Min.X >= other->m_Max.X ||
		m_Min.Y >= other->m_Max.Y)
	{
		return false;
	}
	return true;
}
 
@Tyyppi_77 Thanks. I had that exact same code but it was not working. I solved it by doing this.
 
user92578
like i have no idea what you are talking about, this code works just fine
 
Does anyone know an algorithm about how to cull a sphere @DMGregory said that spheres didn't need culing but the minuite i ran my game it crashed becausethey where too many spheres for it to handle
 
user92578
4:29 PM
how does that result in a crash?
 
@Tyyppi_77 The game was stuck on one for loop
 
user92578
that's a bug in the for loop then
 
for(int i = 1;i < objects.size();i++) {
			for(int j = 0; j<objects.size();j++) {

					Entity entity = objects.get(i);
					Entity id1 = objects.get(j);
                   if(!(entity.isStaticObject() && id1.isStaticObject())) {
                	   CollsionInfo[] info = checkFullCollision(entity, id1);

                	   if(info != null) {
                		   addCollisionInfo(info);
                	   }

                }
             }
		}
 
user92578
what is the crash message? how many spheres?
 
user92578
and now I assume we are talking about world space partitioning culling, not rendering culling?
 
4:33 PM
@Tyyppi_77 Collision detection
and no message the for loop just kept looping
 
user92578
yeah so cutting down potential collisions?
 
user92578
@TheMaskedRebel that's not possible since that's not an infinite list
 
@Tyyppi_77 It's what happened. I am very confused
 
user92578
figure out what's up
 
user92578
break there, check out the index values etc.
 
user92578
4:35 PM
and how many spheres did you have?
 
user92578
cool
 
@Tyyppi_77 not enough to freeze the game
 
user92578
what? you just said that it crashes?
 
user92578
give me a number
 
user92578
4:39 PM
THERE MUST BE A FIXED AMOUNT OF OBJECTS AT A GIVEN MOMENT IN THE SYSTEM
 
user92578
there's no reason why you couldn't give me a number
 
user92578
anyways this is shit that I can't help you with, you just need to debug the code, figure out what loop doesn't stop, why, how many objects there are, why is that amount of objects an issue and then figure stuff out
 
@Tyyppi_77 that is how many maximum objects I have
0 min
 
user92578
that is not the number of objects
 
user92578
200*200 is not too many iterations for the code to freeze
 
user92578
4:41 PM
how do you know that that's the for loop that freezes?
 
wait a sec...
@Tyyppi_77 because it works fine when I comment out the for loop
 
user92578
what does checkFullCollision do?
 
private CollsionInfo[] checkFullCollision(Entity entity, Entity id1) {
		CollsionInfo info = entity.getSphere().isColliding(id1.getSphere());
		CollsionInfo info1 = id1.getSphere().isColliding(entity.getSphere());

		return new CollsionInfo[]{info,info1};
	}
 
user92578
but yeah setup breakpoints or log stuff and figure out where it gets stuck
 
4:57 PM
 
user92578
wtf is that
 
friends and heroes
 
user92578
and why did you post that here?
 
@TheMaskedRebel No, I did not say that spheres don't need culling. I said that spheres don't need bounding box checks, since a bounding sphere check is even simpler, and a sphere is its own bounding sphere.
 
@DMGregory So how do you cull bounding spheres
 
user92578
5:12 PM
seriously I'd like to know why you posted that, otherwise I will interpret that you're spamming some christian propaganda and I will flag that
 
@Tyyppi_77 Type the masked rebel on google
 
user92578
I did see the link you shared the other day, that still doesn't answer my question.
 
@Tyyppi_77 because i like friends and heroes
 
user92578
I don't feel like a random screenshot of a show you like belongs in a gamedev chat randomly.
 
@TheMaskedRebel Are you asking about culling for rendering? If so, the frustum checks you were showing were on the right track. Or if you're asking about broadphase collision checks, a spatial partition can help, or sweep-and-prune, etc.
At the broad phase, you're usually not using logic specific to the shape type.You're just isolating small clumps of "stuff that might collide" before you go deeper to check their actual collision shapes against one another.
So you won't really find much about "broad phase collision for spheres" - these approaches usually just treat everything as spheres or AABBs.
 
5:21 PM
🛎️
@DMGregory I was sorting everything by the x-axis, so everything that crossed the x-axis was ripe for collision
 
Sounds like Sweep and Prune / Sort and Sweep
 
@DMGregory it is a very simple version of it, that is why I was asking how to get the x-axis of a sphere defined center, radius.
 
So, it sounds like you solved that problem. What are you stuck on now?
 
@DMGregory I haven't solved it I'm just doing a brute force check for now
 
So you gave up on the axis sweep?
 
5:30 PM
@DMGregory I just didn't know how to do it with sphere's
 
The shape doesn't matter. All you need is the min and max along an axis, which you have.
 
i need to go afk see you tomorrow
@DMGregory I only have center and radius
 
Right, and I showed you above that center.x - radius is the min, and center.x + radius is the max.
You can also draw it on a sheet of graph paper to confirm.
 
@DMGregory thanks
I have another problem but it can wait til tommorow
@Tyyppi_77 gamedev site is for sharing stuff you love and I love that show and I wanna share it
 
@TheMaskedRebel Please try to stick close to the core topic of game development, or at least related to where the conversation is wandering.
3
 
user92578
5:51 PM
@TheMaskedRebel nope
 

« first day (2865 days earlier)      last day (2145 days later) »