Difference between revisions of "PhysPreset Asset"

From COD Engine Research
Jump to: navigation, search
(Advanced Warfare)
(Black Ops 1 & 2)
Line 53: Line 53:
 
== Black Ops 1 & 2 ==
 
== Black Ops 1 & 2 ==
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 +
enum PhysPresetScaling
 +
{
 +
  PHYSPRESET_SCALING_LINEAR = 0x0,
 +
  PHYSPRESET_SCALING_QUADRATIC = 0x1,
 +
  PHYSPRESET_SCALING_COUNT = 0x2,
 +
};
 +
 
#pragma pack(push, 4)
 
#pragma pack(push, 4)
 
struct PhysPreset
 
struct PhysPreset
Line 66: Line 73:
 
   float piecesSpreadFraction;
 
   float piecesSpreadFraction;
 
   float piecesUpwardVelocity;
 
   float piecesUpwardVelocity;
   int bCanFloat;
+
   float minMomentum;
   float gravityScale;
+
   float maxMomentum;
   float massOffset[3];
+
   float minVolume;
   float buoyancyMin[3];
+
   float maxVolume;
   float buoyancyMax[3];
+
   float minPitch;
 +
  float maxPitch;
 +
  PhysPresetScaling volumeType;
 +
  PhysPresetScaling pitchType;
 +
  bool tempDefaultToCylinder;
 +
  bool perSurfaceSndAlias;
 +
};
 
};
 
};
 
#pragma pack(pop)
 
#pragma pack(pop)
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
== Modern Warfare 3 ==
 
== Modern Warfare 3 ==
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">

Revision as of 00:41, 21 December 2014

The PhysPreset asset controls the settings on dynamic objects. Any environmental object that moves from a gunshot or explosion has a physpreset to handle the force. The physpreset has existed in every CoD from the earliest Call of Duty 4 Alpha all the way to Ghosts, and it has changed very little.

Call of Duty 4 & Modern Warfare 2

#pragma pack(push, 4)
struct PhysPreset
{
  const char *name;
  int type;
  float mass;
  float bounce;
  float friction;
  float bulletForceScale;
  float explosiveForceScale;
  const char *sndAliasPrefix;
  float piecesSpreadFraction;
  float piecesUpwardVelocity;
  bool tempDefaultToCylinder;
};
#pragma pack(pop)

Type

The type has never been identified. Changing it appears to alter nothing, and there are no instances of it being used.

World at War

#pragma pack(push, 4)
struct PhysPreset
{	
  const char *name;
  int type;
  float mass;
  float bounce;
  float friction;
  float bulletForceScale;	
  float explosiveForceScale;	
  const char *sndAliasPrefix;	
  float piecesSpreadFraction;	
  float piecesUpwardVelocity;	
  int bCanFloat;	
  float gravityScale;
};
#pragma pack(pop)

Black Ops 1 & 2

enum PhysPresetScaling
{
  PHYSPRESET_SCALING_LINEAR = 0x0,
  PHYSPRESET_SCALING_QUADRATIC = 0x1,
  PHYSPRESET_SCALING_COUNT = 0x2,
};
 
#pragma pack(push, 4)
struct PhysPreset
{	
  const char *name;
  int type;
  float mass;
  float bounce;
  float friction;
  float bulletForceScale;
  float explosiveForceScale;
  const char *sndAliasPrefix;
  float piecesSpreadFraction;
  float piecesUpwardVelocity;
  float minMomentum;
  float maxMomentum;
  float minVolume;
  float maxVolume;
  float minPitch;
  float maxPitch;
  PhysPresetScaling volumeType;
  PhysPresetScaling pitchType;
  bool tempDefaultToCylinder;
  bool perSurfaceSndAlias;
};
};
#pragma pack(pop)

Modern Warfare 3

#pragma pack(push, 4)
struct PhysPreset
{	
  const char *name;	
  int type;	
  float mass;
  float bounce;
  float friction;	
  float bulletForceScale;	
  float explosiveForceScale;	
  const char *sndAliasPrefix;	
  float piecesSpreadFraction;	
  float piecesUpwardVelocity;
  int unknowns[7];
};
#pragma pack(pop)

Ghosts

#pragma pack(push, 4)
struct PhysPreset
{	
  const char *name;	
  int type;	
  float mass;
  float bounce;
  float friction;	
  float bulletForceScale;	
  float explosiveForceScale;	
  const char *sndAliasPrefix;	
  float piecesSpreadFraction;	
  float piecesUpwardVelocity;
  int unknowns[9];
};
#pragma pack(pop)

Advanced Warfare

#pragma pack(push, 4)
struct PhysPreset
{	
  const char *name;	
  int type;	
  float mass;
  float bounce;
  float friction;	
  float bulletForceScale;	
  float explosiveForceScale;
  char unknown[4];
  const char *sndAliasPrefix;	
  float piecesSpreadFraction;	
  float piecesUpwardVelocity;
  int unknowns[9];
};
#pragma pack(pop)

Source Format

The physpreset source files are raw text files with no extension, located at "raw/physic/". They use the same format as many other assets, with each setting name and value separated by a back-slash. The first setting identifies the file, and for physpreset the identifier string is "PHYSIC". PhysPresets are unique because they're the only asset found so far with a setting in the source that doesn't have a setting in the asset. The physpreset source files include an extra setting, "isFrictionInfinity", a bool (At least on IW games, on Treyarch games it has been added). If it is 1, then the source file's friction will say it is 0.5, but once compiled the actual friction will be 340282346638528860000000000000000000000. For example, here is the CoD4 source for "brick" found at "raw/physic/brick".

PHYSIC\sndAliasPrefix\physics_brick\mass\5\friction\0.5\isFrictionInfinity\0\bounce\0.3\bulletForceScale\0.6\explosiveForceScale\0.12\piecesSpreadFraction\0\piecesUpwardVelocity\0\tempDefaultToCylinder\0