Skip to content

Commit

Permalink
change: avoid compiling simple density functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Nov 19, 2024
1 parent a9a4be0 commit 4f2c87d
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import com.ishland.c2me.opts.dfc.common.ast.McToAst;
import com.ishland.c2me.opts.dfc.common.ast.dfvisitor.StripBlending;
import com.ishland.c2me.opts.dfc.common.ast.misc.ConstantNode;
import com.ishland.c2me.opts.dfc.common.ast.misc.DelegateNode;
import com.ishland.c2me.opts.dfc.common.ast.misc.RootNode;
import com.ishland.c2me.opts.dfc.common.ast.misc.YClampedGradientNode;
import com.ishland.c2me.opts.dfc.common.ast.noise.DFTNoiseNode;
import com.ishland.c2me.opts.dfc.common.ast.noise.DFTShiftANode;
import com.ishland.c2me.opts.dfc.common.ast.noise.DFTShiftBNode;
import com.ishland.c2me.opts.dfc.common.ast.noise.DFTShiftNode;
import com.ishland.c2me.opts.dfc.common.util.ArrayCache;
import com.ishland.c2me.opts.dfc.common.vif.AstVanillaInterface;
import it.unimi.dsi.fastutil.Hash;
Expand Down Expand Up @@ -82,6 +88,12 @@ public static DensityFunction compile(DensityFunction densityFunction, Reference
AstNode ast = McToAst.toAst(densityFunction.apply(StripBlending.INSTANCE));
if (ast instanceof ConstantNode constantNode) {
return DensityFunctionTypes.constant(constantNode.getValue());
} else if (ast instanceof DFTNoiseNode ||
ast instanceof DFTShiftANode ||
ast instanceof DFTShiftBNode ||
ast instanceof DFTShiftNode ||
ast instanceof YClampedGradientNode) {
return densityFunction;
}
CompiledDensityFunction compiled = new CompiledDensityFunction(compile0(ast), densityFunction);
tempCache.put(densityFunction, compiled);
Expand Down

0 comments on commit 4f2c87d

Please sign in to comment.