Adding variables to physics entites, and crash

Grab your favourite IDE and tinker with the innards of game engines

Adding variables to physics entites, and crash

Postby chillok on Mon Sep 27, 2010 7:21 pm

Right, I want to add variables (which represent a state) to entity's. These will be changed based on certain events which happen.

tagged with // chx

I have done this so far:


Code: Select all
struct objectparams_t
{
   Vector      *massCenterOverride;
   int         magnet; //chx
   float      mass;
   float      inertia;
   float      damping;
   float      rotdamping;
   float      rotInertiaLimit;
   const char   *pName;            // used only for debugging
   void      *pGameData;
   float      volume;
   float      dragCoefficient;
   bool      enableCollisions;
};


Code: Select all
const objectparams_t g_PhysDefaultObjectParams =
{
   NULL,
   0, // chx - magnet
   1.0, //mass
   1.0, // inertia
   0.1f, // damping
   0.1f, // rotdamping
   0.05f, // rotIntertiaLimit
   "DEFAULT",
   NULL,// game data
   0.f, // volume (leave 0 if you don't have one or call physcollision->CollideVolume() to compute it)
   1.0f, // drag coefficient
   true,// enable collisions?
};


Which create the params and their default values.

(Also added the getters and setters:)

virtual void SetMagnet( int magnet ) = 0;
virtual int GetMagnet( void ) const = 0;

Now, this is all I added. It builds fine.
When you load the level, I think it calls these but then overrides the values based on a script/code. The game then crashes.

Does anyone have any insight into this shiz?
chillok
Dumpling
Dumpling
 
Joined: Mon Sep 27, 2010 7:11 pm

Re: Adding variables to physics entites, and crash

Postby zombie@computer on Mon Sep 27, 2010 9:48 pm

cant you debug? sure youve overridden the virtual functions?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Adding variables to physics entites, and crash

Postby chillok on Mon Sep 27, 2010 11:37 pm

I hit debug, up comes HL2: Ep , i load a map, crash.

In the dump, it shows me the line, specifically a value which points to the above code (mm, indirectly).

See I dont wish to override anything, I'm attempting to add my own values.


Thanks for reply =D
chillok
Dumpling
Dumpling
 
Joined: Mon Sep 27, 2010 7:11 pm

Re: Adding variables to physics entites, and crash

Postby zombie@computer on Tue Sep 28, 2010 4:18 pm

well, what line in the code? to me its totally unclear what you are trying to do...
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Adding variables to physics entites, and crash

Postby chillok on Wed Sep 29, 2010 11:22 am

Sorry, it was the &params variable which was breaking it, which is the struct above which was initialised.

Regardless, I took a different approach and started using the baseentity class, and it works fine.


[For clarity, what I was trying to do is add a variable to the entities/physicsentity and be able to access/mutate it.]
chillok
Dumpling
Dumpling
 
Joined: Mon Sep 27, 2010 7:11 pm

Return to Programming

Who is online

Users browsing this forum: No registered users