Skip to content

Instantly share code, notes, and snippets.

View tanitta's full-sized avatar

tanitta tanitta

View GitHub Profile
@tanitta
tanitta / expandenv
Last active April 3, 2020 12:44
Expand environment variable in hscript expression. https://www.sidefx.com/docs/houdini/network/expression_functions.html
string expandenv(string str)
{
string result = str;
string prev = "";
cont = 1;
while(cont){
prev = result;
result = execute("echo " + "`" + result + "`");
cont = strcmp(prev, result) != 0;
}
@tanitta
tanitta / transfer_transform.py
Created March 1, 2020 05:48
houdiniでoperatorのtransform(positionとrotation)を他のoperatorのtransformに転送するtool
import hou
import sys
def transfer_transform():
source = hou.selectedNodes()[0]
if source is None: return
target = hou.selectedNodes()[1]
if target is None: return
tx = source.parm("tx").eval()
ty = source.parm("ty").eval()
@tanitta
tanitta / save_curve.py
Created November 18, 2019 14:16
Save curve on houdini
import hou
source = hou.selectedNodes()[0]
target = hou.selectedNodes()[1]
elm_list = []
for point in source.geometry().points():
pos = point.floatListAttribValue('P')
elm_list.append(','.join(map(lambda v: str(v), pos)))
elm_list_str = ' '.join(elm_list)
module syncbox;
import rx;
///
struct SyncableObserver{
public{
void put(Event n){}
// void put(int n){} : linker error
}//public
}//struct SyncableObserver

module Aの機能をmodule Bから利用する.ある機能を特定の使い方で特殊化させたsubsetを追加したいとき,そのsubsetをどの段階で実装するか.

case.1

呼びだす側Bで実装する.

メリット

  • 呼びだされるAは最小限の記述.

デメリット

  • Aを用いるmoduleが多いと呼び出し先のそのmodule同士で重複するコードが増える.
#Clone llvm
git clone http://llvm.org/git/llvm.git
#Clone clang
cd llvm/tools/
git clone http://llvm.org/git/clang.git
#Clone clang-Tools-Extra
cd clang/tools
git clone http://llvm.org/git/clang-tools-extra.git extra
lerp(
lerp(
lerp(
grad (aaa, xf , yf , zf), // The gradient function calculates the dot product between a pseudorandom
grad (baa, xf-1, yf , zf), // gradient vector and the vector from the input coordinate to the 8
u
),
lerp(
grad (aba, xf , yf-1, zf), // This is all then lerped together as a sort of weighted average based on the faded (u,v,w)
grad (bba, xf-1, yf-1, zf), // values we made earlier.
@tanitta
tanitta / static_if.d
Created January 10, 2016 17:56
static_if
void setAttribute(Args ...)(string location, Args args){
if(_isLoaded){
static if(Args.length == 1){
static if(is( Args == double[] )){
glVertexAttrib1d(location, v[0]);
}else if(is(Args == float[])){
glVertexAttrib1f(location, v[0]);
}else if(is( Args == ar.Vector!(double, 2) )){
glVertexAttrib2d(location, v[0], v[1]);
}else if(is(Args == ar.Vector!(float, 2))){
@tanitta
tanitta / load_delegate.d
Created December 3, 2015 17:03
load_delegate
import armos;
import std.stdio;
class Hoge{
void func(void delegate() f){
f();
}
}
class TestApp : ar.BaseApp{
auto hoge = new Hoge;
void mouseMoved(int x, int y, int button){
@tanitta
tanitta / hoge.cpp
Created November 14, 2015 16:37
Dのconstメンバ関数
class Moge{};
class Hoge {
public:
Moge moge;
Moge constFunc()const{
return moge;
}
};
int main(){
Hoge obj;