[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math

Search:


View post   

>> No.4722728 [View]
File: 149 KB, 1000x500, 1314093901721.png [View same] [iqdb] [saucenao] [google]
4722728

Ok, I've just about had enough. I'm writing a soft-body simulation in C++ with Opengl and glut. First problem I have is an apparently random "corruption of the heap" if I for instance wanted to change the number of points in a body. Here is some code.

class Point
{
public:
float x,y;
float bx,by;
float InvMass;
float vx,vy;
float bvx,bvy;
float dx,dy;
Point();
Point(int, int );
Point(int, int,float );
};
class Body
{
public:
Point* PointCloud;
Constraint* Constraints;
//Other unimportant things
}

int P=35;
int D=25;
int Ds=(float)sqrt((double)D);
int S=4;

Body Scen0Bodies[MAX_BODIES]=
{Body(D,2*Ds*(Ds-1)+(Ds-1)*(Ds-1)*2,4*(4((Ds1))-4)),
Body(4,6),Body(4,4),Body(P+2,15*(P+2-1)/2,(P+2-1)*2)};


The problem I have here is that I get the "corrupted heap" error if I try to set a P greater than 35. If I lower D to 16 I can add another 2 onto P however for D=9 every value of P will trigger corrupted heap. I'm not too informed on pointers so there might be some size limitations I am overlooking.

Another problem, probably related to this is that my simulation randomly and abruptly changes the values of a certain object's attributes to something insane leading to an unstable simulation; This problem is probably related to the above in some way, either directly or through my lack of programming skill.

I will post the full compile-able source if any brave soul wishes to dive into it.

>> No.4155564 [View]
File: 149 KB, 1000x500, 1308628854812.png [View same] [iqdb] [saucenao] [google]
4155564

>>4155554
So now you have to carry around even more crap?

>> No.3676150 [View]
File: 149 KB, 1000x500, 1313696588427.png [View same] [iqdb] [saucenao] [google]
[ERROR]

>>3676147
>>>/x/

>> No.3145156 [View]
File: 149 KB, 1000x500, 1304209747260.png [View same] [iqdb] [saucenao] [google]
3145156

>>3144949
>witty
>puns

Navigation
View posts[+24][+48][+96]