.float csqcmodel_lerpfractime;
.float csqcmodel_lerpfrac2time;
-void CSQCModel_InterpolateAnimation_PreNote(float sf)
+void CSQCModel_InterpolateAnimation_2To4_PreNote(float sf)
{
-#ifdef CSQCMODEL_HAVE_TWO_FRAMES
if(sf & CSQCMODEL_PROPERTY_FRAME)
{
self.frame3 = self.frame;
self.csqcmodel_lerpfrac2time = self.csqcmodel_lerpfractime;
self.lerpfrac = self.csqcmodel_lerpfrac;
}
-#else
+}
+void CSQCModel_InterpolateAnimation_1To2_PreNote(float sf)
+{
if(sf & CSQCMODEL_PROPERTY_FRAME)
{
self.frame2 = self.frame;
self.frame2time = self.frame1time;
}
+}
+void CSQCModel_InterpolateAnimation_PreNote(float sf)
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+ CSQCModel_InterpolateAnimation_2To4_PreNote(sf);
+#else
+ CSQCModel_InterpolateAnimation_1To2_PreNote(sf);
#endif
}
-void CSQCModel_InterpolateAnimation_Note(float sf)
+void CSQCModel_InterpolateAnimation_2To4_Note(float sf, float set_times)
{
-#ifdef CSQCMODEL_HAVE_TWO_FRAMES
if(sf & CSQCMODEL_PROPERTY_FRAME)
{
- self.frame1time = time;
+ if(set_times)
+ self.frame1time = time;
}
if(sf & CSQCMODEL_PROPERTY_FRAME2)
{
- self.frame2time = time;
+ if(set_times)
+ self.frame2time = time;
}
if(sf & CSQCMODEL_PROPERTY_LERPFRAC)
{
self.csqcmodel_lerpfrac = self.lerpfrac;
- self.csqcmodel_lerpfractime = time;
+ if(set_times)
+ self.csqcmodel_lerpfractime = time;
}
-#else
+}
+void CSQCModel_InterpolateAnimation_1To2_Note(float sf, float set_times)
+{
if(sf & CSQCMODEL_PROPERTY_FRAME)
{
- self.frame1time = time;
+ if(set_times)
+ self.frame1time = time;
}
+}
+void CSQCModel_InterpolateAnimation_Note(float sf)
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+ CSQCModel_InterpolateAnimation_2To4_Note(sf, FALSE);
+#else
+ CSQCModel_InterpolateAnimation_1To2_Note(sf, FALSE);
#endif
}
-void CSQCModel_InterpolateAnimation_Do()
+void CSQCModel_InterpolateAnimation_2To4_Do()
{
-#ifdef CSQCMODEL_HAVE_TWO_FRAMES
if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
{
self.lerpfrac = self.csqcmodel_lerpfrac;
self.frame3time = 0;
}
}
-#else
+}
+void CSQCModel_InterpolateAnimation_1To2_Do()
+{
if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
{
self.lerpfrac = 0;
else
self.lerpfrac = 1 - bound(0, (time - self.frame1time) / autocvar_cl_lerpanim_maxdelta_framegroups, 1);
}
+}
+void CSQCModel_InterpolateAnimation_Do()
+{
+#ifdef CSQCMODEL_HAVE_TWO_FRAMES
+ CSQCModel_InterpolateAnimation_2To4_Do();
+#else
+ CSQCModel_InterpolateAnimation_1To2_Do();
#endif
}
entity CSQCModel_server2csqc(float pl);
.float csqcmodel_teleported;
+
+// this is exported for custom frame animation code. Use with care.
+// to update frames, first call this:
+void CSQCModel_InterpolateAnimation_2To4_PreNote(float sf);
+void CSQCModel_InterpolateAnimation_1To2_PreNote(float sf);
+// then update frame, frame1time (and possibly frame2, frame2time, lerpfrac)
+// if set_times is not set, caller is responsible for frame1time, frame2time, csqcmodel_lerpfractime!
+void CSQCModel_InterpolateAnimation_2To4_Note(float sf, float set_times);
+void CSQCModel_InterpolateAnimation_1To2_Note(float sf, float set_times);
+// to retrieve animation state, call this
+void CSQCModel_InterpolateAnimation_2To4_Do();
+void CSQCModel_InterpolateAnimation_1To2_Do();
+// will overwrite lerpfrac, lerpfrac3, lerpfrac4, and possibly clear frame*time if they are undisplayed according to lerpfracs