Skip to content

Commit 2e1549d

Browse files
TheMrMilchmannSpasi
authored andcommitted
feat(par): add par_streamlines
1 parent 4fd0a2a commit 2e1549d

19 files changed

+3705
-5
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ improve the chances of a quick and useful response.
142142
|[NanoSVG](https://github.com/memononen/nanosvg)|A simple stupid SVG parser.|
143143
|[NanoVG](https://github.com/memononen/nanovg)|A small antialiased vector graphics rendering library for OpenGL.|
144144
|[Nuklear](https://github.com/vurtun/nuklear)|A minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain.|
145-
|[par_shapes](https://github.com/prideout/par)|Generate parametric surfaces and other simple shapes.|
145+
|[par_shapes](https://prideout.net/shapes)|Generate parametric surfaces and other simple shapes.|
146+
|[par_streamlines](https://prideout.net/blog/par_streamlines/)|Triangulate wide lines and curves.|
146147
|[OpenVR](https://github.com/ValveSoftware/openvr)|An API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting.|
147148
|[Shaderc](https://github.com/google/shaderc)|A collection of libraries for shader compilation.|
148149
|[Tiny OpenEXR](https://github.com/syoyo/tinyexr)|A small, single header-only library to load and save OpenEXR(.exr) images.|

Diff for: config/linux/build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
<!-- OpenVR -->
318318
<build_simple module="openvr"/>
319319

320-
<!-- ParShapes -->
320+
<!-- Par -->
321321
<build simple="true" module="par">
322322
<link>
323323
<arg value="-lm"/>

Diff for: config/macos/build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@
269269
<!-- OpenVR -->
270270
<build_simple module="openvr"/>
271271

272-
<!-- ParShapes -->
272+
<!-- Par -->
273273
<build_simple module="par"/>
274274

275275
<!-- Remotery -->

Diff for: config/windows/build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ EXPORTS
292292
<!-- OpenVR -->
293293
<build_simple module="openvr"/>
294294

295-
<!-- ParShapes -->
295+
<!-- Par -->
296296
<build_simple module="par"/>
297297

298298
<!-- Remotery -->

Diff for: doc/notes/3.2.3.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ This build includes the following changes:
99
- Added [Shaderc](https://github.com/google/shaderc) bindings. (#77)
1010
- glfw: Updated to 3.4.0 pre-release (up from 3.3.0)
1111
- nuklear: Updated to 4.01.0 (up from 4.00.2)
12-
- par_shapes: Updated to support `par_shapes_create_cone`
12+
- par: Updated par_shapes to support `par_shapes_create_cone`
13+
- par: Added bindings for par_streamlines
1314
- Vulkan: Updated to 1.1.117 (up from 1.0.107)
1415
* Includes MoltenVK 1.0.36
1516

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright LWJGL. All rights reserved.
3+
* License terms: https://www.lwjgl.org/license
4+
* MACHINE GENERATED FILE, DO NOT EDIT
5+
*/
6+
#include "common_tools.h"
7+
#include "lwjgl_malloc.h"
8+
#define PAR_MALLOC(T, N) ((T*) org_lwjgl_malloc(N * sizeof(T)))
9+
#define PAR_CALLOC(T, N) ((T*) org_lwjgl_calloc(N, sizeof(T)))
10+
#define PAR_REALLOC(T, BUF, N) ((T*) org_lwjgl_realloc(BUF, sizeof(T) * N))
11+
#define PAR_FREE(BUF) org_lwjgl_free(BUF)
12+
DISABLE_WARNINGS()
13+
#define PAR_STREAMLINES_IMPLEMENTATION
14+
#include "par_streamlines.h"
15+
ENABLE_WARNINGS()
16+
17+
EXTERN_C_ENTER
18+
19+
JNIEXPORT jlong JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1create_1context(jlong configAddress) {
20+
parsl_config *config = (parsl_config *)(intptr_t)configAddress;
21+
return (jlong)(intptr_t)parsl_create_context(*config);
22+
}
23+
JNIEXPORT jlong JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1create_1context(JNIEnv *__env, jclass clazz, jlong configAddress) {
24+
UNUSED_PARAMS(__env, clazz)
25+
return JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1create_1context(configAddress);
26+
}
27+
28+
JNIEXPORT void JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1destroy_1context(jlong ctxAddress) {
29+
parsl_context *ctx = (parsl_context *)(intptr_t)ctxAddress;
30+
parsl_destroy_context(ctx);
31+
}
32+
JNIEXPORT void JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1destroy_1context(JNIEnv *__env, jclass clazz, jlong ctxAddress) {
33+
UNUSED_PARAMS(__env, clazz)
34+
JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1destroy_1context(ctxAddress);
35+
}
36+
37+
JNIEXPORT jlong JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1lines(jlong ctxAddress, jlong spinesAddress) {
38+
parsl_context *ctx = (parsl_context *)(intptr_t)ctxAddress;
39+
parsl_spine_list *spines = (parsl_spine_list *)(intptr_t)spinesAddress;
40+
return (jlong)(intptr_t)parsl_mesh_from_lines(ctx, *spines);
41+
}
42+
JNIEXPORT jlong JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1lines(JNIEnv *__env, jclass clazz, jlong ctxAddress, jlong spinesAddress) {
43+
UNUSED_PARAMS(__env, clazz)
44+
return JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1lines(ctxAddress, spinesAddress);
45+
}
46+
47+
JNIEXPORT jlong JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1streamlines(jlong contextAddress, jlong advectAddress, jint first_tick, jint num_ticks, jlong userdataAddress) {
48+
parsl_context *context = (parsl_context *)(intptr_t)contextAddress;
49+
parsl_advection_callback advect = (parsl_advection_callback)(intptr_t)advectAddress;
50+
void *userdata = (void *)(intptr_t)userdataAddress;
51+
return (jlong)(intptr_t)parsl_mesh_from_streamlines(context, advect, (uint32_t)first_tick, (uint32_t)num_ticks, userdata);
52+
}
53+
JNIEXPORT jlong JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1streamlines(JNIEnv *__env, jclass clazz, jlong contextAddress, jlong advectAddress, jint first_tick, jint num_ticks, jlong userdataAddress) {
54+
UNUSED_PARAMS(__env, clazz)
55+
return JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1streamlines(contextAddress, advectAddress, first_tick, num_ticks, userdataAddress);
56+
}
57+
58+
JNIEXPORT jlong JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1cubic(jlong contextAddress, jlong spinesAddress) {
59+
parsl_context *context = (parsl_context *)(intptr_t)contextAddress;
60+
parsl_spine_list *spines = (parsl_spine_list *)(intptr_t)spinesAddress;
61+
return (jlong)(intptr_t)parsl_mesh_from_curves_cubic(context, *spines);
62+
}
63+
JNIEXPORT jlong JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1cubic(JNIEnv *__env, jclass clazz, jlong contextAddress, jlong spinesAddress) {
64+
UNUSED_PARAMS(__env, clazz)
65+
return JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1cubic(contextAddress, spinesAddress);
66+
}
67+
68+
JNIEXPORT jlong JNICALL JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1quadratic(jlong contextAddress, jlong spinesAddress) {
69+
parsl_context *context = (parsl_context *)(intptr_t)contextAddress;
70+
parsl_spine_list *spines = (parsl_spine_list *)(intptr_t)spinesAddress;
71+
return (jlong)(intptr_t)parsl_mesh_from_curves_quadratic(context, *spines);
72+
}
73+
JNIEXPORT jlong JNICALL Java_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1quadratic(JNIEnv *__env, jclass clazz, jlong contextAddress, jlong spinesAddress) {
74+
UNUSED_PARAMS(__env, clazz)
75+
return JavaCritical_org_lwjgl_util_par_ParStreamlines_nparsl_1mesh_1from_1curves_1quadratic(contextAddress, spinesAddress);
76+
}
77+
78+
EXTERN_C_EXIT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright LWJGL. All rights reserved.
3+
* License terms: https://www.lwjgl.org/license
4+
* MACHINE GENERATED FILE, DO NOT EDIT
5+
*/
6+
package org.lwjgl.util.par;
7+
8+
import javax.annotation.*;
9+
10+
import org.lwjgl.system.*;
11+
12+
import static org.lwjgl.system.MemoryUtil.*;
13+
14+
/**
15+
* Instances of this class may be passed to the {@link ParStreamlines#parsl_mesh_from_streamlines mesh_from_streamlines} method.
16+
*
17+
* <h3>Type</h3>
18+
*
19+
* <pre><code>
20+
* void (*) (
21+
* parsl_position *point,
22+
* void *userdata
23+
* )</code></pre>
24+
*/
25+
public abstract class ParSLAdvectionCallback extends Callback implements ParSLAdvectionCallbackI {
26+
27+
/**
28+
* Creates a {@code ParSLAdvectionCallback} instance from the specified function pointer.
29+
*
30+
* @return the new {@code ParSLAdvectionCallback}
31+
*/
32+
public static ParSLAdvectionCallback create(long functionPointer) {
33+
ParSLAdvectionCallbackI instance = Callback.get(functionPointer);
34+
return instance instanceof ParSLAdvectionCallback
35+
? (ParSLAdvectionCallback)instance
36+
: new Container(functionPointer, instance);
37+
}
38+
39+
/** Like {@link #create(long) create}, but returns {@code null} if {@code functionPointer} is {@code NULL}. */
40+
@Nullable
41+
public static ParSLAdvectionCallback createSafe(long functionPointer) {
42+
return functionPointer == NULL ? null : create(functionPointer);
43+
}
44+
45+
/** Creates a {@code ParSLAdvectionCallback} instance that delegates to the specified {@code ParSLAdvectionCallbackI} instance. */
46+
public static ParSLAdvectionCallback create(ParSLAdvectionCallbackI instance) {
47+
return instance instanceof ParSLAdvectionCallback
48+
? (ParSLAdvectionCallback)instance
49+
: new Container(instance.address(), instance);
50+
}
51+
52+
protected ParSLAdvectionCallback() {
53+
super(SIGNATURE);
54+
}
55+
56+
ParSLAdvectionCallback(long functionPointer) {
57+
super(functionPointer);
58+
}
59+
60+
private static final class Container extends ParSLAdvectionCallback {
61+
62+
private final ParSLAdvectionCallbackI delegate;
63+
64+
Container(long functionPointer, ParSLAdvectionCallbackI delegate) {
65+
super(functionPointer);
66+
this.delegate = delegate;
67+
}
68+
69+
@Override
70+
public void invoke(long point, long userdata) {
71+
delegate.invoke(point, userdata);
72+
}
73+
74+
}
75+
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright LWJGL. All rights reserved.
3+
* License terms: https://www.lwjgl.org/license
4+
* MACHINE GENERATED FILE, DO NOT EDIT
5+
*/
6+
package org.lwjgl.util.par;
7+
8+
import org.lwjgl.system.*;
9+
10+
import static org.lwjgl.system.dyncall.DynCallback.*;
11+
12+
/**
13+
* Instances of this interface may be passed to the {@link ParStreamlines#parsl_mesh_from_streamlines mesh_from_streamlines} method.
14+
*
15+
* <h3>Type</h3>
16+
*
17+
* <pre><code>
18+
* void (*) (
19+
* parsl_position *point,
20+
* void *userdata
21+
* )</code></pre>
22+
*/
23+
@FunctionalInterface
24+
@NativeType("parsl_advection_callback")
25+
public interface ParSLAdvectionCallbackI extends CallbackI.V {
26+
27+
String SIGNATURE = "(pp)v";
28+
29+
@Override
30+
default String getSignature() { return SIGNATURE; }
31+
32+
@Override
33+
default void callback(long args) {
34+
invoke(
35+
dcbArgPointer(args),
36+
dcbArgPointer(args)
37+
);
38+
}
39+
40+
/** Client function that moves a streamline particle by a single time step. */
41+
void invoke(@NativeType("parsl_position *") long point, @NativeType("void *") long userdata);
42+
43+
}

0 commit comments

Comments
 (0)