r952 - trunk/code/botlib
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Oct 25 17:20:55 EDT 2006
Author: thilo
Date: 2006-10-25 17:20:55 -0400 (Wed, 25 Oct 2006)
New Revision: 952
Modified:
trunk/code/botlib/be_ai_weight.c
Log:
Fix weight interpolation thanks to cyrri
Modified: trunk/code/botlib/be_ai_weight.c
===================================================================
--- trunk/code/botlib/be_ai_weight.c 2006-10-23 15:18:05 UTC (rev 951)
+++ trunk/code/botlib/be_ai_weight.c 2006-10-25 21:20:55 UTC (rev 952)
@@ -593,9 +593,12 @@
if (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child);
else w2 = fs->next->weight;
//the scale factor
- scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
+ if(fs->next->value == MAX_INVENTORYVALUE) // is fs->next the default case?
+ return w2; // can't interpolate, return default weight
+ else
+ scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
//scale between the two weights
- return scale * w1 + (1 - scale) * w2;
+ return (1 - scale) * w1 + scale * w2;
} //end if
return FuzzyWeight_r(inventory, fs->next);
} //end else if
@@ -627,9 +630,12 @@
if (fs->next->child) w2 = FuzzyWeight_r(inventory, fs->next->child);
else w2 = fs->next->minweight + random() * (fs->next->maxweight - fs->next->minweight);
//the scale factor
- scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
+ if(fs->next->value == MAX_INVENTORYVALUE) // is fs->next the default case?
+ return w2; // can't interpolate, return default weight
+ else
+ scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
//scale between the two weights
- return scale * w1 + (1 - scale) * w2;
+ return (1 - scale) * w1 + scale * w2;
} //end if
return FuzzyWeightUndecided_r(inventory, fs->next);
} //end else if
More information about the quake3-commits
mailing list