Bug 4976 - C++ism in tr_model_iqm.c
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Platform
Version: GIT MASTER
Hardware: All All
: P3 major
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2011-05-04 13:36 EDT by Eugene C.
Modified: 2011-05-05 09:34:09 EDT
1 user (show)

See Also:


Attachments
iqm2.diff (11.91 KB, patch)
2011-05-04 17:06 EDT, gimhael
iqm2.diff (14.71 KB, patch)
2011-05-05 01:21 EDT, gimhael

Description Eugene C. 2011-05-04 13:36:01 EDT
There is constructions like dymamic arrays

float mat[data->num_joints * 12];

Also declarations like

....
rotW = -SQRTFAST(1.0f - rotW);

float xx = 2.0f * joint->rotate[0] * joint->rotate[0];
float yy = 2.0f * joint->rotate[1] * joint->rotate[1];
....

Which is just rejected by MSVC
Comment 1 gimhael 2011-05-04 17:06:10 EDT
Created attachment 2689 [details]
iqm2.diff

Well, they those constructions are officially part of the C standard for over 10 years, but I guess Microsoft still prefers to make it's own standards.

Anyway, here is a patch that should fix these constructs and also adds some features I missed in the first patch, like fog and shadow support.
Comment 2 Thilo Schulz 2011-05-04 17:55:06 EDT
Dynamic arrays are part of the C99 standard, as well as inline variable declaration. Maybe one has to switch C99 on in MSVC?

Nevertheless, gimhael: I'd like to manage without the memory allocation call. For MD4/MDR there's a hard limit on the number of bones. Couldn't we simply impose such a limit on the number of joints and then declare the needed space statically?
Comment 3 gimhael 2011-05-05 01:21:09 EDT
Created attachment 2690 [details]
iqm2.diff

New patch using a static array for the bone matrices.
Comment 4 Thilo Schulz 2011-05-05 09:34:09 EDT
Thank you! Committed r1962

I moved the temp buffers to the local function stack, seems a bit better when it comes to memory footprint to me.