HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
channel.C
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #include <string.h>
29 #include <malloc.h>
30 #include <math.h>
31 #include <UT/UT_DSOVersion.h>
32 #include <EXPR/EXPR.h>
33 #include <OP/OP_Director.h>
34 #include <CH/CH_Support.h>
35 #include <CH/CH_Channel.h>
36 #include <CMD/CMD_Manager.h>
37 
38 
39 static void
40 getTimeValues(int thread,
41  fpreal &t, fpreal &t0, fpreal &t1, fpreal &v0, fpreal &v1,
42  fpreal *m0=0, fpreal *m1=0, fpreal *a0=0, fpreal *a1=0)
43 {
44  // Get the current time and the values for the function
45  CH_Channel::getGlueTime(t, t0, t1, v0, v1, thread);
46 
47  // Now, get the slope & accell
48  if (m0 || m1 || a0 || a1)
49  CH_Channel::getGlueSlope(m0, m1, a0, a1, thread);
50 }
51 
52 #ifndef EV_START_FNNA
53 #define EV_START_FNNA(name) \
54  static void name(EV_FUNCTION *, EV_SYMBOL *result, \
55  EV_SYMBOL **, int thread)
56 #endif // EV_START_FNNA
57 
58 EV_START_FNNA(fn_myLinear)
59 {
60  fpreal t, t0, t1, v0, v1;
61  fpreal dt;
62 
63  getTimeValues(thread, t, t0, t1, v0, v1);
64  dt = t1 - t0;
65  result->value.fval = (dt == 0) ? (v0+v1)*0.5F
66  : v0 + (v1-v0)*(t - t0)/dt;
67 }
68 
69 #define EVF EV_TYPEFLOAT
70 #define EVS EV_TYPESTRING
71 #define EVV EV_TYPEVECTOR
72 
73 //
74 // These flags are important so that JIVE will display the correct handles for
75 // the curve.
76 #define VAL_FLAGS (CH_EXPRVALUE)
77 #define VALSLOPE_FLAGS (CH_EXPRVALUE | CH_EXPRSLOPE)
78 
79 static EV_FUNCTION funcTable[] = {
80  EV_FUNCTION(VAL_FLAGS, "myLinear", 0, EVF, 0, fn_myLinear),
81  EV_FUNCTION(),
82 };
83 
84 void
86 {
87  int i;
88 
89  for (i = 0; funcTable[i].getName(); i++)
90  ev_AddFunction(&funcTable[i]);
91 }
const char * getName() const
Definition: EXPR.h:249
static void getGlueTime(fpreal &t, fpreal &t0, fpreal &t1, fpreal &v0, fpreal &v1, int thread)
Definition: CH_Channel.h:1149
#define EV_START_FNNA(name)
Definition: channel.C:53
#define VAL_FLAGS
Definition: channel.C:76
png_uint_32 i
Definition: png.h:2877
void CMDextendLibrary(CMD_Manager *)
Definition: channel.C:85
#define EVF
Definition: channel.C:69
EXPR_API void ev_AddFunction(EV_FUNCTION *func)
GLfloat v0
Definition: glcorearb.h:815
double fpreal
Definition: SYS_Types.h:269
GLfloat GLfloat v1
Definition: glcorearb.h:816
static void getGlueSlope(fpreal *m0, fpreal *m1, fpreal *a0, fpreal *a1, int thread)
Definition: CH_Channel.h:1205